author | zautrix <zautrix> | 2005-03-31 23:55:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-31 23:55:51 (UTC) |
commit | b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (patch) (unidiff) | |
tree | b0b3d0eb7a3d29981c183275aadeed0cbbef0007 /korganizer/kotodoview.cpp | |
parent | c0fa26aa3b33c293853bdd7d028ddb0545e33c85 (diff) | |
download | kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.zip kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.gz kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kotodoview.cpp | 103 |
1 files changed, 78 insertions, 25 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e008625..ccc4b01 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -243,74 +243,88 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | |||
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::keyReleaseEvent ( QKeyEvent *e ) | ||
268 | { | ||
269 | if ( !e->isAutoRepeat() ) { | ||
270 | mFlagKeyPressed = false; | ||
271 | } | ||
272 | } | ||
273 | |||
274 | |||
267 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 275 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
268 | { | 276 | { |
269 | 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; |
@@ -577,60 +591,59 @@ void KOTodoView::paintNeeded() | |||
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; |
@@ -670,69 +683,108 @@ void KOTodoView::updateView() | |||
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 ); |
694 | mTodoListView->setFocus(); | 707 | resetCurrentItem(); |
695 | if ( mTodoListView->firstChild () ) { | ||
696 | if ( oldInc ) { | ||
697 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | ||
698 | while ( item ) { | ||
699 | if ( item->todo() == oldInc ) { | ||
700 | mTodoListView->setCurrentItem( item ); | ||
701 | mTodoListView->ensureItemVisible( item ); | ||
702 | break; | ||
703 | } | ||
704 | item = (KOTodoViewItem*)item->itemBelow(); | ||
705 | } | ||
706 | if ( ! item ) | ||
707 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | ||
708 | } else { | ||
709 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | ||
710 | } | ||
711 | } | ||
712 | processSelectionChange(); | 708 | processSelectionChange(); |
713 | } | 709 | } |
714 | 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 | { | ||
731 | mTodoListView->setFocus(); | ||
732 | KOTodoViewItem* foundItem = 0; | ||
733 | KOTodoViewItem* foundItemRoot = 0; | ||
734 | KOTodoViewItem* foundItemAbove = 0; | ||
735 | if ( mTodoListView->firstChild () ) { | ||
736 | if ( mCurItem ) { | ||
737 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | ||
738 | while ( item ) { | ||
739 | if ( item->todo() == mCurItem ) { | ||
740 | foundItem = item; | ||
741 | break; | ||
742 | } else if ( item->todo() == mCurItemAbove ) { | ||
743 | foundItemAbove = item; | ||
744 | |||
745 | } else if ( item->todo() == mCurItemRootParent ) { | ||
746 | foundItemRoot = item; | ||
747 | } | ||
748 | item = (KOTodoViewItem*)item->itemBelow(); | ||
749 | } | ||
750 | if ( ! foundItem ) { | ||
751 | if ( foundItemAbove ) | ||
752 | foundItem = foundItemAbove; | ||
753 | else | ||
754 | foundItem = foundItemRoot; | ||
755 | } | ||
756 | } | ||
757 | if ( foundItem ) { | ||
758 | mTodoListView->setCurrentItem( foundItem ); | ||
759 | mTodoListView->ensureItemVisible( foundItem ); | ||
760 | } else { | ||
761 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | ||
762 | } | ||
763 | } | ||
764 | mTodoListView->setFocus(); | ||
765 | } | ||
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 ) { |
@@ -1218,50 +1270,51 @@ void KOTodoView::toggleCompleted() | |||
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; |