author | zautrix <zautrix> | 2005-01-30 15:49:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-30 15:49:34 (UTC) |
commit | a34c528fdd8d2cdec14bae9ccb0eee54c8e4e374 (patch) (unidiff) | |
tree | 21a900be618695f6dac42b5e9df6094201a981d0 | |
parent | 11736af9b5348f251b0e8a3cf90fdb960c877936 (diff) | |
download | kdepimpi-a34c528fdd8d2cdec14bae9ccb0eee54c8e4e374.zip kdepimpi-a34c528fdd8d2cdec14bae9ccb0eee54c8e4e374.tar.gz kdepimpi-a34c528fdd8d2cdec14bae9ccb0eee54c8e4e374.tar.bz2 |
fix
-rw-r--r-- | korganizer/kotodoview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 902f3f4..2f5259f 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,770 +1,770 @@ | |||
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 | 212 | ||
213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
214 | { | 214 | { |
215 | 215 | ||
216 | #ifndef KORG_NODND | 216 | #ifndef KORG_NODND |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | DndFactory factory( mCalendar ); | 223 | DndFactory factory( mCalendar ); |
224 | ICalDrag *vd = factory.createDrag( | 224 | ICalDrag *vd = factory.createDrag( |
225 | ((KOTodoViewItem *)item)->todo(),viewport()); | 225 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | internalDrop = false; | 226 | internalDrop = false; |
227 | // we cannot do any senseful here, because the DnD is still broken in Qt | 227 | // we cannot do any senseful here, because the DnD is still broken in Qt |
228 | if (vd->drag()) { | 228 | if (vd->drag()) { |
229 | if ( !internalDrop ) { | 229 | if ( !internalDrop ) { |
230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
231 | qDebug("Dnd: External move: Delete drag source "); | 231 | qDebug("Dnd: External move: Delete drag source "); |
232 | } else | 232 | } else |
233 | qDebug("Dnd: Internal move "); | 233 | qDebug("Dnd: Internal move "); |
234 | 234 | ||
235 | } else { | 235 | } else { |
236 | if ( !internalDrop ) { | 236 | if ( !internalDrop ) { |
237 | qDebug("Dnd: External Copy"); | 237 | qDebug("Dnd: External Copy"); |
238 | } else | 238 | } else |
239 | qDebug("DnD: Internal copy: Copy pending"); | 239 | qDebug("DnD: Internal copy: Copy pending"); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | #endif | 243 | #endif |
244 | } | 244 | } |
245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
246 | { | 246 | { |
247 | 247 | ||
248 | QListViewItem* cn; | 248 | QListViewItem* cn; |
249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
250 | cn = currentItem(); | 250 | cn = currentItem(); |
251 | if ( cn ) { | 251 | if ( cn ) { |
252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
253 | if ( ci ){ | 253 | if ( ci ){ |
254 | if ( e->state() == ShiftButton ) | 254 | if ( e->state() == ShiftButton ) |
255 | ci->setOn( false ); | 255 | ci->setOn( false ); |
256 | else | 256 | else |
257 | ci->setOn( true ); | 257 | ci->setOn( true ); |
258 | cn = cn->nextSibling(); | 258 | cn = cn->itemBelow(); |
259 | if ( cn ) { | 259 | if ( cn ) { |
260 | setCurrentItem ( cn ); | 260 | setCurrentItem ( cn ); |
261 | ensureItemVisible ( cn ); | 261 | ensureItemVisible ( cn ); |
262 | } | 262 | } |
263 | 263 | ||
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | 269 | ||
270 | // qDebug("KOTodoListView::keyPressEvent "); | 270 | // qDebug("KOTodoListView::keyPressEvent "); |
271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
272 | switch ( e->key() ) { | 272 | switch ( e->key() ) { |
273 | case Qt::Key_Down: | 273 | case Qt::Key_Down: |
274 | case Qt::Key_Up: | 274 | case Qt::Key_Up: |
275 | QListView::keyPressEvent ( e ); | 275 | QListView::keyPressEvent ( e ); |
276 | break; | 276 | break; |
277 | case Qt::Key_Left: | 277 | case Qt::Key_Left: |
278 | case Qt::Key_Right: | 278 | case Qt::Key_Right: |
279 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
280 | e->accept(); | 280 | e->accept(); |
281 | return; | 281 | return; |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | e->ignore(); | 284 | e->ignore(); |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | e->ignore(); | 289 | e->ignore(); |
290 | } | 290 | } |
291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
292 | { | 292 | { |
293 | QListView::contentsMouseReleaseEvent(e); | 293 | QListView::contentsMouseReleaseEvent(e); |
294 | mMousePressed = false; | 294 | mMousePressed = false; |
295 | } | 295 | } |
296 | 296 | ||
297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
298 | { | 298 | { |
299 | if (!e) return; | 299 | if (!e) return; |
300 | 300 | ||
301 | QPoint vp = contentsToViewport(e->pos()); | 301 | QPoint vp = contentsToViewport(e->pos()); |
302 | 302 | ||
303 | QListViewItem *item = itemAt(vp); | 303 | QListViewItem *item = itemAt(vp); |
304 | 304 | ||
305 | emit double_Clicked(item); | 305 | emit double_Clicked(item); |
306 | if (!item) return; | 306 | if (!item) return; |
307 | 307 | ||
308 | emit doubleClicked(item,vp,0); | 308 | emit doubleClicked(item,vp,0); |
309 | } | 309 | } |
310 | 310 | ||
311 | ///////////////////////////////////////////////////////////////////////////// | 311 | ///////////////////////////////////////////////////////////////////////////// |
312 | 312 | ||
313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
314 | QLineEdit(parent) | 314 | QLineEdit(parent) |
315 | { | 315 | { |
316 | setText(i18n("Click to add a new Todo")); | 316 | setText(i18n("Click to add a new Todo")); |
317 | } | 317 | } |
318 | 318 | ||
319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
320 | { | 320 | { |
321 | if ( text()==i18n("Click to add a new Todo") ) | 321 | if ( text()==i18n("Click to add a new Todo") ) |
322 | setText(""); | 322 | setText(""); |
323 | QLineEdit::focusInEvent(ev); | 323 | QLineEdit::focusInEvent(ev); |
324 | } | 324 | } |
325 | 325 | ||
326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
327 | { | 327 | { |
328 | setText(i18n("Click to add a new Todo")); | 328 | setText(i18n("Click to add a new Todo")); |
329 | QLineEdit::focusOutEvent(ev); | 329 | QLineEdit::focusOutEvent(ev); |
330 | } | 330 | } |
331 | 331 | ||
332 | ///////////////////////////////////////////////////////////////////////////// | 332 | ///////////////////////////////////////////////////////////////////////////// |
333 | 333 | ||
334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
335 | KOrg::BaseView(calendar,parent,name) | 335 | KOrg::BaseView(calendar,parent,name) |
336 | { | 336 | { |
337 | isFlatDisplay = false; | 337 | isFlatDisplay = false; |
338 | mNavigator = 0; | 338 | mNavigator = 0; |
339 | QBoxLayout *topLayout = new QVBoxLayout(this); | 339 | QBoxLayout *topLayout = new QVBoxLayout(this); |
340 | mName = QString ( name ); | 340 | mName = QString ( name ); |
341 | mBlockUpdate = false; | 341 | mBlockUpdate = false; |
342 | mQuickAdd = new KOQuickTodo(this); | 342 | mQuickAdd = new KOQuickTodo(this); |
343 | topLayout->addWidget(mQuickAdd); | 343 | topLayout->addWidget(mQuickAdd); |
344 | 344 | ||
345 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 345 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
346 | 346 | ||
347 | mTodoListView = new KOTodoListView(calendar,this, name ); | 347 | mTodoListView = new KOTodoListView(calendar,this, name ); |
348 | topLayout->addWidget(mTodoListView); | 348 | topLayout->addWidget(mTodoListView); |
349 | //mTodoListView->header()->setMaximumHeight(30); | 349 | //mTodoListView->header()->setMaximumHeight(30); |
350 | mTodoListView->setRootIsDecorated(true); | 350 | mTodoListView->setRootIsDecorated(true); |
351 | mTodoListView->setAllColumnsShowFocus(true); | 351 | mTodoListView->setAllColumnsShowFocus(true); |
352 | 352 | ||
353 | mTodoListView->setShowSortIndicator(true); | 353 | mTodoListView->setShowSortIndicator(true); |
354 | 354 | ||
355 | mTodoListView->addColumn(i18n("Todo")); | 355 | mTodoListView->addColumn(i18n("Todo")); |
356 | mTodoListView->addColumn(i18n("Prio")); | 356 | mTodoListView->addColumn(i18n("Prio")); |
357 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 357 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
358 | mTodoListView->addColumn(i18n("Complete")); | 358 | mTodoListView->addColumn(i18n("Complete")); |
359 | mTodoListView->setColumnAlignment(2,AlignCenter); | 359 | mTodoListView->setColumnAlignment(2,AlignCenter); |
360 | 360 | ||
361 | mTodoListView->addColumn(i18n("Due Date")); | 361 | mTodoListView->addColumn(i18n("Due Date")); |
362 | mTodoListView->setColumnAlignment(3,AlignLeft); | 362 | mTodoListView->setColumnAlignment(3,AlignLeft); |
363 | mTodoListView->addColumn(i18n("Due Time")); | 363 | mTodoListView->addColumn(i18n("Due Time")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | 365 | ||
366 | mTodoListView->addColumn(i18n("Start Date")); | 366 | mTodoListView->addColumn(i18n("Start Date")); |
367 | mTodoListView->setColumnAlignment(5,AlignLeft); | 367 | mTodoListView->setColumnAlignment(5,AlignLeft); |
368 | mTodoListView->addColumn(i18n("Start Time")); | 368 | mTodoListView->addColumn(i18n("Start Time")); |
369 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 369 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
370 | 370 | ||
371 | mTodoListView->addColumn(i18n("Cancelled")); | 371 | mTodoListView->addColumn(i18n("Cancelled")); |
372 | mTodoListView->addColumn(i18n("Categories")); | 372 | mTodoListView->addColumn(i18n("Categories")); |
373 | #if 0 | 373 | #if 0 |
374 | mTodoListView->addColumn(i18n("Sort Id")); | 374 | mTodoListView->addColumn(i18n("Sort Id")); |
375 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 375 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
376 | #endif | 376 | #endif |
377 | 377 | ||
378 | mTodoListView->setMinimumHeight( 60 ); | 378 | mTodoListView->setMinimumHeight( 60 ); |
379 | mTodoListView->setItemsRenameable( true ); | 379 | mTodoListView->setItemsRenameable( true ); |
380 | mTodoListView->setRenameable( 0 ); | 380 | mTodoListView->setRenameable( 0 ); |
381 | mTodoListView->setColumnWidth( 0, 120 ); | 381 | mTodoListView->setColumnWidth( 0, 120 ); |
382 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 382 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
383 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 383 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
384 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 384 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
385 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 385 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
386 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 386 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
387 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 387 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
388 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 388 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
389 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 389 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
390 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 390 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
391 | 391 | ||
392 | 392 | ||
393 | mPriorityPopupMenu = new QPopupMenu(this); | 393 | mPriorityPopupMenu = new QPopupMenu(this); |
394 | for (int i = 1; i <= 5; i++) { | 394 | for (int i = 1; i <= 5; i++) { |
395 | QString label = QString ("%1").arg (i); | 395 | QString label = QString ("%1").arg (i); |
396 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 396 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
397 | } | 397 | } |
398 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 398 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
399 | 399 | ||
400 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 400 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
401 | for (int i = 0; i <= 100; i+=20) { | 401 | for (int i = 0; i <= 100; i+=20) { |
402 | QString label = QString ("%1 %").arg (i); | 402 | QString label = QString ("%1 %").arg (i); |
403 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 403 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
404 | } | 404 | } |
405 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 405 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
406 | 406 | ||
407 | 407 | ||
408 | 408 | ||
409 | mItemPopupMenu = new QPopupMenu(this); | 409 | mItemPopupMenu = new QPopupMenu(this); |
410 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 410 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
411 | SLOT (showTodo())); | 411 | SLOT (showTodo())); |
412 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 412 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
413 | SLOT (editTodo())); | 413 | SLOT (editTodo())); |
414 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 414 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
415 | SLOT (deleteTodo())); | 415 | SLOT (deleteTodo())); |
416 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 416 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
417 | SLOT (cloneTodo())); | 417 | SLOT (cloneTodo())); |
418 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 418 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
419 | SLOT (moveTodo())); | 419 | SLOT (moveTodo())); |
420 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 420 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
421 | SLOT (beamTodo())); | 421 | SLOT (beamTodo())); |
422 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 422 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
423 | SLOT (cancelTodo())); | 423 | SLOT (cancelTodo())); |
424 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
425 | 425 | ||
426 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 426 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
427 | SLOT (newTodo())); | 427 | SLOT (newTodo())); |
428 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 428 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
429 | SLOT (newSubTodo())); | 429 | SLOT (newSubTodo())); |
430 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 430 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
431 | SLOT (unparentTodo()),0,21); | 431 | SLOT (unparentTodo()),0,21); |
432 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 432 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
433 | SLOT (reparentTodo()),0,22); | 433 | SLOT (reparentTodo()),0,22); |
434 | mItemPopupMenu->insertSeparator(); | 434 | mItemPopupMenu->insertSeparator(); |
435 | #if 0 | 435 | #if 0 |
436 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 436 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
437 | this, SLOT( purgeCompleted() ) ); | 437 | this, SLOT( purgeCompleted() ) ); |
438 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 438 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
439 | this, SLOT( toggleCompleted() ),0, 33 ); | 439 | this, SLOT( toggleCompleted() ),0, 33 ); |
440 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 440 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
441 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 441 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
442 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 442 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
443 | this, SLOT( toggleRunning() ),0, 35 ); | 443 | this, SLOT( toggleRunning() ),0, 35 ); |
444 | 444 | ||
445 | #endif | 445 | #endif |
446 | mPopupMenu = new QPopupMenu(this); | 446 | mPopupMenu = new QPopupMenu(this); |
447 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 447 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
448 | SLOT (newTodo()),0,1); | 448 | SLOT (newTodo()),0,1); |
449 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 449 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
450 | this, SLOT(purgeCompleted()),0,2); | 450 | this, SLOT(purgeCompleted()),0,2); |
451 | mPopupMenu->insertItem(i18n("Show Completed"), | 451 | mPopupMenu->insertItem(i18n("Show Completed"), |
452 | this, SLOT( toggleCompleted() ),0,3 ); | 452 | this, SLOT( toggleCompleted() ),0,3 ); |
453 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 453 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
454 | this, SLOT( toggleQuickTodo() ),0,4 ); | 454 | this, SLOT( toggleQuickTodo() ),0,4 ); |
455 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 455 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
456 | this, SLOT( toggleRunning() ),0,5 ); | 456 | this, SLOT( toggleRunning() ),0,5 ); |
457 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 457 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
458 | this, SLOT( setAllOpen() ),0,6 ); | 458 | this, SLOT( setAllOpen() ),0,6 ); |
459 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 459 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
460 | this, SLOT( setAllClose() ),0,7 ); | 460 | this, SLOT( setAllClose() ),0,7 ); |
461 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 461 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
462 | this, SLOT( setAllFlat() ),0,8 ); | 462 | this, SLOT( setAllFlat() ),0,8 ); |
463 | mDocPrefs = new DocPrefs( name ); | 463 | mDocPrefs = new DocPrefs( name ); |
464 | 464 | ||
465 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 465 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
466 | mPopupMenu->setCheckable( true ); | 466 | mPopupMenu->setCheckable( true ); |
467 | mItemPopupMenu->setCheckable( true ); | 467 | mItemPopupMenu->setCheckable( true ); |
468 | 468 | ||
469 | 469 | ||
470 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 470 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
471 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 471 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
472 | 472 | ||
473 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 473 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
474 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 474 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
475 | 475 | ||
476 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 476 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
477 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 477 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
478 | 478 | ||
479 | 479 | ||
480 | // Double clicking conflicts with opening/closing the subtree | 480 | // Double clicking conflicts with opening/closing the subtree |
481 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 481 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
482 | SLOT( editItem( QListViewItem *) ) ); | 482 | SLOT( editItem( QListViewItem *) ) ); |
483 | /* | 483 | /* |
484 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 484 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
485 | const QPoint &,int ) ), | 485 | const QPoint &,int ) ), |
486 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 486 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
487 | */ | 487 | */ |
488 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 488 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
489 | const QPoint &,int ) ), | 489 | const QPoint &,int ) ), |
490 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 490 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
491 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 491 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
492 | SLOT( itemClicked( QListViewItem * ) ) ); | 492 | SLOT( itemClicked( QListViewItem * ) ) ); |
493 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 493 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
494 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 494 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
495 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 495 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
496 | SLOT( updateView() ) ); | 496 | SLOT( updateView() ) ); |
497 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 497 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
498 | SLOT( todoModified(Todo *, int) ) ); | 498 | SLOT( todoModified(Todo *, int) ) ); |
499 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 499 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
500 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 500 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
501 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 501 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
502 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 502 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
503 | 503 | ||
504 | #if 0 | 504 | #if 0 |
505 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 505 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
506 | SLOT(selectionChanged(QListViewItem *))); | 506 | SLOT(selectionChanged(QListViewItem *))); |
507 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 507 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
508 | SLOT(selectionChanged(QListViewItem *))); | 508 | SLOT(selectionChanged(QListViewItem *))); |
509 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 509 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
510 | SLOT(selectionChanged(QListViewItem *))); | 510 | SLOT(selectionChanged(QListViewItem *))); |
511 | #endif | 511 | #endif |
512 | 512 | ||
513 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 513 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
514 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 514 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
515 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 515 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
516 | 516 | ||
517 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 517 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
518 | SLOT( processSelectionChange() ) ); | 518 | SLOT( processSelectionChange() ) ); |
519 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 519 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
520 | SLOT( addQuickTodo() ) ); | 520 | SLOT( addQuickTodo() ) ); |
521 | 521 | ||
522 | } | 522 | } |
523 | 523 | ||
524 | KOTodoView::~KOTodoView() | 524 | KOTodoView::~KOTodoView() |
525 | { | 525 | { |
526 | delete mDocPrefs; | 526 | delete mDocPrefs; |
527 | } | 527 | } |
528 | 528 | ||
529 | void KOTodoView::jumpToDate () | 529 | void KOTodoView::jumpToDate () |
530 | { | 530 | { |
531 | // if (mActiveItem) { | 531 | // if (mActiveItem) { |
532 | // mActiveItem->todo()); | 532 | // mActiveItem->todo()); |
533 | // if ( mActiveItem->todo()->hasDueDate() ) | 533 | // if ( mActiveItem->todo()->hasDueDate() ) |
534 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 534 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
535 | } | 535 | } |
536 | 536 | ||
537 | void KOTodoView::updateView() | 537 | void KOTodoView::updateView() |
538 | { | 538 | { |
539 | pendingSubtodo = 0; | 539 | pendingSubtodo = 0; |
540 | if ( mBlockUpdate ) { | 540 | if ( mBlockUpdate ) { |
541 | //qDebug("blocked "); | 541 | //qDebug("blocked "); |
542 | return; | 542 | return; |
543 | } | 543 | } |
544 | if ( isFlatDisplay ) { | 544 | if ( isFlatDisplay ) { |
545 | setAllFlat(); | 545 | setAllFlat(); |
546 | return; | 546 | return; |
547 | } | 547 | } |
548 | //qDebug("update "); | 548 | //qDebug("update "); |
549 | // kdDebug() << "KOTodoView::updateView()" << endl; | 549 | // kdDebug() << "KOTodoView::updateView()" << endl; |
550 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 550 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
551 | mTodoListView->clear(); | 551 | mTodoListView->clear(); |
552 | if ( mName == "todolistsmall" ) { | 552 | if ( mName == "todolistsmall" ) { |
553 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 553 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
554 | int ps = fo.pointSize() -2; | 554 | int ps = fo.pointSize() -2; |
555 | if ( ps > 12 ) | 555 | if ( ps > 12 ) |
556 | ps -= 2; | 556 | ps -= 2; |
557 | fo.setPointSize( ps ); | 557 | fo.setPointSize( ps ); |
558 | } | 558 | } |
559 | } | 559 | } |
560 | 560 | ||
561 | mTodoListView->setFont( fo ); | 561 | mTodoListView->setFont( fo ); |
562 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 562 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
563 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 563 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
564 | QPtrList<Todo> todoList = calendar()->todos(); | 564 | QPtrList<Todo> todoList = calendar()->todos(); |
565 | 565 | ||
566 | /* | 566 | /* |
567 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 567 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
568 | Event *t; | 568 | Event *t; |
569 | for(t = todoList.first(); t; t = todoList.next()) { | 569 | for(t = todoList.first(); t; t = todoList.next()) { |
570 | kdDebug() << " " << t->getSummary() << endl; | 570 | kdDebug() << " " << t->getSummary() << endl; |
571 | 571 | ||
572 | if (t->getRelatedTo()) { | 572 | if (t->getRelatedTo()) { |
573 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 573 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
574 | } | 574 | } |
575 | 575 | ||
576 | QPtrList<Event> l = t->getRelations(); | 576 | QPtrList<Event> l = t->getRelations(); |
577 | Event *c; | 577 | Event *c; |
578 | for(c=l.first();c;c=l.next()) { | 578 | for(c=l.first();c;c=l.next()) { |
579 | kdDebug() << " - relation: " << c->getSummary() << endl; | 579 | kdDebug() << " - relation: " << c->getSummary() << endl; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | */ | 582 | */ |
583 | 583 | ||
584 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 584 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
585 | // specific order of events. That means that we have to generate parent items | 585 | // specific order of events. That means that we have to generate parent items |
586 | // recursively for proper hierarchical display of Todos. | 586 | // recursively for proper hierarchical display of Todos. |
587 | mTodoMap.clear(); | 587 | mTodoMap.clear(); |
588 | Todo *todo; | 588 | Todo *todo; |
589 | todo = todoList.first();// todo; todo = todoList.next()) { | 589 | todo = todoList.first();// todo; todo = todoList.next()) { |
590 | while ( todo ) { | 590 | while ( todo ) { |
591 | bool next = true; | 591 | bool next = true; |
592 | // qDebug("todo %s ", todo->summary().latin1()); | 592 | // qDebug("todo %s ", todo->summary().latin1()); |
593 | Incidence *incidence = todo->relatedTo(); | 593 | Incidence *incidence = todo->relatedTo(); |
594 | while ( incidence ) { | 594 | while ( incidence ) { |
595 | if ( incidence->type() == "Todo") { | 595 | if ( incidence->type() == "Todo") { |
596 | //qDebug("related %s ",incidence->summary().latin1() ); | 596 | //qDebug("related %s ",incidence->summary().latin1() ); |
597 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 597 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
598 | //qDebug("related not found "); | 598 | //qDebug("related not found "); |
599 | todoList.remove( ); | 599 | todoList.remove( ); |
600 | todo = todoList.current(); | 600 | todo = todoList.current(); |
601 | next = false; | 601 | next = false; |
602 | incidence = 0; | 602 | incidence = 0; |
603 | 603 | ||
604 | } else { | 604 | } else { |
605 | //qDebug("related found "); | 605 | //qDebug("related found "); |
606 | incidence = incidence->relatedTo(); | 606 | incidence = incidence->relatedTo(); |
607 | } | 607 | } |
608 | } else | 608 | } else |
609 | incidence = 0; | 609 | incidence = 0; |
610 | } | 610 | } |
611 | if ( next ) | 611 | if ( next ) |
612 | todo = todoList.next(); | 612 | todo = todoList.next(); |
613 | } | 613 | } |
614 | // qDebug("again .... "); | 614 | // qDebug("again .... "); |
615 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 615 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
616 | 616 | ||
617 | // qDebug("yytodo %s ", todo->summary().latin1()); | 617 | // qDebug("yytodo %s ", todo->summary().latin1()); |
618 | // } | 618 | // } |
619 | //qDebug("for "); | 619 | //qDebug("for "); |
620 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 620 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
621 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 621 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
622 | { | 622 | { |
623 | insertTodoItem(todo); | 623 | insertTodoItem(todo); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | //qDebug("for end "); | 626 | //qDebug("for end "); |
627 | // Restore opened/closed state | 627 | // Restore opened/closed state |
628 | mTodoListView->blockSignals( true ); | 628 | mTodoListView->blockSignals( true ); |
629 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 629 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
630 | mTodoListView->blockSignals( false ); | 630 | mTodoListView->blockSignals( false ); |
631 | mTodoListView->setFocus(); | 631 | mTodoListView->setFocus(); |
632 | processSelectionChange(); | 632 | processSelectionChange(); |
633 | } | 633 | } |
634 | 634 | ||
635 | bool KOTodoView::checkTodo( Todo * todo ) | 635 | bool KOTodoView::checkTodo( Todo * todo ) |
636 | { | 636 | { |
637 | 637 | ||
638 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 638 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
639 | return false; | 639 | return false; |
640 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 640 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
641 | if ( todo->hasStartDate() ) | 641 | if ( todo->hasStartDate() ) |
642 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 642 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
643 | return false; | 643 | return false; |
644 | if ( todo->hasDueDate() ) | 644 | if ( todo->hasDueDate() ) |
645 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 645 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
646 | return false; | 646 | return false; |
647 | } | 647 | } |
648 | return true; | 648 | return true; |
649 | } | 649 | } |
650 | 650 | ||
651 | void KOTodoView::restoreItemState( QListViewItem *item ) | 651 | void KOTodoView::restoreItemState( QListViewItem *item ) |
652 | { | 652 | { |
653 | pendingSubtodo = 0; | 653 | pendingSubtodo = 0; |
654 | while( item ) { | 654 | while( item ) { |
655 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 655 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
656 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 656 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
657 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 657 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
658 | item = item->nextSibling(); | 658 | item = item->nextSibling(); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | 662 | ||
663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
664 | KOTodoView::insertTodoItem(Todo *todo) | 664 | KOTodoView::insertTodoItem(Todo *todo) |
665 | { | 665 | { |
666 | 666 | ||
667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
668 | // TODO: Check, if dynmaic cast is necessary | 668 | // TODO: Check, if dynmaic cast is necessary |
669 | 669 | ||
670 | pendingSubtodo = 0; | 670 | pendingSubtodo = 0; |
671 | Incidence *incidence = todo->relatedTo(); | 671 | Incidence *incidence = todo->relatedTo(); |
672 | if (incidence && incidence->type() == "Todo") { | 672 | if (incidence && incidence->type() == "Todo") { |
673 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 673 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
674 | 674 | ||
675 | // kdDebug() << " has Related" << endl; | 675 | // kdDebug() << " has Related" << endl; |
676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
677 | itemIterator = mTodoMap.find(relatedTodo); | 677 | itemIterator = mTodoMap.find(relatedTodo); |
678 | if (itemIterator == mTodoMap.end()) { | 678 | if (itemIterator == mTodoMap.end()) { |
679 | // kdDebug() << " related not yet in list" << endl; | 679 | // kdDebug() << " related not yet in list" << endl; |
680 | itemIterator = insertTodoItem (relatedTodo); | 680 | itemIterator = insertTodoItem (relatedTodo); |
681 | } | 681 | } |
682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
683 | // and one into the map. Sure finding is more easy but why? -zecke | 683 | // and one into the map. Sure finding is more easy but why? -zecke |
684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
685 | return mTodoMap.insert(todo,todoItem); | 685 | return mTodoMap.insert(todo,todoItem); |
686 | } else { | 686 | } else { |
687 | // kdDebug() << " no Related" << endl; | 687 | // kdDebug() << " no Related" << endl; |
688 | // see above -zecke | 688 | // see above -zecke |
689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
690 | return mTodoMap.insert(todo,todoItem); | 690 | return mTodoMap.insert(todo,todoItem); |
691 | } | 691 | } |
692 | } | 692 | } |
693 | 693 | ||
694 | 694 | ||
695 | void KOTodoView::updateConfig() | 695 | void KOTodoView::updateConfig() |
696 | { | 696 | { |
697 | updateView(); | 697 | updateView(); |
698 | mTodoListView->repaintContents(); | 698 | mTodoListView->repaintContents(); |
699 | } | 699 | } |
700 | 700 | ||
701 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 701 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
702 | { | 702 | { |
703 | QPtrList<Incidence> selected; | 703 | QPtrList<Incidence> selected; |
704 | 704 | ||
705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
706 | // if (!item) item = mActiveItem; | 706 | // if (!item) item = mActiveItem; |
707 | if (item) selected.append(item->todo()); | 707 | if (item) selected.append(item->todo()); |
708 | 708 | ||
709 | return selected; | 709 | return selected; |
710 | } | 710 | } |
711 | 711 | ||
712 | QPtrList<Todo> KOTodoView::selectedTodos() | 712 | QPtrList<Todo> KOTodoView::selectedTodos() |
713 | { | 713 | { |
714 | QPtrList<Todo> selected; | 714 | QPtrList<Todo> selected; |
715 | 715 | ||
716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
717 | // if (!item) item = mActiveItem; | 717 | // if (!item) item = mActiveItem; |
718 | if (item) selected.append(item->todo()); | 718 | if (item) selected.append(item->todo()); |
719 | 719 | ||
720 | return selected; | 720 | return selected; |
721 | } | 721 | } |
722 | 722 | ||
723 | void KOTodoView::changeEventDisplay(Event *, int) | 723 | void KOTodoView::changeEventDisplay(Event *, int) |
724 | { | 724 | { |
725 | updateView(); | 725 | updateView(); |
726 | } | 726 | } |
727 | 727 | ||
728 | void KOTodoView::showDates(const QDate &, const QDate &) | 728 | void KOTodoView::showDates(const QDate &, const QDate &) |
729 | { | 729 | { |
730 | } | 730 | } |
731 | 731 | ||
732 | void KOTodoView::showEvents(QPtrList<Event>) | 732 | void KOTodoView::showEvents(QPtrList<Event>) |
733 | { | 733 | { |
734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
735 | } | 735 | } |
736 | 736 | ||
737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
738 | const QDate &td) | 738 | const QDate &td) |
739 | { | 739 | { |
740 | #ifndef KORG_NOPRINTER | 740 | #ifndef KORG_NOPRINTER |
741 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 741 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
742 | #endif | 742 | #endif |
743 | } | 743 | } |
744 | 744 | ||
745 | void KOTodoView::editItem(QListViewItem *item ) | 745 | void KOTodoView::editItem(QListViewItem *item ) |
746 | { | 746 | { |
747 | // qDebug("editItem(QListViewItem *item ) "); | 747 | // qDebug("editItem(QListViewItem *item ) "); |
748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
749 | } | 749 | } |
750 | 750 | ||
751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
752 | { | 752 | { |
753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
754 | } | 754 | } |
755 | 755 | ||
756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) |
757 | { | 757 | { |
758 | pendingSubtodo = 0; | 758 | pendingSubtodo = 0; |
759 | mActiveItem = (KOTodoViewItem *)item; | 759 | mActiveItem = (KOTodoViewItem *)item; |
760 | if (item) { | 760 | if (item) { |
761 | switch (column){ | 761 | switch (column){ |
762 | case 1: | 762 | case 1: |
763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
764 | case 2: | 764 | case 2: |
765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
766 | case 3: | 766 | case 3: |
767 | moveTodo(); | 767 | moveTodo(); |
768 | break; | 768 | break; |
769 | case 8: | 769 | case 8: |
770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |