-rw-r--r-- | korganizer/kotodoview.cpp | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e008625..ccc4b01 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -219,122 +219,136 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | |||
219 | itemMargin() || | 219 | itemMargin() || |
220 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 220 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
221 | if (e->button()==Qt::LeftButton) { | 221 | if (e->button()==Qt::LeftButton) { |
222 | mPressPos = e->pos(); | 222 | mPressPos = e->pos(); |
223 | mMousePressed = true; | 223 | mMousePressed = true; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | } | 226 | } |
227 | #endif | 227 | #endif |
228 | QListView::contentsMousePressEvent(e); | 228 | QListView::contentsMousePressEvent(e); |
229 | } | 229 | } |
230 | void KOTodoListView::paintEvent(QPaintEvent* e) | 230 | void KOTodoListView::paintEvent(QPaintEvent* e) |
231 | { | 231 | { |
232 | emit paintNeeded(); | 232 | emit paintNeeded(); |
233 | QListView::paintEvent( e); | 233 | QListView::paintEvent( e); |
234 | } | 234 | } |
235 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 235 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
236 | { | 236 | { |
237 | 237 | ||
238 | #ifndef KORG_NODND | 238 | #ifndef KORG_NODND |
239 | //QListView::contentsMouseMoveEvent(e); | 239 | //QListView::contentsMouseMoveEvent(e); |
240 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 240 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
241 | QApplication::startDragDistance()*3) { | 241 | QApplication::startDragDistance()*3) { |
242 | mMousePressed = false; | 242 | mMousePressed = false; |
243 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 243 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
244 | if (item) { | 244 | if (item) { |
245 | DndFactory factory( mCalendar ); | 245 | DndFactory factory( mCalendar ); |
246 | ICalDrag *vd = factory.createDrag( | 246 | ICalDrag *vd = factory.createDrag( |
247 | ((KOTodoViewItem *)item)->todo(),viewport()); | 247 | ((KOTodoViewItem *)item)->todo(),viewport()); |
248 | internalDrop = false; | 248 | internalDrop = false; |
249 | // we cannot do any senseful here, because the DnD is still broken in Qt | 249 | // we cannot do any senseful here, because the DnD is still broken in Qt |
250 | if (vd->drag()) { | 250 | if (vd->drag()) { |
251 | if ( !internalDrop ) { | 251 | if ( !internalDrop ) { |
252 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 252 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
253 | qDebug("Dnd: External move: Delete drag source "); | 253 | qDebug("Dnd: External move: Delete drag source "); |
254 | } else | 254 | } else |
255 | qDebug("Dnd: Internal move "); | 255 | qDebug("Dnd: Internal move "); |
256 | 256 | ||
257 | } else { | 257 | } else { |
258 | if ( !internalDrop ) { | 258 | if ( !internalDrop ) { |
259 | qDebug("Dnd: External Copy"); | 259 | qDebug("Dnd: External Copy"); |
260 | } else | 260 | } else |
261 | qDebug("DnD: Internal copy: Copy pending"); | 261 | qDebug("DnD: Internal copy: Copy pending"); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } | 264 | } |
265 | #endif | 265 | #endif |
266 | } | 266 | } |
267 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 267 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
268 | { | 268 | { |
269 | if ( !e->isAutoRepeat() ) { | ||
270 | mFlagKeyPressed = false; | ||
271 | } | ||
272 | } | ||
273 | |||
269 | 274 | ||
275 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | ||
276 | { | ||
277 | qApp->processEvents(); | ||
278 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
279 | e->ignore(); | ||
280 | // qDebug(" ignore %d",e->isAutoRepeat() ); | ||
281 | return; | ||
282 | } | ||
283 | if (! e->isAutoRepeat() ) | ||
284 | mFlagKeyPressed = true; | ||
270 | QListViewItem* cn; | 285 | QListViewItem* cn; |
271 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 286 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
272 | cn = currentItem(); | 287 | cn = currentItem(); |
273 | if ( cn ) { | 288 | if ( cn ) { |
274 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 289 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
275 | if ( ci ){ | 290 | if ( ci ){ |
276 | if ( e->state() == ShiftButton ) | 291 | if ( e->state() == ShiftButton ) |
277 | ci->setOn( false ); | 292 | ci->setOn( false ); |
278 | else | 293 | else |
279 | ci->setOn( true ); | 294 | ci->setOn( true ); |
280 | cn = cn->itemBelow(); | 295 | cn = cn->itemBelow(); |
281 | if ( cn ) { | 296 | if ( cn ) { |
282 | setCurrentItem ( cn ); | 297 | setCurrentItem ( cn ); |
283 | ensureItemVisible ( cn ); | 298 | ensureItemVisible ( cn ); |
284 | } | 299 | } |
285 | 300 | ||
286 | } | 301 | } |
287 | } | 302 | } |
288 | 303 | ||
289 | return; | 304 | return; |
290 | } | 305 | } |
291 | 306 | ||
292 | // qDebug("KOTodoListView::keyPressEvent "); | ||
293 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 307 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
294 | switch ( e->key() ) { | 308 | switch ( e->key() ) { |
295 | case Qt::Key_Down: | 309 | case Qt::Key_Down: |
296 | case Qt::Key_Up: | 310 | case Qt::Key_Up: |
297 | QListView::keyPressEvent ( e ); | 311 | QListView::keyPressEvent ( e ); |
298 | break; | 312 | break; |
299 | case Qt::Key_Left: | 313 | case Qt::Key_Left: |
300 | case Qt::Key_Right: | 314 | case Qt::Key_Right: |
301 | QListView::keyPressEvent ( e ); | 315 | QListView::keyPressEvent ( e ); |
302 | e->accept(); | 316 | e->accept(); |
303 | return; | 317 | return; |
304 | break; | 318 | break; |
305 | default: | 319 | default: |
306 | e->ignore(); | 320 | e->ignore(); |
307 | break; | 321 | break; |
308 | } | 322 | } |
309 | return; | 323 | return; |
310 | } | 324 | } |
311 | e->ignore(); | 325 | e->ignore(); |
312 | } | 326 | } |
313 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 327 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
314 | { | 328 | { |
315 | QListView::contentsMouseReleaseEvent(e); | 329 | QListView::contentsMouseReleaseEvent(e); |
316 | mMousePressed = false; | 330 | mMousePressed = false; |
317 | } | 331 | } |
318 | 332 | ||
319 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 333 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
320 | { | 334 | { |
321 | if (!e) return; | 335 | if (!e) return; |
322 | 336 | ||
323 | QPoint vp = contentsToViewport(e->pos()); | 337 | QPoint vp = contentsToViewport(e->pos()); |
324 | 338 | ||
325 | QListViewItem *item = itemAt(vp); | 339 | QListViewItem *item = itemAt(vp); |
326 | 340 | ||
327 | emit double_Clicked(item); | 341 | emit double_Clicked(item); |
328 | if (!item) return; | 342 | if (!item) return; |
329 | 343 | ||
330 | emit doubleClicked(item,vp,0); | 344 | emit doubleClicked(item,vp,0); |
331 | } | 345 | } |
332 | 346 | ||
333 | ///////////////////////////////////////////////////////////////////////////// | 347 | ///////////////////////////////////////////////////////////////////////////// |
334 | 348 | ||
335 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 349 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
336 | QLineEdit(parent) | 350 | QLineEdit(parent) |
337 | { | 351 | { |
338 | setText(i18n("Click to add a new Todo")); | 352 | setText(i18n("Click to add a new Todo")); |
339 | } | 353 | } |
340 | 354 | ||
@@ -553,210 +567,248 @@ KOTodoView::~KOTodoView() | |||
553 | // delete mKOTodoViewWhatsThis; | 567 | // delete mKOTodoViewWhatsThis; |
554 | delete mDocPrefs; | 568 | delete mDocPrefs; |
555 | } | 569 | } |
556 | QString KOTodoView::getWhatsThisText(QPoint p) | 570 | QString KOTodoView::getWhatsThisText(QPoint p) |
557 | { | 571 | { |
558 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 572 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
559 | if ( item ) | 573 | if ( item ) |
560 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 574 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
561 | KOPrefs::instance()->mWTshowDetails, | 575 | KOPrefs::instance()->mWTshowDetails, |
562 | KOPrefs::instance()->mWTshowCreated, | 576 | KOPrefs::instance()->mWTshowCreated, |
563 | KOPrefs::instance()->mWTshowChanged); | 577 | KOPrefs::instance()->mWTshowChanged); |
564 | return i18n("That is the todo view" ); | 578 | return i18n("That is the todo view" ); |
565 | 579 | ||
566 | } | 580 | } |
567 | 581 | ||
568 | void KOTodoView::jumpToDate () | 582 | void KOTodoView::jumpToDate () |
569 | { | 583 | { |
570 | // if (mActiveItem) { | 584 | // if (mActiveItem) { |
571 | // mActiveItem->todo()); | 585 | // mActiveItem->todo()); |
572 | // if ( mActiveItem->todo()->hasDueDate() ) | 586 | // if ( mActiveItem->todo()->hasDueDate() ) |
573 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 587 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
574 | } | 588 | } |
575 | void KOTodoView::paintNeeded() | 589 | void KOTodoView::paintNeeded() |
576 | { | 590 | { |
577 | if ( mPendingUpdateBeforeRepaint ) { | 591 | if ( mPendingUpdateBeforeRepaint ) { |
578 | updateView(); | 592 | updateView(); |
579 | mPendingUpdateBeforeRepaint = false; | 593 | mPendingUpdateBeforeRepaint = false; |
580 | } | 594 | } |
581 | } | 595 | } |
582 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 596 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
583 | { | 597 | { |
584 | if ( mPendingUpdateBeforeRepaint ) { | 598 | if ( mPendingUpdateBeforeRepaint ) { |
585 | updateView(); | 599 | updateView(); |
586 | mPendingUpdateBeforeRepaint = false; | 600 | mPendingUpdateBeforeRepaint = false; |
587 | } | 601 | } |
588 | KOrg::BaseView::paintEvent( pevent); | 602 | KOrg::BaseView::paintEvent( pevent); |
589 | } | 603 | } |
590 | 604 | ||
591 | void KOTodoView::updateView() | 605 | void KOTodoView::updateView() |
592 | { | 606 | { |
593 | pendingSubtodo = 0; | 607 | pendingSubtodo = 0; |
594 | if ( mBlockUpdate ) { | 608 | if ( mBlockUpdate ) { |
595 | return; | 609 | return; |
596 | } | 610 | } |
597 | if ( !isVisible() ) { | 611 | if ( !isVisible() ) { |
598 | mPendingUpdateBeforeRepaint = true; | 612 | mPendingUpdateBeforeRepaint = true; |
599 | return; | 613 | return; |
600 | } | 614 | } |
615 | storeCurrentItem(); | ||
601 | //qDebug("KOTodoView::updateView() %x", this); | 616 | //qDebug("KOTodoView::updateView() %x", this); |
602 | if ( isFlatDisplay ) { | 617 | if ( isFlatDisplay ) { |
603 | displayAllFlat(); | 618 | displayAllFlat(); |
619 | resetCurrentItem(); | ||
604 | return; | 620 | return; |
605 | } | 621 | } |
606 | //qDebug("update "); | 622 | //qDebug("update "); |
607 | // kdDebug() << "KOTodoView::updateView()" << endl; | 623 | // kdDebug() << "KOTodoView::updateView()" << endl; |
608 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 624 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
609 | Incidence* oldInc = 0; | 625 | |
610 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
611 | if (mActiveItem) | ||
612 | oldInc = mActiveItem->todo(); | ||
613 | 626 | ||
614 | mTodoListView->clear(); | 627 | mTodoListView->clear(); |
615 | if ( mName == "todolistsmall" ) { | 628 | if ( mName == "todolistsmall" ) { |
616 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 629 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
617 | int ps = fo.pointSize() -2; | 630 | int ps = fo.pointSize() -2; |
618 | if ( ps > 12 ) | 631 | if ( ps > 12 ) |
619 | ps -= 2; | 632 | ps -= 2; |
620 | fo.setPointSize( ps ); | 633 | fo.setPointSize( ps ); |
621 | } | 634 | } |
622 | } | 635 | } |
623 | 636 | ||
624 | mTodoListView->setFont( fo ); | 637 | mTodoListView->setFont( fo ); |
625 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 638 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
626 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 639 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
627 | QPtrList<Todo> todoList = calendar()->todos(); | 640 | QPtrList<Todo> todoList = calendar()->todos(); |
628 | 641 | ||
629 | /* | 642 | /* |
630 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 643 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
631 | Event *t; | 644 | Event *t; |
632 | for(t = todoList.first(); t; t = todoList.next()) { | 645 | for(t = todoList.first(); t; t = todoList.next()) { |
633 | kdDebug() << " " << t->getSummary() << endl; | 646 | kdDebug() << " " << t->getSummary() << endl; |
634 | 647 | ||
635 | if (t->getRelatedTo()) { | 648 | if (t->getRelatedTo()) { |
636 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 649 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
637 | } | 650 | } |
638 | 651 | ||
639 | QPtrList<Event> l = t->getRelations(); | 652 | QPtrList<Event> l = t->getRelations(); |
640 | Event *c; | 653 | Event *c; |
641 | for(c=l.first();c;c=l.next()) { | 654 | for(c=l.first();c;c=l.next()) { |
642 | kdDebug() << " - relation: " << c->getSummary() << endl; | 655 | kdDebug() << " - relation: " << c->getSummary() << endl; |
643 | } | 656 | } |
644 | } | 657 | } |
645 | */ | 658 | */ |
646 | 659 | ||
647 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 660 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
648 | // specific order of events. That means that we have to generate parent items | 661 | // specific order of events. That means that we have to generate parent items |
649 | // recursively for proper hierarchical display of Todos. | 662 | // recursively for proper hierarchical display of Todos. |
650 | mTodoMap.clear(); | 663 | mTodoMap.clear(); |
651 | Todo *todo; | 664 | Todo *todo; |
652 | todo = todoList.first();// todo; todo = todoList.next()) { | 665 | todo = todoList.first();// todo; todo = todoList.next()) { |
653 | while ( todo ) { | 666 | while ( todo ) { |
654 | bool next = true; | 667 | bool next = true; |
655 | // qDebug("todo %s ", todo->summary().latin1()); | 668 | // qDebug("todo %s ", todo->summary().latin1()); |
656 | Incidence *incidence = todo->relatedTo(); | 669 | Incidence *incidence = todo->relatedTo(); |
657 | while ( incidence ) { | 670 | while ( incidence ) { |
658 | if ( incidence->type() == "Todo") { | 671 | if ( incidence->type() == "Todo") { |
659 | //qDebug("related %s ",incidence->summary().latin1() ); | 672 | //qDebug("related %s ",incidence->summary().latin1() ); |
660 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 673 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
661 | //qDebug("related not found "); | 674 | //qDebug("related not found "); |
662 | todoList.remove( ); | 675 | todoList.remove( ); |
663 | todo = todoList.current(); | 676 | todo = todoList.current(); |
664 | next = false; | 677 | next = false; |
665 | incidence = 0; | 678 | incidence = 0; |
666 | 679 | ||
667 | } else { | 680 | } else { |
668 | //qDebug("related found "); | 681 | //qDebug("related found "); |
669 | incidence = incidence->relatedTo(); | 682 | incidence = incidence->relatedTo(); |
670 | } | 683 | } |
671 | } else | 684 | } else |
672 | incidence = 0; | 685 | incidence = 0; |
673 | } | 686 | } |
674 | if ( next ) | 687 | if ( next ) |
675 | todo = todoList.next(); | 688 | todo = todoList.next(); |
676 | } | 689 | } |
677 | // qDebug("again .... "); | 690 | // qDebug("again .... "); |
678 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 691 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
679 | 692 | ||
680 | // qDebug("yytodo %s ", todo->summary().latin1()); | 693 | // qDebug("yytodo %s ", todo->summary().latin1()); |
681 | // } | 694 | // } |
682 | //qDebug("for "); | 695 | //qDebug("for "); |
683 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 696 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
684 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 697 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
685 | { | 698 | { |
686 | insertTodoItem(todo); | 699 | insertTodoItem(todo); |
687 | } | 700 | } |
688 | } | 701 | } |
689 | //qDebug("for end "); | 702 | //qDebug("for end "); |
690 | // Restore opened/closed state | 703 | // Restore opened/closed state |
691 | mTodoListView->blockSignals( true ); | 704 | mTodoListView->blockSignals( true ); |
692 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 705 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
693 | mTodoListView->blockSignals( false ); | 706 | mTodoListView->blockSignals( false ); |
707 | resetCurrentItem(); | ||
708 | processSelectionChange(); | ||
709 | } | ||
710 | |||
711 | void KOTodoView::storeCurrentItem() | ||
712 | { | ||
713 | mCurItem = 0; | ||
714 | mCurItemRootParent = 0; | ||
715 | mCurItemAbove = 0; | ||
716 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
717 | if (mActiveItem) { | ||
718 | mCurItem = mActiveItem->todo(); | ||
719 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | ||
720 | if ( activeItemAbove ) | ||
721 | mCurItemAbove = activeItemAbove->todo(); | ||
722 | while ( mActiveItem->parent() != 0 ) | ||
723 | mActiveItem = (KOTodoViewItem*)mActiveItem->parent(); | ||
724 | mCurItemRootParent = mActiveItem->todo(); | ||
725 | } | ||
726 | mActiveItem = 0; | ||
727 | } | ||
728 | |||
729 | void KOTodoView::resetCurrentItem() | ||
730 | { | ||
694 | mTodoListView->setFocus(); | 731 | mTodoListView->setFocus(); |
732 | KOTodoViewItem* foundItem = 0; | ||
733 | KOTodoViewItem* foundItemRoot = 0; | ||
734 | KOTodoViewItem* foundItemAbove = 0; | ||
695 | if ( mTodoListView->firstChild () ) { | 735 | if ( mTodoListView->firstChild () ) { |
696 | if ( oldInc ) { | 736 | if ( mCurItem ) { |
697 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 737 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
698 | while ( item ) { | 738 | while ( item ) { |
699 | if ( item->todo() == oldInc ) { | 739 | if ( item->todo() == mCurItem ) { |
700 | mTodoListView->setCurrentItem( item ); | 740 | foundItem = item; |
701 | mTodoListView->ensureItemVisible( item ); | ||
702 | break; | 741 | break; |
742 | } else if ( item->todo() == mCurItemAbove ) { | ||
743 | foundItemAbove = item; | ||
744 | |||
745 | } else if ( item->todo() == mCurItemRootParent ) { | ||
746 | foundItemRoot = item; | ||
703 | } | 747 | } |
704 | item = (KOTodoViewItem*)item->itemBelow(); | 748 | item = (KOTodoViewItem*)item->itemBelow(); |
705 | } | 749 | } |
706 | if ( ! item ) | 750 | if ( ! foundItem ) { |
707 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 751 | if ( foundItemAbove ) |
752 | foundItem = foundItemAbove; | ||
753 | else | ||
754 | foundItem = foundItemRoot; | ||
755 | } | ||
756 | } | ||
757 | if ( foundItem ) { | ||
758 | mTodoListView->setCurrentItem( foundItem ); | ||
759 | mTodoListView->ensureItemVisible( foundItem ); | ||
708 | } else { | 760 | } else { |
709 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 761 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
710 | } | 762 | } |
711 | } | 763 | } |
712 | processSelectionChange(); | 764 | mTodoListView->setFocus(); |
713 | } | 765 | } |
714 | 766 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | |
715 | bool KOTodoView::checkTodo( Todo * todo ) | 767 | bool KOTodoView::checkTodo( Todo * todo ) |
716 | { | 768 | { |
717 | 769 | ||
718 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 770 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
719 | return false; | 771 | return false; |
720 | if ( !todo->isCompleted() ) { | 772 | if ( !todo->isCompleted() ) { |
721 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 773 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
722 | return true; | 774 | return true; |
723 | } | 775 | } |
724 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 776 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
725 | if ( todo->hasStartDate() ) | 777 | if ( todo->hasStartDate() ) |
726 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 778 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
727 | return false; | 779 | return false; |
728 | if ( todo->hasDueDate() ) | 780 | if ( todo->hasDueDate() ) |
729 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 781 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
730 | return false; | 782 | return false; |
731 | } | 783 | } |
732 | return true; | 784 | return true; |
733 | } | 785 | } |
734 | 786 | ||
735 | void KOTodoView::restoreItemState( QListViewItem *item ) | 787 | void KOTodoView::restoreItemState( QListViewItem *item ) |
736 | { | 788 | { |
737 | pendingSubtodo = 0; | 789 | pendingSubtodo = 0; |
738 | while( item ) { | 790 | while( item ) { |
739 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 791 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
740 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 792 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
741 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 793 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
742 | item = item->nextSibling(); | 794 | item = item->nextSibling(); |
743 | } | 795 | } |
744 | } | 796 | } |
745 | 797 | ||
746 | 798 | ||
747 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 799 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
748 | KOTodoView::insertTodoItem(Todo *todo) | 800 | KOTodoView::insertTodoItem(Todo *todo) |
749 | { | 801 | { |
750 | 802 | ||
751 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 803 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
752 | // TODO: Check, if dynmaic cast is necessary | 804 | // TODO: Check, if dynmaic cast is necessary |
753 | 805 | ||
754 | pendingSubtodo = 0; | 806 | pendingSubtodo = 0; |
755 | Incidence *incidence = todo->relatedTo(); | 807 | Incidence *incidence = todo->relatedTo(); |
756 | if (incidence && incidence->type() == "Todo") { | 808 | if (incidence && incidence->type() == "Todo") { |
757 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 809 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
758 | 810 | ||
759 | // kdDebug() << " has Related" << endl; | 811 | // kdDebug() << " has Related" << endl; |
760 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 812 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
761 | itemIterator = mTodoMap.find(relatedTodo); | 813 | itemIterator = mTodoMap.find(relatedTodo); |
762 | if (itemIterator == mTodoMap.end()) { | 814 | if (itemIterator == mTodoMap.end()) { |
@@ -1194,96 +1246,97 @@ void KOTodoView::purgeCompleted() | |||
1194 | void KOTodoView::toggleQuickTodo() | 1246 | void KOTodoView::toggleQuickTodo() |
1195 | { | 1247 | { |
1196 | if ( mQuickAdd->isVisible() ) { | 1248 | if ( mQuickAdd->isVisible() ) { |
1197 | mQuickAdd->hide(); | 1249 | mQuickAdd->hide(); |
1198 | KOPrefs::instance()->mEnableQuickTodo = false; | 1250 | KOPrefs::instance()->mEnableQuickTodo = false; |
1199 | } | 1251 | } |
1200 | else { | 1252 | else { |
1201 | mQuickAdd->show(); | 1253 | mQuickAdd->show(); |
1202 | KOPrefs::instance()->mEnableQuickTodo = true; | 1254 | KOPrefs::instance()->mEnableQuickTodo = true; |
1203 | } | 1255 | } |
1204 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1256 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1205 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1257 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1206 | } | 1258 | } |
1207 | 1259 | ||
1208 | void KOTodoView::toggleRunning() | 1260 | void KOTodoView::toggleRunning() |
1209 | { | 1261 | { |
1210 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1262 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1211 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1263 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1212 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1264 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1213 | updateView(); | 1265 | updateView(); |
1214 | } | 1266 | } |
1215 | 1267 | ||
1216 | void KOTodoView::toggleCompleted() | 1268 | void KOTodoView::toggleCompleted() |
1217 | { | 1269 | { |
1218 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1270 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1219 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1271 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1220 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1272 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1221 | updateView(); | 1273 | updateView(); |
1222 | } | 1274 | } |
1223 | 1275 | ||
1224 | void KOTodoView::addQuickTodo() | 1276 | void KOTodoView::addQuickTodo() |
1225 | { | 1277 | { |
1226 | Todo *todo = new Todo(); | 1278 | Todo *todo = new Todo(); |
1227 | todo->setSummary(mQuickAdd->text()); | 1279 | todo->setSummary(mQuickAdd->text()); |
1228 | todo->setOrganizer(KOPrefs::instance()->email()); | 1280 | todo->setOrganizer(KOPrefs::instance()->email()); |
1229 | CalFilter * cf = mCalendar->filter(); | 1281 | CalFilter * cf = mCalendar->filter(); |
1230 | if ( cf ) { | 1282 | if ( cf ) { |
1231 | if ( cf->isEnabled()&& cf->showCategories()) { | 1283 | if ( cf->isEnabled()&& cf->showCategories()) { |
1232 | todo->setCategories(cf->categoryList()); | 1284 | todo->setCategories(cf->categoryList()); |
1233 | } | 1285 | } |
1234 | if ( cf->isEnabled() ) | 1286 | if ( cf->isEnabled() ) |
1235 | todo->setSecrecy( cf->getSecrecy()); | 1287 | todo->setSecrecy( cf->getSecrecy()); |
1236 | } | 1288 | } |
1237 | mCalendar->addTodo(todo); | 1289 | mCalendar->addTodo(todo); |
1238 | mQuickAdd->setText(""); | 1290 | mQuickAdd->setText(""); |
1239 | todoModified (todo, KOGlobals::EVENTADDED ); | 1291 | todoModified (todo, KOGlobals::EVENTADDED ); |
1240 | updateView(); | 1292 | updateView(); |
1241 | } | 1293 | } |
1294 | |||
1242 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1295 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1243 | { | 1296 | { |
1244 | // e->ignore(); | 1297 | // e->ignore(); |
1245 | //return; | 1298 | //return; |
1246 | //qDebug("KOTodoView::keyPressEvent "); | 1299 | //qDebug("KOTodoView::keyPressEvent "); |
1247 | switch ( e->key() ) { | 1300 | switch ( e->key() ) { |
1248 | case Qt::Key_Down: | 1301 | case Qt::Key_Down: |
1249 | case Qt::Key_Up: | 1302 | case Qt::Key_Up: |
1250 | QWidget::keyPressEvent ( e ); | 1303 | QWidget::keyPressEvent ( e ); |
1251 | break; | 1304 | break; |
1252 | 1305 | ||
1253 | case Qt::Key_Q: | 1306 | case Qt::Key_Q: |
1254 | toggleQuickTodo(); | 1307 | toggleQuickTodo(); |
1255 | break; | 1308 | break; |
1256 | case Qt::Key_U: | 1309 | case Qt::Key_U: |
1257 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1310 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1258 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1311 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1259 | unparentTodo(); | 1312 | unparentTodo(); |
1260 | e->accept(); | 1313 | e->accept(); |
1261 | } else | 1314 | } else |
1262 | e->ignore(); | 1315 | e->ignore(); |
1263 | break; | 1316 | break; |
1264 | case Qt::Key_S: | 1317 | case Qt::Key_S: |
1265 | if ( e->state() == Qt::ControlButton ) { | 1318 | if ( e->state() == Qt::ControlButton ) { |
1266 | e->ignore(); | 1319 | e->ignore(); |
1267 | break; | 1320 | break; |
1268 | } | 1321 | } |
1269 | if ( e->state() == Qt::ShiftButton ) { | 1322 | if ( e->state() == Qt::ShiftButton ) { |
1270 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1323 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1271 | reparentTodo(); | 1324 | reparentTodo(); |
1272 | e->accept(); | 1325 | e->accept(); |
1273 | } else | 1326 | } else |
1274 | e->ignore(); | 1327 | e->ignore(); |
1275 | break; | 1328 | break; |
1276 | case Qt::Key_P: | 1329 | case Qt::Key_P: |
1277 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1330 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1278 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1331 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1279 | if ( pendingSubtodo ) | 1332 | if ( pendingSubtodo ) |
1280 | itemClicked(mActiveItem); | 1333 | itemClicked(mActiveItem); |
1281 | e->accept(); | 1334 | e->accept(); |
1282 | } else | 1335 | } else |
1283 | e->ignore(); | 1336 | e->ignore(); |
1284 | break; | 1337 | break; |
1285 | case Qt::Key_Escape: | 1338 | case Qt::Key_Escape: |
1286 | if ( pendingSubtodo ) { | 1339 | if ( pendingSubtodo ) { |
1287 | itemClicked(0); | 1340 | itemClicked(0); |
1288 | e->accept(); | 1341 | e->accept(); |
1289 | } else | 1342 | } else |