author | zautrix <zautrix> | 2005-04-28 09:08:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-28 09:08:21 (UTC) |
commit | 8fbdf5d2b0ee1e1496cb856e0ead37c668066353 (patch) (unidiff) | |
tree | 964dd57f1492857fb9471a0af9943d08c56e5c6e /korganizer | |
parent | 42786862c89c0de78cec783f251eae66bcbc53db (diff) | |
download | kdepimpi-8fbdf5d2b0ee1e1496cb856e0ead37c668066353.zip kdepimpi-8fbdf5d2b0ee1e1496cb856e0ead37c668066353.tar.gz kdepimpi-8fbdf5d2b0ee1e1496cb856e0ead37c668066353.tar.bz2 |
added comment for todo
-rw-r--r-- | korganizer/kotodoview.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e95039d..8fe9999 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,156 +1,158 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | 28 | ||
29 | #include <qinputdialog.h> | ||
30 | |||
29 | #include <qvbox.h> | 31 | #include <qvbox.h> |
30 | #include <kdebug.h> | 32 | #include <kdebug.h> |
31 | #include "koprefs.h" | 33 | #include "koprefs.h" |
32 | #include <klocale.h> | 34 | #include <klocale.h> |
33 | #include <kglobal.h> | 35 | #include <kglobal.h> |
34 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
35 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
36 | 38 | ||
37 | #include <libkcal/icaldrag.h> | 39 | #include <libkcal/icaldrag.h> |
38 | #include <libkcal/vcaldrag.h> | 40 | #include <libkcal/vcaldrag.h> |
39 | #include <libkcal/calfilter.h> | 41 | #include <libkcal/calfilter.h> |
40 | #include <libkcal/dndfactory.h> | 42 | #include <libkcal/dndfactory.h> |
41 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
43 | #include <kresources/resourceselectdialog.h> | 45 | #include <kresources/resourceselectdialog.h> |
44 | #include <libkcal/kincidenceformatter.h> | 46 | #include <libkcal/kincidenceformatter.h> |
45 | #ifndef DESKTOP_VERSION | 47 | #ifndef DESKTOP_VERSION |
46 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
47 | #else | 49 | #else |
48 | #include <qapplication.h> | 50 | #include <qapplication.h> |
49 | #endif | 51 | #endif |
50 | #ifndef KORG_NOPRINTER | 52 | #ifndef KORG_NOPRINTER |
51 | #include "calprinter.h" | 53 | #include "calprinter.h" |
52 | #endif | 54 | #endif |
53 | #include "docprefs.h" | 55 | #include "docprefs.h" |
54 | 56 | ||
55 | #include "kotodoview.h" | 57 | #include "kotodoview.h" |
56 | using namespace KOrg; | 58 | using namespace KOrg; |
57 | 59 | ||
58 | 60 | ||
59 | class KOTodoViewWhatsThis :public QWhatsThis | 61 | class KOTodoViewWhatsThis :public QWhatsThis |
60 | { | 62 | { |
61 | public: | 63 | public: |
62 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 64 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
63 | 65 | ||
64 | protected: | 66 | protected: |
65 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
66 | { | 68 | { |
67 | return _view->getWhatsThisText(p) ; | 69 | return _view->getWhatsThisText(p) ; |
68 | } | 70 | } |
69 | private: | 71 | private: |
70 | QWidget* _wid; | 72 | QWidget* _wid; |
71 | KOTodoView * _view; | 73 | KOTodoView * _view; |
72 | }; | 74 | }; |
73 | 75 | ||
74 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 76 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
75 | const char *name) : | 77 | const char *name) : |
76 | KListView(parent,name) | 78 | KListView(parent,name) |
77 | { | 79 | { |
78 | mName = QString ( name ); | 80 | mName = QString ( name ); |
79 | mCalendar = calendar; | 81 | mCalendar = calendar; |
80 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 84 | #endif |
83 | mOldCurrent = 0; | 85 | mOldCurrent = 0; |
84 | mMousePressed = false; | 86 | mMousePressed = false; |
85 | 87 | ||
86 | setAcceptDrops(true); | 88 | setAcceptDrops(true); |
87 | viewport()->setAcceptDrops(true); | 89 | viewport()->setAcceptDrops(true); |
88 | int size = 16; | 90 | int size = 16; |
89 | if (qApp->desktop()->width() < 300 ) | 91 | if (qApp->desktop()->width() < 300 ) |
90 | size = 12; | 92 | size = 12; |
91 | setTreeStepSize( size + 6 ); | 93 | setTreeStepSize( size + 6 ); |
92 | 94 | ||
93 | } | 95 | } |
94 | 96 | ||
95 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 97 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
96 | { | 98 | { |
97 | #ifndef KORG_NODND | 99 | #ifndef KORG_NODND |
98 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 100 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
99 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 101 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
100 | !QTextDrag::canDecode( e ) ) { | 102 | !QTextDrag::canDecode( e ) ) { |
101 | e->ignore(); | 103 | e->ignore(); |
102 | return; | 104 | return; |
103 | } | 105 | } |
104 | 106 | ||
105 | mOldCurrent = currentItem(); | 107 | mOldCurrent = currentItem(); |
106 | #endif | 108 | #endif |
107 | } | 109 | } |
108 | 110 | ||
109 | 111 | ||
110 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 112 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
111 | { | 113 | { |
112 | #ifndef KORG_NODND | 114 | #ifndef KORG_NODND |
113 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 115 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
114 | 116 | ||
115 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 117 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
116 | !QTextDrag::canDecode( e ) ) { | 118 | !QTextDrag::canDecode( e ) ) { |
117 | e->ignore(); | 119 | e->ignore(); |
118 | return; | 120 | return; |
119 | } | 121 | } |
120 | 122 | ||
121 | e->accept(); | 123 | e->accept(); |
122 | #endif | 124 | #endif |
123 | } | 125 | } |
124 | 126 | ||
125 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 127 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
126 | { | 128 | { |
127 | #ifndef KORG_NODND | 129 | #ifndef KORG_NODND |
128 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 130 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
129 | 131 | ||
130 | setCurrentItem(mOldCurrent); | 132 | setCurrentItem(mOldCurrent); |
131 | setSelected(mOldCurrent,true); | 133 | setSelected(mOldCurrent,true); |
132 | #endif | 134 | #endif |
133 | } | 135 | } |
134 | 136 | ||
135 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 137 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
136 | { | 138 | { |
137 | #ifndef KORG_NODND | 139 | #ifndef KORG_NODND |
138 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 140 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
139 | 141 | ||
140 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 142 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
141 | !QTextDrag::canDecode( e ) ) { | 143 | !QTextDrag::canDecode( e ) ) { |
142 | e->ignore(); | 144 | e->ignore(); |
143 | return; | 145 | return; |
144 | } | 146 | } |
145 | 147 | ||
146 | DndFactory factory( mCalendar ); | 148 | DndFactory factory( mCalendar ); |
147 | Todo *todo = factory.createDropTodo(e); | 149 | Todo *todo = factory.createDropTodo(e); |
148 | 150 | ||
149 | if (todo) { | 151 | if (todo) { |
150 | e->acceptAction(); | 152 | e->acceptAction(); |
151 | 153 | ||
152 | KOTodoViewItem *destination = | 154 | KOTodoViewItem *destination = |
153 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 155 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
154 | Todo *destinationEvent = 0; | 156 | Todo *destinationEvent = 0; |
155 | if (destination) destinationEvent = destination->todo(); | 157 | if (destination) destinationEvent = destination->todo(); |
156 | 158 | ||
@@ -1001,260 +1003,270 @@ void KOTodoView::beamTodo() | |||
1001 | 1003 | ||
1002 | 1004 | ||
1003 | void KOTodoView::showTodo() | 1005 | void KOTodoView::showTodo() |
1004 | { | 1006 | { |
1005 | if (mActiveItem) { | 1007 | if (mActiveItem) { |
1006 | emit showTodoSignal(mActiveItem->todo()); | 1008 | emit showTodoSignal(mActiveItem->todo()); |
1007 | } | 1009 | } |
1008 | } | 1010 | } |
1009 | 1011 | ||
1010 | void KOTodoView::deleteTodo() | 1012 | void KOTodoView::deleteTodo() |
1011 | { | 1013 | { |
1012 | if (mActiveItem) { | 1014 | if (mActiveItem) { |
1013 | emit deleteTodoSignal(mActiveItem->todo()); | 1015 | emit deleteTodoSignal(mActiveItem->todo()); |
1014 | } | 1016 | } |
1015 | } | 1017 | } |
1016 | 1018 | ||
1017 | void KOTodoView::setNewPriority(int index) | 1019 | void KOTodoView::setNewPriority(int index) |
1018 | { | 1020 | { |
1019 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1021 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1020 | mActiveItem->todo()->setPriority(mPriority[index]); | 1022 | mActiveItem->todo()->setPriority(mPriority[index]); |
1021 | mActiveItem->construct(); | 1023 | mActiveItem->construct(); |
1022 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1024 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1023 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1025 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1024 | } | 1026 | } |
1025 | } | 1027 | } |
1026 | 1028 | ||
1027 | void KOTodoView::setNewPercentage(int index) | 1029 | void KOTodoView::setNewPercentage(int index) |
1028 | { | 1030 | { |
1029 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1031 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1030 | 1032 | ||
1031 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1033 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1032 | mActiveItem->setOn( true ); | 1034 | mActiveItem->setOn( true ); |
1033 | return; | 1035 | return; |
1034 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1036 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1035 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1037 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1036 | if ( par && par->isOn() ) | 1038 | if ( par && par->isOn() ) |
1037 | par->setOn( false ); | 1039 | par->setOn( false ); |
1038 | } | 1040 | } |
1039 | if (mPercentage[index] == 100) { | 1041 | if (mPercentage[index] == 100) { |
1040 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1042 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1041 | } else { | 1043 | } else { |
1042 | mActiveItem->todo()->setCompleted(false); | 1044 | mActiveItem->todo()->setCompleted(false); |
1043 | } | 1045 | } |
1044 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1046 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1045 | mActiveItem->construct(); | 1047 | mActiveItem->construct(); |
1046 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1048 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1047 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1049 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1048 | } | 1050 | } |
1049 | } | 1051 | } |
1050 | 1052 | ||
1051 | 1053 | ||
1052 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1054 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1053 | { | 1055 | { |
1054 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1056 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1055 | QStringList checkedCategories = todoItem->todo()->categories (); | 1057 | QStringList checkedCategories = todoItem->todo()->categories (); |
1056 | 1058 | ||
1057 | tempMenu->setCheckable (true); | 1059 | tempMenu->setCheckable (true); |
1058 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1060 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1059 | it != KOPrefs::instance()->mCustomCategories.end (); | 1061 | it != KOPrefs::instance()->mCustomCategories.end (); |
1060 | ++it) { | 1062 | ++it) { |
1061 | int index = tempMenu->insertItem (*it); | 1063 | int index = tempMenu->insertItem (*it); |
1062 | mCategory[index] = *it; | 1064 | mCategory[index] = *it; |
1063 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1065 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1064 | } | 1066 | } |
1065 | 1067 | ||
1066 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1068 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1067 | return tempMenu; | 1069 | return tempMenu; |
1068 | 1070 | ||
1069 | 1071 | ||
1070 | } | 1072 | } |
1071 | void KOTodoView::changedCategories(int index) | 1073 | void KOTodoView::changedCategories(int index) |
1072 | { | 1074 | { |
1073 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1075 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1074 | QStringList categories = mActiveItem->todo()->categories (); | 1076 | QStringList categories = mActiveItem->todo()->categories (); |
1075 | QString colcat = categories.first(); | 1077 | QString colcat = categories.first(); |
1076 | if (categories.find (mCategory[index]) != categories.end ()) | 1078 | if (categories.find (mCategory[index]) != categories.end ()) |
1077 | categories.remove (mCategory[index]); | 1079 | categories.remove (mCategory[index]); |
1078 | else | 1080 | else |
1079 | categories.insert (categories.end(), mCategory[index]); | 1081 | categories.insert (categories.end(), mCategory[index]); |
1080 | categories.sort (); | 1082 | categories.sort (); |
1081 | if ( !colcat.isEmpty() ) { | 1083 | if ( !colcat.isEmpty() ) { |
1082 | if ( categories.find ( colcat ) != categories.end () ) { | 1084 | if ( categories.find ( colcat ) != categories.end () ) { |
1083 | categories.remove( colcat ); | 1085 | categories.remove( colcat ); |
1084 | categories.prepend( colcat ); | 1086 | categories.prepend( colcat ); |
1085 | } | 1087 | } |
1086 | } | 1088 | } |
1087 | mActiveItem->todo()->setCategories (categories); | 1089 | mActiveItem->todo()->setCategories (categories); |
1088 | mActiveItem->construct(); | 1090 | mActiveItem->construct(); |
1089 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1091 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1090 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1092 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1091 | } | 1093 | } |
1092 | } | 1094 | } |
1093 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1095 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1094 | { | 1096 | { |
1095 | if ( pendingSubtodo != 0 ) { | 1097 | if ( pendingSubtodo != 0 ) { |
1096 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1098 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1097 | } | 1099 | } |
1098 | pendingSubtodo = 0; | 1100 | pendingSubtodo = 0; |
1099 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1101 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1100 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1102 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1101 | //qDebug("ROW %d ", row); | 1103 | //qDebug("ROW %d ", row); |
1102 | if (!item) { | 1104 | if (!item) { |
1103 | newTodo(); | 1105 | newTodo(); |
1104 | return; | 1106 | return; |
1105 | } else { | 1107 | } else { |
1106 | if ( row == 2 || row == 1 ) { | 1108 | if ( row == 2 || row == 1 ) { |
1107 | mActiveItem = (KOTodoViewItem *) item; | 1109 | mActiveItem = (KOTodoViewItem *) item; |
1108 | newSubTodo(); | 1110 | newSubTodo(); |
1109 | return; | 1111 | return; |
1110 | } | 1112 | } |
1111 | if ( row == 5 || row == 6 ) { | 1113 | if ( row == 5 || row == 6 ) { |
1112 | mActiveItem = (KOTodoViewItem *) item; | 1114 | mActiveItem = (KOTodoViewItem *) item; |
1113 | toggleRunningItem(); | 1115 | toggleRunningItem(); |
1114 | return; | 1116 | return; |
1115 | } | 1117 | } |
1116 | } | 1118 | } |
1117 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1119 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1118 | editItem( item ); | 1120 | editItem( item ); |
1119 | else | 1121 | else |
1120 | showItem( item , QPoint(), 0 ); | 1122 | showItem( item , QPoint(), 0 ); |
1121 | } | 1123 | } |
1122 | void KOTodoView::toggleRunningItem() | 1124 | void KOTodoView::toggleRunningItem() |
1123 | { | 1125 | { |
1124 | // qDebug("KOTodoView::toggleRunning() "); | 1126 | // qDebug("KOTodoView::toggleRunning() "); |
1125 | if ( ! mActiveItem ) | 1127 | if ( ! mActiveItem ) |
1126 | return; | 1128 | return; |
1127 | Todo * t = mActiveItem->todo(); | 1129 | Todo * t = mActiveItem->todo(); |
1128 | if ( t->isRunning() ) { | 1130 | if ( t->isRunning() ) { |
1131 | #if 0 | ||
1129 | int result = KMessageBox::warningContinueCancel(this, | 1132 | int result = KMessageBox::warningContinueCancel(this, |
1130 | i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); | 1133 | i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); |
1131 | if (result != KMessageBox::Continue) return; | 1134 | #endif |
1132 | t->setRunning( false ); | 1135 | |
1136 | int result = KMessageBox::warningYesNoCancel(this, | ||
1137 | i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note")); | ||
1138 | if (result == KMessageBox::Cancel) return; | ||
1139 | if ( result == KMessageBox::No ) { | ||
1140 | QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); | ||
1141 | t->setRunningFalse( comment ); | ||
1142 | } else { | ||
1143 | t->setRunning( false ); | ||
1144 | } | ||
1133 | mActiveItem->construct(); | 1145 | mActiveItem->construct(); |
1134 | } else { | 1146 | } else { |
1135 | int result = KMessageBox::warningContinueCancel(this, | 1147 | int result = KMessageBox::warningContinueCancel(this, |
1136 | i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); | 1148 | i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); |
1137 | if (result != KMessageBox::Continue) return; | 1149 | if (result != KMessageBox::Continue) return; |
1138 | t->setRunning( true ); | 1150 | t->setRunning( true ); |
1139 | mActiveItem->construct(); | 1151 | mActiveItem->construct(); |
1140 | } | 1152 | } |
1141 | } | 1153 | } |
1142 | 1154 | ||
1143 | void KOTodoView::itemClicked(QListViewItem *item) | 1155 | void KOTodoView::itemClicked(QListViewItem *item) |
1144 | { | 1156 | { |
1145 | //qDebug("KOTodoView::itemClicked %d", item); | 1157 | //qDebug("KOTodoView::itemClicked %d", item); |
1146 | if (!item) { | 1158 | if (!item) { |
1147 | if ( pendingSubtodo != 0 ) { | 1159 | if ( pendingSubtodo != 0 ) { |
1148 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1160 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1149 | } | 1161 | } |
1150 | pendingSubtodo = 0; | 1162 | pendingSubtodo = 0; |
1151 | return; | 1163 | return; |
1152 | } | 1164 | } |
1153 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1165 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1154 | if ( pendingSubtodo != 0 ) { | 1166 | if ( pendingSubtodo != 0 ) { |
1155 | bool allowReparent = true; | 1167 | bool allowReparent = true; |
1156 | QListViewItem *par = item; | 1168 | QListViewItem *par = item; |
1157 | while ( par ) { | 1169 | while ( par ) { |
1158 | if ( par == pendingSubtodo ) { | 1170 | if ( par == pendingSubtodo ) { |
1159 | allowReparent = false; | 1171 | allowReparent = false; |
1160 | break; | 1172 | break; |
1161 | } | 1173 | } |
1162 | par = par->parent(); | 1174 | par = par->parent(); |
1163 | } | 1175 | } |
1164 | if ( !allowReparent ) { | 1176 | if ( !allowReparent ) { |
1165 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1177 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1166 | pendingSubtodo = 0; | 1178 | pendingSubtodo = 0; |
1167 | } else { | 1179 | } else { |
1168 | Todo* newParent = todoItem->todo(); | 1180 | Todo* newParent = todoItem->todo(); |
1169 | Todo* newSub = pendingSubtodo->todo(); | 1181 | Todo* newSub = pendingSubtodo->todo(); |
1170 | pendingSubtodo = 0; | 1182 | pendingSubtodo = 0; |
1171 | emit reparentTodoSignal( newParent,newSub ); | 1183 | emit reparentTodoSignal( newParent,newSub ); |
1172 | return; | 1184 | return; |
1173 | } | 1185 | } |
1174 | } | 1186 | } |
1175 | 1187 | ||
1176 | } | 1188 | } |
1177 | 1189 | ||
1178 | void KOTodoView::setDocumentId( const QString &id ) | 1190 | void KOTodoView::setDocumentId( const QString &id ) |
1179 | { | 1191 | { |
1180 | 1192 | ||
1181 | mDocPrefs->setDoc( id ); | 1193 | mDocPrefs->setDoc( id ); |
1182 | } | 1194 | } |
1183 | 1195 | ||
1184 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1196 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1185 | { | 1197 | { |
1186 | if (!item) return; | 1198 | if (!item) return; |
1187 | 1199 | ||
1188 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1200 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1189 | 1201 | ||
1190 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1202 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1191 | 1203 | ||
1192 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1204 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1193 | } | 1205 | } |
1194 | 1206 | ||
1195 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1207 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1196 | { | 1208 | { |
1197 | mTodoListView->saveLayout(config,group); | 1209 | mTodoListView->saveLayout(config,group); |
1198 | } | 1210 | } |
1199 | 1211 | ||
1200 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1212 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1201 | { | 1213 | { |
1202 | mTodoListView->restoreLayout(config,group); | 1214 | mTodoListView->restoreLayout(config,group); |
1203 | } | 1215 | } |
1204 | 1216 | ||
1205 | void KOTodoView::processSelectionChange() | 1217 | void KOTodoView::processSelectionChange() |
1206 | { | 1218 | { |
1207 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1219 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1208 | 1220 | ||
1209 | KOTodoViewItem *item = | 1221 | KOTodoViewItem *item = |
1210 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1222 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1211 | 1223 | ||
1212 | if ( !item ) { | 1224 | if ( !item ) { |
1213 | emit incidenceSelected( 0 ); | 1225 | emit incidenceSelected( 0 ); |
1214 | } else { | 1226 | } else { |
1215 | emit incidenceSelected( item->todo() ); | 1227 | emit incidenceSelected( item->todo() ); |
1216 | } | 1228 | } |
1217 | } | 1229 | } |
1218 | 1230 | ||
1219 | void KOTodoView::modified(bool b) | 1231 | void KOTodoView::modified(bool b) |
1220 | { | 1232 | { |
1221 | emit isModified(b); | 1233 | emit isModified(b); |
1222 | } | 1234 | } |
1223 | void KOTodoView::setTodoModified( Todo* todo ) | 1235 | void KOTodoView::setTodoModified( Todo* todo ) |
1224 | { | 1236 | { |
1225 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1237 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1226 | } | 1238 | } |
1227 | void KOTodoView::clearSelection() | 1239 | void KOTodoView::clearSelection() |
1228 | { | 1240 | { |
1229 | mTodoListView->selectAll( false ); | 1241 | mTodoListView->selectAll( false ); |
1230 | } | 1242 | } |
1231 | void KOTodoView::setAllOpen() | 1243 | void KOTodoView::setAllOpen() |
1232 | { | 1244 | { |
1233 | if ( isFlatDisplay ) { | 1245 | if ( isFlatDisplay ) { |
1234 | isFlatDisplay = false; | 1246 | isFlatDisplay = false; |
1235 | mPopupMenu->setItemChecked( 8,false ); | 1247 | mPopupMenu->setItemChecked( 8,false ); |
1236 | updateView(); | 1248 | updateView(); |
1237 | } else { | 1249 | } else { |
1238 | storeCurrentItem(); | 1250 | storeCurrentItem(); |
1239 | } | 1251 | } |
1240 | setOpen(mTodoListView->firstChild(), true); | 1252 | setOpen(mTodoListView->firstChild(), true); |
1241 | resetCurrentItem(); | 1253 | resetCurrentItem(); |
1242 | } | 1254 | } |
1243 | void KOTodoView::setAllClose() | 1255 | void KOTodoView::setAllClose() |
1244 | { | 1256 | { |
1245 | if ( isFlatDisplay ) { | 1257 | if ( isFlatDisplay ) { |
1246 | isFlatDisplay = false; | 1258 | isFlatDisplay = false; |
1247 | mPopupMenu->setItemChecked( 8,false ); | 1259 | mPopupMenu->setItemChecked( 8,false ); |
1248 | updateView(); | 1260 | updateView(); |
1249 | } else { | 1261 | } else { |
1250 | storeCurrentItem(); | 1262 | storeCurrentItem(); |
1251 | } | 1263 | } |
1252 | setOpen(mTodoListView->firstChild(), false); | 1264 | setOpen(mTodoListView->firstChild(), false); |
1253 | resetCurrentItem(); | 1265 | resetCurrentItem(); |
1254 | } | 1266 | } |
1255 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1267 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1256 | { | 1268 | { |
1257 | 1269 | ||
1258 | while ( item ) { | 1270 | while ( item ) { |
1259 | setOpen( item->firstChild(), setOpenI ); | 1271 | setOpen( item->firstChild(), setOpenI ); |
1260 | item->setOpen( setOpenI ); | 1272 | item->setOpen( setOpenI ); |