summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (show 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
@@ -212,4 +212,5 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
{
+
#ifndef KORG_NODND
// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
@@ -275,4 +276,6 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e )
case Qt::Key_Right:
QListView::keyPressEvent ( e );
+ e->accept();
+ return;
break;
default:
@@ -415,5 +418,7 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
SLOT (newSubTodo()));
mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
- SLOT (unparentTodo()));
+ SLOT (unparentTodo()),0,21);
+ mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
+ SLOT (reparentTodo()),0,22);
mItemPopupMenu->insertSeparator();
mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
@@ -440,7 +445,12 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
SLOT( editItem( QListViewItem *) ) );
+ /*
connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
const QPoint &,int ) ),
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 * ) ),
SLOT( itemClicked( QListViewItem * ) ) );
@@ -696,5 +706,4 @@ void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
{
-
mActiveItem = (KOTodoViewItem *)item;
if (item) {
@@ -731,4 +740,13 @@ void KOTodoView::unparentTodo()
}
}
+
+void KOTodoView::reparentTodo()
+{
+ if (mActiveItem) {
+ qDebug("KOTodoView::reparentTodo() ");
+ topLevelWidget()->setCaption(i18n("Click on new parent item"));
+ pendingSubtodo = mActiveItem;
+ }
+}
void KOTodoView::editTodo()
{
@@ -844,4 +862,8 @@ void KOTodoView::changedCategories(int index)
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
+ if ( pendingSubtodo != 0 ) {
+ topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
+ }
+ pendingSubtodo = 0;
if (!item) {
newTodo();
@@ -855,9 +877,35 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
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?
@@ -975,4 +1023,5 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
// e->ignore();
//return;
+ //qDebug("KOTodoView::keyPressEvent ");
switch ( e->key() ) {
case Qt::Key_Down:
@@ -984,5 +1033,36 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
toggleQuickTodo();
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:
e->ignore();