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) (ignore 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
@@ -419,6 +419,8 @@ void CalendarView::init()
connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
this, SLOT ( todo_unsub( Todo * ) ) );
+ connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
+ this, SLOT ( todo_resub( Todo *,Todo * ) ) );
connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
SLOT( updateTodo( Todo *, int ) ) );
connect( this, SIGNAL( todoModified( Todo *, int )), this,
@@ -2746,6 +2748,20 @@ void CalendarView::appointment_delete()
deleteEvent(anEvent);
}
+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 )
{
// Todo *anTodo = selectedTodo();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 660cce7..9f56cc8 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -354,6 +354,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
/* frees a subtodo from it's relation */
void todo_unsub( Todo * );
+ void todo_resub( Todo * parent, Todo * sub );
/** Take ownership of selected event. */
void takeOverEvent();
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)
void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
{
+
#ifndef KORG_NODND
// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
QListView::contentsMouseMoveEvent(e);
@@ -274,6 +275,8 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e )
case Qt::Key_Left:
case Qt::Key_Right:
QListView::keyPressEvent ( e );
+ e->accept();
+ return;
break;
default:
e->ignore();
@@ -414,7 +417,9 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
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"),
this, SLOT( purgeCompleted() ) );
@@ -439,9 +444,14 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
// Double clicking conflicts with opening/closing the subtree
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 * ) ) );
connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
@@ -695,7 +705,6 @@ void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
{
-
mActiveItem = (KOTodoViewItem *)item;
if (item) {
switch (column){
@@ -730,6 +739,15 @@ void KOTodoView::unparentTodo()
emit unparentTodoSignal(mActiveItem->todo());
}
}
+
+void KOTodoView::reparentTodo()
+{
+ if (mActiveItem) {
+ qDebug("KOTodoView::reparentTodo() ");
+ topLevelWidget()->setCaption(i18n("Click on new parent item"));
+ pendingSubtodo = mActiveItem;
+ }
+}
void KOTodoView::editTodo()
{
if (mActiveItem) {
@@ -843,6 +861,10 @@ void KOTodoView::changedCategories(int index)
}
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
+ if ( pendingSubtodo != 0 ) {
+ topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
+ }
+ pendingSubtodo = 0;
if (!item) {
newTodo();
return;
@@ -854,11 +876,37 @@ 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?
if (todoItem->isOn()) {
@@ -974,6 +1022,7 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
{
// e->ignore();
//return;
+ //qDebug("KOTodoView::keyPressEvent ");
switch ( e->key() ) {
case Qt::Key_Down:
case Qt::Key_Up:
@@ -983,7 +1032,38 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
case Qt::Key_Q:
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();
}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 6bf0203..0c08677 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -147,6 +147,7 @@ class KOTodoView : public KOrg::BaseView
void newTodo();
void newSubTodo();
void unparentTodo();
+ void reparentTodo();
void showTodo();
void editTodo();
void cloneTodo();
@@ -173,6 +174,7 @@ class KOTodoView : public KOrg::BaseView
void newTodoSignal();
void newSubTodoSignal(Todo *);
void unparentTodoSignal(Todo *);
+ void reparentTodoSignal( Todo *,Todo * );
void showTodoSignal(Todo *);
void editTodoSignal(Todo *);
@@ -226,6 +228,7 @@ class KOTodoView : public KOrg::BaseView
bool mBlockUpdate;
void todoModified(Todo *, int );
void keyPressEvent ( QKeyEvent * ) ;
+ KOTodoViewItem * pendingSubtodo;
};
#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 8e6cc53..391f98c 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -498,6 +498,8 @@ void KOViewManager::showTodoView()
mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
mMainView, SLOT ( todo_unsub( Todo * ) ) );
+ connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
+ mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
mMainView, SLOT ( moveIncidence( Incidence * ) ) );
connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8daacc7..06470b8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1147,6 +1147,9 @@ void MainWindow::keyBindings()
i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
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")+
i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+