-rw-r--r-- | korganizer/kotodoview.cpp | 88 |
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 @@ -213,2 +213,3 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { + #ifndef KORG_NODND @@ -276,2 +277,4 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) QListView::keyPressEvent ( e ); + e->accept(); + return; break; @@ -416,3 +419,5 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, - SLOT (unparentTodo())); + SLOT (unparentTodo()),0,21); + mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, + SLOT (reparentTodo()),0,22); mItemPopupMenu->insertSeparator(); @@ -441,2 +446,3 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : SLOT( editItem( QListViewItem *) ) ); + /* connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, @@ -444,2 +450,6 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); + */ + connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, + const QPoint &,int ) ), + SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), @@ -697,3 +707,2 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) { - mActiveItem = (KOTodoViewItem *)item; @@ -732,2 +741,11 @@ void KOTodoView::unparentTodo() } + +void KOTodoView::reparentTodo() +{ + if (mActiveItem) { + qDebug("KOTodoView::reparentTodo() "); + topLevelWidget()->setCaption(i18n("Click on new parent item")); + pendingSubtodo = mActiveItem; + } +} void KOTodoView::editTodo() @@ -845,2 +863,6 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) { + if ( pendingSubtodo != 0 ) { + topLevelWidget()->setCaption(i18n("Reparenting aborted!")); + } + pendingSubtodo = 0; if (!item) { @@ -856,7 +878,33 @@ void KOTodoView::itemClicked(QListViewItem *item) { + if (!item) { + if ( pendingSubtodo != 0 ) { + topLevelWidget()->setCaption(i18n("Reparenting aborted!")); + } + pendingSubtodo = 0; return; } - KOTodoViewItem *todoItem = (KOTodoViewItem *)item; + if ( pendingSubtodo != 0 ) { + bool allowReparent = true; + QListViewItem *par = item; + while ( par ) { + if ( par == pendingSubtodo ) { + allowReparent = false; + break; + } + par = par->parent(); + } + if ( !allowReparent ) { + topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); + qDebug("Recursive reparenting not possible "); + pendingSubtodo = 0; + } else { + Todo* newParent = todoItem->todo(); + Todo* newSub = pendingSubtodo->todo(); + pendingSubtodo = 0; + emit reparentTodoSignal( newParent,newSub ); + return; + } + } int completed = todoItem->todo()->isCompleted(); // Completed or not? @@ -976,2 +1024,3 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e ) //return; + //qDebug("KOTodoView::keyPressEvent "); switch ( e->key() ) { @@ -985,3 +1034,34 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e ) break; - + case Qt::Key_U: + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + unparentTodo(); + e->accept(); + } else + e->ignore(); + break; + case Qt::Key_S: + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + reparentTodo(); + e->accept(); + } else + e->ignore(); + break; + case Qt::Key_P: + if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + if ( pendingSubtodo ) + itemClicked(mActiveItem); + e->accept(); + } else + e->ignore(); + break; + case Qt::Key_Escape: + if ( pendingSubtodo ) { + itemClicked(0); + e->accept(); + } else + e->ignore(); + break; default: |