summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp88
1 files changed, 84 insertions, 4 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index ca5eadd..a8143a0 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -211,6 +211,7 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
211 211
212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
213{ 213{
214
214#ifndef KORG_NODND 215#ifndef KORG_NODND
215// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; 216// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
216 QListView::contentsMouseMoveEvent(e); 217 QListView::contentsMouseMoveEvent(e);
@@ -274,6 +275,8 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e )
274 case Qt::Key_Left: 275 case Qt::Key_Left:
275 case Qt::Key_Right: 276 case Qt::Key_Right:
276 QListView::keyPressEvent ( e ); 277 QListView::keyPressEvent ( e );
278 e->accept();
279 return;
277 break; 280 break;
278 default: 281 default:
279 e->ignore(); 282 e->ignore();
@@ -414,7 +417,9 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
414 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 417 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
415 SLOT (newSubTodo())); 418 SLOT (newSubTodo()));
416 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 419 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
417 SLOT (unparentTodo())); 420 SLOT (unparentTodo()),0,21);
421 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
422 SLOT (reparentTodo()),0,22);
418 mItemPopupMenu->insertSeparator(); 423 mItemPopupMenu->insertSeparator();
419 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 424 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
420 this, SLOT( purgeCompleted() ) ); 425 this, SLOT( purgeCompleted() ) );
@@ -439,9 +444,14 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
439 // Double clicking conflicts with opening/closing the subtree 444 // Double clicking conflicts with opening/closing the subtree
440 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 445 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
441 SLOT( editItem( QListViewItem *) ) ); 446 SLOT( editItem( QListViewItem *) ) );
447 /*
442 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 448 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
443 const QPoint &,int ) ), 449 const QPoint &,int ) ),
444 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 450 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
451 */
452 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
453 const QPoint &,int ) ),
454 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
445 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 455 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
446 SLOT( itemClicked( QListViewItem * ) ) ); 456 SLOT( itemClicked( QListViewItem * ) ) );
447 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 457 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
@@ -695,7 +705,6 @@ void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
695 705
696void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) 706void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
697{ 707{
698
699 mActiveItem = (KOTodoViewItem *)item; 708 mActiveItem = (KOTodoViewItem *)item;
700 if (item) { 709 if (item) {
701 switch (column){ 710 switch (column){
@@ -730,6 +739,15 @@ void KOTodoView::unparentTodo()
730 emit unparentTodoSignal(mActiveItem->todo()); 739 emit unparentTodoSignal(mActiveItem->todo());
731 } 740 }
732} 741}
742
743void KOTodoView::reparentTodo()
744{
745 if (mActiveItem) {
746 qDebug("KOTodoView::reparentTodo() ");
747 topLevelWidget()->setCaption(i18n("Click on new parent item"));
748 pendingSubtodo = mActiveItem;
749 }
750}
733void KOTodoView::editTodo() 751void KOTodoView::editTodo()
734{ 752{
735 if (mActiveItem) { 753 if (mActiveItem) {
@@ -843,6 +861,10 @@ void KOTodoView::changedCategories(int index)
843} 861}
844void KOTodoView::itemDoubleClicked(QListViewItem *item) 862void KOTodoView::itemDoubleClicked(QListViewItem *item)
845{ 863{
864 if ( pendingSubtodo != 0 ) {
865 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
866 }
867 pendingSubtodo = 0;
846 if (!item) { 868 if (!item) {
847 newTodo(); 869 newTodo();
848 return; 870 return;
@@ -854,11 +876,37 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
854} 876}
855void KOTodoView::itemClicked(QListViewItem *item) 877void KOTodoView::itemClicked(QListViewItem *item)
856{ 878{
879
857 if (!item) { 880 if (!item) {
881 if ( pendingSubtodo != 0 ) {
882 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
883 }
884 pendingSubtodo = 0;
858 return; 885 return;
859 } 886 }
860
861 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 887 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
888 if ( pendingSubtodo != 0 ) {
889 bool allowReparent = true;
890 QListViewItem *par = item;
891 while ( par ) {
892 if ( par == pendingSubtodo ) {
893 allowReparent = false;
894 break;
895 }
896 par = par->parent();
897 }
898 if ( !allowReparent ) {
899 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
900 qDebug("Recursive reparenting not possible ");
901 pendingSubtodo = 0;
902 } else {
903 Todo* newParent = todoItem->todo();
904 Todo* newSub = pendingSubtodo->todo();
905 pendingSubtodo = 0;
906 emit reparentTodoSignal( newParent,newSub );
907 return;
908 }
909 }
862 int completed = todoItem->todo()->isCompleted(); // Completed or not? 910 int completed = todoItem->todo()->isCompleted(); // Completed or not?
863 911
864 if (todoItem->isOn()) { 912 if (todoItem->isOn()) {
@@ -974,6 +1022,7 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
974{ 1022{
975 // e->ignore(); 1023 // e->ignore();
976 //return; 1024 //return;
1025 //qDebug("KOTodoView::keyPressEvent ");
977 switch ( e->key() ) { 1026 switch ( e->key() ) {
978 case Qt::Key_Down: 1027 case Qt::Key_Down:
979 case Qt::Key_Up: 1028 case Qt::Key_Up:
@@ -983,7 +1032,38 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
983 case Qt::Key_Q: 1032 case Qt::Key_Q:
984 toggleQuickTodo(); 1033 toggleQuickTodo();
985 break; 1034 break;
986 1035 case Qt::Key_U:
1036 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1037 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1038 unparentTodo();
1039 e->accept();
1040 } else
1041 e->ignore();
1042 break;
1043 case Qt::Key_S:
1044 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1045 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1046 reparentTodo();
1047 e->accept();
1048 } else
1049 e->ignore();
1050 break;
1051 case Qt::Key_P:
1052 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1053 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1054 if ( pendingSubtodo )
1055 itemClicked(mActiveItem);
1056 e->accept();
1057 } else
1058 e->ignore();
1059 break;
1060 case Qt::Key_Escape:
1061 if ( pendingSubtodo ) {
1062 itemClicked(0);
1063 e->accept();
1064 } else
1065 e->ignore();
1066 break;
987 default: 1067 default:
988 e->ignore(); 1068 e->ignore();
989 } 1069 }