author | zautrix <zautrix> | 2005-02-01 00:07:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-01 00:07:00 (UTC) |
commit | 74c59cea6db3e3a1c0a5922f7fa12ada24f4672b (patch) (unidiff) | |
tree | 8fe561a0aa3eca8c1949209c95c286adcd03a9c3 /korganizer | |
parent | fce3fd8accec495a2deda6fe3cd55375fac46432 (diff) | |
download | kdepimpi-74c59cea6db3e3a1c0a5922f7fa12ada24f4672b.zip kdepimpi-74c59cea6db3e3a1c0a5922f7fa12ada24f4672b.tar.gz kdepimpi-74c59cea6db3e3a1c0a5922f7fa12ada24f4672b.tar.bz2 |
VINklumpen
-rw-r--r-- | korganizer/kotodoview.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 99402c4..da8b4bc 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1014 +1,1014 @@ | |||
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 | 27 | ||
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | #include "koprefs.h" | 30 | #include "koprefs.h" |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/vcaldrag.h> | 37 | #include <libkcal/vcaldrag.h> |
38 | #include <libkcal/calfilter.h> | 38 | #include <libkcal/calfilter.h> |
39 | #include <libkcal/dndfactory.h> | 39 | #include <libkcal/dndfactory.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
43 | #ifndef DESKTOP_VERSION | 43 | #ifndef DESKTOP_VERSION |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #else | 45 | #else |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | #endif | 47 | #endif |
48 | #ifndef KORG_NOPRINTER | 48 | #ifndef KORG_NOPRINTER |
49 | #include "calprinter.h" | 49 | #include "calprinter.h" |
50 | #endif | 50 | #endif |
51 | #include "docprefs.h" | 51 | #include "docprefs.h" |
52 | 52 | ||
53 | #include "kotodoview.h" | 53 | #include "kotodoview.h" |
54 | using namespace KOrg; | 54 | using namespace KOrg; |
55 | 55 | ||
56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KListView(parent,name) | 58 | KListView(parent,name) |
59 | { | 59 | { |
60 | mName = QString ( name ); | 60 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | Incidence *to = destinationEvent; | 142 | Incidence *to = destinationEvent; |
143 | while(to) { | 143 | while(to) { |
144 | if (to->uid() == todo->uid()) { | 144 | if (to->uid() == todo->uid()) { |
145 | KMessageBox::sorry(this, | 145 | KMessageBox::sorry(this, |
146 | i18n("Cannot move To-Do to itself\nor a child of itself"), | 146 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
147 | i18n("Drop To-Do")); | 147 | i18n("Drop To-Do")); |
148 | delete todo; | 148 | delete todo; |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | to = to->relatedTo(); | 151 | to = to->relatedTo(); |
152 | } | 152 | } |
153 | internalDrop = true; | 153 | internalDrop = true; |
154 | if ( destinationEvent ) | 154 | if ( destinationEvent ) |
155 | reparentTodoSignal( destinationEvent, existingTodo ); | 155 | reparentTodoSignal( destinationEvent, existingTodo ); |
156 | else | 156 | else |
157 | unparentTodoSignal(existingTodo); | 157 | unparentTodoSignal(existingTodo); |
158 | delete todo; | 158 | delete todo; |
159 | } else { | 159 | } else { |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 161 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
162 | if ( destinationEvent ) | 162 | if ( destinationEvent ) |
163 | reparentTodoSignal( destinationEvent, todo ); | 163 | reparentTodoSignal( destinationEvent, todo ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | QString text; | 167 | QString text; |
168 | if (QTextDrag::decode(e,text)) { | 168 | if (QTextDrag::decode(e,text)) { |
169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
171 | qDebug("Dropped : " + text); | 171 | qDebug("Dropped : " + text); |
172 | QStringList emails = QStringList::split(",",text); | 172 | QStringList emails = QStringList::split(",",text); |
173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | #ifndef KORG_NODND | 192 | #ifndef KORG_NODND |
193 | QPoint p(contentsToViewport(e->pos())); | 193 | QPoint p(contentsToViewport(e->pos())); |
194 | QListViewItem *i = itemAt(p); | 194 | QListViewItem *i = itemAt(p); |
195 | mMousePressed = false; | 195 | mMousePressed = false; |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | QListView::contentsMousePressEvent(e); | 210 | QListView::contentsMousePressEvent(e); |
211 | } | 211 | } |
212 | void KOTodoListView::paintEvent(QPaintEvent* e) | 212 | void KOTodoListView::paintEvent(QPaintEvent* e) |
213 | { | 213 | { |
214 | emit paintNeeded(); | 214 | emit paintNeeded(); |
215 | QListView::paintEvent( e); | 215 | QListView::paintEvent( e); |
216 | } | 216 | } |
217 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 217 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
218 | { | 218 | { |
219 | 219 | ||
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | QListView::contentsMouseMoveEvent(e); | 221 | //QListView::contentsMouseMoveEvent(e); |
222 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 222 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
223 | QApplication::startDragDistance()) { | 223 | QApplication::startDragDistance()*3) { |
224 | mMousePressed = false; | 224 | mMousePressed = false; |
225 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 225 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
226 | if (item) { | 226 | if (item) { |
227 | DndFactory factory( mCalendar ); | 227 | DndFactory factory( mCalendar ); |
228 | ICalDrag *vd = factory.createDrag( | 228 | ICalDrag *vd = factory.createDrag( |
229 | ((KOTodoViewItem *)item)->todo(),viewport()); | 229 | ((KOTodoViewItem *)item)->todo(),viewport()); |
230 | internalDrop = false; | 230 | internalDrop = false; |
231 | // we cannot do any senseful here, because the DnD is still broken in Qt | 231 | // we cannot do any senseful here, because the DnD is still broken in Qt |
232 | if (vd->drag()) { | 232 | if (vd->drag()) { |
233 | if ( !internalDrop ) { | 233 | if ( !internalDrop ) { |
234 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 234 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
235 | qDebug("Dnd: External move: Delete drag source "); | 235 | qDebug("Dnd: External move: Delete drag source "); |
236 | } else | 236 | } else |
237 | qDebug("Dnd: Internal move "); | 237 | qDebug("Dnd: Internal move "); |
238 | 238 | ||
239 | } else { | 239 | } else { |
240 | if ( !internalDrop ) { | 240 | if ( !internalDrop ) { |
241 | qDebug("Dnd: External Copy"); | 241 | qDebug("Dnd: External Copy"); |
242 | } else | 242 | } else |
243 | qDebug("DnD: Internal copy: Copy pending"); | 243 | qDebug("DnD: Internal copy: Copy pending"); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | #endif | 247 | #endif |
248 | } | 248 | } |
249 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 249 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
250 | { | 250 | { |
251 | 251 | ||
252 | QListViewItem* cn; | 252 | QListViewItem* cn; |
253 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 253 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
254 | cn = currentItem(); | 254 | cn = currentItem(); |
255 | if ( cn ) { | 255 | if ( cn ) { |
256 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 256 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
257 | if ( ci ){ | 257 | if ( ci ){ |
258 | if ( e->state() == ShiftButton ) | 258 | if ( e->state() == ShiftButton ) |
259 | ci->setOn( false ); | 259 | ci->setOn( false ); |
260 | else | 260 | else |
261 | ci->setOn( true ); | 261 | ci->setOn( true ); |
262 | cn = cn->itemBelow(); | 262 | cn = cn->itemBelow(); |
263 | if ( cn ) { | 263 | if ( cn ) { |
264 | setCurrentItem ( cn ); | 264 | setCurrentItem ( cn ); |
265 | ensureItemVisible ( cn ); | 265 | ensureItemVisible ( cn ); |
266 | } | 266 | } |
267 | 267 | ||
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | // qDebug("KOTodoListView::keyPressEvent "); | 274 | // qDebug("KOTodoListView::keyPressEvent "); |
275 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 275 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
276 | switch ( e->key() ) { | 276 | switch ( e->key() ) { |
277 | case Qt::Key_Down: | 277 | case Qt::Key_Down: |
278 | case Qt::Key_Up: | 278 | case Qt::Key_Up: |
279 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
280 | break; | 280 | break; |
281 | case Qt::Key_Left: | 281 | case Qt::Key_Left: |
282 | case Qt::Key_Right: | 282 | case Qt::Key_Right: |
283 | QListView::keyPressEvent ( e ); | 283 | QListView::keyPressEvent ( e ); |
284 | e->accept(); | 284 | e->accept(); |
285 | return; | 285 | return; |
286 | break; | 286 | break; |
287 | default: | 287 | default: |
288 | e->ignore(); | 288 | e->ignore(); |
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | e->ignore(); | 293 | e->ignore(); |
294 | } | 294 | } |
295 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | QListView::contentsMouseReleaseEvent(e); | 297 | QListView::contentsMouseReleaseEvent(e); |
298 | mMousePressed = false; | 298 | mMousePressed = false; |
299 | } | 299 | } |
300 | 300 | ||
301 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 301 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
302 | { | 302 | { |
303 | if (!e) return; | 303 | if (!e) return; |
304 | 304 | ||
305 | QPoint vp = contentsToViewport(e->pos()); | 305 | QPoint vp = contentsToViewport(e->pos()); |
306 | 306 | ||
307 | QListViewItem *item = itemAt(vp); | 307 | QListViewItem *item = itemAt(vp); |
308 | 308 | ||
309 | emit double_Clicked(item); | 309 | emit double_Clicked(item); |
310 | if (!item) return; | 310 | if (!item) return; |
311 | 311 | ||
312 | emit doubleClicked(item,vp,0); | 312 | emit doubleClicked(item,vp,0); |
313 | } | 313 | } |
314 | 314 | ||
315 | ///////////////////////////////////////////////////////////////////////////// | 315 | ///////////////////////////////////////////////////////////////////////////// |
316 | 316 | ||
317 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 317 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
318 | QLineEdit(parent) | 318 | QLineEdit(parent) |
319 | { | 319 | { |
320 | setText(i18n("Click to add a new Todo")); | 320 | setText(i18n("Click to add a new Todo")); |
321 | } | 321 | } |
322 | 322 | ||
323 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 323 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
324 | { | 324 | { |
325 | if ( text()==i18n("Click to add a new Todo") ) | 325 | if ( text()==i18n("Click to add a new Todo") ) |
326 | setText(""); | 326 | setText(""); |
327 | QLineEdit::focusInEvent(ev); | 327 | QLineEdit::focusInEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 330 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
331 | { | 331 | { |
332 | setText(i18n("Click to add a new Todo")); | 332 | setText(i18n("Click to add a new Todo")); |
333 | QLineEdit::focusOutEvent(ev); | 333 | QLineEdit::focusOutEvent(ev); |
334 | } | 334 | } |
335 | 335 | ||
336 | ///////////////////////////////////////////////////////////////////////////// | 336 | ///////////////////////////////////////////////////////////////////////////// |
337 | 337 | ||
338 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 338 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
339 | KOrg::BaseView(calendar,parent,name) | 339 | KOrg::BaseView(calendar,parent,name) |
340 | { | 340 | { |
341 | mPendingUpdateBeforeRepaint = false; | 341 | mPendingUpdateBeforeRepaint = false; |
342 | isFlatDisplay = false; | 342 | isFlatDisplay = false; |
343 | mNavigator = 0; | 343 | mNavigator = 0; |
344 | QBoxLayout *topLayout = new QVBoxLayout(this); | 344 | QBoxLayout *topLayout = new QVBoxLayout(this); |
345 | mName = QString ( name ); | 345 | mName = QString ( name ); |
346 | mBlockUpdate = false; | 346 | mBlockUpdate = false; |
347 | mQuickAdd = new KOQuickTodo(this); | 347 | mQuickAdd = new KOQuickTodo(this); |
348 | topLayout->addWidget(mQuickAdd); | 348 | topLayout->addWidget(mQuickAdd); |
349 | 349 | ||
350 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 350 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
351 | 351 | ||
352 | mTodoListView = new KOTodoListView(calendar,this, name ); | 352 | mTodoListView = new KOTodoListView(calendar,this, name ); |
353 | topLayout->addWidget(mTodoListView); | 353 | topLayout->addWidget(mTodoListView); |
354 | //mTodoListView->header()->setMaximumHeight(30); | 354 | //mTodoListView->header()->setMaximumHeight(30); |
355 | mTodoListView->setRootIsDecorated(true); | 355 | mTodoListView->setRootIsDecorated(true); |
356 | mTodoListView->setAllColumnsShowFocus(true); | 356 | mTodoListView->setAllColumnsShowFocus(true); |
357 | 357 | ||
358 | mTodoListView->setShowSortIndicator(true); | 358 | mTodoListView->setShowSortIndicator(true); |
359 | 359 | ||
360 | mTodoListView->addColumn(i18n("Todo")); | 360 | mTodoListView->addColumn(i18n("Todo")); |
361 | mTodoListView->addColumn(i18n("Prio")); | 361 | mTodoListView->addColumn(i18n("Prio")); |
362 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 362 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
363 | mTodoListView->addColumn(i18n("Complete")); | 363 | mTodoListView->addColumn(i18n("Complete")); |
364 | mTodoListView->setColumnAlignment(2,AlignCenter); | 364 | mTodoListView->setColumnAlignment(2,AlignCenter); |
365 | 365 | ||
366 | mTodoListView->addColumn(i18n("Due Date")); | 366 | mTodoListView->addColumn(i18n("Due Date")); |
367 | mTodoListView->setColumnAlignment(3,AlignLeft); | 367 | mTodoListView->setColumnAlignment(3,AlignLeft); |
368 | mTodoListView->addColumn(i18n("Due Time")); | 368 | mTodoListView->addColumn(i18n("Due Time")); |
369 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 369 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
370 | 370 | ||
371 | mTodoListView->addColumn(i18n("Start Date")); | 371 | mTodoListView->addColumn(i18n("Start Date")); |
372 | mTodoListView->setColumnAlignment(5,AlignLeft); | 372 | mTodoListView->setColumnAlignment(5,AlignLeft); |
373 | mTodoListView->addColumn(i18n("Start Time")); | 373 | mTodoListView->addColumn(i18n("Start Time")); |
374 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 374 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
375 | 375 | ||
376 | mTodoListView->addColumn(i18n("Cancelled")); | 376 | mTodoListView->addColumn(i18n("Cancelled")); |
377 | mTodoListView->addColumn(i18n("Categories")); | 377 | mTodoListView->addColumn(i18n("Categories")); |
378 | #if 0 | 378 | #if 0 |
379 | mTodoListView->addColumn(i18n("Sort Id")); | 379 | mTodoListView->addColumn(i18n("Sort Id")); |
380 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 380 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
381 | #endif | 381 | #endif |
382 | 382 | ||
383 | mTodoListView->setMinimumHeight( 60 ); | 383 | mTodoListView->setMinimumHeight( 60 ); |
384 | mTodoListView->setItemsRenameable( true ); | 384 | mTodoListView->setItemsRenameable( true ); |
385 | mTodoListView->setRenameable( 0 ); | 385 | mTodoListView->setRenameable( 0 ); |
386 | mTodoListView->setColumnWidth( 0, 120 ); | 386 | mTodoListView->setColumnWidth( 0, 120 ); |
387 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 387 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
388 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 388 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
389 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 389 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
390 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 390 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
391 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 391 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
392 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 392 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
393 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 393 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
394 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 394 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
395 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 395 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
396 | 396 | ||
397 | 397 | ||
398 | mPriorityPopupMenu = new QPopupMenu(this); | 398 | mPriorityPopupMenu = new QPopupMenu(this); |
399 | for (int i = 1; i <= 5; i++) { | 399 | for (int i = 1; i <= 5; i++) { |
400 | QString label = QString ("%1").arg (i); | 400 | QString label = QString ("%1").arg (i); |
401 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 401 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
402 | } | 402 | } |
403 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 403 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
404 | 404 | ||
405 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 405 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
406 | for (int i = 0; i <= 100; i+=20) { | 406 | for (int i = 0; i <= 100; i+=20) { |
407 | QString label = QString ("%1 %").arg (i); | 407 | QString label = QString ("%1 %").arg (i); |
408 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 408 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
409 | } | 409 | } |
410 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 410 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
411 | 411 | ||
412 | 412 | ||
413 | 413 | ||
414 | mItemPopupMenu = new QPopupMenu(this); | 414 | mItemPopupMenu = new QPopupMenu(this); |
415 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 415 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
416 | SLOT (showTodo())); | 416 | SLOT (showTodo())); |
417 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 417 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
418 | SLOT (editTodo())); | 418 | SLOT (editTodo())); |
419 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 419 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
420 | SLOT (deleteTodo())); | 420 | SLOT (deleteTodo())); |
421 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 421 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
422 | SLOT (cloneTodo())); | 422 | SLOT (cloneTodo())); |
423 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 423 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
424 | SLOT (moveTodo())); | 424 | SLOT (moveTodo())); |
425 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 425 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
426 | SLOT (beamTodo())); | 426 | SLOT (beamTodo())); |
427 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 427 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
428 | SLOT (cancelTodo())); | 428 | SLOT (cancelTodo())); |
429 | mItemPopupMenu->insertSeparator(); | 429 | mItemPopupMenu->insertSeparator(); |
430 | 430 | ||
431 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 431 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
432 | SLOT (newTodo())); | 432 | SLOT (newTodo())); |
433 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 433 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
434 | SLOT (newSubTodo())); | 434 | SLOT (newSubTodo())); |
435 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 435 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
436 | SLOT (unparentTodo()),0,21); | 436 | SLOT (unparentTodo()),0,21); |
437 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 437 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
438 | SLOT (reparentTodo()),0,22); | 438 | SLOT (reparentTodo()),0,22); |
439 | mItemPopupMenu->insertSeparator(); | 439 | mItemPopupMenu->insertSeparator(); |
440 | #if 0 | 440 | #if 0 |
441 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 441 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
442 | this, SLOT( purgeCompleted() ) ); | 442 | this, SLOT( purgeCompleted() ) ); |
443 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 443 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
444 | this, SLOT( toggleCompleted() ),0, 33 ); | 444 | this, SLOT( toggleCompleted() ),0, 33 ); |
445 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 445 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
446 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 446 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
447 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 447 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
448 | this, SLOT( toggleRunning() ),0, 35 ); | 448 | this, SLOT( toggleRunning() ),0, 35 ); |
449 | 449 | ||
450 | #endif | 450 | #endif |
451 | mPopupMenu = new QPopupMenu(this); | 451 | mPopupMenu = new QPopupMenu(this); |
452 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 452 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
453 | SLOT (newTodo()),0,1); | 453 | SLOT (newTodo()),0,1); |
454 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 454 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
455 | this, SLOT(purgeCompleted()),0,2); | 455 | this, SLOT(purgeCompleted()),0,2); |
456 | mPopupMenu->insertItem(i18n("Show Completed"), | 456 | mPopupMenu->insertItem(i18n("Show Completed"), |
457 | this, SLOT( toggleCompleted() ),0,3 ); | 457 | this, SLOT( toggleCompleted() ),0,3 ); |
458 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 458 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
459 | this, SLOT( toggleQuickTodo() ),0,4 ); | 459 | this, SLOT( toggleQuickTodo() ),0,4 ); |
460 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 460 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
461 | this, SLOT( toggleRunning() ),0,5 ); | 461 | this, SLOT( toggleRunning() ),0,5 ); |
462 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 462 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
463 | this, SLOT( setAllOpen() ),0,6 ); | 463 | this, SLOT( setAllOpen() ),0,6 ); |
464 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 464 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
465 | this, SLOT( setAllClose() ),0,7 ); | 465 | this, SLOT( setAllClose() ),0,7 ); |
466 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 466 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
467 | this, SLOT( setAllFlat() ),0,8 ); | 467 | this, SLOT( setAllFlat() ),0,8 ); |
468 | mDocPrefs = new DocPrefs( name ); | 468 | mDocPrefs = new DocPrefs( name ); |
469 | 469 | ||
470 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 470 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
471 | mPopupMenu->setCheckable( true ); | 471 | mPopupMenu->setCheckable( true ); |
472 | mItemPopupMenu->setCheckable( true ); | 472 | mItemPopupMenu->setCheckable( true ); |
473 | 473 | ||
474 | 474 | ||
475 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 475 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
476 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 476 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
477 | 477 | ||
478 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 478 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
479 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 479 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
480 | 480 | ||
481 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 481 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
482 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 482 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
483 | 483 | ||
484 | 484 | ||
485 | // Double clicking conflicts with opening/closing the subtree | 485 | // Double clicking conflicts with opening/closing the subtree |
486 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 486 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
487 | SLOT( editItem( QListViewItem *) ) ); | 487 | SLOT( editItem( QListViewItem *) ) ); |
488 | /* | 488 | /* |
489 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 489 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
490 | const QPoint &,int ) ), | 490 | const QPoint &,int ) ), |
491 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 491 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
492 | */ | 492 | */ |
493 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 493 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
494 | const QPoint &,int ) ), | 494 | const QPoint &,int ) ), |
495 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 495 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
496 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 496 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
497 | SLOT( itemClicked( QListViewItem * ) ) ); | 497 | SLOT( itemClicked( QListViewItem * ) ) ); |
498 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 498 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
499 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 499 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
500 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 500 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
501 | SLOT( updateView() ) ); | 501 | SLOT( updateView() ) ); |
502 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 502 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
503 | SLOT( todoModified(Todo *, int) ) ); | 503 | SLOT( todoModified(Todo *, int) ) ); |
504 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 504 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
505 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 505 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
506 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 506 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
507 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 507 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
508 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 508 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
509 | SLOT( paintNeeded()) ); | 509 | SLOT( paintNeeded()) ); |
510 | 510 | ||
511 | #if 0 | 511 | #if 0 |
512 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 512 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
513 | SLOT(selectionChanged(QListViewItem *))); | 513 | SLOT(selectionChanged(QListViewItem *))); |
514 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 514 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
515 | SLOT(selectionChanged(QListViewItem *))); | 515 | SLOT(selectionChanged(QListViewItem *))); |
516 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 516 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
517 | SLOT(selectionChanged(QListViewItem *))); | 517 | SLOT(selectionChanged(QListViewItem *))); |
518 | #endif | 518 | #endif |
519 | 519 | ||
520 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 520 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
521 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 521 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
522 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 522 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
523 | 523 | ||
524 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 524 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
525 | SLOT( processSelectionChange() ) ); | 525 | SLOT( processSelectionChange() ) ); |
526 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 526 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
527 | SLOT( addQuickTodo() ) ); | 527 | SLOT( addQuickTodo() ) ); |
528 | 528 | ||
529 | } | 529 | } |
530 | 530 | ||
531 | KOTodoView::~KOTodoView() | 531 | KOTodoView::~KOTodoView() |
532 | { | 532 | { |
533 | delete mDocPrefs; | 533 | delete mDocPrefs; |
534 | } | 534 | } |
535 | 535 | ||
536 | void KOTodoView::jumpToDate () | 536 | void KOTodoView::jumpToDate () |
537 | { | 537 | { |
538 | // if (mActiveItem) { | 538 | // if (mActiveItem) { |
539 | // mActiveItem->todo()); | 539 | // mActiveItem->todo()); |
540 | // if ( mActiveItem->todo()->hasDueDate() ) | 540 | // if ( mActiveItem->todo()->hasDueDate() ) |
541 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 541 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
542 | } | 542 | } |
543 | void KOTodoView::paintNeeded() | 543 | void KOTodoView::paintNeeded() |
544 | { | 544 | { |
545 | if ( mPendingUpdateBeforeRepaint ) { | 545 | if ( mPendingUpdateBeforeRepaint ) { |
546 | updateView(); | 546 | updateView(); |
547 | mPendingUpdateBeforeRepaint = false; | 547 | mPendingUpdateBeforeRepaint = false; |
548 | } | 548 | } |
549 | } | 549 | } |
550 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 550 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
551 | { | 551 | { |
552 | if ( mPendingUpdateBeforeRepaint ) { | 552 | if ( mPendingUpdateBeforeRepaint ) { |
553 | updateView(); | 553 | updateView(); |
554 | mPendingUpdateBeforeRepaint = false; | 554 | mPendingUpdateBeforeRepaint = false; |
555 | } | 555 | } |
556 | KOrg::BaseView::paintEvent( pevent); | 556 | KOrg::BaseView::paintEvent( pevent); |
557 | } | 557 | } |
558 | 558 | ||
559 | void KOTodoView::updateView() | 559 | void KOTodoView::updateView() |
560 | { | 560 | { |
561 | pendingSubtodo = 0; | 561 | pendingSubtodo = 0; |
562 | if ( mBlockUpdate ) { | 562 | if ( mBlockUpdate ) { |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | if ( !isVisible() ) { | 565 | if ( !isVisible() ) { |
566 | mPendingUpdateBeforeRepaint = true; | 566 | mPendingUpdateBeforeRepaint = true; |
567 | return; | 567 | return; |
568 | } | 568 | } |
569 | //qDebug("KOTodoView::updateView() %x", this); | 569 | //qDebug("KOTodoView::updateView() %x", this); |
570 | if ( isFlatDisplay ) { | 570 | if ( isFlatDisplay ) { |
571 | setAllFlat(); | 571 | setAllFlat(); |
572 | return; | 572 | return; |
573 | } | 573 | } |
574 | //qDebug("update "); | 574 | //qDebug("update "); |
575 | // kdDebug() << "KOTodoView::updateView()" << endl; | 575 | // kdDebug() << "KOTodoView::updateView()" << endl; |
576 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 576 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
577 | mTodoListView->clear(); | 577 | mTodoListView->clear(); |
578 | if ( mName == "todolistsmall" ) { | 578 | if ( mName == "todolistsmall" ) { |
579 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 579 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
580 | int ps = fo.pointSize() -2; | 580 | int ps = fo.pointSize() -2; |
581 | if ( ps > 12 ) | 581 | if ( ps > 12 ) |
582 | ps -= 2; | 582 | ps -= 2; |
583 | fo.setPointSize( ps ); | 583 | fo.setPointSize( ps ); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | mTodoListView->setFont( fo ); | 587 | mTodoListView->setFont( fo ); |
588 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 588 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
589 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 589 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
590 | QPtrList<Todo> todoList = calendar()->todos(); | 590 | QPtrList<Todo> todoList = calendar()->todos(); |
591 | 591 | ||
592 | /* | 592 | /* |
593 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 593 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
594 | Event *t; | 594 | Event *t; |
595 | for(t = todoList.first(); t; t = todoList.next()) { | 595 | for(t = todoList.first(); t; t = todoList.next()) { |
596 | kdDebug() << " " << t->getSummary() << endl; | 596 | kdDebug() << " " << t->getSummary() << endl; |
597 | 597 | ||
598 | if (t->getRelatedTo()) { | 598 | if (t->getRelatedTo()) { |
599 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 599 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
600 | } | 600 | } |
601 | 601 | ||
602 | QPtrList<Event> l = t->getRelations(); | 602 | QPtrList<Event> l = t->getRelations(); |
603 | Event *c; | 603 | Event *c; |
604 | for(c=l.first();c;c=l.next()) { | 604 | for(c=l.first();c;c=l.next()) { |
605 | kdDebug() << " - relation: " << c->getSummary() << endl; | 605 | kdDebug() << " - relation: " << c->getSummary() << endl; |
606 | } | 606 | } |
607 | } | 607 | } |
608 | */ | 608 | */ |
609 | 609 | ||
610 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 610 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
611 | // specific order of events. That means that we have to generate parent items | 611 | // specific order of events. That means that we have to generate parent items |
612 | // recursively for proper hierarchical display of Todos. | 612 | // recursively for proper hierarchical display of Todos. |
613 | mTodoMap.clear(); | 613 | mTodoMap.clear(); |
614 | Todo *todo; | 614 | Todo *todo; |
615 | todo = todoList.first();// todo; todo = todoList.next()) { | 615 | todo = todoList.first();// todo; todo = todoList.next()) { |
616 | while ( todo ) { | 616 | while ( todo ) { |
617 | bool next = true; | 617 | bool next = true; |
618 | // qDebug("todo %s ", todo->summary().latin1()); | 618 | // qDebug("todo %s ", todo->summary().latin1()); |
619 | Incidence *incidence = todo->relatedTo(); | 619 | Incidence *incidence = todo->relatedTo(); |
620 | while ( incidence ) { | 620 | while ( incidence ) { |
621 | if ( incidence->type() == "Todo") { | 621 | if ( incidence->type() == "Todo") { |
622 | //qDebug("related %s ",incidence->summary().latin1() ); | 622 | //qDebug("related %s ",incidence->summary().latin1() ); |
623 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 623 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
624 | //qDebug("related not found "); | 624 | //qDebug("related not found "); |
625 | todoList.remove( ); | 625 | todoList.remove( ); |
626 | todo = todoList.current(); | 626 | todo = todoList.current(); |
627 | next = false; | 627 | next = false; |
628 | incidence = 0; | 628 | incidence = 0; |
629 | 629 | ||
630 | } else { | 630 | } else { |
631 | //qDebug("related found "); | 631 | //qDebug("related found "); |
632 | incidence = incidence->relatedTo(); | 632 | incidence = incidence->relatedTo(); |
633 | } | 633 | } |
634 | } else | 634 | } else |
635 | incidence = 0; | 635 | incidence = 0; |
636 | } | 636 | } |
637 | if ( next ) | 637 | if ( next ) |
638 | todo = todoList.next(); | 638 | todo = todoList.next(); |
639 | } | 639 | } |
640 | // qDebug("again .... "); | 640 | // qDebug("again .... "); |
641 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 641 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
642 | 642 | ||
643 | // qDebug("yytodo %s ", todo->summary().latin1()); | 643 | // qDebug("yytodo %s ", todo->summary().latin1()); |
644 | // } | 644 | // } |
645 | //qDebug("for "); | 645 | //qDebug("for "); |
646 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 646 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
647 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 647 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
648 | { | 648 | { |
649 | insertTodoItem(todo); | 649 | insertTodoItem(todo); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | //qDebug("for end "); | 652 | //qDebug("for end "); |
653 | // Restore opened/closed state | 653 | // Restore opened/closed state |
654 | mTodoListView->blockSignals( true ); | 654 | mTodoListView->blockSignals( true ); |
655 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 655 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
656 | mTodoListView->blockSignals( false ); | 656 | mTodoListView->blockSignals( false ); |
657 | mTodoListView->setFocus(); | 657 | mTodoListView->setFocus(); |
658 | processSelectionChange(); | 658 | processSelectionChange(); |
659 | } | 659 | } |
660 | 660 | ||
661 | bool KOTodoView::checkTodo( Todo * todo ) | 661 | bool KOTodoView::checkTodo( Todo * todo ) |
662 | { | 662 | { |
663 | 663 | ||
664 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 664 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
665 | return false; | 665 | return false; |
666 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 666 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
667 | if ( todo->hasStartDate() ) | 667 | if ( todo->hasStartDate() ) |
668 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 668 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
669 | return false; | 669 | return false; |
670 | if ( todo->hasDueDate() ) | 670 | if ( todo->hasDueDate() ) |
671 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 671 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
672 | return false; | 672 | return false; |
673 | } | 673 | } |
674 | return true; | 674 | return true; |
675 | } | 675 | } |
676 | 676 | ||
677 | void KOTodoView::restoreItemState( QListViewItem *item ) | 677 | void KOTodoView::restoreItemState( QListViewItem *item ) |
678 | { | 678 | { |
679 | pendingSubtodo = 0; | 679 | pendingSubtodo = 0; |
680 | while( item ) { | 680 | while( item ) { |
681 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 681 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
682 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 682 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
683 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 683 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
684 | item = item->nextSibling(); | 684 | item = item->nextSibling(); |
685 | } | 685 | } |
686 | } | 686 | } |
687 | 687 | ||
688 | 688 | ||
689 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 689 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
690 | KOTodoView::insertTodoItem(Todo *todo) | 690 | KOTodoView::insertTodoItem(Todo *todo) |
691 | { | 691 | { |
692 | 692 | ||
693 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 693 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
694 | // TODO: Check, if dynmaic cast is necessary | 694 | // TODO: Check, if dynmaic cast is necessary |
695 | 695 | ||
696 | pendingSubtodo = 0; | 696 | pendingSubtodo = 0; |
697 | Incidence *incidence = todo->relatedTo(); | 697 | Incidence *incidence = todo->relatedTo(); |
698 | if (incidence && incidence->type() == "Todo") { | 698 | if (incidence && incidence->type() == "Todo") { |
699 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 699 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
700 | 700 | ||
701 | // kdDebug() << " has Related" << endl; | 701 | // kdDebug() << " has Related" << endl; |
702 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 702 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
703 | itemIterator = mTodoMap.find(relatedTodo); | 703 | itemIterator = mTodoMap.find(relatedTodo); |
704 | if (itemIterator == mTodoMap.end()) { | 704 | if (itemIterator == mTodoMap.end()) { |
705 | // kdDebug() << " related not yet in list" << endl; | 705 | // kdDebug() << " related not yet in list" << endl; |
706 | itemIterator = insertTodoItem (relatedTodo); | 706 | itemIterator = insertTodoItem (relatedTodo); |
707 | } | 707 | } |
708 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 708 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
709 | // and one into the map. Sure finding is more easy but why? -zecke | 709 | // and one into the map. Sure finding is more easy but why? -zecke |
710 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 710 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
711 | return mTodoMap.insert(todo,todoItem); | 711 | return mTodoMap.insert(todo,todoItem); |
712 | } else { | 712 | } else { |
713 | // kdDebug() << " no Related" << endl; | 713 | // kdDebug() << " no Related" << endl; |
714 | // see above -zecke | 714 | // see above -zecke |
715 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 715 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
716 | return mTodoMap.insert(todo,todoItem); | 716 | return mTodoMap.insert(todo,todoItem); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | void KOTodoView::updateConfig() | 721 | void KOTodoView::updateConfig() |
722 | { | 722 | { |
723 | updateView(); | 723 | updateView(); |
724 | mTodoListView->repaintContents(); | 724 | mTodoListView->repaintContents(); |
725 | } | 725 | } |
726 | 726 | ||
727 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 727 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
728 | { | 728 | { |
729 | QPtrList<Incidence> selected; | 729 | QPtrList<Incidence> selected; |
730 | 730 | ||
731 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 731 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
732 | // if (!item) item = mActiveItem; | 732 | // if (!item) item = mActiveItem; |
733 | if (item) selected.append(item->todo()); | 733 | if (item) selected.append(item->todo()); |
734 | 734 | ||
735 | return selected; | 735 | return selected; |
736 | } | 736 | } |
737 | 737 | ||
738 | QPtrList<Todo> KOTodoView::selectedTodos() | 738 | QPtrList<Todo> KOTodoView::selectedTodos() |
739 | { | 739 | { |
740 | QPtrList<Todo> selected; | 740 | QPtrList<Todo> selected; |
741 | 741 | ||
742 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 742 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
743 | // if (!item) item = mActiveItem; | 743 | // if (!item) item = mActiveItem; |
744 | if (item) selected.append(item->todo()); | 744 | if (item) selected.append(item->todo()); |
745 | 745 | ||
746 | return selected; | 746 | return selected; |
747 | } | 747 | } |
748 | 748 | ||
749 | void KOTodoView::changeEventDisplay(Event *, int) | 749 | void KOTodoView::changeEventDisplay(Event *, int) |
750 | { | 750 | { |
751 | updateView(); | 751 | updateView(); |
752 | } | 752 | } |
753 | 753 | ||
754 | void KOTodoView::showDates(const QDate &, const QDate &) | 754 | void KOTodoView::showDates(const QDate &, const QDate &) |
755 | { | 755 | { |
756 | } | 756 | } |
757 | 757 | ||
758 | void KOTodoView::showEvents(QPtrList<Event>) | 758 | void KOTodoView::showEvents(QPtrList<Event>) |
759 | { | 759 | { |
760 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 760 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
761 | } | 761 | } |
762 | 762 | ||
763 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 763 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
764 | const QDate &td) | 764 | const QDate &td) |
765 | { | 765 | { |
766 | #ifndef KORG_NOPRINTER | 766 | #ifndef KORG_NOPRINTER |
767 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 767 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
768 | #endif | 768 | #endif |
769 | } | 769 | } |
770 | 770 | ||
771 | void KOTodoView::editItem(QListViewItem *item ) | 771 | void KOTodoView::editItem(QListViewItem *item ) |
772 | { | 772 | { |
773 | // qDebug("editItem(QListViewItem *item ) "); | 773 | // qDebug("editItem(QListViewItem *item ) "); |
774 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 774 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
775 | } | 775 | } |
776 | 776 | ||
777 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 777 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
778 | { | 778 | { |
779 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 779 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
780 | } | 780 | } |
781 | 781 | ||
782 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 782 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
783 | { | 783 | { |
784 | pendingSubtodo = 0; | 784 | pendingSubtodo = 0; |
785 | mActiveItem = (KOTodoViewItem *)item; | 785 | mActiveItem = (KOTodoViewItem *)item; |
786 | if (item) { | 786 | if (item) { |
787 | switch (column){ | 787 | switch (column){ |
788 | case 1: | 788 | case 1: |
789 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 789 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
790 | case 2: | 790 | case 2: |
791 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 791 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
792 | case 3: | 792 | case 3: |
793 | moveTodo(); | 793 | moveTodo(); |
794 | break; | 794 | break; |
795 | case 8: | 795 | case 8: |
796 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 796 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
797 | default: | 797 | default: |
798 | mItemPopupMenu->popup(QCursor::pos()); | 798 | mItemPopupMenu->popup(QCursor::pos()); |
799 | } | 799 | } |
800 | } else mPopupMenu->popup(QCursor::pos()); | 800 | } else mPopupMenu->popup(QCursor::pos()); |
801 | } | 801 | } |
802 | void KOTodoView::newTodo() | 802 | void KOTodoView::newTodo() |
803 | { | 803 | { |
804 | emit newTodoSignal(); | 804 | emit newTodoSignal(); |
805 | } | 805 | } |
806 | 806 | ||
807 | void KOTodoView::newSubTodo() | 807 | void KOTodoView::newSubTodo() |
808 | { | 808 | { |
809 | if (mActiveItem) { | 809 | if (mActiveItem) { |
810 | emit newSubTodoSignal(mActiveItem->todo()); | 810 | emit newSubTodoSignal(mActiveItem->todo()); |
811 | } | 811 | } |
812 | } | 812 | } |
813 | void KOTodoView::unparentTodo() | 813 | void KOTodoView::unparentTodo() |
814 | { | 814 | { |
815 | if (mActiveItem) { | 815 | if (mActiveItem) { |
816 | emit unparentTodoSignal(mActiveItem->todo()); | 816 | emit unparentTodoSignal(mActiveItem->todo()); |
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
820 | void KOTodoView::reparentTodo() | 820 | void KOTodoView::reparentTodo() |
821 | { | 821 | { |
822 | if (mActiveItem) { | 822 | if (mActiveItem) { |
823 | qDebug("KOTodoView::reparentTodo() "); | 823 | qDebug("KOTodoView::reparentTodo() "); |
824 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 824 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
825 | pendingSubtodo = mActiveItem; | 825 | pendingSubtodo = mActiveItem; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | void KOTodoView::editTodo() | 828 | void KOTodoView::editTodo() |
829 | { | 829 | { |
830 | if (mActiveItem) { | 830 | if (mActiveItem) { |
831 | emit editTodoSignal(mActiveItem->todo()); | 831 | emit editTodoSignal(mActiveItem->todo()); |
832 | } | 832 | } |
833 | } | 833 | } |
834 | void KOTodoView::cloneTodo() | 834 | void KOTodoView::cloneTodo() |
835 | { | 835 | { |
836 | if (mActiveItem) { | 836 | if (mActiveItem) { |
837 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 837 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | void KOTodoView::cancelTodo() | 840 | void KOTodoView::cancelTodo() |
841 | { | 841 | { |
842 | if (mActiveItem) { | 842 | if (mActiveItem) { |
843 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 843 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | void KOTodoView::moveTodo() | 846 | void KOTodoView::moveTodo() |
847 | { | 847 | { |
848 | if (mActiveItem) { | 848 | if (mActiveItem) { |
849 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 849 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | void KOTodoView::beamTodo() | 852 | void KOTodoView::beamTodo() |
853 | { | 853 | { |
854 | if (mActiveItem) { | 854 | if (mActiveItem) { |
855 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 855 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
856 | } | 856 | } |
857 | } | 857 | } |
858 | 858 | ||
859 | 859 | ||
860 | void KOTodoView::showTodo() | 860 | void KOTodoView::showTodo() |
861 | { | 861 | { |
862 | if (mActiveItem) { | 862 | if (mActiveItem) { |
863 | emit showTodoSignal(mActiveItem->todo()); | 863 | emit showTodoSignal(mActiveItem->todo()); |
864 | } | 864 | } |
865 | } | 865 | } |
866 | 866 | ||
867 | void KOTodoView::deleteTodo() | 867 | void KOTodoView::deleteTodo() |
868 | { | 868 | { |
869 | if (mActiveItem) { | 869 | if (mActiveItem) { |
870 | emit deleteTodoSignal(mActiveItem->todo()); | 870 | emit deleteTodoSignal(mActiveItem->todo()); |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void KOTodoView::setNewPriority(int index) | 874 | void KOTodoView::setNewPriority(int index) |
875 | { | 875 | { |
876 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 876 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
877 | mActiveItem->todo()->setPriority(mPriority[index]); | 877 | mActiveItem->todo()->setPriority(mPriority[index]); |
878 | mActiveItem->construct(); | 878 | mActiveItem->construct(); |
879 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 879 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
880 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 880 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
881 | } | 881 | } |
882 | } | 882 | } |
883 | 883 | ||
884 | void KOTodoView::setNewPercentage(int index) | 884 | void KOTodoView::setNewPercentage(int index) |
885 | { | 885 | { |
886 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 886 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
887 | 887 | ||
888 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 888 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
889 | mActiveItem->setOn( true ); | 889 | mActiveItem->setOn( true ); |
890 | return; | 890 | return; |
891 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 891 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
892 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 892 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
893 | if ( par && par->isOn() ) | 893 | if ( par && par->isOn() ) |
894 | par->setOn( false ); | 894 | par->setOn( false ); |
895 | } | 895 | } |
896 | if (mPercentage[index] == 100) { | 896 | if (mPercentage[index] == 100) { |
897 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 897 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
898 | } else { | 898 | } else { |
899 | mActiveItem->todo()->setCompleted(false); | 899 | mActiveItem->todo()->setCompleted(false); |
900 | } | 900 | } |
901 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 901 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
902 | mActiveItem->construct(); | 902 | mActiveItem->construct(); |
903 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 903 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
904 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 904 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
905 | } | 905 | } |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 909 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
910 | { | 910 | { |
911 | QPopupMenu* tempMenu = new QPopupMenu (this); | 911 | QPopupMenu* tempMenu = new QPopupMenu (this); |
912 | QStringList checkedCategories = todoItem->todo()->categories (); | 912 | QStringList checkedCategories = todoItem->todo()->categories (); |
913 | 913 | ||
914 | tempMenu->setCheckable (true); | 914 | tempMenu->setCheckable (true); |
915 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 915 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
916 | it != KOPrefs::instance()->mCustomCategories.end (); | 916 | it != KOPrefs::instance()->mCustomCategories.end (); |
917 | ++it) { | 917 | ++it) { |
918 | int index = tempMenu->insertItem (*it); | 918 | int index = tempMenu->insertItem (*it); |
919 | mCategory[index] = *it; | 919 | mCategory[index] = *it; |
920 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 920 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
921 | } | 921 | } |
922 | 922 | ||
923 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 923 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
924 | return tempMenu; | 924 | return tempMenu; |
925 | 925 | ||
926 | 926 | ||
927 | } | 927 | } |
928 | void KOTodoView::changedCategories(int index) | 928 | void KOTodoView::changedCategories(int index) |
929 | { | 929 | { |
930 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 930 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
931 | QStringList categories = mActiveItem->todo()->categories (); | 931 | QStringList categories = mActiveItem->todo()->categories (); |
932 | if (categories.find (mCategory[index]) != categories.end ()) | 932 | if (categories.find (mCategory[index]) != categories.end ()) |
933 | categories.remove (mCategory[index]); | 933 | categories.remove (mCategory[index]); |
934 | else | 934 | else |
935 | categories.insert (categories.end(), mCategory[index]); | 935 | categories.insert (categories.end(), mCategory[index]); |
936 | categories.sort (); | 936 | categories.sort (); |
937 | mActiveItem->todo()->setCategories (categories); | 937 | mActiveItem->todo()->setCategories (categories); |
938 | mActiveItem->construct(); | 938 | mActiveItem->construct(); |
939 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 939 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
940 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 940 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
941 | } | 941 | } |
942 | } | 942 | } |
943 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 943 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
944 | { | 944 | { |
945 | if ( pendingSubtodo != 0 ) { | 945 | if ( pendingSubtodo != 0 ) { |
946 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 946 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
947 | } | 947 | } |
948 | pendingSubtodo = 0; | 948 | pendingSubtodo = 0; |
949 | if (!item) { | 949 | if (!item) { |
950 | newTodo(); | 950 | newTodo(); |
951 | return; | 951 | return; |
952 | } | 952 | } |
953 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 953 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
954 | editItem( item ); | 954 | editItem( item ); |
955 | else | 955 | else |
956 | showItem( item , QPoint(), 0 ); | 956 | showItem( item , QPoint(), 0 ); |
957 | } | 957 | } |
958 | void KOTodoView::itemClicked(QListViewItem *item) | 958 | void KOTodoView::itemClicked(QListViewItem *item) |
959 | { | 959 | { |
960 | 960 | ||
961 | if (!item) { | 961 | if (!item) { |
962 | if ( pendingSubtodo != 0 ) { | 962 | if ( pendingSubtodo != 0 ) { |
963 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 963 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
964 | } | 964 | } |
965 | pendingSubtodo = 0; | 965 | pendingSubtodo = 0; |
966 | return; | 966 | return; |
967 | } | 967 | } |
968 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 968 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
969 | if ( pendingSubtodo != 0 ) { | 969 | if ( pendingSubtodo != 0 ) { |
970 | bool allowReparent = true; | 970 | bool allowReparent = true; |
971 | QListViewItem *par = item; | 971 | QListViewItem *par = item; |
972 | while ( par ) { | 972 | while ( par ) { |
973 | if ( par == pendingSubtodo ) { | 973 | if ( par == pendingSubtodo ) { |
974 | allowReparent = false; | 974 | allowReparent = false; |
975 | break; | 975 | break; |
976 | } | 976 | } |
977 | par = par->parent(); | 977 | par = par->parent(); |
978 | } | 978 | } |
979 | if ( !allowReparent ) { | 979 | if ( !allowReparent ) { |
980 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 980 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
981 | qDebug("Recursive reparenting not possible "); | 981 | qDebug("Recursive reparenting not possible "); |
982 | pendingSubtodo = 0; | 982 | pendingSubtodo = 0; |
983 | } else { | 983 | } else { |
984 | Todo* newParent = todoItem->todo(); | 984 | Todo* newParent = todoItem->todo(); |
985 | Todo* newSub = pendingSubtodo->todo(); | 985 | Todo* newSub = pendingSubtodo->todo(); |
986 | pendingSubtodo = 0; | 986 | pendingSubtodo = 0; |
987 | emit reparentTodoSignal( newParent,newSub ); | 987 | emit reparentTodoSignal( newParent,newSub ); |
988 | return; | 988 | return; |
989 | } | 989 | } |
990 | } | 990 | } |
991 | #if 0 | 991 | #if 0 |
992 | // handled by the item itself | 992 | // handled by the item itself |
993 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? | 993 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? |
994 | qDebug("com %d ",completed ); | 994 | qDebug("com %d ",completed ); |
995 | qDebug("itemclicked "); | 995 | qDebug("itemclicked "); |
996 | if (todoItem->isOn()) { | 996 | if (todoItem->isOn()) { |
997 | qDebug("on "); | 997 | qDebug("on "); |
998 | if (!completed) { | 998 | if (!completed) { |
999 | qDebug("set true "); | 999 | qDebug("set true "); |
1000 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1000 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1001 | } | 1001 | } |
1002 | } else { | 1002 | } else { |
1003 | qDebug("not on "); | 1003 | qDebug("not on "); |
1004 | if (completed) { | 1004 | if (completed) { |
1005 | qDebug("set false "); | 1005 | qDebug("set false "); |
1006 | todoItem->todo()->setCompleted(false); | 1006 | todoItem->todo()->setCompleted(false); |
1007 | } | 1007 | } |
1008 | } | 1008 | } |
1009 | #endif | 1009 | #endif |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void KOTodoView::setDocumentId( const QString &id ) | 1012 | void KOTodoView::setDocumentId( const QString &id ) |
1013 | { | 1013 | { |
1014 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 1014 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |