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,284 +1,286 @@ | |||
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 | ||
157 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 159 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
158 | 160 | ||
159 | if(existingTodo) { | 161 | if(existingTodo) { |
160 | Incidence *to = destinationEvent; | 162 | Incidence *to = destinationEvent; |
161 | while(to) { | 163 | while(to) { |
162 | if (to->uid() == todo->uid()) { | 164 | if (to->uid() == todo->uid()) { |
163 | KMessageBox::sorry(this, | 165 | KMessageBox::sorry(this, |
164 | i18n("Cannot move Todo to itself\nor a child of itself"), | 166 | i18n("Cannot move Todo to itself\nor a child of itself"), |
165 | i18n("Drop Todo")); | 167 | i18n("Drop Todo")); |
166 | delete todo; | 168 | delete todo; |
167 | return; | 169 | return; |
168 | } | 170 | } |
169 | to = to->relatedTo(); | 171 | to = to->relatedTo(); |
170 | } | 172 | } |
171 | internalDrop = true; | 173 | internalDrop = true; |
172 | if ( destinationEvent ) | 174 | if ( destinationEvent ) |
173 | reparentTodoSignal( destinationEvent, existingTodo ); | 175 | reparentTodoSignal( destinationEvent, existingTodo ); |
174 | else | 176 | else |
175 | unparentTodoSignal(existingTodo); | 177 | unparentTodoSignal(existingTodo); |
176 | delete todo; | 178 | delete todo; |
177 | } else { | 179 | } else { |
178 | mCalendar->addTodo(todo); | 180 | mCalendar->addTodo(todo); |
179 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 181 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
180 | if ( destinationEvent ) | 182 | if ( destinationEvent ) |
181 | reparentTodoSignal( destinationEvent, todo ); | 183 | reparentTodoSignal( destinationEvent, todo ); |
182 | } | 184 | } |
183 | } | 185 | } |
184 | else { | 186 | else { |
185 | QString text; | 187 | QString text; |
186 | if (QTextDrag::decode(e,text)) { | 188 | if (QTextDrag::decode(e,text)) { |
187 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 189 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
188 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 190 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
189 | qDebug("Dropped : " + text); | 191 | qDebug("Dropped : " + text); |
190 | QStringList emails = QStringList::split(",",text); | 192 | QStringList emails = QStringList::split(",",text); |
191 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 193 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
192 | int pos = (*it).find("<"); | 194 | int pos = (*it).find("<"); |
193 | QString name = (*it).left(pos); | 195 | QString name = (*it).left(pos); |
194 | QString email = (*it).mid(pos); | 196 | QString email = (*it).mid(pos); |
195 | if (!email.isEmpty() && todoi) { | 197 | if (!email.isEmpty() && todoi) { |
196 | todoi->todo()->addAttendee(new Attendee(name,email)); | 198 | todoi->todo()->addAttendee(new Attendee(name,email)); |
197 | } | 199 | } |
198 | } | 200 | } |
199 | } | 201 | } |
200 | else { | 202 | else { |
201 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 203 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
202 | e->ignore(); | 204 | e->ignore(); |
203 | } | 205 | } |
204 | } | 206 | } |
205 | #endif | 207 | #endif |
206 | } | 208 | } |
207 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 209 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
208 | { | 210 | { |
209 | QListView::wheelEvent (e); | 211 | QListView::wheelEvent (e); |
210 | } | 212 | } |
211 | 213 | ||
212 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 214 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
213 | { | 215 | { |
214 | 216 | ||
215 | QPoint p(contentsToViewport(e->pos())); | 217 | QPoint p(contentsToViewport(e->pos())); |
216 | QListViewItem *i = itemAt(p); | 218 | QListViewItem *i = itemAt(p); |
217 | bool rootClicked = true; | 219 | bool rootClicked = true; |
218 | if (i) { | 220 | if (i) { |
219 | // if the user clicked into the root decoration of the item, don't | 221 | // if the user clicked into the root decoration of the item, don't |
220 | // try to start a drag! | 222 | // try to start a drag! |
221 | int X = p.x(); | 223 | int X = p.x(); |
222 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 224 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
223 | if (X > header()->sectionPos(0) + | 225 | if (X > header()->sectionPos(0) + |
224 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 226 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
225 | itemMargin() +i->height()|| | 227 | itemMargin() +i->height()|| |
226 | X < header()->sectionPos(0)) { | 228 | X < header()->sectionPos(0)) { |
227 | rootClicked = false; | 229 | rootClicked = false; |
228 | } | 230 | } |
229 | } else { | 231 | } else { |
230 | rootClicked = false; | 232 | rootClicked = false; |
231 | } | 233 | } |
232 | #ifndef KORG_NODND | 234 | #ifndef KORG_NODND |
233 | mMousePressed = false; | 235 | mMousePressed = false; |
234 | if (! rootClicked && !( e->button() == RightButton) ) { | 236 | if (! rootClicked && !( e->button() == RightButton) ) { |
235 | mPressPos = e->pos(); | 237 | mPressPos = e->pos(); |
236 | mMousePressed = true; | 238 | mMousePressed = true; |
237 | } else { | 239 | } else { |
238 | mMousePressed = false; | 240 | mMousePressed = false; |
239 | } | 241 | } |
240 | #endif | 242 | #endif |
241 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 243 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
242 | #ifndef DESKTOP_VERSION | 244 | #ifndef DESKTOP_VERSION |
243 | if (!( e->button() == RightButton && rootClicked) ) | 245 | if (!( e->button() == RightButton && rootClicked) ) |
244 | QListView::contentsMousePressEvent(e); | 246 | QListView::contentsMousePressEvent(e); |
245 | #else | 247 | #else |
246 | QListView::contentsMousePressEvent(e); | 248 | QListView::contentsMousePressEvent(e); |
247 | #endif | 249 | #endif |
248 | } | 250 | } |
249 | void KOTodoListView::paintEvent(QPaintEvent* e) | 251 | void KOTodoListView::paintEvent(QPaintEvent* e) |
250 | { | 252 | { |
251 | emit paintNeeded(); | 253 | emit paintNeeded(); |
252 | QListView::paintEvent( e); | 254 | QListView::paintEvent( e); |
253 | } | 255 | } |
254 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 256 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
255 | { | 257 | { |
256 | 258 | ||
257 | #ifndef KORG_NODND | 259 | #ifndef KORG_NODND |
258 | //QListView::contentsMouseMoveEvent(e); | 260 | //QListView::contentsMouseMoveEvent(e); |
259 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 261 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
260 | QApplication::startDragDistance()*3) { | 262 | QApplication::startDragDistance()*3) { |
261 | mMousePressed = false; | 263 | mMousePressed = false; |
262 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 264 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
263 | if (item) { | 265 | if (item) { |
264 | DndFactory factory( mCalendar ); | 266 | DndFactory factory( mCalendar ); |
265 | ICalDrag *vd = factory.createDrag( | 267 | ICalDrag *vd = factory.createDrag( |
266 | ((KOTodoViewItem *)item)->todo(),viewport()); | 268 | ((KOTodoViewItem *)item)->todo(),viewport()); |
267 | internalDrop = false; | 269 | internalDrop = false; |
268 | // we cannot do any senseful here, because the DnD is still broken in Qt | 270 | // we cannot do any senseful here, because the DnD is still broken in Qt |
269 | if (vd->drag()) { | 271 | if (vd->drag()) { |
270 | if ( !internalDrop ) { | 272 | if ( !internalDrop ) { |
271 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 273 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
272 | qDebug("Dnd: External move: Delete drag source "); | 274 | qDebug("Dnd: External move: Delete drag source "); |
273 | } else | 275 | } else |
274 | qDebug("Dnd: Internal move "); | 276 | qDebug("Dnd: Internal move "); |
275 | 277 | ||
276 | } else { | 278 | } else { |
277 | if ( !internalDrop ) { | 279 | if ( !internalDrop ) { |
278 | qDebug("Dnd: External Copy"); | 280 | qDebug("Dnd: External Copy"); |
279 | } else | 281 | } else |
280 | qDebug("DnD: Internal copy: Copy pending"); | 282 | qDebug("DnD: Internal copy: Copy pending"); |
281 | } | 283 | } |
282 | } | 284 | } |
283 | } | 285 | } |
284 | #endif | 286 | #endif |
@@ -873,516 +875,526 @@ QPtrList<Incidence> KOTodoView::selectedIncidences() | |||
873 | { | 875 | { |
874 | QPtrList<Incidence> selected; | 876 | QPtrList<Incidence> selected; |
875 | 877 | ||
876 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 878 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
877 | // if (!item) item = mActiveItem; | 879 | // if (!item) item = mActiveItem; |
878 | if (item) selected.append(item->todo()); | 880 | if (item) selected.append(item->todo()); |
879 | 881 | ||
880 | return selected; | 882 | return selected; |
881 | } | 883 | } |
882 | 884 | ||
883 | QPtrList<Todo> KOTodoView::selectedTodos() | 885 | QPtrList<Todo> KOTodoView::selectedTodos() |
884 | { | 886 | { |
885 | QPtrList<Todo> selected; | 887 | QPtrList<Todo> selected; |
886 | 888 | ||
887 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 889 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
888 | // if (!item) item = mActiveItem; | 890 | // if (!item) item = mActiveItem; |
889 | if (item) selected.append(item->todo()); | 891 | if (item) selected.append(item->todo()); |
890 | 892 | ||
891 | return selected; | 893 | return selected; |
892 | } | 894 | } |
893 | 895 | ||
894 | void KOTodoView::changeEventDisplay(Event *, int) | 896 | void KOTodoView::changeEventDisplay(Event *, int) |
895 | { | 897 | { |
896 | updateView(); | 898 | updateView(); |
897 | } | 899 | } |
898 | 900 | ||
899 | void KOTodoView::showDates(const QDate &, const QDate &) | 901 | void KOTodoView::showDates(const QDate &, const QDate &) |
900 | { | 902 | { |
901 | } | 903 | } |
902 | 904 | ||
903 | void KOTodoView::showEvents(QPtrList<Event>) | 905 | void KOTodoView::showEvents(QPtrList<Event>) |
904 | { | 906 | { |
905 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 907 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
906 | } | 908 | } |
907 | 909 | ||
908 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 910 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
909 | const QDate &td) | 911 | const QDate &td) |
910 | { | 912 | { |
911 | #ifndef KORG_NOPRINTER | 913 | #ifndef KORG_NOPRINTER |
912 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 914 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
913 | #endif | 915 | #endif |
914 | } | 916 | } |
915 | 917 | ||
916 | void KOTodoView::editItem(QListViewItem *item ) | 918 | void KOTodoView::editItem(QListViewItem *item ) |
917 | { | 919 | { |
918 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 920 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
919 | } | 921 | } |
920 | 922 | ||
921 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 923 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
922 | { | 924 | { |
923 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 925 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
924 | } | 926 | } |
925 | 927 | ||
926 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 928 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
927 | { | 929 | { |
928 | pendingSubtodo = 0; | 930 | pendingSubtodo = 0; |
929 | mActiveItem = (KOTodoViewItem *)item; | 931 | mActiveItem = (KOTodoViewItem *)item; |
930 | if (item) { | 932 | if (item) { |
931 | switch (column){ | 933 | switch (column){ |
932 | case 1: | 934 | case 1: |
933 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 935 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
934 | case 2: | 936 | case 2: |
935 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 937 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
936 | case 3: | 938 | case 3: |
937 | moveTodo(); | 939 | moveTodo(); |
938 | break; | 940 | break; |
939 | case 8: | 941 | case 8: |
940 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 942 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
941 | default: | 943 | default: |
942 | mItemPopupMenu->popup(QCursor::pos()); | 944 | mItemPopupMenu->popup(QCursor::pos()); |
943 | } | 945 | } |
944 | } else mPopupMenu->popup(QCursor::pos()); | 946 | } else mPopupMenu->popup(QCursor::pos()); |
945 | } | 947 | } |
946 | void KOTodoView::newTodo() | 948 | void KOTodoView::newTodo() |
947 | { | 949 | { |
948 | emit newTodoSignal(); | 950 | emit newTodoSignal(); |
949 | } | 951 | } |
950 | 952 | ||
951 | void KOTodoView::newSubTodo() | 953 | void KOTodoView::newSubTodo() |
952 | { | 954 | { |
953 | if (mActiveItem) { | 955 | if (mActiveItem) { |
954 | emit newSubTodoSignal(mActiveItem->todo()); | 956 | emit newSubTodoSignal(mActiveItem->todo()); |
955 | } | 957 | } |
956 | } | 958 | } |
957 | void KOTodoView::unparentTodo() | 959 | void KOTodoView::unparentTodo() |
958 | { | 960 | { |
959 | if (mActiveItem) { | 961 | if (mActiveItem) { |
960 | emit unparentTodoSignal(mActiveItem->todo()); | 962 | emit unparentTodoSignal(mActiveItem->todo()); |
961 | } | 963 | } |
962 | } | 964 | } |
963 | 965 | ||
964 | void KOTodoView::reparentTodo() | 966 | void KOTodoView::reparentTodo() |
965 | { | 967 | { |
966 | if (mActiveItem) { | 968 | if (mActiveItem) { |
967 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 969 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
968 | pendingSubtodo = mActiveItem; | 970 | pendingSubtodo = mActiveItem; |
969 | } | 971 | } |
970 | } | 972 | } |
971 | void KOTodoView::editTodo() | 973 | void KOTodoView::editTodo() |
972 | { | 974 | { |
973 | if (mActiveItem) { | 975 | if (mActiveItem) { |
974 | emit editTodoSignal(mActiveItem->todo()); | 976 | emit editTodoSignal(mActiveItem->todo()); |
975 | } | 977 | } |
976 | } | 978 | } |
977 | void KOTodoView::cloneTodo() | 979 | void KOTodoView::cloneTodo() |
978 | { | 980 | { |
979 | if (mActiveItem) { | 981 | if (mActiveItem) { |
980 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 982 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
981 | } | 983 | } |
982 | } | 984 | } |
983 | void KOTodoView::cancelTodo() | 985 | void KOTodoView::cancelTodo() |
984 | { | 986 | { |
985 | if (mActiveItem) { | 987 | if (mActiveItem) { |
986 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 988 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
987 | } | 989 | } |
988 | } | 990 | } |
989 | void KOTodoView::moveTodo() | 991 | void KOTodoView::moveTodo() |
990 | { | 992 | { |
991 | if (mActiveItem) { | 993 | if (mActiveItem) { |
992 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 994 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
993 | } | 995 | } |
994 | } | 996 | } |
995 | void KOTodoView::beamTodo() | 997 | void KOTodoView::beamTodo() |
996 | { | 998 | { |
997 | if (mActiveItem) { | 999 | if (mActiveItem) { |
998 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1000 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
999 | } | 1001 | } |
1000 | } | 1002 | } |
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 ); |
1261 | item = item->nextSibling(); | 1273 | item = item->nextSibling(); |
1262 | } | 1274 | } |
1263 | } | 1275 | } |
1264 | 1276 | ||
1265 | void KOTodoView::displayAllFlat() | 1277 | void KOTodoView::displayAllFlat() |
1266 | { | 1278 | { |
1267 | pendingSubtodo = 0; | 1279 | pendingSubtodo = 0; |
1268 | if ( mBlockUpdate ) { | 1280 | if ( mBlockUpdate ) { |
1269 | return; | 1281 | return; |
1270 | } | 1282 | } |
1271 | mPopupMenu->setItemChecked( 8,true ); | 1283 | mPopupMenu->setItemChecked( 8,true ); |
1272 | isFlatDisplay = true; | 1284 | isFlatDisplay = true; |
1273 | QPtrList<Todo> todoList = calendar()->todos(); | 1285 | QPtrList<Todo> todoList = calendar()->todos(); |
1274 | mTodoMap.clear(); | 1286 | mTodoMap.clear(); |
1275 | mTodoListView->clear(); | 1287 | mTodoListView->clear(); |
1276 | Todo *todo; | 1288 | Todo *todo; |
1277 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1289 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1278 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1290 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1279 | mTodoMap.insert(todo,todoItem); | 1291 | mTodoMap.insert(todo,todoItem); |
1280 | } | 1292 | } |
1281 | mTodoListView->setFocus(); | 1293 | mTodoListView->setFocus(); |
1282 | processSelectionChange(); | 1294 | processSelectionChange(); |
1283 | } | 1295 | } |
1284 | 1296 | ||
1285 | void KOTodoView::setAllFlat() | 1297 | void KOTodoView::setAllFlat() |
1286 | { | 1298 | { |
1287 | if ( isFlatDisplay ) { | 1299 | if ( isFlatDisplay ) { |
1288 | isFlatDisplay = false; | 1300 | isFlatDisplay = false; |
1289 | mPopupMenu->setItemChecked( 8,false ); | 1301 | mPopupMenu->setItemChecked( 8,false ); |
1290 | updateView(); | 1302 | updateView(); |
1291 | return; | 1303 | return; |
1292 | } | 1304 | } |
1293 | storeCurrentItem(); | 1305 | storeCurrentItem(); |
1294 | displayAllFlat(); | 1306 | displayAllFlat(); |
1295 | resetCurrentItem(); | 1307 | resetCurrentItem(); |
1296 | } | 1308 | } |
1297 | 1309 | ||
1298 | void KOTodoView::purgeCompleted() | 1310 | void KOTodoView::purgeCompleted() |
1299 | { | 1311 | { |
1300 | emit purgeCompletedSignal(); | 1312 | emit purgeCompletedSignal(); |
1301 | 1313 | ||
1302 | } | 1314 | } |
1303 | void KOTodoView::toggleQuickTodo() | 1315 | void KOTodoView::toggleQuickTodo() |
1304 | { | 1316 | { |
1305 | if ( mQuickAdd->isVisible() ) { | 1317 | if ( mQuickAdd->isVisible() ) { |
1306 | mQuickAdd->hide(); | 1318 | mQuickAdd->hide(); |
1307 | KOPrefs::instance()->mEnableQuickTodo = false; | 1319 | KOPrefs::instance()->mEnableQuickTodo = false; |
1308 | } | 1320 | } |
1309 | else { | 1321 | else { |
1310 | mQuickAdd->show(); | 1322 | mQuickAdd->show(); |
1311 | KOPrefs::instance()->mEnableQuickTodo = true; | 1323 | KOPrefs::instance()->mEnableQuickTodo = true; |
1312 | } | 1324 | } |
1313 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1325 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1314 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1326 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1315 | } | 1327 | } |
1316 | 1328 | ||
1317 | void KOTodoView::toggleRunning() | 1329 | void KOTodoView::toggleRunning() |
1318 | { | 1330 | { |
1319 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1331 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1320 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1332 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1321 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1333 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1322 | updateView(); | 1334 | updateView(); |
1323 | } | 1335 | } |
1324 | 1336 | ||
1325 | void KOTodoView::toggleCompleted() | 1337 | void KOTodoView::toggleCompleted() |
1326 | { | 1338 | { |
1327 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1339 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1328 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1340 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1329 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1341 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1330 | updateView(); | 1342 | updateView(); |
1331 | } | 1343 | } |
1332 | 1344 | ||
1333 | void KOTodoView::addQuickTodo() | 1345 | void KOTodoView::addQuickTodo() |
1334 | { | 1346 | { |
1335 | Todo *todo = new Todo(); | 1347 | Todo *todo = new Todo(); |
1336 | todo->setSummary(mQuickAdd->text()); | 1348 | todo->setSummary(mQuickAdd->text()); |
1337 | todo->setOrganizer(KOPrefs::instance()->email()); | 1349 | todo->setOrganizer(KOPrefs::instance()->email()); |
1338 | CalFilter * cf = mCalendar->filter(); | 1350 | CalFilter * cf = mCalendar->filter(); |
1339 | if ( cf ) { | 1351 | if ( cf ) { |
1340 | if ( cf->isEnabled()&& cf->showCategories()) { | 1352 | if ( cf->isEnabled()&& cf->showCategories()) { |
1341 | todo->setCategories(cf->categoryList()); | 1353 | todo->setCategories(cf->categoryList()); |
1342 | } | 1354 | } |
1343 | if ( cf->isEnabled() ) | 1355 | if ( cf->isEnabled() ) |
1344 | todo->setSecrecy( cf->getSecrecy()); | 1356 | todo->setSecrecy( cf->getSecrecy()); |
1345 | } | 1357 | } |
1346 | mCalendar->addTodo(todo); | 1358 | mCalendar->addTodo(todo); |
1347 | mQuickAdd->setText(""); | 1359 | mQuickAdd->setText(""); |
1348 | todoModified (todo, KOGlobals::EVENTADDED ); | 1360 | todoModified (todo, KOGlobals::EVENTADDED ); |
1349 | updateView(); | 1361 | updateView(); |
1350 | } | 1362 | } |
1351 | 1363 | ||
1352 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1364 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1353 | { | 1365 | { |
1354 | // e->ignore(); | 1366 | // e->ignore(); |
1355 | //return; | 1367 | //return; |
1356 | //qDebug("KOTodoView::keyPressEvent "); | 1368 | //qDebug("KOTodoView::keyPressEvent "); |
1357 | switch ( e->key() ) { | 1369 | switch ( e->key() ) { |
1358 | case Qt::Key_Down: | 1370 | case Qt::Key_Down: |
1359 | case Qt::Key_Up: | 1371 | case Qt::Key_Up: |
1360 | QWidget::keyPressEvent ( e ); | 1372 | QWidget::keyPressEvent ( e ); |
1361 | break; | 1373 | break; |
1362 | 1374 | ||
1363 | case Qt::Key_Q: | 1375 | case Qt::Key_Q: |
1364 | toggleQuickTodo(); | 1376 | toggleQuickTodo(); |
1365 | break; | 1377 | break; |
1366 | case Qt::Key_U: | 1378 | case Qt::Key_U: |
1367 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1379 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1368 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1380 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1369 | unparentTodo(); | 1381 | unparentTodo(); |
1370 | e->accept(); | 1382 | e->accept(); |
1371 | } else | 1383 | } else |
1372 | e->ignore(); | 1384 | e->ignore(); |
1373 | break; | 1385 | break; |
1374 | case Qt::Key_S: | 1386 | case Qt::Key_S: |
1375 | if ( e->state() == Qt::ControlButton ) { | 1387 | if ( e->state() == Qt::ControlButton ) { |
1376 | e->ignore(); | 1388 | e->ignore(); |
1377 | break; | 1389 | break; |
1378 | } | 1390 | } |
1379 | if ( e->state() == Qt::ShiftButton ) { | 1391 | if ( e->state() == Qt::ShiftButton ) { |
1380 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1392 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1381 | reparentTodo(); | 1393 | reparentTodo(); |
1382 | e->accept(); | 1394 | e->accept(); |
1383 | } else | 1395 | } else |
1384 | e->ignore(); | 1396 | e->ignore(); |
1385 | break; | 1397 | break; |
1386 | case Qt::Key_P: | 1398 | case Qt::Key_P: |
1387 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1399 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1388 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1400 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |