-rw-r--r-- | korganizer/kolistview.cpp | 11 |
1 files changed, 11 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 | |||
@@ -154,192 +154,193 @@ bool ListItemVisitor::visit(Event *e) | |||
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())); |
@@ -954,197 +955,207 @@ void KOListView::showDates(bool show) | |||
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 | } |