summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-16 13:36:11 (UTC)
committer zautrix <zautrix>2004-10-16 13:36:11 (UTC)
commitc3325ebbb92a2814fcb622caaf71316cfa0c2908 (patch) (side-by-side diff)
treeb53545c39f84fc6ce694f371509b4a9fe2ddd743 /korganizer
parent023b3c542a6dd4d1c4b53dba6bb2c68f605a7917 (diff)
downloadkdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.zip
kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.tar.gz
kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.tar.bz2
made todos reparentable
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp16
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/kotodoview.cpp88
-rw-r--r--korganizer/kotodoview.h3
-rw-r--r--korganizer/koviewmanager.cpp2
-rw-r--r--korganizer/mainwindow.cpp3
6 files changed, 109 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e4a11f5..1f8ad5b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -421,2 +421,4 @@ void CalendarView::init()
+ connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
+ this, SLOT ( todo_resub( Todo *,Todo * ) ) );
connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
@@ -2748,2 +2750,16 @@ void CalendarView::appointment_delete()
+void CalendarView::todo_resub( Todo * parent, Todo * sub )
+{
+ if (!sub) return;
+ if (!parent) return;
+ if ( sub->relatedTo() )
+ sub->relatedTo()->removeRelation(sub);
+ sub->setRelatedTo(parent);
+ sub->setRelatedToUid(parent->uid());
+ parent->addRelation(sub);
+ sub->updated();
+ parent->updated();
+ setModified(true);
+ updateView();
+}
void CalendarView::todo_unsub(Todo *anTodo )
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 660cce7..9f56cc8 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -356,2 +356,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void todo_unsub( Todo * );
+ void todo_resub( Todo * parent, Todo * sub );
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:
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 6bf0203..0c08677 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -149,2 +149,3 @@ class KOTodoView : public KOrg::BaseView
void unparentTodo();
+ void reparentTodo();
void showTodo();
@@ -175,2 +176,3 @@ class KOTodoView : public KOrg::BaseView
void unparentTodoSignal(Todo *);
+ void reparentTodoSignal( Todo *,Todo * );
void showTodoSignal(Todo *);
@@ -228,2 +230,3 @@ class KOTodoView : public KOrg::BaseView
void keyPressEvent ( QKeyEvent * ) ;
+ KOTodoViewItem * pendingSubtodo;
};
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 8e6cc53..391f98c 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -500,2 +500,4 @@ void KOViewManager::showTodoView()
mMainView, SLOT ( todo_unsub( Todo * ) ) );
+ connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
+ mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8daacc7..06470b8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1149,2 +1149,5 @@ void MainWindow::keyBindings()
i18n("<p><h3>In todo view:</h3></p>\n") +
+ i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
+ i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
+ i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+