-rw-r--r-- | korganizer/kotodoview.cpp | 15 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 1 |
2 files changed, 6 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 35c2a9f..b2ff33b 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -239,403 +239,398 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | |||
239 | } else { | 239 | } else { |
240 | mMousePressed = false; | 240 | mMousePressed = false; |
241 | } | 241 | } |
242 | #endif | 242 | #endif |
243 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 243 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
244 | #ifndef DESKTOP_VERSION | 244 | #ifndef DESKTOP_VERSION |
245 | if (!( e->button() == RightButton && rootClicked) ) | 245 | if (!( e->button() == RightButton && rootClicked) ) |
246 | QListView::contentsMousePressEvent(e); | 246 | QListView::contentsMousePressEvent(e); |
247 | #else | 247 | #else |
248 | QListView::contentsMousePressEvent(e); | 248 | QListView::contentsMousePressEvent(e); |
249 | #endif | 249 | #endif |
250 | } | 250 | } |
251 | void KOTodoListView::paintEvent(QPaintEvent* e) | 251 | void KOTodoListView::paintEvent(QPaintEvent* e) |
252 | { | 252 | { |
253 | emit paintNeeded(); | 253 | emit paintNeeded(); |
254 | QListView::paintEvent( e); | 254 | QListView::paintEvent( e); |
255 | } | 255 | } |
256 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 256 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
257 | { | 257 | { |
258 | 258 | ||
259 | #ifndef KORG_NODND | 259 | #ifndef KORG_NODND |
260 | //QListView::contentsMouseMoveEvent(e); | 260 | //QListView::contentsMouseMoveEvent(e); |
261 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 261 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
262 | QApplication::startDragDistance()*3) { | 262 | QApplication::startDragDistance()*3) { |
263 | mMousePressed = false; | 263 | mMousePressed = false; |
264 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 264 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
265 | if (item) { | 265 | if (item) { |
266 | DndFactory factory( mCalendar ); | 266 | DndFactory factory( mCalendar ); |
267 | ICalDrag *vd = factory.createDrag( | 267 | ICalDrag *vd = factory.createDrag( |
268 | ((KOTodoViewItem *)item)->todo(),viewport()); | 268 | ((KOTodoViewItem *)item)->todo(),viewport()); |
269 | internalDrop = false; | 269 | internalDrop = false; |
270 | // we cannot do any senseful here, because the DnD is still broken in Qt | 270 | // we cannot do any senseful here, because the DnD is still broken in Qt |
271 | if (vd->drag()) { | 271 | if (vd->drag()) { |
272 | if ( !internalDrop ) { | 272 | if ( !internalDrop ) { |
273 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 273 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
274 | qDebug("Dnd: External move: Delete drag source "); | 274 | qDebug("Dnd: External move: Delete drag source "); |
275 | } else | 275 | } else |
276 | qDebug("Dnd: Internal move "); | 276 | qDebug("Dnd: Internal move "); |
277 | 277 | ||
278 | } else { | 278 | } else { |
279 | if ( !internalDrop ) { | 279 | if ( !internalDrop ) { |
280 | qDebug("Dnd: External Copy"); | 280 | qDebug("Dnd: External Copy"); |
281 | } else | 281 | } else |
282 | qDebug("DnD: Internal copy: Copy pending"); | 282 | qDebug("DnD: Internal copy: Copy pending"); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | #endif | 286 | #endif |
287 | } | 287 | } |
288 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 288 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
289 | { | 289 | { |
290 | if ( !e->isAutoRepeat() ) { | 290 | if ( !e->isAutoRepeat() ) { |
291 | mFlagKeyPressed = false; | 291 | mFlagKeyPressed = false; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 296 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
297 | { | 297 | { |
298 | qApp->processEvents(); | 298 | qApp->processEvents(); |
299 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 299 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
300 | e->ignore(); | 300 | e->ignore(); |
301 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 301 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
302 | return; | 302 | return; |
303 | } | 303 | } |
304 | if (! e->isAutoRepeat() ) | 304 | if (! e->isAutoRepeat() ) |
305 | mFlagKeyPressed = true; | 305 | mFlagKeyPressed = true; |
306 | QListViewItem* cn; | 306 | QListViewItem* cn; |
307 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 307 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
308 | cn = currentItem(); | 308 | cn = currentItem(); |
309 | if ( cn ) { | 309 | if ( cn ) { |
310 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 310 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
311 | if ( ci ){ | 311 | if ( ci ){ |
312 | if ( e->state() == ShiftButton ) | 312 | if ( e->state() == ShiftButton ) |
313 | ci->setOn( false ); | 313 | ci->setOn( false ); |
314 | else | 314 | else |
315 | ci->setOn( true ); | 315 | ci->setOn( true ); |
316 | cn = cn->itemBelow(); | 316 | cn = cn->itemBelow(); |
317 | if ( cn ) { | 317 | if ( cn ) { |
318 | setCurrentItem ( cn ); | 318 | setCurrentItem ( cn ); |
319 | ensureItemVisible ( cn ); | 319 | ensureItemVisible ( cn ); |
320 | } | 320 | } |
321 | 321 | ||
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | return; | 325 | return; |
326 | } | 326 | } |
327 | 327 | ||
328 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 328 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
329 | switch ( e->key() ) { | 329 | switch ( e->key() ) { |
330 | case Qt::Key_Down: | 330 | case Qt::Key_Down: |
331 | case Qt::Key_Up: | 331 | case Qt::Key_Up: |
332 | QListView::keyPressEvent ( e ); | 332 | QListView::keyPressEvent ( e ); |
333 | break; | 333 | break; |
334 | case Qt::Key_Left: | 334 | case Qt::Key_Left: |
335 | case Qt::Key_Right: | 335 | case Qt::Key_Right: |
336 | QListView::keyPressEvent ( e ); | 336 | QListView::keyPressEvent ( e ); |
337 | e->accept(); | 337 | e->accept(); |
338 | return; | 338 | return; |
339 | break; | 339 | break; |
340 | default: | 340 | default: |
341 | e->ignore(); | 341 | e->ignore(); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | e->ignore(); | 346 | e->ignore(); |
347 | } | 347 | } |
348 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 348 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
349 | { | 349 | { |
350 | QListView::contentsMouseReleaseEvent(e); | 350 | QListView::contentsMouseReleaseEvent(e); |
351 | mMousePressed = false; | 351 | mMousePressed = false; |
352 | } | 352 | } |
353 | 353 | ||
354 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 354 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
355 | { | 355 | { |
356 | if (!e) return; | 356 | if (!e) return; |
357 | 357 | ||
358 | QPoint vp = contentsToViewport(e->pos()); | 358 | QPoint vp = contentsToViewport(e->pos()); |
359 | 359 | ||
360 | QListViewItem *item = itemAt(vp); | 360 | QListViewItem *item = itemAt(vp); |
361 | 361 | ||
362 | emit double_Clicked(item); | 362 | emit double_Clicked(item); |
363 | if (!item) return; | 363 | if (!item) return; |
364 | 364 | ||
365 | emit doubleClicked(item,vp,0); | 365 | emit doubleClicked(item,vp,0); |
366 | } | 366 | } |
367 | 367 | ||
368 | ///////////////////////////////////////////////////////////////////////////// | 368 | ///////////////////////////////////////////////////////////////////////////// |
369 | 369 | ||
370 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 370 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
371 | QLineEdit(parent) | 371 | QLineEdit(parent) |
372 | { | 372 | { |
373 | setText(i18n("Click to add a new Todo")); | 373 | setText(i18n("Click to add a new Todo")); |
374 | } | 374 | } |
375 | 375 | ||
376 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 376 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
377 | { | 377 | { |
378 | if ( text()==i18n("Click to add a new Todo") ) | 378 | if ( text()==i18n("Click to add a new Todo") ) |
379 | setText(""); | 379 | setText(""); |
380 | QLineEdit::focusInEvent(ev); | 380 | QLineEdit::focusInEvent(ev); |
381 | } | 381 | } |
382 | 382 | ||
383 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 383 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
384 | { | 384 | { |
385 | setText(i18n("Click to add a new Todo")); | 385 | setText(i18n("Click to add a new Todo")); |
386 | QLineEdit::focusOutEvent(ev); | 386 | QLineEdit::focusOutEvent(ev); |
387 | } | 387 | } |
388 | 388 | ||
389 | ///////////////////////////////////////////////////////////////////////////// | 389 | ///////////////////////////////////////////////////////////////////////////// |
390 | 390 | ||
391 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 391 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
392 | KOrg::BaseView(calendar,parent,name) | 392 | KOrg::BaseView(calendar,parent,name) |
393 | { | 393 | { |
394 | mPendingUpdateBeforeRepaint = false; | 394 | mPendingUpdateBeforeRepaint = false; |
395 | isFlatDisplay = false; | 395 | isFlatDisplay = false; |
396 | mNavigator = 0; | 396 | mNavigator = 0; |
397 | QBoxLayout *topLayout = new QVBoxLayout(this); | 397 | QBoxLayout *topLayout = new QVBoxLayout(this); |
398 | mName = QString ( name ); | 398 | mName = QString ( name ); |
399 | mBlockUpdate = false; | 399 | mBlockUpdate = false; |
400 | mQuickAdd = new KOQuickTodo(this); | 400 | mQuickAdd = new KOQuickTodo(this); |
401 | topLayout->addWidget(mQuickAdd); | 401 | topLayout->addWidget(mQuickAdd); |
402 | 402 | ||
403 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 403 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
404 | 404 | ||
405 | mTodoListView = new KOTodoListView(calendar,this, name ); | 405 | mTodoListView = new KOTodoListView(calendar,this, name ); |
406 | topLayout->addWidget(mTodoListView); | 406 | topLayout->addWidget(mTodoListView); |
407 | //mTodoListView->header()->setMaximumHeight(30); | 407 | //mTodoListView->header()->setMaximumHeight(30); |
408 | mTodoListView->setRootIsDecorated(true); | 408 | mTodoListView->setRootIsDecorated(true); |
409 | mTodoListView->setAllColumnsShowFocus(true); | 409 | mTodoListView->setAllColumnsShowFocus(true); |
410 | 410 | ||
411 | mTodoListView->setShowSortIndicator(true); | 411 | mTodoListView->setShowSortIndicator(true); |
412 | 412 | ||
413 | mTodoListView->addColumn(i18n("Todo")); | 413 | mTodoListView->addColumn(i18n("Todo")); |
414 | mTodoListView->addColumn(i18n("Prio")); | 414 | mTodoListView->addColumn(i18n("Prio")); |
415 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 415 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
416 | mTodoListView->addColumn(i18n("Complete")); | 416 | mTodoListView->addColumn(i18n("Complete")); |
417 | mTodoListView->setColumnAlignment(2,AlignCenter); | 417 | mTodoListView->setColumnAlignment(2,AlignCenter); |
418 | 418 | ||
419 | mTodoListView->addColumn(i18n("Due Date")); | 419 | mTodoListView->addColumn(i18n("Due Date")); |
420 | mTodoListView->setColumnAlignment(3,AlignLeft); | 420 | mTodoListView->setColumnAlignment(3,AlignLeft); |
421 | mTodoListView->addColumn(i18n("Due Time")); | 421 | mTodoListView->addColumn(i18n("Due Time")); |
422 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 422 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
423 | 423 | ||
424 | mTodoListView->addColumn(i18n("Start Date")); | 424 | mTodoListView->addColumn(i18n("Start Date")); |
425 | mTodoListView->setColumnAlignment(5,AlignLeft); | 425 | mTodoListView->setColumnAlignment(5,AlignLeft); |
426 | mTodoListView->addColumn(i18n("Start Time")); | 426 | mTodoListView->addColumn(i18n("Start Time")); |
427 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 427 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
428 | 428 | ||
429 | mTodoListView->addColumn(i18n("Cancelled")); | 429 | mTodoListView->addColumn(i18n("Cancelled")); |
430 | mTodoListView->addColumn(i18n("Categories")); | 430 | mTodoListView->addColumn(i18n("Categories")); |
431 | mTodoListView->addColumn(i18n("Calendar")); | ||
431 | #if 0 | 432 | #if 0 |
432 | mTodoListView->addColumn(i18n("Sort Id")); | 433 | mTodoListView->addColumn(i18n("Sort Id")); |
433 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 434 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
434 | #endif | 435 | #endif |
435 | 436 | ||
436 | mTodoListView->setMinimumHeight( 60 ); | 437 | mTodoListView->setMinimumHeight( 60 ); |
437 | mTodoListView->setItemsRenameable( true ); | 438 | mTodoListView->setItemsRenameable( true ); |
438 | mTodoListView->setRenameable( 0 ); | 439 | mTodoListView->setRenameable( 0 ); |
439 | mTodoListView->setColumnWidth( 0, 120 ); | 440 | mTodoListView->setColumnWidth( 0, 120 ); |
440 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 441 | int iii = 0; |
441 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 442 | for ( iii = 0; iii< 10 ; ++iii ) |
442 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 443 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
443 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 444 | |
444 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | ||
445 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | ||
446 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | ||
447 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | ||
448 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | ||
449 | |||
450 | 445 | ||
451 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 446 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
452 | 447 | ||
453 | mPriorityPopupMenu = new QPopupMenu(this); | 448 | mPriorityPopupMenu = new QPopupMenu(this); |
454 | for (int i = 1; i <= 5; i++) { | 449 | for (int i = 1; i <= 5; i++) { |
455 | QString label = QString ("%1").arg (i); | 450 | QString label = QString ("%1").arg (i); |
456 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 451 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
457 | } | 452 | } |
458 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 453 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
459 | 454 | ||
460 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 455 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
461 | for (int i = 0; i <= 100; i+=20) { | 456 | for (int i = 0; i <= 100; i+=20) { |
462 | QString label = QString ("%1 %").arg (i); | 457 | QString label = QString ("%1 %").arg (i); |
463 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 458 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
464 | } | 459 | } |
465 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 460 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
466 | 461 | ||
467 | 462 | ||
468 | 463 | ||
469 | mItemPopupMenu = new QPopupMenu(this); | 464 | mItemPopupMenu = new QPopupMenu(this); |
470 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 465 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
471 | SLOT (showTodo())); | 466 | SLOT (showTodo())); |
472 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 467 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
473 | SLOT (editTodo())); | 468 | SLOT (editTodo())); |
474 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 469 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
475 | SLOT (deleteTodo())); | 470 | SLOT (deleteTodo())); |
476 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 471 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
477 | SLOT (cloneTodo())); | 472 | SLOT (cloneTodo())); |
478 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 473 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
479 | SLOT (moveTodo())); | 474 | SLOT (moveTodo())); |
480 | #ifndef DESKTOP_VERSION | 475 | #ifndef DESKTOP_VERSION |
481 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 476 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
482 | SLOT (beamTodo())); | 477 | SLOT (beamTodo())); |
483 | #endif | 478 | #endif |
484 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 479 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
485 | SLOT (cancelTodo())); | 480 | SLOT (cancelTodo())); |
486 | mItemPopupMenu->insertSeparator(); | 481 | mItemPopupMenu->insertSeparator(); |
487 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 482 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
488 | SLOT (toggleRunningItem())); | 483 | SLOT (toggleRunningItem())); |
489 | mItemPopupMenu->insertSeparator(); | 484 | mItemPopupMenu->insertSeparator(); |
490 | /* | 485 | /* |
491 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 486 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
492 | SLOT (newTodo())); | 487 | SLOT (newTodo())); |
493 | */ | 488 | */ |
494 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 489 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
495 | SLOT (newSubTodo())); | 490 | SLOT (newSubTodo())); |
496 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 491 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
497 | SLOT (unparentTodo()),0,21); | 492 | SLOT (unparentTodo()),0,21); |
498 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 493 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
499 | SLOT (reparentTodo()),0,22); | 494 | SLOT (reparentTodo()),0,22); |
500 | mItemPopupMenu->insertSeparator(); | 495 | mItemPopupMenu->insertSeparator(); |
501 | #if 0 | 496 | #if 0 |
502 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 497 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
503 | this, SLOT( purgeCompleted() ) ); | 498 | this, SLOT( purgeCompleted() ) ); |
504 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 499 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
505 | this, SLOT( toggleCompleted() ),0, 33 ); | 500 | this, SLOT( toggleCompleted() ),0, 33 ); |
506 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 501 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
507 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 502 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
508 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 503 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
509 | this, SLOT( toggleRunning() ),0, 35 ); | 504 | this, SLOT( toggleRunning() ),0, 35 ); |
510 | 505 | ||
511 | #endif | 506 | #endif |
512 | mPopupMenu = new QPopupMenu(this); | 507 | mPopupMenu = new QPopupMenu(this); |
513 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 508 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
514 | SLOT (newTodo()),0,1); | 509 | SLOT (newTodo()),0,1); |
515 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 510 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
516 | this, SLOT(purgeCompleted()),0,2); | 511 | this, SLOT(purgeCompleted()),0,2); |
517 | mPopupMenu->insertItem(i18n("Show Completed"), | 512 | mPopupMenu->insertItem(i18n("Show Completed"), |
518 | this, SLOT( toggleCompleted() ),0,3 ); | 513 | this, SLOT( toggleCompleted() ),0,3 ); |
519 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 514 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
520 | this, SLOT( toggleRunning() ),0,5 ); | 515 | this, SLOT( toggleRunning() ),0,5 ); |
521 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 516 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
522 | this, SLOT( setAllOpen() ),0,6 ); | 517 | this, SLOT( setAllOpen() ),0,6 ); |
523 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 518 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
524 | this, SLOT( setAllClose() ),0,7 ); | 519 | this, SLOT( setAllClose() ),0,7 ); |
525 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 520 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
526 | this, SLOT( setAllFlat() ),0,8 ); | 521 | this, SLOT( setAllFlat() ),0,8 ); |
527 | mPopupMenu->insertSeparator(); | 522 | mPopupMenu->insertSeparator(); |
528 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 523 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
529 | this, SLOT( toggleQuickTodo() ),0,4 ); | 524 | this, SLOT( toggleQuickTodo() ),0,4 ); |
530 | mDocPrefs = new DocPrefs( name ); | 525 | mDocPrefs = new DocPrefs( name ); |
531 | 526 | ||
532 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 527 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
533 | mPopupMenu->setCheckable( true ); | 528 | mPopupMenu->setCheckable( true ); |
534 | mItemPopupMenu->setCheckable( true ); | 529 | mItemPopupMenu->setCheckable( true ); |
535 | 530 | ||
536 | 531 | ||
537 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 532 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
538 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 533 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
539 | 534 | ||
540 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 535 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
541 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 536 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
542 | 537 | ||
543 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 538 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
544 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 539 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
545 | 540 | ||
546 | 541 | ||
547 | // Double clicking conflicts with opening/closing the subtree | 542 | // Double clicking conflicts with opening/closing the subtree |
548 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 543 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
549 | SLOT( editItem( QListViewItem *) ) ); | 544 | SLOT( editItem( QListViewItem *) ) ); |
550 | /* | 545 | /* |
551 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 546 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
552 | const QPoint &,int ) ), | 547 | const QPoint &,int ) ), |
553 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 548 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
554 | */ | 549 | */ |
555 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 550 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
556 | const QPoint &,int ) ), | 551 | const QPoint &,int ) ), |
557 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 552 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
558 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 553 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
559 | SLOT( itemClicked( QListViewItem * ) ) ); | 554 | SLOT( itemClicked( QListViewItem * ) ) ); |
560 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 555 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
561 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 556 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
562 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 557 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
563 | SLOT( updateView() ) ); | 558 | SLOT( updateView() ) ); |
564 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 559 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
565 | SLOT( todoModified(Todo *, int) ) ); | 560 | SLOT( todoModified(Todo *, int) ) ); |
566 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 561 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
567 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 562 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
568 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 563 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
569 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 564 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
570 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 565 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
571 | SLOT( paintNeeded()) ); | 566 | SLOT( paintNeeded()) ); |
572 | 567 | ||
573 | #if 0 | 568 | #if 0 |
574 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 569 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
575 | SLOT(selectionChanged(QListViewItem *))); | 570 | SLOT(selectionChanged(QListViewItem *))); |
576 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 571 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
577 | SLOT(selectionChanged(QListViewItem *))); | 572 | SLOT(selectionChanged(QListViewItem *))); |
578 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 573 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
579 | SLOT(selectionChanged(QListViewItem *))); | 574 | SLOT(selectionChanged(QListViewItem *))); |
580 | #endif | 575 | #endif |
581 | 576 | ||
582 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 577 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
583 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 578 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
584 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 579 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
585 | 580 | ||
586 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 581 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
587 | SLOT( processSelectionChange() ) ); | 582 | SLOT( processSelectionChange() ) ); |
588 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 583 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
589 | SLOT( addQuickTodo() ) ); | 584 | SLOT( addQuickTodo() ) ); |
590 | 585 | ||
591 | } | 586 | } |
592 | 587 | ||
593 | KOTodoView::~KOTodoView() | 588 | KOTodoView::~KOTodoView() |
594 | { | 589 | { |
595 | 590 | ||
596 | #if QT_VERSION >= 0x030000 | 591 | #if QT_VERSION >= 0x030000 |
597 | 592 | ||
598 | #else | 593 | #else |
599 | delete mKOTodoViewWhatsThis; | 594 | delete mKOTodoViewWhatsThis; |
600 | #endif | 595 | #endif |
601 | 596 | ||
602 | delete mDocPrefs; | 597 | delete mDocPrefs; |
603 | } | 598 | } |
604 | QString KOTodoView::getWhatsThisText(QPoint p) | 599 | QString KOTodoView::getWhatsThisText(QPoint p) |
605 | { | 600 | { |
606 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 601 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
607 | if ( item ) | 602 | if ( item ) |
608 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 603 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
609 | KOPrefs::instance()->mWTshowDetails, | 604 | KOPrefs::instance()->mWTshowDetails, |
610 | KOPrefs::instance()->mWTshowCreated, | 605 | KOPrefs::instance()->mWTshowCreated, |
611 | KOPrefs::instance()->mWTshowChanged); | 606 | KOPrefs::instance()->mWTshowChanged); |
612 | return i18n("That is the todo view" ); | 607 | return i18n("That is the todo view" ); |
613 | 608 | ||
614 | } | 609 | } |
615 | 610 | ||
616 | void KOTodoView::jumpToDate () | 611 | void KOTodoView::jumpToDate () |
617 | { | 612 | { |
618 | // if (mActiveItem) { | 613 | // if (mActiveItem) { |
619 | // mActiveItem->todo()); | 614 | // mActiveItem->todo()); |
620 | // if ( mActiveItem->todo()->hasDueDate() ) | 615 | // if ( mActiveItem->todo()->hasDueDate() ) |
621 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 616 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
622 | } | 617 | } |
623 | void KOTodoView::paintNeeded() | 618 | void KOTodoView::paintNeeded() |
624 | { | 619 | { |
625 | if ( mPendingUpdateBeforeRepaint ) { | 620 | if ( mPendingUpdateBeforeRepaint ) { |
626 | updateView(); | 621 | updateView(); |
627 | mPendingUpdateBeforeRepaint = false; | 622 | mPendingUpdateBeforeRepaint = false; |
628 | } | 623 | } |
629 | } | 624 | } |
630 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 625 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
631 | { | 626 | { |
632 | if ( mPendingUpdateBeforeRepaint ) { | 627 | if ( mPendingUpdateBeforeRepaint ) { |
633 | updateView(); | 628 | updateView(); |
634 | mPendingUpdateBeforeRepaint = false; | 629 | mPendingUpdateBeforeRepaint = false; |
635 | } | 630 | } |
636 | KOrg::BaseView::paintEvent( pevent); | 631 | KOrg::BaseView::paintEvent( pevent); |
637 | } | 632 | } |
638 | 633 | ||
639 | void KOTodoView::updateView() | 634 | void KOTodoView::updateView() |
640 | { | 635 | { |
641 | pendingSubtodo = 0; | 636 | pendingSubtodo = 0; |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 748f3e4..f62aab8 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,349 +1,350 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | #include <kglobal.h> | 23 | #include <kglobal.h> |
24 | 24 | ||
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include "kotodoviewitem.h" | 26 | #include "kotodoviewitem.h" |
27 | #include "kotodoview.h" | 27 | #include "kotodoview.h" |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | 29 | ||
30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
32 | { | 32 | { |
33 | construct(); | 33 | construct(); |
34 | } | 34 | } |
35 | 35 | ||
36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
38 | { | 38 | { |
39 | construct(); | 39 | construct(); |
40 | } | 40 | } |
41 | 41 | ||
42 | QString KOTodoViewItem::key(int column,bool) const | 42 | QString KOTodoViewItem::key(int column,bool) const |
43 | { | 43 | { |
44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
45 | if (it == mKeyMap.end()) { | 45 | if (it == mKeyMap.end()) { |
46 | return text(column).lower(); | 46 | return text(column).lower(); |
47 | } else { | 47 | } else { |
48 | return *it; | 48 | return *it; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void KOTodoViewItem:: setup() | 52 | void KOTodoViewItem:: setup() |
53 | { | 53 | { |
54 | 54 | ||
55 | int h = 20; | 55 | int h = 20; |
56 | if ( listView () ) { | 56 | if ( listView () ) { |
57 | QFontMetrics fm ( listView ()->font () ); | 57 | QFontMetrics fm ( listView ()->font () ); |
58 | h = fm.height(); | 58 | h = fm.height(); |
59 | } | 59 | } |
60 | setHeight( h ); | 60 | setHeight( h ); |
61 | 61 | ||
62 | } | 62 | } |
63 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 63 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
64 | { | 64 | { |
65 | mKeyMap.insert(column,key); | 65 | mKeyMap.insert(column,key); |
66 | } | 66 | } |
67 | 67 | ||
68 | #if QT_VERSION >= 0x030000 | 68 | #if QT_VERSION >= 0x030000 |
69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
70 | int y,int h) | 70 | int y,int h) |
71 | { | 71 | { |
72 | QListViewItem::paintBranches(p,cg,w,y,h); | 72 | QListViewItem::paintBranches(p,cg,w,y,h); |
73 | } | 73 | } |
74 | #else | 74 | #else |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | void KOTodoViewItem::construct() | 77 | void KOTodoViewItem::construct() |
78 | { | 78 | { |
79 | // qDebug("KOTodoViewItem::construct() "); | 79 | // qDebug("KOTodoViewItem::construct() "); |
80 | m_init = true; | 80 | m_init = true; |
81 | QString keyd = "=="; | 81 | QString keyd = "=="; |
82 | QString keyt = "=="; | 82 | QString keyt = "=="; |
83 | QString skeyd = "=="; | 83 | QString skeyd = "=="; |
84 | QString skeyt = "=="; | 84 | QString skeyt = "=="; |
85 | 85 | ||
86 | setOn(mTodo->isCompleted()); | 86 | setOn(mTodo->isCompleted()); |
87 | setText(0,mTodo->summary()); | 87 | setText(0,mTodo->summary()); |
88 | setText(1,QString::number(mTodo->priority())); | 88 | setText(1,QString::number(mTodo->priority())); |
89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
90 | if (mTodo->percentComplete()<100) { | 90 | if (mTodo->percentComplete()<100) { |
91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
92 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 92 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
93 | } | 93 | } |
94 | else { | 94 | else { |
95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
96 | else setSortKey(2,QString::number(99)); | 96 | else setSortKey(2,QString::number(99)); |
97 | } | 97 | } |
98 | if (mTodo->hasDueDate()) { | 98 | if (mTodo->hasDueDate()) { |
99 | setText(3, mTodo->dtDueDateStr()); | 99 | setText(3, mTodo->dtDueDateStr()); |
100 | QDate d = mTodo->dtDue().date(); | 100 | QDate d = mTodo->dtDue().date(); |
101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
102 | // setSortKey(3,keyd); | 102 | // setSortKey(3,keyd); |
103 | if (mTodo->doesFloat()) { | 103 | if (mTodo->doesFloat()) { |
104 | setText(4,""); | 104 | setText(4,""); |
105 | } | 105 | } |
106 | else { | 106 | else { |
107 | setText(4,mTodo->dtDueTimeStr()); | 107 | setText(4,mTodo->dtDueTimeStr()); |
108 | QTime t = mTodo->dtDue().time(); | 108 | QTime t = mTodo->dtDue().time(); |
109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
110 | //setSortKey(4,keyt); | 110 | //setSortKey(4,keyt); |
111 | } | 111 | } |
112 | } else { | 112 | } else { |
113 | setText(3,""); | 113 | setText(3,""); |
114 | setText(4,""); | 114 | setText(4,""); |
115 | } | 115 | } |
116 | setSortKey(3,keyd); | 116 | setSortKey(3,keyd); |
117 | setSortKey(4,keyt); | 117 | setSortKey(4,keyt); |
118 | 118 | ||
119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | keyd = ""; | 124 | keyd = ""; |
125 | keyt = ""; | 125 | keyt = ""; |
126 | 126 | ||
127 | if (mTodo->isRunning() ) { | 127 | if (mTodo->isRunning() ) { |
128 | QDate d = mTodo->runStart().date(); | 128 | QDate d = mTodo->runStart().date(); |
129 | QTime t = mTodo->runStart().time(); | 129 | QTime t = mTodo->runStart().time(); |
130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
132 | keyd = KGlobal::locale()->formatDate( d , true); | 132 | keyd = KGlobal::locale()->formatDate( d , true); |
133 | keyt = KGlobal::locale()->formatTime( t ); | 133 | keyt = KGlobal::locale()->formatTime( t ); |
134 | 134 | ||
135 | } else { | 135 | } else { |
136 | 136 | ||
137 | if (mTodo->hasStartDate()) { | 137 | if (mTodo->hasStartDate()) { |
138 | keyd = mTodo->dtStartDateStr(); | 138 | keyd = mTodo->dtStartDateStr(); |
139 | QDate d = mTodo->dtStart().date(); | 139 | QDate d = mTodo->dtStart().date(); |
140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
141 | 141 | ||
142 | if ( !mTodo->doesFloat()) { | 142 | if ( !mTodo->doesFloat()) { |
143 | keyt = mTodo->dtStartTimeStr(); | 143 | keyt = mTodo->dtStartTimeStr(); |
144 | QTime t = mTodo->dtStart().time(); | 144 | QTime t = mTodo->dtStart().time(); |
145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | } | 149 | } |
150 | } | 150 | } |
151 | setText(5,keyd); | 151 | setText(5,keyd); |
152 | setText(6,keyt); | 152 | setText(6,keyt); |
153 | setSortKey(5,skeyd); | 153 | setSortKey(5,skeyd); |
154 | setSortKey(6,skeyt); | 154 | setSortKey(6,skeyt); |
155 | 155 | ||
156 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 156 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
157 | setText(8,mTodo->categoriesStr()); | 157 | setText(8,mTodo->categoriesStr()); |
158 | setText(9,KOPrefs::instance()->calName( mTodo->calID())); | ||
158 | 159 | ||
159 | #if 0 | 160 | #if 0 |
160 | // Find sort id in description. It's the text behind the last '#' character | 161 | // Find sort id in description. It's the text behind the last '#' character |
161 | // found in the description. White spaces are removed from beginning and end | 162 | // found in the description. White spaces are removed from beginning and end |
162 | // of sort id. | 163 | // of sort id. |
163 | int pos = mTodo->description().findRev('#'); | 164 | int pos = mTodo->description().findRev('#'); |
164 | if (pos < 0) { | 165 | if (pos < 0) { |
165 | setText(6,""); | 166 | setText(6,""); |
166 | } else { | 167 | } else { |
167 | QString str = mTodo->description().mid(pos+1); | 168 | QString str = mTodo->description().mid(pos+1); |
168 | str.stripWhiteSpace(); | 169 | str.stripWhiteSpace(); |
169 | setText(6,str); | 170 | setText(6,str); |
170 | } | 171 | } |
171 | #endif | 172 | #endif |
172 | 173 | ||
173 | m_known = false; | 174 | m_known = false; |
174 | m_init = false; | 175 | m_init = false; |
175 | 176 | ||
176 | setMyPixmap(); | 177 | setMyPixmap(); |
177 | 178 | ||
178 | } | 179 | } |
179 | void KOTodoViewItem::setMyPixmap() | 180 | void KOTodoViewItem::setMyPixmap() |
180 | { | 181 | { |
181 | int size = 5; | 182 | int size = 5; |
182 | QPixmap pixi = QPixmap( 1, 1 ); | 183 | QPixmap pixi = QPixmap( 1, 1 ); |
183 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 184 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
184 | // pixi = SmallIcon("redcross16"); | 185 | // pixi = SmallIcon("redcross16"); |
185 | // } else { | 186 | // } else { |
186 | QPainter p; | 187 | QPainter p; |
187 | 188 | ||
188 | int pixSize = 0; | 189 | int pixSize = 0; |
189 | QPixmap pPix = QPixmap( size, size ); | 190 | QPixmap pPix = QPixmap( size, size ); |
190 | if ( mTodo->description().length() > 0 ) { | 191 | if ( mTodo->description().length() > 0 ) { |
191 | pixi.resize(size, pixSize+size); | 192 | pixi.resize(size, pixSize+size); |
192 | pPix.fill( Qt::darkGreen ); | 193 | pPix.fill( Qt::darkGreen ); |
193 | p.begin( &pixi ); | 194 | p.begin( &pixi ); |
194 | p. drawPixmap ( 0, pixSize, pPix); | 195 | p. drawPixmap ( 0, pixSize, pPix); |
195 | p.end(); | 196 | p.end(); |
196 | pixSize += size; | 197 | pixSize += size; |
197 | } | 198 | } |
198 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { | 199 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { |
199 | pixi.resize(size, pixSize+size); | 200 | pixi.resize(size, pixSize+size); |
200 | pPix.fill( Qt::red ); | 201 | pPix.fill( Qt::red ); |
201 | p.begin( &pixi ); | 202 | p.begin( &pixi ); |
202 | p. drawPixmap ( 0, pixSize, pPix); | 203 | p. drawPixmap ( 0, pixSize, pPix); |
203 | p.end(); | 204 | p.end(); |
204 | pixSize += size; | 205 | pixSize += size; |
205 | } | 206 | } |
206 | if ( mTodo->doesRecur() ) { | 207 | if ( mTodo->doesRecur() ) { |
207 | pixi.resize(size, pixSize+size); | 208 | pixi.resize(size, pixSize+size); |
208 | pPix.fill( Qt::blue ); | 209 | pPix.fill( Qt::blue ); |
209 | p.begin( &pixi ); | 210 | p.begin( &pixi ); |
210 | p. drawPixmap ( 0, pixSize, pPix); | 211 | p. drawPixmap ( 0, pixSize, pPix); |
211 | p.end(); | 212 | p.end(); |
212 | pixSize += size; | 213 | pixSize += size; |
213 | } | 214 | } |
214 | // } | 215 | // } |
215 | if ( pixi.width() > 1 ) { | 216 | if ( pixi.width() > 1 ) { |
216 | setPixmap ( 0,pixi ) ; | 217 | setPixmap ( 0,pixi ) ; |
217 | } else { | 218 | } else { |
218 | setPixmap ( 0,QPixmap() ) ; | 219 | setPixmap ( 0,QPixmap() ) ; |
219 | } | 220 | } |
220 | } | 221 | } |
221 | void KOTodoViewItem::stateChange(bool state) | 222 | void KOTodoViewItem::stateChange(bool state) |
222 | { | 223 | { |
223 | // qDebug("KOTodoViewItem::stateChange %d ", state); | 224 | // qDebug("KOTodoViewItem::stateChange %d ", state); |
224 | // do not change setting on startup | 225 | // do not change setting on startup |
225 | if ( m_init ) return; | 226 | if ( m_init ) return; |
226 | if (isOn()!=state) { | 227 | if (isOn()!=state) { |
227 | setOn(state); | 228 | setOn(state); |
228 | //qDebug("SETON "); | 229 | //qDebug("SETON "); |
229 | return; | 230 | return; |
230 | } | 231 | } |
231 | if ( mTodo->isCompleted() == state ) { | 232 | if ( mTodo->isCompleted() == state ) { |
232 | //qDebug("STATECHANGE:nothing to do "); | 233 | //qDebug("STATECHANGE:nothing to do "); |
233 | return; | 234 | return; |
234 | } | 235 | } |
235 | QString keyd = "=="; | 236 | QString keyd = "=="; |
236 | QString keyt = "=="; | 237 | QString keyt = "=="; |
237 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); | 238 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); |
238 | if ( mTodo->doesRecur() ){ | 239 | if ( mTodo->doesRecur() ){ |
239 | QDateTime start = mTodo->dtStart(); | 240 | QDateTime start = mTodo->dtStart(); |
240 | mTodo->setCompleted(state); | 241 | mTodo->setCompleted(state); |
241 | if ( start != mTodo->dtStart() ) { | 242 | if ( start != mTodo->dtStart() ) { |
242 | if ( state && !mTodo->isCompleted() ) { | 243 | if ( state && !mTodo->isCompleted() ) { |
243 | setOn( false ); | 244 | setOn( false ); |
244 | state = false; | 245 | state = false; |
245 | } | 246 | } |
246 | } | 247 | } |
247 | } else | 248 | } else |
248 | mTodo->setCompleted(state); | 249 | mTodo->setCompleted(state); |
249 | 250 | ||
250 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); | 251 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
251 | 252 | ||
252 | if (mTodo->hasDueDate()) { | 253 | if (mTodo->hasDueDate()) { |
253 | setText(3, mTodo->dtDueDateStr()); | 254 | setText(3, mTodo->dtDueDateStr()); |
254 | QDate d = mTodo->dtDue().date(); | 255 | QDate d = mTodo->dtDue().date(); |
255 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 256 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
256 | setSortKey(3,keyd); | 257 | setSortKey(3,keyd); |
257 | if (mTodo->doesFloat()) { | 258 | if (mTodo->doesFloat()) { |
258 | setText(4,""); | 259 | setText(4,""); |
259 | } | 260 | } |
260 | else { | 261 | else { |
261 | setText(4,mTodo->dtDueTimeStr()); | 262 | setText(4,mTodo->dtDueTimeStr()); |
262 | QTime t = mTodo->dtDue().time(); | 263 | QTime t = mTodo->dtDue().time(); |
263 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 264 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
264 | setSortKey(4,keyt); | 265 | setSortKey(4,keyt); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | if (mTodo->hasStartDate()) { | 268 | if (mTodo->hasStartDate()) { |
268 | QString skeyt = "=="; | 269 | QString skeyt = "=="; |
269 | QString skeyd = "=="; | 270 | QString skeyd = "=="; |
270 | setText(5, mTodo->dtStartDateStr()); | 271 | setText(5, mTodo->dtStartDateStr()); |
271 | QDate d = mTodo->dtStart().date(); | 272 | QDate d = mTodo->dtStart().date(); |
272 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 273 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
273 | 274 | ||
274 | if (mTodo->doesFloat()) { | 275 | if (mTodo->doesFloat()) { |
275 | setText(6,""); | 276 | setText(6,""); |
276 | } | 277 | } |
277 | else { | 278 | else { |
278 | setText(6,mTodo->dtStartTimeStr()); | 279 | setText(6,mTodo->dtStartTimeStr()); |
279 | QTime t = mTodo->dtStart().time(); | 280 | QTime t = mTodo->dtStart().time(); |
280 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 281 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
281 | 282 | ||
282 | } | 283 | } |
283 | setSortKey(5,skeyd); | 284 | setSortKey(5,skeyd); |
284 | setSortKey(6,skeyt); | 285 | setSortKey(6,skeyt); |
285 | } | 286 | } |
286 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 287 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
287 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 288 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
288 | 289 | ||
289 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 290 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
290 | if (mTodo->percentComplete()<100) { | 291 | if (mTodo->percentComplete()<100) { |
291 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 292 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
292 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 293 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
293 | } | 294 | } |
294 | else { | 295 | else { |
295 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 296 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
296 | else setSortKey(2,QString::number(99)); | 297 | else setSortKey(2,QString::number(99)); |
297 | } | 298 | } |
298 | if ( state ) { | 299 | if ( state ) { |
299 | QListViewItem * myChild = firstChild(); | 300 | QListViewItem * myChild = firstChild(); |
300 | KOTodoViewItem *item; | 301 | KOTodoViewItem *item; |
301 | while( myChild ) { | 302 | while( myChild ) { |
302 | //qDebug("stateCH "); | 303 | //qDebug("stateCH "); |
303 | item = static_cast<KOTodoViewItem*>(myChild); | 304 | item = static_cast<KOTodoViewItem*>(myChild); |
304 | item->stateChange(state); | 305 | item->stateChange(state); |
305 | myChild = myChild->nextSibling(); | 306 | myChild = myChild->nextSibling(); |
306 | } | 307 | } |
307 | } else { | 308 | } else { |
308 | QListViewItem * myChild = parent(); | 309 | QListViewItem * myChild = parent(); |
309 | if ( myChild ) | 310 | if ( myChild ) |
310 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 311 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
311 | } | 312 | } |
312 | mTodoView->modified(true); | 313 | mTodoView->modified(true); |
313 | setMyPixmap(); | 314 | setMyPixmap(); |
314 | mTodoView->setTodoModified( mTodo ); | 315 | mTodoView->setTodoModified( mTodo ); |
315 | } | 316 | } |
316 | 317 | ||
317 | bool KOTodoViewItem::isAlternate() | 318 | bool KOTodoViewItem::isAlternate() |
318 | { | 319 | { |
319 | 320 | ||
320 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 321 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
321 | if (lv && lv->alternateBackground().isValid()) | 322 | if (lv && lv->alternateBackground().isValid()) |
322 | { | 323 | { |
323 | KOTodoViewItem *above = 0; | 324 | KOTodoViewItem *above = 0; |
324 | above = static_cast<KOTodoViewItem *>(itemAbove()); | 325 | above = static_cast<KOTodoViewItem *>(itemAbove()); |
325 | m_known = above ? above->m_known : true; | 326 | m_known = above ? above->m_known : true; |
326 | if (m_known) | 327 | if (m_known) |
327 | { | 328 | { |
328 | m_odd = above ? !above->m_odd : false; | 329 | m_odd = above ? !above->m_odd : false; |
329 | } | 330 | } |
330 | else | 331 | else |
331 | { | 332 | { |
332 | KOTodoViewItem *item; | 333 | KOTodoViewItem *item; |
333 | bool previous = true; | 334 | bool previous = true; |
334 | if (QListViewItem::parent()) | 335 | if (QListViewItem::parent()) |
335 | { | 336 | { |
336 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); | 337 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); |
337 | if (item) | 338 | if (item) |
338 | previous = item->m_odd; | 339 | previous = item->m_odd; |
339 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 340 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
340 | } | 341 | } |
341 | else | 342 | else |
342 | { | 343 | { |
343 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 344 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
344 | } | 345 | } |
345 | 346 | ||
346 | while(item) | 347 | while(item) |
347 | { | 348 | { |
348 | item->m_odd = previous = !previous; | 349 | item->m_odd = previous = !previous; |
349 | item->m_known = true; | 350 | item->m_known = true; |