-rw-r--r-- | korganizer/kolistview.cpp | 11 | ||||
-rw-r--r-- | korganizer/kolistview.h | 2 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 0b2f9a4..22d9ac0 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1454 +1,1465 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpaintdevicemetrics.h> | 38 | #include <qpaintdevicemetrics.h> |
39 | 39 | ||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | 44 | ||
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | #include <libkcal/calendar.h> | 46 | #include <libkcal/calendar.h> |
47 | #include <libkcal/calendarlocal.h> | 47 | #include <libkcal/calendarlocal.h> |
48 | #include <libkcal/icalformat.h> | 48 | #include <libkcal/icalformat.h> |
49 | #include <libkcal/vcalformat.h> | 49 | #include <libkcal/vcalformat.h> |
50 | #include <libkcal/recurrence.h> | 50 | #include <libkcal/recurrence.h> |
51 | #include <libkcal/filestorage.h> | 51 | #include <libkcal/filestorage.h> |
52 | #include <libkdepim/categoryselectdialog.h> | 52 | #include <libkdepim/categoryselectdialog.h> |
53 | #include <libkcal/kincidenceformatter.h> | 53 | #include <libkcal/kincidenceformatter.h> |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef KORG_NOPRINTER | 60 | #ifndef KORG_NOPRINTER |
61 | #include "calprinter.h" | 61 | #include "calprinter.h" |
62 | #endif | 62 | #endif |
63 | #include "koglobals.h" | 63 | #include "koglobals.h" |
64 | #include "koprefs.h" | 64 | #include "koprefs.h" |
65 | #include "kfiledialog.h" | 65 | #include "kfiledialog.h" |
66 | 66 | ||
67 | #include "kolistview.h" | 67 | #include "kolistview.h" |
68 | #include "koeventviewer.h" | 68 | #include "koeventviewer.h" |
69 | 69 | ||
70 | extern QPixmap* sgListViewCompletedPix[6]; | 70 | extern QPixmap* sgListViewCompletedPix[6]; |
71 | 71 | ||
72 | class KOListViewWhatsThis :public QWhatsThis | 72 | class KOListViewWhatsThis :public QWhatsThis |
73 | { | 73 | { |
74 | public: | 74 | public: |
75 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 75 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
76 | 76 | ||
77 | protected: | 77 | protected: |
78 | virtual QString text( const QPoint& p) | 78 | virtual QString text( const QPoint& p) |
79 | { | 79 | { |
80 | return _view->getWhatsThisText(p) ; | 80 | return _view->getWhatsThisText(p) ; |
81 | } | 81 | } |
82 | private: | 82 | private: |
83 | QWidget* _wid; | 83 | QWidget* _wid; |
84 | KOListView * _view; | 84 | KOListView * _view; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | 87 | ||
88 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 88 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
89 | { | 89 | { |
90 | mItem = item; | 90 | mItem = item; |
91 | mDate = date; | 91 | mDate = date; |
92 | } | 92 | } |
93 | 93 | ||
94 | ListItemVisitor::~ListItemVisitor() | 94 | ListItemVisitor::~ListItemVisitor() |
95 | { | 95 | { |
96 | } | 96 | } |
97 | 97 | ||
98 | bool ListItemVisitor::visit(Event *e) | 98 | bool ListItemVisitor::visit(Event *e) |
99 | { | 99 | { |
100 | bool ok = false; | 100 | bool ok = false; |
101 | QString start, end; | 101 | QString start, end; |
102 | QDate ds, de; | 102 | QDate ds, de; |
103 | if ( e->doesRecur() ) { | 103 | if ( e->doesRecur() ) { |
104 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 104 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
105 | if ( ok ) { | 105 | if ( ok ) { |
106 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 106 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
107 | start = KGlobal::locale()->formatDate(ds,true); | 107 | start = KGlobal::locale()->formatDate(ds,true); |
108 | de = ds.addDays( days); | 108 | de = ds.addDays( days); |
109 | end = KGlobal::locale()->formatDate(de,true); | 109 | end = KGlobal::locale()->formatDate(de,true); |
110 | } | 110 | } |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! ok ) { | 113 | if ( ! ok ) { |
114 | start =e->dtStartDateStr(); | 114 | start =e->dtStartDateStr(); |
115 | end = e->dtEndDateStr(); | 115 | end = e->dtEndDateStr(); |
116 | ds = e->dtStart().date(); | 116 | ds = e->dtStart().date(); |
117 | de = e->dtEnd().date(); | 117 | de = e->dtEnd().date(); |
118 | } | 118 | } |
119 | mItem->setText(0,e->summary()); | 119 | mItem->setText(0,e->summary()); |
120 | mItem->setText(1,start); | 120 | mItem->setText(1,start); |
121 | if ( e->doesFloat() ) | 121 | if ( e->doesFloat() ) |
122 | mItem->setText(2,"---"); | 122 | mItem->setText(2,"---"); |
123 | else | 123 | else |
124 | mItem->setText(2,e->dtStartTimeStr()); | 124 | mItem->setText(2,e->dtStartTimeStr()); |
125 | mItem->setText(3,end); | 125 | mItem->setText(3,end); |
126 | if ( e->doesFloat() ) | 126 | if ( e->doesFloat() ) |
127 | mItem->setText(4,"---"); | 127 | mItem->setText(4,"---"); |
128 | else | 128 | else |
129 | mItem->setText(4,e->dtEndTimeStr()); | 129 | mItem->setText(4,e->dtEndTimeStr()); |
130 | if ( e->isAlarmEnabled() ) { | 130 | if ( e->isAlarmEnabled() ) { |
131 | mItem->setText(5,e->alarms().first()->offsetText() ); | 131 | mItem->setText(5,e->alarms().first()->offsetText() ); |
132 | } else { | 132 | } else { |
133 | mItem->setText(5, i18n("No")); | 133 | mItem->setText(5, i18n("No")); |
134 | } | 134 | } |
135 | mItem->setText(6, e->recurrence()->recurrenceText()); | 135 | mItem->setText(6, e->recurrence()->recurrenceText()); |
136 | if( ! e->doesRecur() ) | 136 | if( ! e->doesRecur() ) |
137 | mItem->setSortKey( 6, "-" ); | 137 | mItem->setSortKey( 6, "-" ); |
138 | mItem->setText(7,"---"); | 138 | mItem->setText(7,"---"); |
139 | mItem->setText(8,"---"); | 139 | mItem->setText(8,"---"); |
140 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 140 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
141 | mItem->setText(10,e->categoriesStr()); | 141 | mItem->setText(10,e->categoriesStr()); |
142 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); | 142 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); |
143 | 143 | ||
144 | QString key; | 144 | QString key; |
145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
146 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 146 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
147 | mItem->setSortKey(1,key); | 147 | mItem->setSortKey(1,key); |
148 | 148 | ||
149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
150 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 150 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
151 | mItem->setSortKey(3,key); | 151 | mItem->setSortKey(3,key); |
152 | return true; | 152 | return true; |
153 | } | 153 | } |
154 | 154 | ||
155 | bool ListItemVisitor::visit(Todo *t) | 155 | bool ListItemVisitor::visit(Todo *t) |
156 | { | 156 | { |
157 | mItem->setText(0,t->summary()); | 157 | mItem->setText(0,t->summary()); |
158 | if ( t->isCompleted() ) { | 158 | if ( t->isCompleted() ) { |
159 | mItem->setSortKey(0,"99"+ t->summary().left(10)); | 159 | mItem->setSortKey(0,"99"+ t->summary().left(10)); |
160 | } else | 160 | } else |
161 | mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); | 161 | mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); |
162 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); | 162 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); |
163 | if (t->hasStartDate()) { | 163 | if (t->hasStartDate()) { |
164 | mItem->setText(1,t->dtStartDateStr()); | 164 | mItem->setText(1,t->dtStartDateStr()); |
165 | if (t->doesFloat()) { | 165 | if (t->doesFloat()) { |
166 | mItem->setText(2,"---"); | 166 | mItem->setText(2,"---"); |
167 | } else { | 167 | } else { |
168 | mItem->setText(2,t->dtStartTimeStr()); | 168 | mItem->setText(2,t->dtStartTimeStr()); |
169 | } | 169 | } |
170 | } else { | 170 | } else { |
171 | mItem->setText(1,"---"); | 171 | mItem->setText(1,"---"); |
172 | mItem->setText(2,"---"); | 172 | mItem->setText(2,"---"); |
173 | } | 173 | } |
174 | mItem->setText(3,"---"); | 174 | mItem->setText(3,"---"); |
175 | mItem->setText(4,"---"); | 175 | mItem->setText(4,"---"); |
176 | if ( t->isAlarmEnabled() ) { | 176 | if ( t->isAlarmEnabled() ) { |
177 | mItem->setText(5,t->alarms().first()->offsetText() ); | 177 | mItem->setText(5,t->alarms().first()->offsetText() ); |
178 | } else { | 178 | } else { |
179 | mItem->setText(5, i18n("No")); | 179 | mItem->setText(5, i18n("No")); |
180 | } | 180 | } |
181 | mItem->setText(6, t->recurrence()->recurrenceText()); | 181 | mItem->setText(6, t->recurrence()->recurrenceText()); |
182 | if( ! t->doesRecur() ) | 182 | if( ! t->doesRecur() ) |
183 | mItem->setSortKey( 6, "-" ); | 183 | mItem->setSortKey( 6, "-" ); |
184 | if (t->hasDueDate()) { | 184 | if (t->hasDueDate()) { |
185 | mItem->setText(7,t->dtDueDateStr()); | 185 | mItem->setText(7,t->dtDueDateStr()); |
186 | if (t->doesFloat()) { | 186 | if (t->doesFloat()) { |
187 | mItem->setText(8,"---"); | 187 | mItem->setText(8,"---"); |
188 | } else { | 188 | } else { |
189 | mItem->setText(8,t->dtDueTimeStr()); | 189 | mItem->setText(8,t->dtDueTimeStr()); |
190 | } | 190 | } |
191 | } else { | 191 | } else { |
192 | mItem->setText(7,"---"); | 192 | mItem->setText(7,"---"); |
193 | mItem->setText(8,"---"); | 193 | mItem->setText(8,"---"); |
194 | } | 194 | } |
195 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 195 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
196 | mItem->setText(10,t->categoriesStr()); | 196 | mItem->setText(10,t->categoriesStr()); |
197 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); | 197 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); |
198 | 198 | ||
199 | QString key; | 199 | QString key; |
200 | QDate d; | 200 | QDate d; |
201 | if (t->hasDueDate()) { | 201 | if (t->hasDueDate()) { |
202 | d = t->dtDue().date(); | 202 | d = t->dtDue().date(); |
203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
204 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 204 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
205 | mItem->setSortKey(7,key); | 205 | mItem->setSortKey(7,key); |
206 | } | 206 | } |
207 | if ( t->hasStartDate() ) { | 207 | if ( t->hasStartDate() ) { |
208 | d = t->dtStart().date(); | 208 | d = t->dtStart().date(); |
209 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 209 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
210 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 210 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
211 | mItem->setSortKey(1,key); | 211 | mItem->setSortKey(1,key); |
212 | } | 212 | } |
213 | return true; | 213 | return true; |
214 | } | 214 | } |
215 | 215 | ||
216 | bool ListItemVisitor::visit(Journal * j) | 216 | bool ListItemVisitor::visit(Journal * j) |
217 | { | 217 | { |
218 | QString des = j->description().left(30); | 218 | QString des = j->description().left(30); |
219 | des = des.simplifyWhiteSpace (); | 219 | des = des.simplifyWhiteSpace (); |
220 | des.replace (QRegExp ("\\n"),"" ); | 220 | des.replace (QRegExp ("\\n"),"" ); |
221 | des.replace (QRegExp ("\\r"),"" ); | 221 | des.replace (QRegExp ("\\r"),"" ); |
222 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 222 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
223 | mItem->setText(1,j->dtStartDateStr()); | 223 | mItem->setText(1,j->dtStartDateStr()); |
224 | mItem->setText(2,"---"); | 224 | mItem->setText(2,"---"); |
225 | mItem->setText(3,"---"); | 225 | mItem->setText(3,"---"); |
226 | mItem->setText(4,"---"); | 226 | mItem->setText(4,"---"); |
227 | mItem->setText(5,"---"); | 227 | mItem->setText(5,"---"); |
228 | mItem->setText(6,"---"); | 228 | mItem->setText(6,"---"); |
229 | mItem->setText(7,j->dtStartDateStr()); | 229 | mItem->setText(7,j->dtStartDateStr()); |
230 | mItem->setText(8,"---"); | 230 | mItem->setText(8,"---"); |
231 | mItem->setText(9,"---"); | 231 | mItem->setText(9,"---"); |
232 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 232 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
233 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); | 233 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); |
234 | 234 | ||
235 | QString key; | 235 | QString key; |
236 | QDate d = j->dtStart().date(); | 236 | QDate d = j->dtStart().date(); |
237 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 237 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
238 | mItem->setSortKey(1,key); | 238 | mItem->setSortKey(1,key); |
239 | mItem->setSortKey(7,key); | 239 | mItem->setSortKey(7,key); |
240 | 240 | ||
241 | return true; | 241 | return true; |
242 | } | 242 | } |
243 | 243 | ||
244 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 244 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
245 | const char *name) | 245 | const char *name) |
246 | : KOEventView(calendar, parent, name) | 246 | : KOEventView(calendar, parent, name) |
247 | { | 247 | { |
248 | 248 | ||
249 | mActiveItem = 0; | 249 | mActiveItem = 0; |
250 | mForceShowCompletedTodos = false; | ||
250 | mListView = new KOListViewListView(this); | 251 | mListView = new KOListViewListView(this); |
251 | mListView->addColumn(i18n("Summary")); | 252 | mListView->addColumn(i18n("Summary")); |
252 | mListView->addColumn(i18n("Start Date")); | 253 | mListView->addColumn(i18n("Start Date")); |
253 | mListView->addColumn(i18n("Start Time")); | 254 | mListView->addColumn(i18n("Start Time")); |
254 | mListView->addColumn(i18n("End Date")); | 255 | mListView->addColumn(i18n("End Date")); |
255 | mListView->addColumn(i18n("End Time")); | 256 | mListView->addColumn(i18n("End Time")); |
256 | mListView->addColumn(i18n("Alarm")); // alarm set? | 257 | mListView->addColumn(i18n("Alarm")); // alarm set? |
257 | mListView->addColumn(i18n("Recurs")); // recurs? | 258 | mListView->addColumn(i18n("Recurs")); // recurs? |
258 | mListView->addColumn(i18n("Due Date")); | 259 | mListView->addColumn(i18n("Due Date")); |
259 | mListView->addColumn(i18n("Due Time")); | 260 | mListView->addColumn(i18n("Due Time")); |
260 | mListView->addColumn(i18n("Cancelled")); | 261 | mListView->addColumn(i18n("Cancelled")); |
261 | mListView->addColumn(i18n("Categories")); | 262 | mListView->addColumn(i18n("Categories")); |
262 | mListView->addColumn(i18n("Calendar")); | 263 | mListView->addColumn(i18n("Calendar")); |
263 | 264 | ||
264 | mListView->setColumnAlignment(0,AlignLeft); | 265 | mListView->setColumnAlignment(0,AlignLeft); |
265 | mListView->setColumnAlignment(1,AlignLeft); | 266 | mListView->setColumnAlignment(1,AlignLeft); |
266 | mListView->setColumnAlignment(2,AlignHCenter); | 267 | mListView->setColumnAlignment(2,AlignHCenter); |
267 | mListView->setColumnAlignment(3,AlignLeft); | 268 | mListView->setColumnAlignment(3,AlignLeft); |
268 | mListView->setColumnAlignment(4,AlignHCenter); | 269 | mListView->setColumnAlignment(4,AlignHCenter); |
269 | mListView->setColumnAlignment(5,AlignLeft); | 270 | mListView->setColumnAlignment(5,AlignLeft); |
270 | mListView->setColumnAlignment(6,AlignLeft); | 271 | mListView->setColumnAlignment(6,AlignLeft); |
271 | mListView->setColumnAlignment(7,AlignLeft); | 272 | mListView->setColumnAlignment(7,AlignLeft); |
272 | mListView->setColumnAlignment(8,AlignLeft); | 273 | mListView->setColumnAlignment(8,AlignLeft); |
273 | mListView->setColumnAlignment(9,AlignLeft); | 274 | mListView->setColumnAlignment(9,AlignLeft); |
274 | mListView->setColumnAlignment(10,AlignLeft); | 275 | mListView->setColumnAlignment(10,AlignLeft); |
275 | mListView->setColumnAlignment(11,AlignLeft); | 276 | mListView->setColumnAlignment(11,AlignLeft); |
276 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 277 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
277 | 278 | ||
278 | int iii = 0; | 279 | int iii = 0; |
279 | for ( iii = 0; iii< 12 ; ++iii ) | 280 | for ( iii = 0; iii< 12 ; ++iii ) |
280 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 281 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
281 | 282 | ||
282 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 283 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
283 | layoutTop->addWidget(mListView); | 284 | layoutTop->addWidget(mListView); |
284 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 285 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
285 | mPopupMenu = eventPopup(); | 286 | mPopupMenu = eventPopup(); |
286 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 287 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
287 | i18n("Select all"),this, | 288 | i18n("Select all"),this, |
288 | SLOT(allSelection()),true); | 289 | SLOT(allSelection()),true); |
289 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 290 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
290 | i18n("Deselect all"),this, | 291 | i18n("Deselect all"),this, |
291 | SLOT(clearSelection()),true); | 292 | SLOT(clearSelection()),true); |
292 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 293 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
293 | i18n("Delete all selected"),this, | 294 | i18n("Delete all selected"),this, |
294 | SLOT(deleteAll()),true); | 295 | SLOT(deleteAll()),true); |
295 | 296 | ||
296 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 297 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
297 | i18n("Hide all selected"),this, | 298 | i18n("Hide all selected"),this, |
298 | SLOT(hideAll()),true); | 299 | SLOT(hideAll()),true); |
299 | 300 | ||
300 | mPopupMenu->insertSeparator(); | 301 | mPopupMenu->insertSeparator(); |
301 | #ifdef DESKTOP_VERSION | 302 | #ifdef DESKTOP_VERSION |
302 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 303 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
303 | i18n("Print complete list"),this, | 304 | i18n("Print complete list"),this, |
304 | SLOT(printList()),true); | 305 | SLOT(printList()),true); |
305 | mPopupMenu->insertSeparator(); | 306 | mPopupMenu->insertSeparator(); |
306 | #endif | 307 | #endif |
307 | mCalPopup = new QPopupMenu ( this ); | 308 | mCalPopup = new QPopupMenu ( this ); |
308 | mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); | 309 | mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); |
309 | 310 | ||
310 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, | 311 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, |
311 | SLOT( populateCalPopup() )); | 312 | SLOT( populateCalPopup() )); |
312 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, | 313 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, |
313 | SLOT( setCalendar( int ) )); | 314 | SLOT( setCalendar( int ) )); |
314 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 315 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
315 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 316 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
316 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 317 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
317 | SLOT(saveToFile())); | 318 | SLOT(saveToFile())); |
318 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 319 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
319 | SLOT(saveToFileVCS())); | 320 | SLOT(saveToFileVCS())); |
320 | exportPO->insertItem( i18n("Journal/Details..."),this, | 321 | exportPO->insertItem( i18n("Journal/Details..."),this, |
321 | SLOT(saveDescriptionToFile())); | 322 | SLOT(saveDescriptionToFile())); |
322 | // mPopupMenu->insertSeparator(); | 323 | // mPopupMenu->insertSeparator(); |
323 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 324 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
324 | i18n("Add Categ. to selected..."),this, | 325 | i18n("Add Categ. to selected..."),this, |
325 | SLOT(addCat()),true); | 326 | SLOT(addCat()),true); |
326 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 327 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
327 | i18n("Set Categ. for selected..."),this, | 328 | i18n("Set Categ. for selected..."),this, |
328 | SLOT(setCat()),true); | 329 | SLOT(setCat()),true); |
329 | //mPopupMenu->insertSeparator(); | 330 | //mPopupMenu->insertSeparator(); |
330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 331 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
331 | i18n("Set alarm for selected..."),this, | 332 | i18n("Set alarm for selected..."),this, |
332 | SLOT(setAlarm()),true); | 333 | SLOT(setAlarm()),true); |
333 | 334 | ||
334 | 335 | ||
335 | 336 | ||
336 | #ifndef DESKTOP_VERSION | 337 | #ifndef DESKTOP_VERSION |
337 | mPopupMenu->insertSeparator(); | 338 | mPopupMenu->insertSeparator(); |
338 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 339 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
339 | i18n("Beam selected via IR"),this, | 340 | i18n("Beam selected via IR"),this, |
340 | SLOT(beamSelected()),true); | 341 | SLOT(beamSelected()),true); |
341 | #endif | 342 | #endif |
342 | /* | 343 | /* |
343 | mPopupMenu = new QPopupMenu; | 344 | mPopupMenu = new QPopupMenu; |
344 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 345 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
345 | SLOT (editEvent())); | 346 | SLOT (editEvent())); |
346 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 347 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
347 | SLOT (deleteEvent())); | 348 | SLOT (deleteEvent())); |
348 | mPopupMenu->insertSeparator(); | 349 | mPopupMenu->insertSeparator(); |
349 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 350 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
350 | SLOT(showDates())); | 351 | SLOT(showDates())); |
351 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 352 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
352 | SLOT(hideDates())); | 353 | SLOT(hideDates())); |
353 | */ | 354 | */ |
354 | QObject::connect(mListView,SIGNAL( newEvent()), | 355 | QObject::connect(mListView,SIGNAL( newEvent()), |
355 | this,SIGNAL(signalNewEvent())); | 356 | this,SIGNAL(signalNewEvent())); |
356 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 357 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
357 | this,SLOT(defaultItemAction(QListViewItem *))); | 358 | this,SLOT(defaultItemAction(QListViewItem *))); |
358 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 359 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
359 | const QPoint &, int )), | 360 | const QPoint &, int )), |
360 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 361 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
361 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 362 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
362 | SLOT(processSelectionChange(QListViewItem *))); | 363 | SLOT(processSelectionChange(QListViewItem *))); |
363 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 364 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
364 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 365 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
365 | 366 | ||
366 | readSettings(KOGlobals::config(),"KOListView Layout"); | 367 | readSettings(KOGlobals::config(),"KOListView Layout"); |
367 | } | 368 | } |
368 | 369 | ||
369 | KOListView::~KOListView() | 370 | KOListView::~KOListView() |
370 | { | 371 | { |
371 | delete mPopupMenu; | 372 | delete mPopupMenu; |
372 | #if QT_VERSION >= 0x030000 | 373 | #if QT_VERSION >= 0x030000 |
373 | 374 | ||
374 | #else | 375 | #else |
375 | delete mKOListViewWhatsThis; | 376 | delete mKOListViewWhatsThis; |
376 | #endif | 377 | #endif |
377 | } | 378 | } |
378 | 379 | ||
379 | QString KOListView::getWhatsThisText(QPoint p) | 380 | QString KOListView::getWhatsThisText(QPoint p) |
380 | { | 381 | { |
381 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 382 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
382 | if ( item ) | 383 | if ( item ) |
383 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 384 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
384 | KOPrefs::instance()->mWTshowDetails, | 385 | KOPrefs::instance()->mWTshowDetails, |
385 | KOPrefs::instance()->mWTshowCreated, | 386 | KOPrefs::instance()->mWTshowCreated, |
386 | KOPrefs::instance()->mWTshowChanged); | 387 | KOPrefs::instance()->mWTshowChanged); |
387 | return i18n("That is the list view" ); | 388 | return i18n("That is the list view" ); |
388 | 389 | ||
389 | } | 390 | } |
390 | 391 | ||
391 | void KOListView::setCalendar( int c ) | 392 | void KOListView::setCalendar( int c ) |
392 | { | 393 | { |
393 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 394 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
394 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 395 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
395 | i18n("Continue"), i18n("Cancel"), 0, | 396 | i18n("Continue"), i18n("Cancel"), 0, |
396 | 0, 1 ); | 397 | 0, 1 ); |
397 | if ( result != 0 ) { | 398 | if ( result != 0 ) { |
398 | return; | 399 | return; |
399 | } | 400 | } |
400 | 401 | ||
401 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 402 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
402 | int icount = delSel.count(); | 403 | int icount = delSel.count(); |
403 | if ( icount ) { | 404 | if ( icount ) { |
404 | Incidence *incidence = delSel.first(); | 405 | Incidence *incidence = delSel.first(); |
405 | while ( incidence ) { | 406 | while ( incidence ) { |
406 | incidence->setCalID( c ); | 407 | incidence->setCalID( c ); |
407 | KOListViewItem * item = getItemForEvent( incidence ); | 408 | KOListViewItem * item = getItemForEvent( incidence ); |
408 | if ( item ) { | 409 | if ( item ) { |
409 | ListItemVisitor v(item, mStartDate ); | 410 | ListItemVisitor v(item, mStartDate ); |
410 | incidence->accept(v); | 411 | incidence->accept(v); |
411 | } | 412 | } |
412 | incidence = delSel.next(); | 413 | incidence = delSel.next(); |
413 | } | 414 | } |
414 | } | 415 | } |
415 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 416 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
416 | KopiCalendarFile * cal = calendars.first(); | 417 | KopiCalendarFile * cal = calendars.first(); |
417 | while ( cal ) { | 418 | while ( cal ) { |
418 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 419 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
419 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 420 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
420 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 421 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
421 | if ( cal->isStandard ) | 422 | if ( cal->isStandard ) |
422 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 423 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
423 | cal = calendars.next(); | 424 | cal = calendars.next(); |
424 | } | 425 | } |
425 | mCalendar->setSyncEventsReadOnly(); | 426 | mCalendar->setSyncEventsReadOnly(); |
426 | mCalendar->reInitAlarmSettings(); | 427 | mCalendar->reInitAlarmSettings(); |
427 | 428 | ||
428 | } | 429 | } |
429 | void KOListView::populateCalPopup() | 430 | void KOListView::populateCalPopup() |
430 | { | 431 | { |
431 | mCalPopup->clear(); | 432 | mCalPopup->clear(); |
432 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 433 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
433 | while ( kkf ) { | 434 | while ( kkf ) { |
434 | mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); | 435 | mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); |
435 | kkf = KOPrefs::instance()->mCalendars.next(); | 436 | kkf = KOPrefs::instance()->mCalendars.next(); |
436 | } | 437 | } |
437 | } | 438 | } |
438 | void KOListView::updateList() | 439 | void KOListView::updateList() |
439 | { | 440 | { |
440 | // qDebug(" KOListView::updateList() "); | 441 | // qDebug(" KOListView::updateList() "); |
441 | 442 | ||
442 | } | 443 | } |
443 | 444 | ||
444 | void KOListView::clearList() | 445 | void KOListView::clearList() |
445 | { | 446 | { |
446 | clear (); | 447 | clear (); |
447 | } | 448 | } |
448 | void KOListView::addCat( ) | 449 | void KOListView::addCat( ) |
449 | { | 450 | { |
450 | setCategories( false ); | 451 | setCategories( false ); |
451 | } | 452 | } |
452 | void KOListView::setCat() | 453 | void KOListView::setCat() |
453 | { | 454 | { |
454 | setCategories( true ); | 455 | setCategories( true ); |
455 | } | 456 | } |
456 | 457 | ||
457 | void KOListView::setAlarm() | 458 | void KOListView::setAlarm() |
458 | { | 459 | { |
459 | KOAlarmPrefs kap( this); | 460 | KOAlarmPrefs kap( this); |
460 | if ( !kap.exec() ) | 461 | if ( !kap.exec() ) |
461 | return; | 462 | return; |
462 | QStringList itemList; | 463 | QStringList itemList; |
463 | QPtrList<KOListViewItem> sel ; | 464 | QPtrList<KOListViewItem> sel ; |
464 | QListViewItem *qitem = mListView->firstChild (); | 465 | QListViewItem *qitem = mListView->firstChild (); |
465 | while ( qitem ) { | 466 | while ( qitem ) { |
466 | if ( qitem->isSelected() ) { | 467 | if ( qitem->isSelected() ) { |
467 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 468 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
468 | if ( inc->typeID() != journalID ) { | 469 | if ( inc->typeID() != journalID ) { |
469 | if ( inc->typeID() == todoID ) { | 470 | if ( inc->typeID() == todoID ) { |
470 | if ( ((Todo*)inc)->hasDueDate() ) | 471 | if ( ((Todo*)inc)->hasDueDate() ) |
471 | sel.append(((KOListViewItem *)qitem)); | 472 | sel.append(((KOListViewItem *)qitem)); |
472 | } else | 473 | } else |
473 | sel.append(((KOListViewItem *)qitem)); | 474 | sel.append(((KOListViewItem *)qitem)); |
474 | } | 475 | } |
475 | } | 476 | } |
476 | qitem = qitem->nextSibling(); | 477 | qitem = qitem->nextSibling(); |
477 | } | 478 | } |
478 | int count = 0; | 479 | int count = 0; |
479 | KOListViewItem * item, *temp; | 480 | KOListViewItem * item, *temp; |
480 | item = sel.first(); | 481 | item = sel.first(); |
481 | Incidence* inc; | 482 | Incidence* inc; |
482 | while ( item ) { | 483 | while ( item ) { |
483 | inc = item->data(); | 484 | inc = item->data(); |
484 | ++count; | 485 | ++count; |
485 | if (kap.mAlarmButton->isChecked()) { | 486 | if (kap.mAlarmButton->isChecked()) { |
486 | if (inc->alarms().count() == 0) | 487 | if (inc->alarms().count() == 0) |
487 | inc->newAlarm(); | 488 | inc->newAlarm(); |
488 | QPtrList<Alarm> alarms = inc->alarms(); | 489 | QPtrList<Alarm> alarms = inc->alarms(); |
489 | Alarm *alarm; | 490 | Alarm *alarm; |
490 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 491 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
491 | alarm->setEnabled(true); | 492 | alarm->setEnabled(true); |
492 | int j = kap.mAlarmTimeEdit->value()* -60; | 493 | int j = kap.mAlarmTimeEdit->value()* -60; |
493 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 494 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
494 | j = j * 60; | 495 | j = j * 60; |
495 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 496 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
496 | j = j * (60 * 24); | 497 | j = j * (60 * 24); |
497 | alarm->setStartOffset( j ); | 498 | alarm->setStartOffset( j ); |
498 | 499 | ||
499 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 500 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
500 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 501 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
501 | } | 502 | } |
502 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 503 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
503 | alarm->setAudioAlarm(kap.mAlarmSound); | 504 | alarm->setAudioAlarm(kap.mAlarmSound); |
504 | else | 505 | else |
505 | alarm->setType(Alarm::Invalid); | 506 | alarm->setType(Alarm::Invalid); |
506 | //alarm->setAudioAlarm("default"); | 507 | //alarm->setAudioAlarm("default"); |
507 | // TODO: Deal with multiple alarms | 508 | // TODO: Deal with multiple alarms |
508 | break; // For now, stop after the first alarm | 509 | break; // For now, stop after the first alarm |
509 | } | 510 | } |
510 | } else { | 511 | } else { |
511 | Alarm* alarm = inc->alarms().first(); | 512 | Alarm* alarm = inc->alarms().first(); |
512 | if ( alarm ) { | 513 | if ( alarm ) { |
513 | alarm->setEnabled(false); | 514 | alarm->setEnabled(false); |
514 | alarm->setType(Alarm::Invalid); | 515 | alarm->setType(Alarm::Invalid); |
515 | } | 516 | } |
516 | } | 517 | } |
517 | ListItemVisitor v(item, mStartDate ); | 518 | ListItemVisitor v(item, mStartDate ); |
518 | inc->accept(v); | 519 | inc->accept(v); |
519 | item = sel.next(); | 520 | item = sel.next(); |
520 | } | 521 | } |
521 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 522 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
522 | qDebug("KO: Set alarm for %d items", count); | 523 | qDebug("KO: Set alarm for %d items", count); |
523 | calendar()->reInitAlarmSettings(); | 524 | calendar()->reInitAlarmSettings(); |
524 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 525 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
525 | } | 526 | } |
526 | void KOListView::setCategories( bool removeOld ) | 527 | void KOListView::setCategories( bool removeOld ) |
527 | { | 528 | { |
528 | 529 | ||
529 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 530 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
530 | csd->setColorEnabled(); | 531 | csd->setColorEnabled(); |
531 | if (! csd->exec()) { | 532 | if (! csd->exec()) { |
532 | delete csd; | 533 | delete csd; |
533 | return; | 534 | return; |
534 | } | 535 | } |
535 | QStringList catList = csd->selectedCategories(); | 536 | QStringList catList = csd->selectedCategories(); |
536 | delete csd; | 537 | delete csd; |
537 | // if ( catList.count() == 0 ) | 538 | // if ( catList.count() == 0 ) |
538 | // return; | 539 | // return; |
539 | //catList.sort(); | 540 | //catList.sort(); |
540 | QString categoriesStr = catList.join(","); | 541 | QString categoriesStr = catList.join(","); |
541 | int i; | 542 | int i; |
542 | QStringList itemList; | 543 | QStringList itemList; |
543 | QPtrList<KOListViewItem> sel ; | 544 | QPtrList<KOListViewItem> sel ; |
544 | QListViewItem *qitem = mListView->firstChild (); | 545 | QListViewItem *qitem = mListView->firstChild (); |
545 | while ( qitem ) { | 546 | while ( qitem ) { |
546 | if ( qitem->isSelected() ) { | 547 | if ( qitem->isSelected() ) { |
547 | sel.append(((KOListViewItem *)qitem)); | 548 | sel.append(((KOListViewItem *)qitem)); |
548 | } | 549 | } |
549 | qitem = qitem->nextSibling(); | 550 | qitem = qitem->nextSibling(); |
550 | } | 551 | } |
551 | KOListViewItem * item, *temp; | 552 | KOListViewItem * item, *temp; |
552 | item = sel.first(); | 553 | item = sel.first(); |
553 | if( item ) { | 554 | if( item ) { |
554 | Incidence* inc = item->data() ; | 555 | Incidence* inc = item->data() ; |
555 | bool setSub = false; | 556 | bool setSub = false; |
556 | if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { | 557 | if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { |
557 | int result = KMessageBox::warningYesNoCancel(this, | 558 | int result = KMessageBox::warningYesNoCancel(this, |
558 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), | 559 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), |
559 | i18n("Todo has subtodos"), | 560 | i18n("Todo has subtodos"), |
560 | i18n("Yes"), | 561 | i18n("Yes"), |
561 | i18n("No")); | 562 | i18n("No")); |
562 | if (result == KMessageBox::Cancel) item = 0; | 563 | if (result == KMessageBox::Cancel) item = 0; |
563 | if (result == KMessageBox::Yes) setSub = true; | 564 | if (result == KMessageBox::Yes) setSub = true; |
564 | } | 565 | } |
565 | while ( item ) { | 566 | while ( item ) { |
566 | inc = item->data(); | 567 | inc = item->data(); |
567 | if ( removeOld ) { | 568 | if ( removeOld ) { |
568 | inc->setCategories( catList, setSub ); | 569 | inc->setCategories( catList, setSub ); |
569 | } else { | 570 | } else { |
570 | inc->addCategories( catList, setSub ); | 571 | inc->addCategories( catList, setSub ); |
571 | } | 572 | } |
572 | ListItemVisitor v(item, mStartDate ); | 573 | ListItemVisitor v(item, mStartDate ); |
573 | inc->accept(v); | 574 | inc->accept(v); |
574 | item = sel.next(); | 575 | item = sel.next(); |
575 | } | 576 | } |
576 | } | 577 | } |
577 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 578 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
578 | } | 579 | } |
579 | 580 | ||
580 | void KOListView::beamSelected() | 581 | void KOListView::beamSelected() |
581 | { | 582 | { |
582 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 583 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
583 | int icount = delSel.count(); | 584 | int icount = delSel.count(); |
584 | if ( icount ) { | 585 | if ( icount ) { |
585 | emit beamIncidenceList( delSel ); | 586 | emit beamIncidenceList( delSel ); |
586 | return; | 587 | return; |
587 | QString fn ; | 588 | QString fn ; |
588 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 589 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
589 | QString mes; | 590 | QString mes; |
590 | bool createbup = true; | 591 | bool createbup = true; |
591 | if ( createbup ) { | 592 | if ( createbup ) { |
592 | QString description = "\n"; | 593 | QString description = "\n"; |
593 | CalendarLocal* cal = new CalendarLocal(); | 594 | CalendarLocal* cal = new CalendarLocal(); |
594 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 595 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
595 | Incidence *incidence = delSel.first(); | 596 | Incidence *incidence = delSel.first(); |
596 | while ( incidence ) { | 597 | while ( incidence ) { |
597 | Incidence *in = incidence->clone(); | 598 | Incidence *in = incidence->clone(); |
598 | description += in->summary() + "\n"; | 599 | description += in->summary() + "\n"; |
599 | cal->addIncidence( in ); | 600 | cal->addIncidence( in ); |
600 | incidence = delSel.next(); | 601 | incidence = delSel.next(); |
601 | } | 602 | } |
602 | FileStorage storage( cal, fn, new VCalFormat ); | 603 | FileStorage storage( cal, fn, new VCalFormat ); |
603 | storage.save(); | 604 | storage.save(); |
604 | delete cal; | 605 | delete cal; |
605 | mes = i18n("KO/Pi: Ready for beaming"); | 606 | mes = i18n("KO/Pi: Ready for beaming"); |
606 | topLevelWidget()->setCaption(mes); | 607 | topLevelWidget()->setCaption(mes); |
607 | 608 | ||
608 | #ifndef DESKTOP_VERSION | 609 | #ifndef DESKTOP_VERSION |
609 | Ir *ir = new Ir( this ); | 610 | Ir *ir = new Ir( this ); |
610 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 611 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
611 | ir->send( fn, description, "text/x-vCalendar" ); | 612 | ir->send( fn, description, "text/x-vCalendar" ); |
612 | #endif | 613 | #endif |
613 | } | 614 | } |
614 | } | 615 | } |
615 | } | 616 | } |
616 | void KOListView::beamDone( Ir *ir ) | 617 | void KOListView::beamDone( Ir *ir ) |
617 | { | 618 | { |
618 | #ifndef DESKTOP_VERSION | 619 | #ifndef DESKTOP_VERSION |
619 | delete ir; | 620 | delete ir; |
620 | #endif | 621 | #endif |
621 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 622 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
622 | } | 623 | } |
623 | 624 | ||
624 | void KOListView::saveDescriptionToFile() | 625 | void KOListView::saveDescriptionToFile() |
625 | { | 626 | { |
626 | 627 | ||
627 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 628 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
628 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 629 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
629 | i18n("Continue"), i18n("Cancel"), 0, | 630 | i18n("Continue"), i18n("Cancel"), 0, |
630 | 0, 1 ); | 631 | 0, 1 ); |
631 | if ( result != 0 ) { | 632 | if ( result != 0 ) { |
632 | return; | 633 | return; |
633 | } | 634 | } |
634 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 635 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
635 | int icount = delSel.count(); | 636 | int icount = delSel.count(); |
636 | if ( icount ) { | 637 | if ( icount ) { |
637 | QString fn = KOPrefs::instance()->mLastSaveFile; | 638 | QString fn = KOPrefs::instance()->mLastSaveFile; |
638 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 639 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
639 | 640 | ||
640 | if ( fn == "" ) | 641 | if ( fn == "" ) |
641 | return; | 642 | return; |
642 | QFileInfo info; | 643 | QFileInfo info; |
643 | info.setFile( fn ); | 644 | info.setFile( fn ); |
644 | QString mes; | 645 | QString mes; |
645 | bool createbup = true; | 646 | bool createbup = true; |
646 | if ( info. exists() ) { | 647 | if ( info. exists() ) { |
647 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 648 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
648 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 649 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
649 | i18n("Overwrite!"), i18n("Cancel"), 0, | 650 | i18n("Overwrite!"), i18n("Cancel"), 0, |
650 | 0, 1 ); | 651 | 0, 1 ); |
651 | if ( result != 0 ) { | 652 | if ( result != 0 ) { |
652 | createbup = false; | 653 | createbup = false; |
653 | } | 654 | } |
654 | } | 655 | } |
655 | if ( createbup ) { | 656 | if ( createbup ) { |
656 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 657 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
657 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 658 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
658 | Incidence *incidence = delSel.first(); | 659 | Incidence *incidence = delSel.first(); |
659 | icount = 0; | 660 | icount = 0; |
660 | while ( incidence ) { | 661 | while ( incidence ) { |
661 | if ( incidence->typeID() == journalID ) { | 662 | if ( incidence->typeID() == journalID ) { |
662 | text += "\n************************************\n"; | 663 | text += "\n************************************\n"; |
663 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 664 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
664 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 665 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
665 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 666 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
666 | ++icount; | 667 | ++icount; |
667 | 668 | ||
668 | } else { | 669 | } else { |
669 | if ( !incidence->description().isEmpty() ) { | 670 | if ( !incidence->description().isEmpty() ) { |
670 | text += "\n************************************\n"; | 671 | text += "\n************************************\n"; |
671 | if ( incidence->typeID() == todoID ) | 672 | if ( incidence->typeID() == todoID ) |
672 | text += i18n("To-Do: "); | 673 | text += i18n("To-Do: "); |
673 | text += incidence->summary(); | 674 | text += incidence->summary(); |
674 | if ( incidence->hasStartDate() ) | 675 | if ( incidence->hasStartDate() ) |
675 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 676 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
676 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 677 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
677 | if ( !incidence->location().isEmpty() ) | 678 | if ( !incidence->location().isEmpty() ) |
678 | text += "\n" +i18n("Location: ") + incidence->location(); | 679 | text += "\n" +i18n("Location: ") + incidence->location(); |
679 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 680 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
680 | ++icount; | 681 | ++icount; |
681 | 682 | ||
682 | } | 683 | } |
683 | } | 684 | } |
684 | incidence = delSel.next(); | 685 | incidence = delSel.next(); |
685 | } | 686 | } |
686 | QFile file( fn ); | 687 | QFile file( fn ); |
687 | if (!file.open( IO_WriteOnly ) ) { | 688 | if (!file.open( IO_WriteOnly ) ) { |
688 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 689 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
689 | return; | 690 | return; |
690 | } | 691 | } |
691 | QTextStream ts( &file ); | 692 | QTextStream ts( &file ); |
692 | ts << text; | 693 | ts << text; |
693 | file.close(); | 694 | file.close(); |
694 | //qDebug("%s ", text.latin1()); | 695 | //qDebug("%s ", text.latin1()); |
695 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 696 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
696 | KOPrefs::instance()->mLastSaveFile = fn; | 697 | KOPrefs::instance()->mLastSaveFile = fn; |
697 | topLevelWidget()->setCaption(mes); | 698 | topLevelWidget()->setCaption(mes); |
698 | } | 699 | } |
699 | } | 700 | } |
700 | } | 701 | } |
701 | void KOListView::saveToFileVCS() | 702 | void KOListView::saveToFileVCS() |
702 | { | 703 | { |
703 | writeToFile( false ); | 704 | writeToFile( false ); |
704 | } | 705 | } |
705 | void KOListView::saveToFile() | 706 | void KOListView::saveToFile() |
706 | { | 707 | { |
707 | writeToFile( true ); | 708 | writeToFile( true ); |
708 | } | 709 | } |
709 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) | 710 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
710 | { | 711 | { |
711 | QPtrList<Incidence> delSel ; | 712 | QPtrList<Incidence> delSel ; |
712 | bool addSubTodos = false; | 713 | bool addSubTodos = false; |
713 | bool askSubTodos = true; | 714 | bool askSubTodos = true; |
714 | QListViewItem *item = mListView->firstChild (); | 715 | QListViewItem *item = mListView->firstChild (); |
715 | while ( item ) { | 716 | while ( item ) { |
716 | if ( item->isSelected() ) { | 717 | if ( item->isSelected() ) { |
717 | Incidence* inc = ((KOListViewItem *)item)->data(); | 718 | Incidence* inc = ((KOListViewItem *)item)->data(); |
718 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { | 719 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
719 | if ( (inc->typeID() == todoID && includeTodos) || | 720 | if ( (inc->typeID() == todoID && includeTodos) || |
720 | (inc->typeID() == eventID && includeEvents) || | 721 | (inc->typeID() == eventID && includeEvents) || |
721 | (inc->typeID() == journalID && includeJournals) ) { | 722 | (inc->typeID() == journalID && includeJournals) ) { |
722 | if ( inc->typeID() == todoID && onlyDueTodos ) { | 723 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
723 | if ( ((Todo*)inc)->hasDueDate() ) | 724 | if ( ((Todo*)inc)->hasDueDate() ) |
724 | delSel.append( inc ); | 725 | delSel.append( inc ); |
725 | } else | 726 | } else |
726 | delSel.append( inc ); | 727 | delSel.append( inc ); |
727 | 728 | ||
728 | } | 729 | } |
729 | } | 730 | } |
730 | if ( inc->typeID() == todoID ) { | 731 | if ( inc->typeID() == todoID ) { |
731 | Todo * todo = (Todo*) inc; | 732 | Todo * todo = (Todo*) inc; |
732 | if ( todo->relations().count() ) { | 733 | if ( todo->relations().count() ) { |
733 | if ( askSubTodos ) { | 734 | if ( askSubTodos ) { |
734 | int result = KMessageBox::warningYesNoCancel(this, | 735 | int result = KMessageBox::warningYesNoCancel(this, |
735 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 736 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
736 | i18n("Todo has subtodos"), | 737 | i18n("Todo has subtodos"), |
737 | i18n("Yes"), | 738 | i18n("Yes"), |
738 | i18n("No")); | 739 | i18n("No")); |
739 | if ( result == KMessageBox::Cancel ) { | 740 | if ( result == KMessageBox::Cancel ) { |
740 | delSel.clear(); | 741 | delSel.clear(); |
741 | return delSel; | 742 | return delSel; |
742 | } | 743 | } |
743 | if (result == KMessageBox::Yes) | 744 | if (result == KMessageBox::Yes) |
744 | addSubTodos = true; | 745 | addSubTodos = true; |
745 | askSubTodos = false; | 746 | askSubTodos = false; |
746 | } | 747 | } |
747 | if ( addSubTodos ) { | 748 | if ( addSubTodos ) { |
748 | inc->addRelationsToList( &delSel ); | 749 | inc->addRelationsToList( &delSel ); |
749 | } | 750 | } |
750 | } | 751 | } |
751 | } | 752 | } |
752 | } | 753 | } |
753 | item = item->nextSibling(); | 754 | item = item->nextSibling(); |
754 | } | 755 | } |
755 | return delSel; | 756 | return delSel; |
756 | } | 757 | } |
757 | 758 | ||
758 | void KOListView::writeToFile( bool iCal ) | 759 | void KOListView::writeToFile( bool iCal ) |
759 | { | 760 | { |
760 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 761 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
761 | if ( !iCal ) { | 762 | if ( !iCal ) { |
762 | bool journal = false; | 763 | bool journal = false; |
763 | Incidence *incidence = delSel.first(); | 764 | Incidence *incidence = delSel.first(); |
764 | while ( incidence ) { | 765 | while ( incidence ) { |
765 | if ( incidence->typeID() == journalID ) { | 766 | if ( incidence->typeID() == journalID ) { |
766 | journal = true; | 767 | journal = true; |
767 | break; | 768 | break; |
768 | } | 769 | } |
769 | incidence = delSel.next(); | 770 | incidence = delSel.next(); |
770 | } | 771 | } |
771 | if ( journal ) { | 772 | if ( journal ) { |
772 | int result = KMessageBox::warningContinueCancel(this, | 773 | int result = KMessageBox::warningContinueCancel(this, |
773 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 774 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
774 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 775 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
775 | true); | 776 | true); |
776 | if (result != KMessageBox::Continue) return; | 777 | if (result != KMessageBox::Continue) return; |
777 | } | 778 | } |
778 | } | 779 | } |
779 | if ( delSel.count() ) { | 780 | if ( delSel.count() ) { |
780 | QString fn = KOPrefs::instance()->mLastSaveFile; | 781 | QString fn = KOPrefs::instance()->mLastSaveFile; |
781 | QString extension; | 782 | QString extension; |
782 | if ( iCal ) { | 783 | if ( iCal ) { |
783 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 784 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
784 | fn = fn.left( fn.length() -3) + "ics"; | 785 | fn = fn.left( fn.length() -3) + "ics"; |
785 | } | 786 | } |
786 | } else { | 787 | } else { |
787 | if ( fn.right( 4 ).lower() == ".ics" ) { | 788 | if ( fn.right( 4 ).lower() == ".ics" ) { |
788 | fn = fn.left( fn.length() -3) + "vcs"; | 789 | fn = fn.left( fn.length() -3) + "vcs"; |
789 | } | 790 | } |
790 | } | 791 | } |
791 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 792 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
792 | 793 | ||
793 | if ( fn == "" ) | 794 | if ( fn == "" ) |
794 | return; | 795 | return; |
795 | QFileInfo info; | 796 | QFileInfo info; |
796 | info.setFile( fn ); | 797 | info.setFile( fn ); |
797 | QString mes; | 798 | QString mes; |
798 | bool createbup = true; | 799 | bool createbup = true; |
799 | if ( info. exists() ) { | 800 | if ( info. exists() ) { |
800 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 801 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
801 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 802 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
802 | i18n("Overwrite!"), i18n("Cancel"), 0, | 803 | i18n("Overwrite!"), i18n("Cancel"), 0, |
803 | 0, 1 ); | 804 | 0, 1 ); |
804 | if ( result != 0 ) { | 805 | if ( result != 0 ) { |
805 | createbup = false; | 806 | createbup = false; |
806 | } | 807 | } |
807 | } | 808 | } |
808 | if ( createbup ) { | 809 | if ( createbup ) { |
809 | CalendarLocal cal; | 810 | CalendarLocal cal; |
810 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 811 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
811 | Incidence *incidence = delSel.first(); | 812 | Incidence *incidence = delSel.first(); |
812 | while ( incidence ) { | 813 | while ( incidence ) { |
813 | cal.addIncidence( incidence->clone() ); | 814 | cal.addIncidence( incidence->clone() ); |
814 | incidence = delSel.next(); | 815 | incidence = delSel.next(); |
815 | } | 816 | } |
816 | if ( iCal ) { | 817 | if ( iCal ) { |
817 | ICalFormat format; | 818 | ICalFormat format; |
818 | format.save( &cal, fn ); | 819 | format.save( &cal, fn ); |
819 | } else { | 820 | } else { |
820 | 821 | ||
821 | VCalFormat format; | 822 | VCalFormat format; |
822 | format.save( &cal, fn ); | 823 | format.save( &cal, fn ); |
823 | } | 824 | } |
824 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 825 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
825 | KOPrefs::instance()->mLastSaveFile = fn; | 826 | KOPrefs::instance()->mLastSaveFile = fn; |
826 | topLevelWidget()->setCaption(mes); | 827 | topLevelWidget()->setCaption(mes); |
827 | } | 828 | } |
828 | } | 829 | } |
829 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 830 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
830 | } | 831 | } |
831 | void KOListView::hideAll() | 832 | void KOListView::hideAll() |
832 | { | 833 | { |
833 | QPtrList<QListViewItem> delSel ; | 834 | QPtrList<QListViewItem> delSel ; |
834 | QListViewItem *item = mListView->firstChild (); | 835 | QListViewItem *item = mListView->firstChild (); |
835 | while ( item ) { | 836 | while ( item ) { |
836 | if ( item->isSelected() ) { | 837 | if ( item->isSelected() ) { |
837 | delSel.append(item); | 838 | delSel.append(item); |
838 | } | 839 | } |
839 | item = item->nextSibling(); | 840 | item = item->nextSibling(); |
840 | } | 841 | } |
841 | item = delSel.first() ; | 842 | item = delSel.first() ; |
842 | while ( item ) { | 843 | while ( item ) { |
843 | QListViewItem * del = item; | 844 | QListViewItem * del = item; |
844 | item = delSel.next(); | 845 | item = delSel.next(); |
845 | delete del; | 846 | delete del; |
846 | } | 847 | } |
847 | } | 848 | } |
848 | void KOListView::printList() | 849 | void KOListView::printList() |
849 | { | 850 | { |
850 | mListView->printList(); | 851 | mListView->printList(); |
851 | } | 852 | } |
852 | void KOListView::deleteAll() | 853 | void KOListView::deleteAll() |
853 | { | 854 | { |
854 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; | 855 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; |
855 | if ( delSel.count() ) { | 856 | if ( delSel.count() ) { |
856 | int icount = delSel.count(); | 857 | int icount = delSel.count(); |
857 | Incidence *incidence = delSel.first(); | 858 | Incidence *incidence = delSel.first(); |
858 | Incidence *toDelete; | 859 | Incidence *toDelete; |
859 | KOPrefs *p = KOPrefs::instance(); | 860 | KOPrefs *p = KOPrefs::instance(); |
860 | bool confirm = p->mConfirm; | 861 | bool confirm = p->mConfirm; |
861 | QString mess; | 862 | QString mess; |
862 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 863 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
863 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 864 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
864 | p->mConfirm = false; | 865 | p->mConfirm = false; |
865 | int delCounter = 0; | 866 | int delCounter = 0; |
866 | QDialog dia ( this, "p-dialog", true ); | 867 | QDialog dia ( this, "p-dialog", true ); |
867 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 868 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
868 | QVBoxLayout lay( &dia ); | 869 | QVBoxLayout lay( &dia ); |
869 | lay.setMargin(7); | 870 | lay.setMargin(7); |
870 | lay.setSpacing(7); | 871 | lay.setSpacing(7); |
871 | lay.addWidget( &lab); | 872 | lay.addWidget( &lab); |
872 | QProgressBar bar( icount, &dia ); | 873 | QProgressBar bar( icount, &dia ); |
873 | lay.addWidget( &bar); | 874 | lay.addWidget( &bar); |
874 | int w = 220; | 875 | int w = 220; |
875 | int h = 50; | 876 | int h = 50; |
876 | int dw = QApplication::desktop()->width(); | 877 | int dw = QApplication::desktop()->width(); |
877 | int dh = QApplication::desktop()->height(); | 878 | int dh = QApplication::desktop()->height(); |
878 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 879 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
879 | //dia.resize( 240,50 ); | 880 | //dia.resize( 240,50 ); |
880 | dia.show(); | 881 | dia.show(); |
881 | 882 | ||
882 | while ( incidence ) { | 883 | while ( incidence ) { |
883 | bar.setProgress( delCounter ); | 884 | bar.setProgress( delCounter ); |
884 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 885 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
885 | dia.setCaption( mess ); | 886 | dia.setCaption( mess ); |
886 | qApp->processEvents(); | 887 | qApp->processEvents(); |
887 | toDelete = (incidence); | 888 | toDelete = (incidence); |
888 | incidence = delSel.next(); | 889 | incidence = delSel.next(); |
889 | emit deleteIncidenceSignal(toDelete ); | 890 | emit deleteIncidenceSignal(toDelete ); |
890 | if ( dia.result() != 0 ) | 891 | if ( dia.result() != 0 ) |
891 | break; | 892 | break; |
892 | 893 | ||
893 | } | 894 | } |
894 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 895 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
895 | topLevelWidget ()->setCaption( mess ); | 896 | topLevelWidget ()->setCaption( mess ); |
896 | p->mConfirm = confirm; | 897 | p->mConfirm = confirm; |
897 | } | 898 | } |
898 | } | 899 | } |
899 | 900 | ||
900 | 901 | ||
901 | } | 902 | } |
902 | int KOListView::maxDatesHint() | 903 | int KOListView::maxDatesHint() |
903 | { | 904 | { |
904 | return 0; | 905 | return 0; |
905 | } | 906 | } |
906 | 907 | ||
907 | int KOListView::currentDateCount() | 908 | int KOListView::currentDateCount() |
908 | { | 909 | { |
909 | return 0; | 910 | return 0; |
910 | } | 911 | } |
911 | 912 | ||
912 | QPtrList<Incidence> KOListView::selectedIncidences() | 913 | QPtrList<Incidence> KOListView::selectedIncidences() |
913 | { | 914 | { |
914 | QPtrList<Incidence> eventList; | 915 | QPtrList<Incidence> eventList; |
915 | QListViewItem *item = mListView->firstChild (); | 916 | QListViewItem *item = mListView->firstChild (); |
916 | while ( item ) { | 917 | while ( item ) { |
917 | if ( item->isSelected() ) { | 918 | if ( item->isSelected() ) { |
918 | eventList.append(((KOListViewItem *)item)->data()); | 919 | eventList.append(((KOListViewItem *)item)->data()); |
919 | } | 920 | } |
920 | 921 | ||
921 | item = item->nextSibling(); | 922 | item = item->nextSibling(); |
922 | } | 923 | } |
923 | 924 | ||
924 | // // QListViewItem *item = mListView->selectedItem(); | 925 | // // QListViewItem *item = mListView->selectedItem(); |
925 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 926 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
926 | 927 | ||
927 | return eventList; | 928 | return eventList; |
928 | } | 929 | } |
929 | 930 | ||
930 | DateList KOListView::selectedDates() | 931 | DateList KOListView::selectedDates() |
931 | { | 932 | { |
932 | DateList eventList; | 933 | DateList eventList; |
933 | return eventList; | 934 | return eventList; |
934 | } | 935 | } |
935 | 936 | ||
936 | void KOListView::showDates(bool show) | 937 | void KOListView::showDates(bool show) |
937 | { | 938 | { |
938 | // Shouldn't we set it to a value greater 0? When showDates is called with | 939 | // Shouldn't we set it to a value greater 0? When showDates is called with |
939 | // show == true at first, then the columnwidths are set to zero. | 940 | // show == true at first, then the columnwidths are set to zero. |
940 | static int oldColWidth1 = 0; | 941 | static int oldColWidth1 = 0; |
941 | static int oldColWidth3 = 0; | 942 | static int oldColWidth3 = 0; |
942 | 943 | ||
943 | if (!show) { | 944 | if (!show) { |
944 | oldColWidth1 = mListView->columnWidth(1); | 945 | oldColWidth1 = mListView->columnWidth(1); |
945 | oldColWidth3 = mListView->columnWidth(3); | 946 | oldColWidth3 = mListView->columnWidth(3); |
946 | mListView->setColumnWidth(1, 0); | 947 | mListView->setColumnWidth(1, 0); |
947 | mListView->setColumnWidth(3, 0); | 948 | mListView->setColumnWidth(3, 0); |
948 | } else { | 949 | } else { |
949 | mListView->setColumnWidth(1, oldColWidth1); | 950 | mListView->setColumnWidth(1, oldColWidth1); |
950 | mListView->setColumnWidth(3, oldColWidth3); | 951 | mListView->setColumnWidth(3, oldColWidth3); |
951 | } | 952 | } |
952 | mListView->repaint(); | 953 | mListView->repaint(); |
953 | } | 954 | } |
954 | 955 | ||
955 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 956 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
956 | const QDate &td) | 957 | const QDate &td) |
957 | { | 958 | { |
958 | #ifndef KORG_NOPRINTER | 959 | #ifndef KORG_NOPRINTER |
959 | calPrinter->preview(CalPrinter::Day, fd, td); | 960 | calPrinter->preview(CalPrinter::Day, fd, td); |
960 | #endif | 961 | #endif |
961 | } | 962 | } |
962 | 963 | ||
963 | void KOListView::showDates() | 964 | void KOListView::showDates() |
964 | { | 965 | { |
965 | showDates(true); | 966 | showDates(true); |
966 | } | 967 | } |
967 | 968 | ||
968 | void KOListView::hideDates() | 969 | void KOListView::hideDates() |
969 | { | 970 | { |
970 | showDates(false); | 971 | showDates(false); |
971 | } | 972 | } |
972 | 973 | ||
973 | void KOListView::resetFocus() | 974 | void KOListView::resetFocus() |
974 | { | 975 | { |
975 | topLevelWidget()->setActiveWindow(); | 976 | topLevelWidget()->setActiveWindow(); |
976 | topLevelWidget()->raise(); | 977 | topLevelWidget()->raise(); |
977 | mListView->setFocus(); | 978 | mListView->setFocus(); |
978 | } | 979 | } |
979 | void KOListView::updateView() | 980 | void KOListView::updateView() |
980 | { | 981 | { |
981 | mListView->setFocus(); | 982 | mListView->setFocus(); |
982 | if ( mListView->firstChild () ) | 983 | if ( mListView->firstChild () ) |
983 | mListView->setCurrentItem( mListView->firstChild () ); | 984 | mListView->setCurrentItem( mListView->firstChild () ); |
984 | } | 985 | } |
985 | void KOListView::updateConfig() | 986 | void KOListView::updateConfig() |
986 | { | 987 | { |
987 | 988 | ||
988 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 989 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
989 | updateView(); | 990 | updateView(); |
990 | 991 | ||
991 | } | 992 | } |
992 | void KOListView::setStartDate(const QDate &start) | 993 | void KOListView::setStartDate(const QDate &start) |
993 | { | 994 | { |
994 | mStartDate = start; | 995 | mStartDate = start; |
995 | } | 996 | } |
996 | 997 | ||
997 | void KOListView::showDates(const QDate &start, const QDate &end) | 998 | void KOListView::showDates(const QDate &start, const QDate &end) |
998 | { | 999 | { |
999 | clear(); | 1000 | clear(); |
1000 | mStartDate = start; | 1001 | mStartDate = start; |
1001 | QDate date = start; | 1002 | QDate date = start; |
1002 | QPtrList<Journal> j_list; | 1003 | QPtrList<Journal> j_list; |
1003 | while( date <= end ) { | 1004 | while( date <= end ) { |
1004 | addEvents(calendar()->events(date)); | 1005 | addEvents(calendar()->events(date)); |
1005 | addTodos(calendar()->todos(date)); | 1006 | addTodos(calendar()->todos(date)); |
1006 | Journal* jo = calendar()->journal(date); | 1007 | Journal* jo = calendar()->journal(date); |
1007 | if ( jo ) | 1008 | if ( jo ) |
1008 | j_list.append( jo ); | 1009 | j_list.append( jo ); |
1009 | date = date.addDays( 1 ); | 1010 | date = date.addDays( 1 ); |
1010 | } | 1011 | } |
1011 | addJournals(j_list); | 1012 | addJournals(j_list); |
1012 | emit incidenceSelected( 0 ); | 1013 | emit incidenceSelected( 0 ); |
1013 | updateView(); | 1014 | updateView(); |
1014 | 1015 | ||
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | void KOListView::addEvents(QPtrList<Event> eventList) | 1018 | void KOListView::addEvents(QPtrList<Event> eventList) |
1018 | { | 1019 | { |
1019 | 1020 | ||
1020 | Event *ev; | 1021 | Event *ev; |
1021 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1022 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1022 | addIncidence(ev); | 1023 | addIncidence(ev); |
1023 | } | 1024 | } |
1024 | if ( !mListView->currentItem() ){ | 1025 | if ( !mListView->currentItem() ){ |
1025 | updateView(); | 1026 | updateView(); |
1026 | } | 1027 | } |
1027 | } | 1028 | } |
1028 | 1029 | ||
1029 | void KOListView::addTodos(QPtrList<Todo> eventList) | 1030 | void KOListView::addTodos(QPtrList<Todo> eventList) |
1030 | { | 1031 | { |
1031 | Todo *ev; | 1032 | Todo *ev; |
1032 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1033 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1033 | addIncidence(ev); | 1034 | addIncidence(ev); |
1034 | } | 1035 | } |
1035 | if ( !mListView->currentItem() ){ | 1036 | if ( !mListView->currentItem() ){ |
1036 | updateView(); | 1037 | updateView(); |
1037 | } | 1038 | } |
1038 | } | 1039 | } |
1039 | void KOListView::addJournals(QPtrList<Journal> eventList) | 1040 | void KOListView::addJournals(QPtrList<Journal> eventList) |
1040 | { | 1041 | { |
1041 | Journal *ev; | 1042 | Journal *ev; |
1042 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1043 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1043 | addIncidence(ev); | 1044 | addIncidence(ev); |
1044 | } | 1045 | } |
1045 | if ( !mListView->currentItem() ){ | 1046 | if ( !mListView->currentItem() ){ |
1046 | updateView(); | 1047 | updateView(); |
1047 | } | 1048 | } |
1048 | } | 1049 | } |
1049 | 1050 | ||
1051 | void KOListView::showCompletedTodos() | ||
1052 | { | ||
1053 | mForceShowCompletedTodos = true; | ||
1054 | } | ||
1050 | void KOListView::addIncidence(Incidence *incidence) | 1055 | void KOListView::addIncidence(Incidence *incidence) |
1051 | { | 1056 | { |
1052 | if ( mUidDict.find( incidence->uid() ) ) return; | 1057 | if ( mUidDict.find( incidence->uid() ) ) return; |
1053 | 1058 | ||
1054 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 1059 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
1060 | if ( incidence->typeID() == todoID ) { | ||
1061 | if ( ! mForceShowCompletedTodos ) { | ||
1062 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) | ||
1063 | return; | ||
1064 | } | ||
1065 | } | ||
1055 | mUidDict.insert( incidence->uid(), incidence ); | 1066 | mUidDict.insert( incidence->uid(), incidence ); |
1056 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 1067 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
1057 | ListItemVisitor v(item, mStartDate ); | 1068 | ListItemVisitor v(item, mStartDate ); |
1058 | if (incidence->accept(v)) { | 1069 | if (incidence->accept(v)) { |
1059 | return; | 1070 | return; |
1060 | } | 1071 | } |
1061 | else delete item; | 1072 | else delete item; |
1062 | } | 1073 | } |
1063 | 1074 | ||
1064 | void KOListView::showEvents(QPtrList<Event> eventList) | 1075 | void KOListView::showEvents(QPtrList<Event> eventList) |
1065 | { | 1076 | { |
1066 | clear(); | 1077 | clear(); |
1067 | 1078 | ||
1068 | addEvents(eventList); | 1079 | addEvents(eventList); |
1069 | 1080 | ||
1070 | // After new creation of list view no events are selected. | 1081 | // After new creation of list view no events are selected. |
1071 | emit incidenceSelected( 0 ); | 1082 | emit incidenceSelected( 0 ); |
1072 | } | 1083 | } |
1073 | int KOListView::count() | 1084 | int KOListView::count() |
1074 | { | 1085 | { |
1075 | return mListView->childCount(); | 1086 | return mListView->childCount(); |
1076 | } | 1087 | } |
1077 | 1088 | ||
1078 | void KOListView::changeEventDisplay(Event *event, int action) | 1089 | void KOListView::changeEventDisplay(Event *event, int action) |
1079 | { | 1090 | { |
1080 | KOListViewItem *item; | 1091 | KOListViewItem *item; |
1081 | 1092 | ||
1082 | switch(action) { | 1093 | switch(action) { |
1083 | case KOGlobals::EVENTADDED: | 1094 | case KOGlobals::EVENTADDED: |
1084 | addIncidence( event ); | 1095 | addIncidence( event ); |
1085 | break; | 1096 | break; |
1086 | case KOGlobals::EVENTEDITED: | 1097 | case KOGlobals::EVENTEDITED: |
1087 | item = getItemForEvent(event); | 1098 | item = getItemForEvent(event); |
1088 | if (item) { | 1099 | if (item) { |
1089 | mUidDict.remove( event->uid() ); | 1100 | mUidDict.remove( event->uid() ); |
1090 | delete item; | 1101 | delete item; |
1091 | addIncidence( event ); | 1102 | addIncidence( event ); |
1092 | } | 1103 | } |
1093 | break; | 1104 | break; |
1094 | case KOGlobals::EVENTDELETED: | 1105 | case KOGlobals::EVENTDELETED: |
1095 | item = getItemForEvent(event); | 1106 | item = getItemForEvent(event); |
1096 | if (item) { | 1107 | if (item) { |
1097 | mUidDict.remove( event->uid() ); | 1108 | mUidDict.remove( event->uid() ); |
1098 | delete item; | 1109 | delete item; |
1099 | } | 1110 | } |
1100 | break; | 1111 | break; |
1101 | default: | 1112 | default: |
1102 | ; | 1113 | ; |
1103 | } | 1114 | } |
1104 | } | 1115 | } |
1105 | 1116 | ||
1106 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) | 1117 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) |
1107 | { | 1118 | { |
1108 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 1119 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
1109 | while (item) { | 1120 | while (item) { |
1110 | if (item->data() == event) return item; | 1121 | if (item->data() == event) return item; |
1111 | item = (KOListViewItem *)item->nextSibling(); | 1122 | item = (KOListViewItem *)item->nextSibling(); |
1112 | } | 1123 | } |
1113 | return 0; | 1124 | return 0; |
1114 | } | 1125 | } |
1115 | 1126 | ||
1116 | void KOListView::defaultItemAction(QListViewItem *i) | 1127 | void KOListView::defaultItemAction(QListViewItem *i) |
1117 | { | 1128 | { |
1118 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 1129 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
1119 | if ( item ) defaultAction( item->data() ); | 1130 | if ( item ) defaultAction( item->data() ); |
1120 | 1131 | ||
1121 | } | 1132 | } |
1122 | 1133 | ||
1123 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1134 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1124 | { | 1135 | { |
1125 | mActiveItem = (KOListViewItem *)item; | 1136 | mActiveItem = (KOListViewItem *)item; |
1126 | if (mActiveItem) { | 1137 | if (mActiveItem) { |
1127 | Incidence *incidence = mActiveItem->data(); | 1138 | Incidence *incidence = mActiveItem->data(); |
1128 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | 1139 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); |
1129 | mPopupMenu->showIncidencePopup(incidence); | 1140 | mPopupMenu->showIncidencePopup(incidence); |
1130 | 1141 | ||
1131 | /* | 1142 | /* |
1132 | if ( incidence && incidence->type() == "Event" ) { | 1143 | if ( incidence && incidence->type() == "Event" ) { |
1133 | Event *event = static_cast<Event *>( incidence ); | 1144 | Event *event = static_cast<Event *>( incidence ); |
1134 | mPopupMenu->showEventPopup(event); | 1145 | mPopupMenu->showEventPopup(event); |
1135 | } | 1146 | } |
1136 | */ | 1147 | */ |
1137 | } | 1148 | } |
1138 | } | 1149 | } |
1139 | 1150 | ||
1140 | void KOListView::readSettings(KConfig *config, QString setting) | 1151 | void KOListView::readSettings(KConfig *config, QString setting) |
1141 | { | 1152 | { |
1142 | // qDebug("KOListView::readSettings "); | 1153 | // qDebug("KOListView::readSettings "); |
1143 | mListView->restoreLayout(config,setting); | 1154 | mListView->restoreLayout(config,setting); |
1144 | } | 1155 | } |
1145 | 1156 | ||
1146 | void KOListView::writeSettings(KConfig *config, QString setting) | 1157 | void KOListView::writeSettings(KConfig *config, QString setting) |
1147 | { | 1158 | { |
1148 | // qDebug("KOListView::writeSettings "); | 1159 | // qDebug("KOListView::writeSettings "); |
1149 | mListView->saveLayout(config, setting); | 1160 | mListView->saveLayout(config, setting); |
1150 | } | 1161 | } |
1151 | 1162 | ||
1152 | void KOListView::processSelectionChange(QListViewItem *) | 1163 | void KOListView::processSelectionChange(QListViewItem *) |
1153 | { | 1164 | { |
1154 | 1165 | ||
1155 | KOListViewItem *item = | 1166 | KOListViewItem *item = |
1156 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1167 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1157 | 1168 | ||
1158 | if ( !item ) { | 1169 | if ( !item ) { |
1159 | emit incidenceSelected( 0 ); | 1170 | emit incidenceSelected( 0 ); |
1160 | } else { | 1171 | } else { |
1161 | emit incidenceSelected( item->data() ); | 1172 | emit incidenceSelected( item->data() ); |
1162 | } | 1173 | } |
1163 | } | 1174 | } |
1164 | 1175 | ||
1165 | void KOListView::clearSelection() | 1176 | void KOListView::clearSelection() |
1166 | { | 1177 | { |
1167 | mListView->selectAll( false ); | 1178 | mListView->selectAll( false ); |
1168 | } | 1179 | } |
1169 | void KOListView::allSelection() | 1180 | void KOListView::allSelection() |
1170 | { | 1181 | { |
1171 | mListView->selectAll( true ); | 1182 | mListView->selectAll( true ); |
1172 | } | 1183 | } |
1173 | 1184 | ||
1174 | void KOListView::clear() | 1185 | void KOListView::clear() |
1175 | { | 1186 | { |
1176 | mListView->clear(); | 1187 | mListView->clear(); |
1177 | mUidDict.clear(); | 1188 | mUidDict.clear(); |
1178 | } | 1189 | } |
1179 | 1190 | ||
1180 | Incidence* KOListView::currentItem() | 1191 | Incidence* KOListView::currentItem() |
1181 | { | 1192 | { |
1182 | if ( mListView->currentItem() ) | 1193 | if ( mListView->currentItem() ) |
1183 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1194 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1184 | return 0; | 1195 | return 0; |
1185 | } | 1196 | } |
1186 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1197 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1187 | { | 1198 | { |
1188 | 1199 | ||
1189 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1200 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1190 | deleteAll(); | 1201 | deleteAll(); |
1191 | return; | 1202 | return; |
1192 | } | 1203 | } |
1193 | 1204 | ||
1194 | e->ignore(); | 1205 | e->ignore(); |
1195 | } | 1206 | } |
1196 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1207 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1197 | { | 1208 | { |
1198 | 1209 | ||
1199 | switch ( e->key() ) { | 1210 | switch ( e->key() ) { |
1200 | case Qt::Key_Down: | 1211 | case Qt::Key_Down: |
1201 | if ( e->state() == ShiftButton ) { | 1212 | if ( e->state() == ShiftButton ) { |
1202 | QListViewItem* cn = currentItem(); | 1213 | QListViewItem* cn = currentItem(); |
1203 | if ( !cn ) | 1214 | if ( !cn ) |
1204 | cn = firstChild(); | 1215 | cn = firstChild(); |
1205 | if ( !cn ) | 1216 | if ( !cn ) |
1206 | return; | 1217 | return; |
1207 | while ( cn->nextSibling() ) | 1218 | while ( cn->nextSibling() ) |
1208 | cn = cn->nextSibling(); | 1219 | cn = cn->nextSibling(); |
1209 | setCurrentItem ( cn ); | 1220 | setCurrentItem ( cn ); |
1210 | ensureItemVisible ( cn ); | 1221 | ensureItemVisible ( cn ); |
1211 | 1222 | ||
1212 | e->accept(); | 1223 | e->accept(); |
1213 | return; | 1224 | return; |
1214 | } | 1225 | } |
1215 | if ( e->state() == ControlButton ) { | 1226 | if ( e->state() == ControlButton ) { |
1216 | int count = childCount (); | 1227 | int count = childCount (); |
1217 | int jump = count / 5; | 1228 | int jump = count / 5; |
1218 | QListViewItem* cn; | 1229 | QListViewItem* cn; |
1219 | cn = currentItem(); | 1230 | cn = currentItem(); |
1220 | if ( ! cn ) | 1231 | if ( ! cn ) |
1221 | return; | 1232 | return; |
1222 | if ( jump == 0 ) | 1233 | if ( jump == 0 ) |
1223 | jump = 1; | 1234 | jump = 1; |
1224 | while ( jump && cn->nextSibling() ) { | 1235 | while ( jump && cn->nextSibling() ) { |
1225 | cn = cn->nextSibling(); | 1236 | cn = cn->nextSibling(); |
1226 | --jump; | 1237 | --jump; |
1227 | } | 1238 | } |
1228 | setCurrentItem ( cn ); | 1239 | setCurrentItem ( cn ); |
1229 | ensureItemVisible ( cn ); | 1240 | ensureItemVisible ( cn ); |
1230 | 1241 | ||
1231 | } else | 1242 | } else |
1232 | QListView::keyPressEvent ( e ) ; | 1243 | QListView::keyPressEvent ( e ) ; |
1233 | e->accept(); | 1244 | e->accept(); |
1234 | break; | 1245 | break; |
1235 | 1246 | ||
1236 | case Qt::Key_Up: | 1247 | case Qt::Key_Up: |
1237 | if ( e->state() == ShiftButton ) { | 1248 | if ( e->state() == ShiftButton ) { |
1238 | QListViewItem* cn = firstChild(); | 1249 | QListViewItem* cn = firstChild(); |
1239 | if ( cn ) { | 1250 | if ( cn ) { |
1240 | setCurrentItem ( cn ); | 1251 | setCurrentItem ( cn ); |
1241 | ensureItemVisible ( cn ); | 1252 | ensureItemVisible ( cn ); |
1242 | } | 1253 | } |
1243 | e->accept(); | 1254 | e->accept(); |
1244 | return; | 1255 | return; |
1245 | } | 1256 | } |
1246 | if ( e->state() == ControlButton ) { | 1257 | if ( e->state() == ControlButton ) { |
1247 | int count = childCount (); | 1258 | int count = childCount (); |
1248 | int jump = count / 5; | 1259 | int jump = count / 5; |
1249 | QListViewItem* cn; | 1260 | QListViewItem* cn; |
1250 | cn = currentItem(); | 1261 | cn = currentItem(); |
1251 | if ( ! cn ) | 1262 | if ( ! cn ) |
1252 | return; | 1263 | return; |
1253 | if ( jump == 0 ) | 1264 | if ( jump == 0 ) |
1254 | jump = 1; | 1265 | jump = 1; |
1255 | while ( jump && cn->itemAbove ()) { | 1266 | while ( jump && cn->itemAbove ()) { |
1256 | cn = cn->itemAbove (); | 1267 | cn = cn->itemAbove (); |
1257 | --jump; | 1268 | --jump; |
1258 | } | 1269 | } |
1259 | setCurrentItem ( cn ); | 1270 | setCurrentItem ( cn ); |
1260 | ensureItemVisible ( cn ); | 1271 | ensureItemVisible ( cn ); |
1261 | } else | 1272 | } else |
1262 | QListView::keyPressEvent ( e ) ; | 1273 | QListView::keyPressEvent ( e ) ; |
1263 | e->accept(); | 1274 | e->accept(); |
1264 | break; | 1275 | break; |
1265 | case Qt::Key_I: { | 1276 | case Qt::Key_I: { |
1266 | QListViewItem* cn; | 1277 | QListViewItem* cn; |
1267 | cn = currentItem(); | 1278 | cn = currentItem(); |
1268 | if ( cn ) { | 1279 | if ( cn ) { |
1269 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1280 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1270 | if ( ci ){ | 1281 | if ( ci ){ |
1271 | //emit showIncidence( ci->data()); | 1282 | //emit showIncidence( ci->data()); |
1272 | cn = cn->nextSibling(); | 1283 | cn = cn->nextSibling(); |
1273 | if ( cn ) { | 1284 | if ( cn ) { |
1274 | setCurrentItem ( cn ); | 1285 | setCurrentItem ( cn ); |
1275 | ensureItemVisible ( cn ); | 1286 | ensureItemVisible ( cn ); |
1276 | } | 1287 | } |
1277 | emit showIncidence( ci->data()); | 1288 | emit showIncidence( ci->data()); |
1278 | } | 1289 | } |
1279 | } | 1290 | } |
1280 | e->accept(); | 1291 | e->accept(); |
1281 | } | 1292 | } |
1282 | break; | 1293 | break; |
1283 | case Qt::Key_Return: | 1294 | case Qt::Key_Return: |
1284 | case Qt::Key_Enter: | 1295 | case Qt::Key_Enter: |
1285 | { | 1296 | { |
1286 | QListViewItem* cn; | 1297 | QListViewItem* cn; |
1287 | cn = currentItem(); | 1298 | cn = currentItem(); |
1288 | if ( cn ) { | 1299 | if ( cn ) { |
1289 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1300 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1290 | if ( ci ){ | 1301 | if ( ci ){ |
1291 | if ( e->state() == ShiftButton ) | 1302 | if ( e->state() == ShiftButton ) |
1292 | ci->setSelected( false ); | 1303 | ci->setSelected( false ); |
1293 | else | 1304 | else |
1294 | ci->setSelected( true ); | 1305 | ci->setSelected( true ); |
1295 | cn = cn->nextSibling(); | 1306 | cn = cn->nextSibling(); |
1296 | if ( cn ) { | 1307 | if ( cn ) { |
1297 | setCurrentItem ( cn ); | 1308 | setCurrentItem ( cn ); |
1298 | ensureItemVisible ( cn ); | 1309 | ensureItemVisible ( cn ); |
1299 | } | 1310 | } |
1300 | } | 1311 | } |
1301 | } | 1312 | } |
1302 | e->accept(); | 1313 | e->accept(); |
1303 | } | 1314 | } |
1304 | break; | 1315 | break; |
1305 | default: | 1316 | default: |
1306 | e->ignore(); | 1317 | e->ignore(); |
1307 | } | 1318 | } |
1308 | } | 1319 | } |
1309 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1320 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1310 | : KListView( lv, "kolistlistview", false ) | 1321 | : KListView( lv, "kolistlistview", false ) |
1311 | { | 1322 | { |
1312 | mYMousePos = 0; | 1323 | mYMousePos = 0; |
1313 | mPopupTimer = new QTimer(this); | 1324 | mPopupTimer = new QTimer(this); |
1314 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1325 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1315 | #ifndef DESKTOP_VERSION | 1326 | #ifndef DESKTOP_VERSION |
1316 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1327 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1317 | #endif | 1328 | #endif |
1318 | setSelectionMode( QListView::Multi ); | 1329 | setSelectionMode( QListView::Multi ); |
1319 | setMultiSelection( true); | 1330 | setMultiSelection( true); |
1320 | } | 1331 | } |
1321 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1332 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) |
1322 | { | 1333 | { |
1323 | int selCount = 0; | 1334 | int selCount = 0; |
1324 | QListViewItem *qitem = firstChild (); | 1335 | QListViewItem *qitem = firstChild (); |
1325 | while ( qitem ) { | 1336 | while ( qitem ) { |
1326 | if ( qitem->isSelected() && item != qitem ) | 1337 | if ( qitem->isSelected() && item != qitem ) |
1327 | return true; | 1338 | return true; |
1328 | qitem = qitem->nextSibling(); | 1339 | qitem = qitem->nextSibling(); |
1329 | } | 1340 | } |
1330 | return false; | 1341 | return false; |
1331 | } | 1342 | } |
1332 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1343 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1333 | { | 1344 | { |
1334 | if (!e) return; | 1345 | if (!e) return; |
1335 | QPoint vp = contentsToViewport(e->pos()); | 1346 | QPoint vp = contentsToViewport(e->pos()); |
1336 | QListViewItem *item = itemAt(vp); | 1347 | QListViewItem *item = itemAt(vp); |
1337 | if (!item) { | 1348 | if (!item) { |
1338 | emit newEvent(); | 1349 | emit newEvent(); |
1339 | return; | 1350 | return; |
1340 | } | 1351 | } |
1341 | KListView::contentsMouseDoubleClickEvent(e); | 1352 | KListView::contentsMouseDoubleClickEvent(e); |
1342 | } | 1353 | } |
1343 | #if 0 | 1354 | #if 0 |
1344 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1355 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1345 | { | 1356 | { |
1346 | //qDebug("contentsMousePressEvent++++ "); | 1357 | //qDebug("contentsMousePressEvent++++ "); |
1347 | KListView::contentsMousePressEvent( e ); | 1358 | KListView::contentsMousePressEvent( e ); |
1348 | if ( e->button() == RightButton ) { | 1359 | if ( e->button() == RightButton ) { |
1349 | QListViewItem* ci = currentItem(); | 1360 | QListViewItem* ci = currentItem(); |
1350 | clearSelection () ; | 1361 | clearSelection () ; |
1351 | if ( ci ) | 1362 | if ( ci ) |
1352 | ci->setSelected( true ); | 1363 | ci->setSelected( true ); |
1353 | } | 1364 | } |
1354 | } | 1365 | } |
1355 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1366 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1356 | { | 1367 | { |
1357 | KListView::contentsMouseReleaseEvent(e); | 1368 | KListView::contentsMouseReleaseEvent(e); |
1358 | } | 1369 | } |
1359 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1370 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1360 | { | 1371 | { |
1361 | KListView::contentsMouseMoveEvent(e); | 1372 | KListView::contentsMouseMoveEvent(e); |
1362 | } | 1373 | } |
1363 | #endif | 1374 | #endif |
1364 | void KOListViewListView::popupMenu() | 1375 | void KOListViewListView::popupMenu() |
1365 | { | 1376 | { |
1366 | mPopupTimer->stop(); | 1377 | mPopupTimer->stop(); |
1367 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1378 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1368 | QApplication::postEvent( this->viewport(), e ); | 1379 | QApplication::postEvent( this->viewport(), e ); |
1369 | 1380 | ||
1370 | } | 1381 | } |
1371 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1382 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1372 | { | 1383 | { |
1373 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1384 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1374 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1385 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1375 | if ( e->button() == LeftButton ) { | 1386 | if ( e->button() == LeftButton ) { |
1376 | mPopupTimer->start( 600 ); | 1387 | mPopupTimer->start( 600 ); |
1377 | mEventPos = contentsToViewport(e->pos()); | 1388 | mEventPos = contentsToViewport(e->pos()); |
1378 | mEventGlobalPos = e->globalPos(); | 1389 | mEventGlobalPos = e->globalPos(); |
1379 | } | 1390 | } |
1380 | KListView::contentsMousePressEvent( e ); | 1391 | KListView::contentsMousePressEvent( e ); |
1381 | if ( e->button() == RightButton ) { | 1392 | if ( e->button() == RightButton ) { |
1382 | QListViewItem* ci = currentItem(); | 1393 | QListViewItem* ci = currentItem(); |
1383 | //clearSelection(); | 1394 | //clearSelection(); |
1384 | if ( ci ) | 1395 | if ( ci ) |
1385 | ci->setSelected( true ); | 1396 | ci->setSelected( true ); |
1386 | } | 1397 | } |
1387 | } | 1398 | } |
1388 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1399 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1389 | { | 1400 | { |
1390 | mPopupTimer->stop(); | 1401 | mPopupTimer->stop(); |
1391 | KListView::contentsMouseReleaseEvent(e); | 1402 | KListView::contentsMouseReleaseEvent(e); |
1392 | } | 1403 | } |
1393 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1404 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1394 | { | 1405 | { |
1395 | // qDebug("contentsMouseMoveEv....... "); | 1406 | // qDebug("contentsMouseMoveEv....... "); |
1396 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1407 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1397 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1408 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1398 | if ( diff < 0 ) diff = -diff; | 1409 | if ( diff < 0 ) diff = -diff; |
1399 | if ( diff > 15 ) | 1410 | if ( diff > 15 ) |
1400 | mPopupTimer->stop(); | 1411 | mPopupTimer->stop(); |
1401 | else { | 1412 | else { |
1402 | mEventPos = contentsToViewport(e->pos()); | 1413 | mEventPos = contentsToViewport(e->pos()); |
1403 | mEventGlobalPos = e->globalPos(); | 1414 | mEventGlobalPos = e->globalPos(); |
1404 | } | 1415 | } |
1405 | KListView::contentsMouseMoveEvent(e); | 1416 | KListView::contentsMouseMoveEvent(e); |
1406 | } | 1417 | } |
1407 | 1418 | ||
1408 | #define protected public | 1419 | #define protected public |
1409 | #include <qheader.h> | 1420 | #include <qheader.h> |
1410 | #undef protected | 1421 | #undef protected |
1411 | void KOListViewListView::printList() | 1422 | void KOListViewListView::printList() |
1412 | { | 1423 | { |
1413 | #ifdef DESKTOP_VERSION | 1424 | #ifdef DESKTOP_VERSION |
1414 | KOPrintPrefs pp ( this ); | 1425 | KOPrintPrefs pp ( this ); |
1415 | if (!pp.exec() ) | 1426 | if (!pp.exec() ) |
1416 | return; | 1427 | return; |
1417 | int scaleval = pp.printMode() ; | 1428 | int scaleval = pp.printMode() ; |
1418 | 1429 | ||
1419 | QPrinter printer; | 1430 | QPrinter printer; |
1420 | if (!printer.setup() ) | 1431 | if (!printer.setup() ) |
1421 | return; | 1432 | return; |
1422 | clearSelection (); | 1433 | clearSelection (); |
1423 | QPainter p; | 1434 | QPainter p; |
1424 | p.begin ( &printer ); | 1435 | p.begin ( &printer ); |
1425 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 1436 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
1426 | float dx, dy; | 1437 | float dx, dy; |
1427 | int wid = (m.width() * 9)/10; | 1438 | int wid = (m.width() * 9)/10; |
1428 | dx = (float) wid/(float)contentsWidth (); | 1439 | dx = (float) wid/(float)contentsWidth (); |
1429 | dy = (float)(m.height()) / (float)contentsHeight (); | 1440 | dy = (float)(m.height()) / (float)contentsHeight (); |
1430 | float scale; | 1441 | float scale; |
1431 | // scale to fit the width or height of the paper | 1442 | // scale to fit the width or height of the paper |
1432 | if ( dx < dy ) | 1443 | if ( dx < dy ) |
1433 | scale = dx; | 1444 | scale = dx; |
1434 | else | 1445 | else |
1435 | scale = dy; | 1446 | scale = dy; |
1436 | 1447 | ||
1437 | p.translate( m.width()/10,m.width()/10 ); | 1448 | p.translate( m.width()/10,m.width()/10 ); |
1438 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1449 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1439 | p.scale( scale, scale ); | 1450 | p.scale( scale, scale ); |
1440 | } | 1451 | } |
1441 | 1452 | ||
1442 | int cou = header()->count(); | 1453 | int cou = header()->count(); |
1443 | int iii; | 1454 | int iii; |
1444 | QRect rect ( 0,0,0, header()->height()); | 1455 | QRect rect ( 0,0,0, header()->height()); |
1445 | for ( iii = 0; iii < cou; ++iii ) { | 1456 | for ( iii = 0; iii < cou; ++iii ) { |
1446 | rect.setLeft ( header()->sectionPos( iii ) ); | 1457 | rect.setLeft ( header()->sectionPos( iii ) ); |
1447 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1458 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1448 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1459 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
1449 | } | 1460 | } |
1450 | p.translate( 0, header()->height()); | 1461 | p.translate( 0, header()->height()); |
1451 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | 1462 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); |
1452 | p.end(); | 1463 | p.end(); |
1453 | #endif | 1464 | #endif |
1454 | } | 1465 | } |
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index d384af0..bcef0f0 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h | |||
@@ -1,321 +1,323 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef _KOLISTVIEW_H | 24 | #ifndef _KOLISTVIEW_H |
25 | #define _KOLISTVIEW_H | 25 | #define _KOLISTVIEW_H |
26 | 26 | ||
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include <klistview.h> | 31 | #include <klistview.h> |
32 | 32 | ||
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/incidence.h> | 38 | #include <libkcal/incidence.h> |
39 | 39 | ||
40 | #include "koeventview.h" | 40 | #include "koeventview.h" |
41 | #include "customlistviewitem.h" | 41 | #include "customlistviewitem.h" |
42 | 42 | ||
43 | using namespace KCal; | 43 | using namespace KCal; |
44 | 44 | ||
45 | class KOListViewWhatsThis; | 45 | class KOListViewWhatsThis; |
46 | 46 | ||
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qdialog.h> | 49 | #include <qdialog.h> |
50 | #include <qtimer.h> | 50 | #include <qtimer.h> |
51 | #include <qcombobox.h> | 51 | #include <qcombobox.h> |
52 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
53 | #include <qtooltip.h> | 53 | #include <qtooltip.h> |
54 | #include <qcheckbox.h> | 54 | #include <qcheckbox.h> |
55 | #include <qhbox.h> | 55 | #include <qhbox.h> |
56 | #include <qlabel.h> | 56 | #include <qlabel.h> |
57 | #include <kiconloader.h> | 57 | #include <kiconloader.h> |
58 | #include "kfiledialog.h" | 58 | #include "kfiledialog.h" |
59 | #include "koprefs.h" | 59 | #include "koprefs.h" |
60 | class KOAlarmPrefs : public QDialog | 60 | class KOAlarmPrefs : public QDialog |
61 | { | 61 | { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | public: | 63 | public: |
64 | KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : | 64 | KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : |
65 | QDialog( par, name, true ) | 65 | QDialog( par, name, true ) |
66 | { | 66 | { |
67 | setCaption( i18n("Alarm Options") ); | 67 | setCaption( i18n("Alarm Options") ); |
68 | QVBoxLayout* alarmLayout = new QVBoxLayout( this ); | 68 | QVBoxLayout* alarmLayout = new QVBoxLayout( this ); |
69 | alarmLayout->setSpacing( 3 ); | 69 | alarmLayout->setSpacing( 3 ); |
70 | alarmLayout->setMargin( 3 ); | 70 | alarmLayout->setMargin( 3 ); |
71 | QWidget *parent = this; | 71 | QWidget *parent = this; |
72 | mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); | 72 | mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); |
73 | alarmLayout->addWidget(mAlarmButton); | 73 | alarmLayout->addWidget(mAlarmButton); |
74 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 74 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
75 | mAlarmTimeEdit->setValue( 15 ); | 75 | mAlarmTimeEdit->setValue( 15 ); |
76 | alarmLayout->addWidget(mAlarmTimeEdit); | 76 | alarmLayout->addWidget(mAlarmTimeEdit); |
77 | mAlarmIncrCombo = new QComboBox(false, parent); | 77 | mAlarmIncrCombo = new QComboBox(false, parent); |
78 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 78 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
79 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 79 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
80 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 80 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
81 | alarmLayout->addWidget(mAlarmIncrCombo); | 81 | alarmLayout->addWidget(mAlarmIncrCombo); |
82 | QHBox * hb = new QHBox ( parent ); | 82 | QHBox * hb = new QHBox ( parent ); |
83 | alarmLayout->addWidget(hb); | 83 | alarmLayout->addWidget(hb); |
84 | mAlarmSoundButton = new QPushButton(hb); | 84 | mAlarmSoundButton = new QPushButton(hb); |
85 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 85 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
86 | mAlarmSoundButton->setToggleButton(true); | 86 | mAlarmSoundButton->setToggleButton(true); |
87 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 87 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
88 | mAlarmProgramButton = new QPushButton(hb); | 88 | mAlarmProgramButton = new QPushButton(hb); |
89 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 89 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
90 | mAlarmProgramButton->setToggleButton(true); | 90 | mAlarmProgramButton->setToggleButton(true); |
91 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 91 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
92 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 92 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
93 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 93 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
94 | mAlarmLabel = new QLabel( this ); | 94 | mAlarmLabel = new QLabel( this ); |
95 | alarmLayout->addWidget( mAlarmLabel ); | 95 | alarmLayout->addWidget( mAlarmLabel ); |
96 | mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); | 96 | mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); |
97 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 97 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
98 | mAlarmSoundButton->setOn( true ); | 98 | mAlarmSoundButton->setOn( true ); |
99 | QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); | 99 | QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); |
100 | alarmLayout->addWidget( ok ); | 100 | alarmLayout->addWidget( ok ); |
101 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 101 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
102 | alarmLayout->addWidget( cancel ); | 102 | alarmLayout->addWidget( cancel ); |
103 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 103 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
104 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 104 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
105 | resize( 200, 200 ); | 105 | resize( 200, 200 ); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | QString mAlarmSound, mAlarmProgram ; | 111 | QString mAlarmSound, mAlarmProgram ; |
112 | QCheckBox* mAlarmButton; | 112 | QCheckBox* mAlarmButton; |
113 | QSpinBox* mAlarmTimeEdit; | 113 | QSpinBox* mAlarmTimeEdit; |
114 | QLabel* mAlarmLabel; | 114 | QLabel* mAlarmLabel; |
115 | QComboBox* mAlarmIncrCombo ; | 115 | QComboBox* mAlarmIncrCombo ; |
116 | QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; | 116 | QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; |
117 | private slots: | 117 | private slots: |
118 | 118 | ||
119 | void pickAlarmSound() | 119 | void pickAlarmSound() |
120 | { | 120 | { |
121 | //QString prefix = mAlarmSound; | 121 | //QString prefix = mAlarmSound; |
122 | if (!mAlarmSoundButton->isOn()) { | 122 | if (!mAlarmSoundButton->isOn()) { |
123 | //mAlarmSound = ""; | 123 | //mAlarmSound = ""; |
124 | QToolTip::remove(mAlarmSoundButton); | 124 | QToolTip::remove(mAlarmSoundButton); |
125 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 125 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
126 | mAlarmProgramButton->setOn(true); | 126 | mAlarmProgramButton->setOn(true); |
127 | mAlarmSoundButton->setOn(false); | 127 | mAlarmSoundButton->setOn(false); |
128 | } else { | 128 | } else { |
129 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 129 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
130 | i18n("*.wav|Wav Files"), 0)); | 130 | i18n("*.wav|Wav Files"), 0)); |
131 | if (!fileName.isEmpty()) { | 131 | if (!fileName.isEmpty()) { |
132 | mAlarmSound = fileName; | 132 | mAlarmSound = fileName; |
133 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); | 133 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); |
134 | QToolTip::remove(mAlarmSoundButton); | 134 | QToolTip::remove(mAlarmSoundButton); |
135 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 135 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
136 | QToolTip::add(mAlarmSoundButton, dispStr); | 136 | QToolTip::add(mAlarmSoundButton, dispStr); |
137 | mAlarmProgramButton->setOn(false); | 137 | mAlarmProgramButton->setOn(false); |
138 | mAlarmSoundButton->setOn(true); | 138 | mAlarmSoundButton->setOn(true); |
139 | } else { | 139 | } else { |
140 | mAlarmProgramButton->setOn(true); | 140 | mAlarmProgramButton->setOn(true); |
141 | mAlarmSoundButton->setOn(false); | 141 | mAlarmSoundButton->setOn(false); |
142 | 142 | ||
143 | } | 143 | } |
144 | } | 144 | } |
145 | }; | 145 | }; |
146 | 146 | ||
147 | void pickAlarmProgram() | 147 | void pickAlarmProgram() |
148 | { | 148 | { |
149 | if (!mAlarmProgramButton->isOn()) { | 149 | if (!mAlarmProgramButton->isOn()) { |
150 | //mAlarmProgram = ""; | 150 | //mAlarmProgram = ""; |
151 | QToolTip::remove(mAlarmProgramButton); | 151 | QToolTip::remove(mAlarmProgramButton); |
152 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 152 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
153 | mAlarmProgramButton->setOn(false); | 153 | mAlarmProgramButton->setOn(false); |
154 | mAlarmSoundButton->setOn(true); | 154 | mAlarmSoundButton->setOn(true); |
155 | } else { | 155 | } else { |
156 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); | 156 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); |
157 | if (!fileName.isEmpty()) { | 157 | if (!fileName.isEmpty()) { |
158 | mAlarmProgram = fileName; | 158 | mAlarmProgram = fileName; |
159 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); | 159 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); |
160 | QToolTip::remove(mAlarmProgramButton); | 160 | QToolTip::remove(mAlarmProgramButton); |
161 | QString dispStr = i18n("Running '%1'").arg(fileName); | 161 | QString dispStr = i18n("Running '%1'").arg(fileName); |
162 | QToolTip::add(mAlarmProgramButton, dispStr); | 162 | QToolTip::add(mAlarmProgramButton, dispStr); |
163 | mAlarmSoundButton->setOn(false); | 163 | mAlarmSoundButton->setOn(false); |
164 | mAlarmProgramButton->setOn(true); | 164 | mAlarmProgramButton->setOn(true); |
165 | } else { | 165 | } else { |
166 | mAlarmProgramButton->setOn(false); | 166 | mAlarmProgramButton->setOn(false); |
167 | mAlarmSoundButton->setOn(true); | 167 | mAlarmSoundButton->setOn(true); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | }; | 170 | }; |
171 | 171 | ||
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | 177 | ||
178 | 178 | ||
179 | 179 | ||
180 | typedef CustomListViewItem<Incidence *> KOListViewItem; | 180 | typedef CustomListViewItem<Incidence *> KOListViewItem; |
181 | 181 | ||
182 | /** | 182 | /** |
183 | This class provides the initialisation of a KOListViewItem for calendar | 183 | This class provides the initialisation of a KOListViewItem for calendar |
184 | components using the Incidence::Visitor. | 184 | components using the Incidence::Visitor. |
185 | */ | 185 | */ |
186 | class ListItemVisitor : public Incidence::Visitor | 186 | class ListItemVisitor : public Incidence::Visitor |
187 | { | 187 | { |
188 | public: | 188 | public: |
189 | ListItemVisitor(KOListViewItem *, QDate d); | 189 | ListItemVisitor(KOListViewItem *, QDate d); |
190 | ~ListItemVisitor(); | 190 | ~ListItemVisitor(); |
191 | 191 | ||
192 | bool visit(Event *); | 192 | bool visit(Event *); |
193 | bool visit(Todo *); | 193 | bool visit(Todo *); |
194 | bool visit(Journal *); | 194 | bool visit(Journal *); |
195 | 195 | ||
196 | private: | 196 | private: |
197 | KOListViewItem *mItem; | 197 | KOListViewItem *mItem; |
198 | QDate mDate; | 198 | QDate mDate; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | This class provides a multi-column list view of events. It can | 202 | This class provides a multi-column list view of events. It can |
203 | display events from one particular day or several days, it doesn't | 203 | display events from one particular day or several days, it doesn't |
204 | matter. To use a view that only handles one day at a time, use | 204 | matter. To use a view that only handles one day at a time, use |
205 | KODayListView. | 205 | KODayListView. |
206 | 206 | ||
207 | @short multi-column list view of various events. | 207 | @short multi-column list view of various events. |
208 | @author Preston Brown <pbrown@kde.org> | 208 | @author Preston Brown <pbrown@kde.org> |
209 | @see KOBaseView, KODayListView | 209 | @see KOBaseView, KODayListView |
210 | */ | 210 | */ |
211 | class KOListView; | 211 | class KOListView; |
212 | 212 | ||
213 | class KOListViewListView : public KListView | 213 | class KOListViewListView : public KListView |
214 | { | 214 | { |
215 | Q_OBJECT | 215 | Q_OBJECT |
216 | public: | 216 | public: |
217 | KOListViewListView(KOListView * lv ); | 217 | KOListViewListView(KOListView * lv ); |
218 | bool hasMultiSelection(QListViewItem*); | 218 | bool hasMultiSelection(QListViewItem*); |
219 | void printList(); | 219 | void printList(); |
220 | signals: | 220 | signals: |
221 | void newEvent(); | 221 | void newEvent(); |
222 | void showIncidence( Incidence* ); | 222 | void showIncidence( Incidence* ); |
223 | public slots: | 223 | public slots: |
224 | void popupMenu(); | 224 | void popupMenu(); |
225 | private: | 225 | private: |
226 | QPoint mEventPos; | 226 | QPoint mEventPos; |
227 | QPoint mEventGlobalPos; | 227 | QPoint mEventGlobalPos; |
228 | QTimer* mPopupTimer; | 228 | QTimer* mPopupTimer; |
229 | int mYMousePos; | 229 | int mYMousePos; |
230 | void keyPressEvent ( QKeyEvent * ) ; | 230 | void keyPressEvent ( QKeyEvent * ) ; |
231 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | 231 | void contentsMouseDoubleClickEvent(QMouseEvent *e); |
232 | void contentsMousePressEvent(QMouseEvent *e); | 232 | void contentsMousePressEvent(QMouseEvent *e); |
233 | void contentsMouseReleaseEvent(QMouseEvent *e); | 233 | void contentsMouseReleaseEvent(QMouseEvent *e); |
234 | void contentsMouseMoveEvent(QMouseEvent *e); | 234 | void contentsMouseMoveEvent(QMouseEvent *e); |
235 | bool mMouseDown; | 235 | bool mMouseDown; |
236 | }; | 236 | }; |
237 | 237 | ||
238 | class KOListView : public KOEventView | 238 | class KOListView : public KOEventView |
239 | { | 239 | { |
240 | Q_OBJECT | 240 | Q_OBJECT |
241 | public: | 241 | public: |
242 | KOListView(Calendar *calendar, QWidget *parent = 0, | 242 | KOListView(Calendar *calendar, QWidget *parent = 0, |
243 | const char *name = 0); | 243 | const char *name = 0); |
244 | ~KOListView(); | 244 | ~KOListView(); |
245 | 245 | ||
246 | virtual int maxDatesHint(); | 246 | virtual int maxDatesHint(); |
247 | virtual int currentDateCount(); | 247 | virtual int currentDateCount(); |
248 | virtual QPtrList<Incidence> selectedIncidences(); | 248 | virtual QPtrList<Incidence> selectedIncidences(); |
249 | virtual DateList selectedDates(); | 249 | virtual DateList selectedDates(); |
250 | 250 | ||
251 | void showDates(bool show); | 251 | void showDates(bool show); |
252 | Incidence* currentItem(); | 252 | Incidence* currentItem(); |
253 | void addTodos(QPtrList<Todo> eventList); | 253 | void addTodos(QPtrList<Todo> eventList); |
254 | void addJournals(QPtrList<Journal> eventList); | 254 | void addJournals(QPtrList<Journal> eventList); |
255 | virtual void printPreview(CalPrinter *calPrinter, | 255 | virtual void printPreview(CalPrinter *calPrinter, |
256 | const QDate &, const QDate &); | 256 | const QDate &, const QDate &); |
257 | 257 | ||
258 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); | 258 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); |
259 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); | 259 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); |
260 | void updateList(); | 260 | void updateList(); |
261 | void clearList(); | 261 | void clearList(); |
262 | void setStartDate(const QDate &start); | 262 | void setStartDate(const QDate &start); |
263 | int count(); | 263 | int count(); |
264 | QString getWhatsThisText(QPoint p); | 264 | QString getWhatsThisText(QPoint p); |
265 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); | 265 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); |
266 | void showCompletedTodos(); | ||
266 | signals: | 267 | signals: |
267 | void signalNewEvent(); | 268 | void signalNewEvent(); |
268 | void beamIncidenceList(QPtrList<Incidence>); | 269 | void beamIncidenceList(QPtrList<Incidence>); |
269 | 270 | ||
270 | public slots: | 271 | public slots: |
271 | void hideAll(); | 272 | void hideAll(); |
272 | void printList(); | 273 | void printList(); |
273 | void resetFocus(); | 274 | void resetFocus(); |
274 | virtual void updateView(); | 275 | virtual void updateView(); |
275 | virtual void showDates(const QDate &start, const QDate &end); | 276 | virtual void showDates(const QDate &start, const QDate &end); |
276 | virtual void showEvents(QPtrList<Event> eventList); | 277 | virtual void showEvents(QPtrList<Event> eventList); |
277 | void clearSelection(); | 278 | void clearSelection(); |
278 | void allSelection(); | 279 | void allSelection(); |
279 | 280 | ||
280 | void clear(); | 281 | void clear(); |
281 | void beamDone( Ir *ir ); | 282 | void beamDone( Ir *ir ); |
282 | void showDates(); | 283 | void showDates(); |
283 | void hideDates(); | 284 | void hideDates(); |
284 | void deleteAll(); | 285 | void deleteAll(); |
285 | void saveToFile(); | 286 | void saveToFile(); |
286 | void saveToFileVCS(); | 287 | void saveToFileVCS(); |
287 | void saveDescriptionToFile(); | 288 | void saveDescriptionToFile(); |
288 | void beamSelected(); | 289 | void beamSelected(); |
289 | void updateConfig(); | 290 | void updateConfig(); |
290 | void addCat(); | 291 | void addCat(); |
291 | void setCat(); | 292 | void setCat(); |
292 | void setAlarm(); | 293 | void setAlarm(); |
293 | void setCategories( bool removeOld ); | 294 | void setCategories( bool removeOld ); |
294 | void changeEventDisplay(Event *, int); | 295 | void changeEventDisplay(Event *, int); |
295 | 296 | ||
296 | void defaultItemAction(QListViewItem *item); | 297 | void defaultItemAction(QListViewItem *item); |
297 | void popupMenu(QListViewItem *item,const QPoint &,int); | 298 | void popupMenu(QListViewItem *item,const QPoint &,int); |
298 | void setCalendar( int c ); | 299 | void setCalendar( int c ); |
299 | void populateCalPopup(); | 300 | void populateCalPopup(); |
300 | 301 | ||
301 | protected slots: | 302 | protected slots: |
302 | void processSelectionChange(QListViewItem *); | 303 | void processSelectionChange(QListViewItem *); |
303 | 304 | ||
304 | protected: | 305 | protected: |
305 | void writeToFile( bool iCal ); | 306 | void writeToFile( bool iCal ); |
306 | void addEvents(QPtrList<Event> eventList); | 307 | void addEvents(QPtrList<Event> eventList); |
307 | void addIncidence(Incidence *); | 308 | void addIncidence(Incidence *); |
308 | KOListViewItem *getItemForEvent(Incidence *event); | 309 | KOListViewItem *getItemForEvent(Incidence *event); |
309 | 310 | ||
310 | private: | 311 | private: |
312 | bool mForceShowCompletedTodos; | ||
311 | QPopupMenu* mCalPopup; | 313 | QPopupMenu* mCalPopup; |
312 | KOListViewWhatsThis *mKOListViewWhatsThis; | 314 | KOListViewWhatsThis *mKOListViewWhatsThis; |
313 | KOListViewListView *mListView; | 315 | KOListViewListView *mListView; |
314 | KOEventPopupMenu *mPopupMenu; | 316 | KOEventPopupMenu *mPopupMenu; |
315 | KOListViewItem *mActiveItem; | 317 | KOListViewItem *mActiveItem; |
316 | QDict<Incidence> mUidDict; | 318 | QDict<Incidence> mUidDict; |
317 | QDate mStartDate; | 319 | QDate mStartDate; |
318 | void keyPressEvent ( QKeyEvent * ) ; | 320 | void keyPressEvent ( QKeyEvent * ) ; |
319 | }; | 321 | }; |
320 | 322 | ||
321 | #endif | 323 | #endif |
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index bba49f0..a8de297 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -1,587 +1,588 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | #include <qgroupbox.h> | 27 | #include <qgroupbox.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlistview.h> | 29 | #include <qlistview.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qhbuttongroup.h> | 33 | #include <qhbuttongroup.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <libkdepim/kdateedit.h> | 37 | #include <libkdepim/kdateedit.h> |
38 | 38 | ||
39 | #include "koglobals.h" | 39 | #include "koglobals.h" |
40 | #include "koprefs.h" | 40 | #include "koprefs.h" |
41 | #include "klineedit.h" | 41 | #include "klineedit.h" |
42 | 42 | ||
43 | #include "calendarview.h" | 43 | #include "calendarview.h" |
44 | #include "koviewmanager.h" | 44 | #include "koviewmanager.h" |
45 | #include "searchdialog.h" | 45 | #include "searchdialog.h" |
46 | 46 | ||
47 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | 47 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) |
48 | : QVBox( 0 ) | 48 | : QVBox( 0 ) |
49 | 49 | ||
50 | { | 50 | { |
51 | mCalendar = calendar; | 51 | mCalendar = calendar; |
52 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); | 52 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); |
53 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); | 53 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); |
54 | 54 | ||
55 | // Search expression | 55 | // Search expression |
56 | QHBoxLayout *subLayout = new QHBoxLayout(); | 56 | QHBoxLayout *subLayout = new QHBoxLayout(); |
57 | layout->addLayout(subLayout); | 57 | layout->addLayout(subLayout); |
58 | /* | 58 | /* |
59 | searchLabel = new QLabel(topFrame); | 59 | searchLabel = new QLabel(topFrame); |
60 | searchLabel->setText(i18n("Search for:")); | 60 | searchLabel->setText(i18n("Search for:")); |
61 | subLayout->addWidget(searchLabel); | 61 | subLayout->addWidget(searchLabel); |
62 | */ | 62 | */ |
63 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); | 63 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); |
64 | //OkButton->setDefault( true ); | 64 | //OkButton->setDefault( true ); |
65 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); | 65 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); |
66 | subLayout->addWidget(OkButton); | 66 | subLayout->addWidget(OkButton); |
67 | searchEdit = new KLineEdit(topFrame); | 67 | searchEdit = new KLineEdit(topFrame); |
68 | subLayout->addWidget(searchEdit); | 68 | subLayout->addWidget(searchEdit); |
69 | 69 | ||
70 | mAddItems = new QRadioButton( "+ ", topFrame ); | 70 | mAddItems = new QRadioButton( "+ ", topFrame ); |
71 | mSubItems = new QRadioButton( "- ", topFrame ); | 71 | mSubItems = new QRadioButton( "- ", topFrame ); |
72 | mRefineItems = new QRadioButton( "< ", topFrame ); | 72 | mRefineItems = new QRadioButton( "< ", topFrame ); |
73 | subLayout->addWidget( mAddItems ); | 73 | subLayout->addWidget( mAddItems ); |
74 | subLayout->addWidget( mSubItems ); | 74 | subLayout->addWidget( mSubItems ); |
75 | subLayout->addWidget( mRefineItems ); | 75 | subLayout->addWidget( mRefineItems ); |
76 | QFont fo ( mAddItems->font() ); | 76 | QFont fo ( mAddItems->font() ); |
77 | fo.setBold( true ); | 77 | fo.setBold( true ); |
78 | fo.setPointSize( fo.pointSize() + 2 ); | 78 | fo.setPointSize( fo.pointSize() + 2 ); |
79 | mAddItems->setFont( fo ); | 79 | mAddItems->setFont( fo ); |
80 | mSubItems->setFont( fo ); | 80 | mSubItems->setFont( fo ); |
81 | mRefineItems->setFont( fo ); | 81 | mRefineItems->setFont( fo ); |
82 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); | 82 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); |
83 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); | 83 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); |
84 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); | 84 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); |
85 | 85 | ||
86 | QPushButton *togButton = new QPushButton( "", topFrame ); | 86 | QPushButton *togButton = new QPushButton( "", topFrame ); |
87 | subLayout->addWidget(togButton); | 87 | subLayout->addWidget(togButton); |
88 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); | 88 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); |
89 | togButton->setPixmap(SmallIcon("1updownarrow")); | 89 | togButton->setPixmap(SmallIcon("1updownarrow")); |
90 | togButton->setMinimumWidth( togButton->sizeHint().height() ); | 90 | togButton->setMinimumWidth( togButton->sizeHint().height() ); |
91 | 91 | ||
92 | searchEdit->setText("*"); // Find all events by default | 92 | searchEdit->setText("*"); // Find all events by default |
93 | searchEdit->setFocus(); | 93 | searchEdit->setFocus(); |
94 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); | 94 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); |
95 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); | 95 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); |
96 | // Subjects to search | 96 | // Subjects to search |
97 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), | 97 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), |
98 | // topFrame); | 98 | // topFrame); |
99 | 99 | ||
100 | incidenceGroup = new QHBox( topFrame ); | 100 | incidenceGroup = new QHBox( topFrame ); |
101 | layout->addWidget(incidenceGroup); | 101 | layout->addWidget(incidenceGroup); |
102 | 102 | ||
103 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); | 103 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); |
104 | //mSearchEvent->setChecked(true); | 104 | //mSearchEvent->setChecked(true); |
105 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); | 105 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); |
106 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); | 106 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); |
107 | 107 | ||
108 | subjectGroup = new QHBox( topFrame ); | 108 | subjectGroup = new QHBox( topFrame ); |
109 | layout->addWidget(subjectGroup); | 109 | layout->addWidget(subjectGroup); |
110 | 110 | ||
111 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); | 111 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); |
112 | mSummaryCheck->setChecked(true); | 112 | mSummaryCheck->setChecked(true); |
113 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); | 113 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); |
114 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); | 114 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); |
115 | 115 | ||
116 | attendeeGroup = new QHBox( topFrame ); | 116 | attendeeGroup = new QHBox( topFrame ); |
117 | layout->addWidget(attendeeGroup ); | 117 | layout->addWidget(attendeeGroup ); |
118 | new QLabel( i18n("Attendee:"),attendeeGroup ); | 118 | new QLabel( i18n("Attendee:"),attendeeGroup ); |
119 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); | 119 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); |
120 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); | 120 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); |
121 | // Date range | 121 | // Date range |
122 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), | 122 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), |
123 | // topFrame); | 123 | // topFrame); |
124 | // layout->addWidget(rangeGroup); | 124 | // layout->addWidget(rangeGroup); |
125 | 125 | ||
126 | QWidget *rangeWidget = new QWidget(topFrame); | 126 | QWidget *rangeWidget = new QWidget(topFrame); |
127 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); | 127 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); |
128 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); | 128 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); |
129 | mStartDate = new KDateEdit(rangeWidget); | 129 | mStartDate = new KDateEdit(rangeWidget); |
130 | rangeLayout->addWidget(mStartDate); | 130 | rangeLayout->addWidget(mStartDate); |
131 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); | 131 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); |
132 | mEndDate = new KDateEdit(rangeWidget); | 132 | mEndDate = new KDateEdit(rangeWidget); |
133 | mEndDate->setDate(QDate::currentDate().addDays(365)); | 133 | mEndDate->setDate(QDate::currentDate().addDays(365)); |
134 | rangeLayout->addWidget(mEndDate); | 134 | rangeLayout->addWidget(mEndDate); |
135 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); | 135 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); |
136 | rangeLayout->addWidget( (QWidget*)wt ); | 136 | rangeLayout->addWidget( (QWidget*)wt ); |
137 | layout->addWidget(rangeWidget); | 137 | layout->addWidget(rangeWidget); |
138 | // Results list view | 138 | // Results list view |
139 | listView = new KOListView(mCalendar,topFrame); | 139 | listView = new KOListView(mCalendar,topFrame); |
140 | layout->addWidget(listView); | 140 | layout->addWidget(listView); |
141 | listView->showCompletedTodos(); | ||
141 | //layout->setStretchFactor( listView, 333 ); | 142 | //layout->setStretchFactor( listView, 333 ); |
142 | //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); | 143 | //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); |
143 | //listView->setMaximumHeight( 50 ); | 144 | //listView->setMaximumHeight( 50 ); |
144 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); | 145 | listView->readSettings(KOGlobals::config(),"SearchListView Layout"); |
145 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); | 146 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); |
146 | 147 | ||
147 | setCaption( i18n("KO/Pi Find: ")); | 148 | setCaption( i18n("KO/Pi Find: ")); |
148 | #ifdef DESKTOP_VERSION | 149 | #ifdef DESKTOP_VERSION |
149 | OkButton = new QPushButton( i18n("Close"), this ); | 150 | OkButton = new QPushButton( i18n("Close"), this ); |
150 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); | 151 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); |
151 | #endif | 152 | #endif |
152 | } | 153 | } |
153 | 154 | ||
154 | SearchDialog::~SearchDialog() | 155 | SearchDialog::~SearchDialog() |
155 | { | 156 | { |
156 | 157 | ||
157 | } | 158 | } |
158 | void SearchDialog::slot_add( bool b ) | 159 | void SearchDialog::slot_add( bool b ) |
159 | { | 160 | { |
160 | if ( b ) { | 161 | if ( b ) { |
161 | if ( mSubItems->isOn() ) mSubItems->toggle(); | 162 | if ( mSubItems->isOn() ) mSubItems->toggle(); |
162 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | 163 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); |
163 | setCaption( i18n("Matching items will be added to list")); | 164 | setCaption( i18n("Matching items will be added to list")); |
164 | } else | 165 | } else |
165 | setCaption( i18n("List will be cleared before search")); | 166 | setCaption( i18n("List will be cleared before search")); |
166 | } | 167 | } |
167 | void SearchDialog::slot_sub( bool b) | 168 | void SearchDialog::slot_sub( bool b) |
168 | { | 169 | { |
169 | if ( b ) { | 170 | if ( b ) { |
170 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | 171 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); |
171 | if ( mAddItems->isOn() ) mAddItems->toggle(); | 172 | if ( mAddItems->isOn() ) mAddItems->toggle(); |
172 | setCaption( i18n("Matching items will be removed from list")); | 173 | setCaption( i18n("Matching items will be removed from list")); |
173 | } else | 174 | } else |
174 | setCaption( i18n("List will be cleared before search")); | 175 | setCaption( i18n("List will be cleared before search")); |
175 | } | 176 | } |
176 | void SearchDialog::slot_refine( bool b) | 177 | void SearchDialog::slot_refine( bool b) |
177 | { | 178 | { |
178 | if ( b ) { | 179 | if ( b ) { |
179 | if ( mSubItems->isOn() ) mSubItems->toggle(); | 180 | if ( mSubItems->isOn() ) mSubItems->toggle(); |
180 | if ( mAddItems->isOn() ) mAddItems->toggle(); | 181 | if ( mAddItems->isOn() ) mAddItems->toggle(); |
181 | setCaption( i18n("Search on displayed list only")); | 182 | setCaption( i18n("Search on displayed list only")); |
182 | } else | 183 | } else |
183 | setCaption( i18n("List will be cleared before search")); | 184 | setCaption( i18n("List will be cleared before search")); |
184 | } | 185 | } |
185 | void SearchDialog::toggleCheckboxes() | 186 | void SearchDialog::toggleCheckboxes() |
186 | { | 187 | { |
187 | if ( incidenceGroup->isVisible() ) { | 188 | if ( incidenceGroup->isVisible() ) { |
188 | incidenceGroup->hide() ; | 189 | incidenceGroup->hide() ; |
189 | subjectGroup->hide() ; | 190 | subjectGroup->hide() ; |
190 | attendeeGroup->hide() ; | 191 | attendeeGroup->hide() ; |
191 | } else { | 192 | } else { |
192 | incidenceGroup->show() ; | 193 | incidenceGroup->show() ; |
193 | subjectGroup->show() ; | 194 | subjectGroup->show() ; |
194 | attendeeGroup->show() ; | 195 | attendeeGroup->show() ; |
195 | } | 196 | } |
196 | } | 197 | } |
197 | void SearchDialog::raiseAndSelect() | 198 | void SearchDialog::raiseAndSelect() |
198 | { | 199 | { |
199 | 200 | ||
200 | static int currentState = 0; | 201 | static int currentState = 0; |
201 | 202 | ||
202 | if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) | 203 | if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) |
203 | currentState = 0; | 204 | currentState = 0; |
204 | int newState = 0; | 205 | int newState = 0; |
205 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 206 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
206 | newState = VIEW_J_VIEW; | 207 | newState = VIEW_J_VIEW; |
207 | } | 208 | } |
208 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 209 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
209 | newState = VIEW_T_VIEW; | 210 | newState = VIEW_T_VIEW; |
210 | } | 211 | } |
211 | else { | 212 | else { |
212 | newState = VIEW_A_VIEW; | 213 | newState = VIEW_A_VIEW; |
213 | } | 214 | } |
214 | if ( newState != currentState ) { | 215 | if ( newState != currentState ) { |
215 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 216 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
216 | if ( ! mSearchJournal->isChecked() ) { | 217 | if ( ! mSearchJournal->isChecked() ) { |
217 | mSearchJournal->setChecked( true ); | 218 | mSearchJournal->setChecked( true ); |
218 | mSearchTodo->setChecked( false ); | 219 | mSearchTodo->setChecked( false ); |
219 | mSearchEvent->setChecked( false ); | 220 | mSearchEvent->setChecked( false ); |
220 | } | 221 | } |
221 | } | 222 | } |
222 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 223 | else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
223 | if ( ! mSearchTodo->isChecked() ) { | 224 | if ( ! mSearchTodo->isChecked() ) { |
224 | mSearchTodo->setChecked( true ); | 225 | mSearchTodo->setChecked( true ); |
225 | mSearchJournal->setChecked( false ); | 226 | mSearchJournal->setChecked( false ); |
226 | mSearchEvent->setChecked( false ); | 227 | mSearchEvent->setChecked( false ); |
227 | } | 228 | } |
228 | } | 229 | } |
229 | else { | 230 | else { |
230 | if ( ! mSearchEvent->isChecked() ) { | 231 | if ( ! mSearchEvent->isChecked() ) { |
231 | mSearchEvent->setChecked( true ); | 232 | mSearchEvent->setChecked( true ); |
232 | mSearchJournal->setChecked( false ); | 233 | mSearchJournal->setChecked( false ); |
233 | mSearchTodo->setChecked( false ); | 234 | mSearchTodo->setChecked( false ); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | } | 237 | } |
237 | currentState = newState; | 238 | currentState = newState; |
238 | raise(); | 239 | raise(); |
239 | } | 240 | } |
240 | void SearchDialog::setFocusToList() | 241 | void SearchDialog::setFocusToList() |
241 | { | 242 | { |
242 | listView->resetFocus(); | 243 | listView->resetFocus(); |
243 | } | 244 | } |
244 | void SearchDialog::accept() | 245 | void SearchDialog::accept() |
245 | { | 246 | { |
246 | doSearch(); | 247 | doSearch(); |
247 | } | 248 | } |
248 | void SearchDialog::updateList() | 249 | void SearchDialog::updateList() |
249 | { | 250 | { |
250 | //listView->updateList(); | 251 | //listView->updateList(); |
251 | if ( isVisible() ) { | 252 | if ( isVisible() ) { |
252 | updateView(); | 253 | updateView(); |
253 | //qDebug("SearchDialog::updated "); | 254 | //qDebug("SearchDialog::updated "); |
254 | } | 255 | } |
255 | else { | 256 | else { |
256 | listView->clear(); | 257 | listView->clear(); |
257 | //qDebug("SearchDialog::cleared "); | 258 | //qDebug("SearchDialog::cleared "); |
258 | 259 | ||
259 | } | 260 | } |
260 | } | 261 | } |
261 | void SearchDialog::searchTextChanged( const QString &_text ) | 262 | void SearchDialog::searchTextChanged( const QString &_text ) |
262 | { | 263 | { |
263 | #if 0 | 264 | #if 0 |
264 | enableButton( KDialogBase::User1, !_text.isEmpty() ); | 265 | enableButton( KDialogBase::User1, !_text.isEmpty() ); |
265 | #endif | 266 | #endif |
266 | } | 267 | } |
267 | 268 | ||
268 | void SearchDialog::doSearch() | 269 | void SearchDialog::doSearch() |
269 | { | 270 | { |
270 | QRegExp re; | 271 | QRegExp re; |
271 | 272 | ||
272 | re.setWildcard(true); // most people understand these better. | 273 | re.setWildcard(true); // most people understand these better. |
273 | re.setCaseSensitive(false); | 274 | re.setCaseSensitive(false); |
274 | QString st = searchEdit->text(); | 275 | QString st = searchEdit->text(); |
275 | if ( st.right(1) != "*") | 276 | if ( st.right(1) != "*") |
276 | st += "*"; | 277 | st += "*"; |
277 | re.setPattern(st); | 278 | re.setPattern(st); |
278 | if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { | 279 | if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { |
279 | KMessageBox::sorry(this, | 280 | KMessageBox::sorry(this, |
280 | i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); | 281 | i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); |
281 | return; | 282 | return; |
282 | } | 283 | } |
283 | if (!re.isValid() ) { | 284 | if (!re.isValid() ) { |
284 | KMessageBox::sorry(this, | 285 | KMessageBox::sorry(this, |
285 | i18n("Invalid search expression,\ncannot perform " | 286 | i18n("Invalid search expression,\ncannot perform " |
286 | "the search.\nPlease enter a search expression\n" | 287 | "the search.\nPlease enter a search expression\n" |
287 | "using the wildcard characters\n '*' and '?'" | 288 | "using the wildcard characters\n '*' and '?'" |
288 | "where needed.")); | 289 | "where needed.")); |
289 | return; | 290 | return; |
290 | } | 291 | } |
291 | search(re); | 292 | search(re); |
292 | listView->setStartDate( mStartDate->date() ); | 293 | listView->setStartDate( mStartDate->date() ); |
293 | listView->showEvents(mMatchedEvents); | 294 | listView->showEvents(mMatchedEvents); |
294 | listView->addTodos(mMatchedTodos); | 295 | listView->addTodos(mMatchedTodos); |
295 | listView->addJournals(mMatchedJournals); | 296 | listView->addJournals(mMatchedJournals); |
296 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { | 297 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { |
297 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); | 298 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); |
298 | } else { | 299 | } else { |
299 | QString mess; | 300 | QString mess; |
300 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); | 301 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); |
301 | setCaption( i18n("KO/Pi Find: ") + mess); | 302 | setCaption( i18n("KO/Pi Find: ") + mess); |
302 | 303 | ||
303 | } | 304 | } |
304 | searchEdit->setFocus(); | 305 | searchEdit->setFocus(); |
305 | } | 306 | } |
306 | void SearchDialog::updateConfig() | 307 | void SearchDialog::updateConfig() |
307 | { | 308 | { |
308 | listView->updateConfig(); | 309 | listView->updateConfig(); |
309 | } | 310 | } |
310 | void SearchDialog::updateView() | 311 | void SearchDialog::updateView() |
311 | { | 312 | { |
312 | //qDebug("SearchDialog::updateView() %d ", isVisible()); | 313 | //qDebug("SearchDialog::updateView() %d ", isVisible()); |
313 | QRegExp re; | 314 | QRegExp re; |
314 | re.setWildcard(true); // most people understand these better. | 315 | re.setWildcard(true); // most people understand these better. |
315 | re.setCaseSensitive(false); | 316 | re.setCaseSensitive(false); |
316 | QString st = searchEdit->text(); | 317 | QString st = searchEdit->text(); |
317 | if ( st.right(1) != "*") | 318 | if ( st.right(1) != "*") |
318 | st += "*"; | 319 | st += "*"; |
319 | re.setPattern(st); | 320 | re.setPattern(st); |
320 | if (re.isValid()) { | 321 | if (re.isValid()) { |
321 | search(re); | 322 | search(re); |
322 | } else { | 323 | } else { |
323 | mMatchedEvents.clear(); | 324 | mMatchedEvents.clear(); |
324 | mMatchedTodos.clear(); | 325 | mMatchedTodos.clear(); |
325 | mMatchedJournals.clear(); | 326 | mMatchedJournals.clear(); |
326 | } | 327 | } |
327 | listView->setStartDate( mStartDate->date() ); | 328 | listView->setStartDate( mStartDate->date() ); |
328 | listView->showEvents(mMatchedEvents); | 329 | listView->showEvents(mMatchedEvents); |
329 | listView->addTodos(mMatchedTodos); | 330 | listView->addTodos(mMatchedTodos); |
330 | listView->addJournals(mMatchedJournals); | 331 | listView->addJournals(mMatchedJournals); |
331 | } | 332 | } |
332 | 333 | ||
333 | void SearchDialog::search(const QRegExp &re) | 334 | void SearchDialog::search(const QRegExp &re) |
334 | { | 335 | { |
335 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), | 336 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), |
336 | mEndDate->date(), | 337 | mEndDate->date(), |
337 | false /*mInclusiveCheck->isChecked()*/ ); | 338 | false /*mInclusiveCheck->isChecked()*/ ); |
338 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | 339 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
339 | if ( mRefineItems->isChecked() ) events = mMatchedEvents; | 340 | if ( mRefineItems->isChecked() ) events = mMatchedEvents; |
340 | mMatchedEvents.clear(); | 341 | mMatchedEvents.clear(); |
341 | } | 342 | } |
342 | if ( mSearchEvent->isChecked() ) { | 343 | if ( mSearchEvent->isChecked() ) { |
343 | Event *ev; | 344 | Event *ev; |
344 | for(ev=events.first();ev;ev=events.next()) { | 345 | for(ev=events.first();ev;ev=events.next()) { |
345 | if (mSummaryCheck->isChecked()) { | 346 | if (mSummaryCheck->isChecked()) { |
346 | #if QT_VERSION >= 0x030000 | 347 | #if QT_VERSION >= 0x030000 |
347 | if (re.search(ev->summary()) != -1) | 348 | if (re.search(ev->summary()) != -1) |
348 | #else | 349 | #else |
349 | if (re.match(ev->summary()) != -1) | 350 | if (re.match(ev->summary()) != -1) |
350 | #endif | 351 | #endif |
351 | { | 352 | { |
352 | if ( mSubItems->isChecked() ) | 353 | if ( mSubItems->isChecked() ) |
353 | mMatchedEvents.remove(ev); | 354 | mMatchedEvents.remove(ev); |
354 | else { | 355 | else { |
355 | if ( !mMatchedEvents.contains( ev ) ) | 356 | if ( !mMatchedEvents.contains( ev ) ) |
356 | mMatchedEvents.append(ev); | 357 | mMatchedEvents.append(ev); |
357 | } | 358 | } |
358 | continue; | 359 | continue; |
359 | } | 360 | } |
360 | #if QT_VERSION >= 0x030000 | 361 | #if QT_VERSION >= 0x030000 |
361 | if (re.search(ev->location()) != -1) | 362 | if (re.search(ev->location()) != -1) |
362 | #else | 363 | #else |
363 | if (re.match(ev->location()) != -1) | 364 | if (re.match(ev->location()) != -1) |
364 | #endif | 365 | #endif |
365 | { | 366 | { |
366 | if ( mSubItems->isChecked() ) | 367 | if ( mSubItems->isChecked() ) |
367 | mMatchedEvents.remove(ev); | 368 | mMatchedEvents.remove(ev); |
368 | else{ | 369 | else{ |
369 | if ( !mMatchedEvents.contains( ev ) ) | 370 | if ( !mMatchedEvents.contains( ev ) ) |
370 | mMatchedEvents.append(ev); | 371 | mMatchedEvents.append(ev); |
371 | } | 372 | } |
372 | continue; | 373 | continue; |
373 | } | 374 | } |
374 | } | 375 | } |
375 | if (mDescriptionCheck->isChecked()) { | 376 | if (mDescriptionCheck->isChecked()) { |
376 | #if QT_VERSION >= 0x030000 | 377 | #if QT_VERSION >= 0x030000 |
377 | if (re.search(ev->description()) != -1) | 378 | if (re.search(ev->description()) != -1) |
378 | #else | 379 | #else |
379 | if (re.match(ev->description()) != -1) | 380 | if (re.match(ev->description()) != -1) |
380 | #endif | 381 | #endif |
381 | { | 382 | { |
382 | if ( mSubItems->isChecked() ) | 383 | if ( mSubItems->isChecked() ) |
383 | mMatchedEvents.remove(ev); | 384 | mMatchedEvents.remove(ev); |
384 | else{ | 385 | else{ |
385 | if ( !mMatchedEvents.contains( ev ) ) | 386 | if ( !mMatchedEvents.contains( ev ) ) |
386 | mMatchedEvents.append(ev); | 387 | mMatchedEvents.append(ev); |
387 | } | 388 | } |
388 | continue; | 389 | continue; |
389 | } | 390 | } |
390 | } | 391 | } |
391 | if (mCategoryCheck->isChecked()) { | 392 | if (mCategoryCheck->isChecked()) { |
392 | #if QT_VERSION >= 0x030000 | 393 | #if QT_VERSION >= 0x030000 |
393 | if (re.search(ev->categoriesStr()) != -1) | 394 | if (re.search(ev->categoriesStr()) != -1) |
394 | #else | 395 | #else |
395 | if (re.match(ev->categoriesStr()) != -1) | 396 | if (re.match(ev->categoriesStr()) != -1) |
396 | #endif | 397 | #endif |
397 | { | 398 | { |
398 | 399 | ||
399 | if ( mSubItems->isChecked() ) | 400 | if ( mSubItems->isChecked() ) |
400 | mMatchedEvents.remove(ev); | 401 | mMatchedEvents.remove(ev); |
401 | else{ | 402 | else{ |
402 | if ( !mMatchedEvents.contains( ev ) ) | 403 | if ( !mMatchedEvents.contains( ev ) ) |
403 | mMatchedEvents.append(ev); | 404 | mMatchedEvents.append(ev); |
404 | } | 405 | } |
405 | continue; | 406 | continue; |
406 | } | 407 | } |
407 | } | 408 | } |
408 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 409 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
409 | QPtrList<Attendee> tmpAList = ev->attendees(); | 410 | QPtrList<Attendee> tmpAList = ev->attendees(); |
410 | Attendee *a; | 411 | Attendee *a; |
411 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 412 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
412 | if (mSearchAName->isChecked()) { | 413 | if (mSearchAName->isChecked()) { |
413 | #if QT_VERSION >= 0x030000 | 414 | #if QT_VERSION >= 0x030000 |
414 | if (re.search(a->name()) != -1) | 415 | if (re.search(a->name()) != -1) |
415 | #else | 416 | #else |
416 | if (re.match(a->name()) != -1) | 417 | if (re.match(a->name()) != -1) |
417 | #endif | 418 | #endif |
418 | { | 419 | { |
419 | if ( mSubItems->isChecked() ) | 420 | if ( mSubItems->isChecked() ) |
420 | mMatchedEvents.remove(ev); | 421 | mMatchedEvents.remove(ev); |
421 | else{ | 422 | else{ |
422 | if ( !mMatchedEvents.contains( ev ) ) | 423 | if ( !mMatchedEvents.contains( ev ) ) |
423 | mMatchedEvents.append(ev); | 424 | mMatchedEvents.append(ev); |
424 | } | 425 | } |
425 | break; | 426 | break; |
426 | } | 427 | } |
427 | } | 428 | } |
428 | if (mSearchAEmail->isChecked()) { | 429 | if (mSearchAEmail->isChecked()) { |
429 | #if QT_VERSION >= 0x030000 | 430 | #if QT_VERSION >= 0x030000 |
430 | if (re.search(a->email()) != -1) | 431 | if (re.search(a->email()) != -1) |
431 | #else | 432 | #else |
432 | if (re.match(a->email()) != -1) | 433 | if (re.match(a->email()) != -1) |
433 | #endif | 434 | #endif |
434 | { | 435 | { |
435 | if ( mSubItems->isChecked() ) | 436 | if ( mSubItems->isChecked() ) |
436 | mMatchedEvents.remove(ev); | 437 | mMatchedEvents.remove(ev); |
437 | else{ | 438 | else{ |
438 | if ( !mMatchedEvents.contains( ev ) ) | 439 | if ( !mMatchedEvents.contains( ev ) ) |
439 | mMatchedEvents.append(ev); | 440 | mMatchedEvents.append(ev); |
440 | } | 441 | } |
441 | break; | 442 | break; |
442 | } | 443 | } |
443 | } | 444 | } |
444 | } | 445 | } |
445 | } | 446 | } |
446 | } | 447 | } |
447 | } | 448 | } |
448 | QPtrList<Todo> todos = mCalendar->todos( ); | 449 | QPtrList<Todo> todos = mCalendar->todos( ); |
449 | 450 | ||
450 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | 451 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
451 | if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; | 452 | if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; |
452 | mMatchedTodos.clear(); | 453 | mMatchedTodos.clear(); |
453 | } | 454 | } |
454 | 455 | ||
455 | if ( mSearchTodo->isChecked() ) { | 456 | if ( mSearchTodo->isChecked() ) { |
456 | Todo *tod; | 457 | Todo *tod; |
457 | for(tod=todos.first();tod;tod=todos.next()) { | 458 | for(tod=todos.first();tod;tod=todos.next()) { |
458 | if (mSummaryCheck->isChecked()) { | 459 | if (mSummaryCheck->isChecked()) { |
459 | #if QT_VERSION >= 0x030000 | 460 | #if QT_VERSION >= 0x030000 |
460 | if (re.search(tod->summary()) != -1) | 461 | if (re.search(tod->summary()) != -1) |
461 | #else | 462 | #else |
462 | if (re.match(tod->summary()) != -1) | 463 | if (re.match(tod->summary()) != -1) |
463 | #endif | 464 | #endif |
464 | { | 465 | { |
465 | if ( mSubItems->isChecked() ) | 466 | if ( mSubItems->isChecked() ) |
466 | mMatchedTodos.remove(tod); | 467 | mMatchedTodos.remove(tod); |
467 | else if (!mMatchedTodos.contains( tod )) | 468 | else if (!mMatchedTodos.contains( tod )) |
468 | mMatchedTodos.append(tod); | 469 | mMatchedTodos.append(tod); |
469 | continue; | 470 | continue; |
470 | } | 471 | } |
471 | } | 472 | } |
472 | if (mDescriptionCheck->isChecked()) { | 473 | if (mDescriptionCheck->isChecked()) { |
473 | #if QT_VERSION >= 0x030000 | 474 | #if QT_VERSION >= 0x030000 |
474 | if (re.search(tod->description()) != -1) | 475 | if (re.search(tod->description()) != -1) |
475 | #else | 476 | #else |
476 | if (re.match(tod->description()) != -1) | 477 | if (re.match(tod->description()) != -1) |
477 | #endif | 478 | #endif |
478 | { | 479 | { |
479 | if ( mSubItems->isChecked() ) | 480 | if ( mSubItems->isChecked() ) |
480 | mMatchedTodos.remove(tod); | 481 | mMatchedTodos.remove(tod); |
481 | else if (!mMatchedTodos.contains( tod )) | 482 | else if (!mMatchedTodos.contains( tod )) |
482 | mMatchedTodos.append(tod); | 483 | mMatchedTodos.append(tod); |
483 | continue; | 484 | continue; |
484 | } | 485 | } |
485 | } | 486 | } |
486 | if (mCategoryCheck->isChecked()) { | 487 | if (mCategoryCheck->isChecked()) { |
487 | #if QT_VERSION >= 0x030000 | 488 | #if QT_VERSION >= 0x030000 |
488 | if (re.search(tod->categoriesStr()) != -1) | 489 | if (re.search(tod->categoriesStr()) != -1) |
489 | #else | 490 | #else |
490 | if (re.match(tod->categoriesStr()) != -1) | 491 | if (re.match(tod->categoriesStr()) != -1) |
491 | #endif | 492 | #endif |
492 | { | 493 | { |
493 | if ( mSubItems->isChecked() ) | 494 | if ( mSubItems->isChecked() ) |
494 | mMatchedTodos.remove(tod); | 495 | mMatchedTodos.remove(tod); |
495 | else if (!mMatchedTodos.contains( tod )) | 496 | else if (!mMatchedTodos.contains( tod )) |
496 | mMatchedTodos.append(tod); | 497 | mMatchedTodos.append(tod); |
497 | continue; | 498 | continue; |
498 | } | 499 | } |
499 | } | 500 | } |
500 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 501 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
501 | QPtrList<Attendee> tmpAList = tod->attendees(); | 502 | QPtrList<Attendee> tmpAList = tod->attendees(); |
502 | Attendee *a; | 503 | Attendee *a; |
503 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 504 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
504 | if (mSearchAName->isChecked()) { | 505 | if (mSearchAName->isChecked()) { |
505 | #if QT_VERSION >= 0x030000 | 506 | #if QT_VERSION >= 0x030000 |
506 | if (re.search(a->name()) != -1) | 507 | if (re.search(a->name()) != -1) |
507 | #else | 508 | #else |
508 | if (re.match(a->name()) != -1) | 509 | if (re.match(a->name()) != -1) |
509 | #endif | 510 | #endif |
510 | { | 511 | { |
511 | if ( mSubItems->isChecked() ) | 512 | if ( mSubItems->isChecked() ) |
512 | mMatchedTodos.remove(tod); | 513 | mMatchedTodos.remove(tod); |
513 | else if (!mMatchedTodos.contains( tod )) | 514 | else if (!mMatchedTodos.contains( tod )) |
514 | mMatchedTodos.append(tod); | 515 | mMatchedTodos.append(tod); |
515 | break; | 516 | break; |
516 | } | 517 | } |
517 | } | 518 | } |
518 | if (mSearchAEmail->isChecked()) { | 519 | if (mSearchAEmail->isChecked()) { |
519 | #if QT_VERSION >= 0x030000 | 520 | #if QT_VERSION >= 0x030000 |
520 | if (re.search(a->email()) != -1) | 521 | if (re.search(a->email()) != -1) |
521 | #else | 522 | #else |
522 | if (re.match(a->email()) != -1) | 523 | if (re.match(a->email()) != -1) |
523 | #endif | 524 | #endif |
524 | { | 525 | { |
525 | if ( mSubItems->isChecked() ) | 526 | if ( mSubItems->isChecked() ) |
526 | mMatchedTodos.remove(tod); | 527 | mMatchedTodos.remove(tod); |
527 | else if (!mMatchedTodos.contains( tod )) | 528 | else if (!mMatchedTodos.contains( tod )) |
528 | mMatchedTodos.append(tod); | 529 | mMatchedTodos.append(tod); |
529 | break; | 530 | break; |
530 | } | 531 | } |
531 | } | 532 | } |
532 | } | 533 | } |
533 | } | 534 | } |
534 | } | 535 | } |
535 | } | 536 | } |
536 | 537 | ||
537 | QPtrList<Journal> journals = mCalendar->journals( ); | 538 | QPtrList<Journal> journals = mCalendar->journals( ); |
538 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | 539 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
539 | if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; | 540 | if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; |
540 | mMatchedJournals.clear(); | 541 | mMatchedJournals.clear(); |
541 | } | 542 | } |
542 | if (mSearchJournal->isChecked() ) { | 543 | if (mSearchJournal->isChecked() ) { |
543 | Journal* journ; | 544 | Journal* journ; |
544 | 545 | ||
545 | for(journ=journals.first();journ;journ=journals.next()) { | 546 | for(journ=journals.first();journ;journ=journals.next()) { |
546 | if ( journ->dtStart().date() <= mEndDate->date() | 547 | if ( journ->dtStart().date() <= mEndDate->date() |
547 | &&journ->dtStart().date() >= mStartDate->date()) { | 548 | &&journ->dtStart().date() >= mStartDate->date()) { |
548 | #if QT_VERSION >= 0x030000 | 549 | #if QT_VERSION >= 0x030000 |
549 | if (re.search(journ->description()) != -1) | 550 | if (re.search(journ->description()) != -1) |
550 | #else | 551 | #else |
551 | if (re.match(journ->description()) != -1) | 552 | if (re.match(journ->description()) != -1) |
552 | #endif | 553 | #endif |
553 | { | 554 | { |
554 | if ( mSubItems->isChecked() ) | 555 | if ( mSubItems->isChecked() ) |
555 | mMatchedJournals.remove(journ); | 556 | mMatchedJournals.remove(journ); |
556 | else if (!mMatchedJournals.contains( journ )) | 557 | else if (!mMatchedJournals.contains( journ )) |
557 | mMatchedJournals.append(journ); | 558 | mMatchedJournals.append(journ); |
558 | continue; | 559 | continue; |
559 | } | 560 | } |
560 | } | 561 | } |
561 | } | 562 | } |
562 | } | 563 | } |
563 | 564 | ||
564 | } | 565 | } |
565 | 566 | ||
566 | void SearchDialog::keyPressEvent ( QKeyEvent *e) | 567 | void SearchDialog::keyPressEvent ( QKeyEvent *e) |
567 | { | 568 | { |
568 | switch ( e->key() ) { | 569 | switch ( e->key() ) { |
569 | case Qt::Key_Escape: | 570 | case Qt::Key_Escape: |
570 | close(); | 571 | close(); |
571 | break; | 572 | break; |
572 | case Qt::Key_F: | 573 | case Qt::Key_F: |
573 | if ( e->state() == Qt::ControlButton ) { | 574 | if ( e->state() == Qt::ControlButton ) { |
574 | 575 | ||
575 | } | 576 | } |
576 | break; | 577 | break; |
577 | case Qt::Key_Return: | 578 | case Qt::Key_Return: |
578 | case Qt::Key_Enter: | 579 | case Qt::Key_Enter: |
579 | doSearch(); | 580 | doSearch(); |
580 | break; | 581 | break; |
581 | 582 | ||
582 | default: | 583 | default: |
583 | e->ignore(); | 584 | e->ignore(); |
584 | } | 585 | } |
585 | } | 586 | } |
586 | 587 | ||
587 | //mMatchedJournals; | 588 | //mMatchedJournals; |