-rw-r--r-- | korganizer/kotodoview.cpp | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1fb480d..8c1953d 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -46,289 +46,291 @@ | |||
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 | // kdDebug() << "Drop existing Todo" << endl; | ||
143 | Incidence *to = destinationEvent; | 142 | Incidence *to = destinationEvent; |
144 | while(to) { | 143 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 144 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 145 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 146 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
148 | i18n("Drop To-Do")); | 147 | i18n("Drop To-Do")); |
149 | delete todo; | 148 | delete todo; |
150 | return; | 149 | return; |
151 | } | 150 | } |
152 | to = to->relatedTo(); | 151 | to = to->relatedTo(); |
153 | } | 152 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 153 | internalDrop = true; |
155 | emit todoDropped(todo); | 154 | if ( destinationEvent ) |
155 | reparentTodoSignal( destinationEvent, existingTodo ); | ||
156 | else | ||
157 | unparentTodoSignal(existingTodo); | ||
156 | delete todo; | 158 | delete todo; |
157 | } else { | 159 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | ||
159 | todo->setRelatedTo(destinationEvent); | ||
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | emit todoDropped(todo, KOGlobals::EVENTADDED); | |
162 | emit todoDropped(todo); | 162 | if ( destinationEvent ) |
163 | reparentTodoSignal( destinationEvent, todo ); | ||
163 | } | 164 | } |
164 | } | 165 | } |
165 | else { | 166 | else { |
166 | QString text; | 167 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 168 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 171 | qDebug("Dropped : " + text); |
171 | QStringList emails = QStringList::split(",",text); | 172 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | ||
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 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 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 | QListView::contentsMousePressEvent(e); | ||
193 | #ifndef KORG_NODND | 192 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 193 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 194 | QListViewItem *i = itemAt(p); |
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 | } | 211 | } |
211 | 212 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 214 | { |
214 | 215 | ||
215 | #ifndef KORG_NODND | 216 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | ||
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 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | ||
224 | DndFactory factory( mCalendar ); | 223 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 224 | ICalDrag *vd = factory.createDrag( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 225 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | internalDrop = false; | ||
227 | // we cannot do any senseful here, because the DnD is still broken in Qt | ||
227 | if (vd->drag()) { | 228 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 229 | if ( !internalDrop ) { |
230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | ||
231 | qDebug("Dnd: External move: Delete drag source "); | ||
232 | } else | ||
233 | qDebug("Dnd: Internal move "); | ||
234 | |||
235 | } else { | ||
236 | if ( !internalDrop ) { | ||
237 | qDebug("Dnd: External Copy"); | ||
238 | } else | ||
239 | qDebug("DnD: Internal copy: Copy pending"); | ||
229 | } | 240 | } |
230 | /* | ||
231 | QString source = fullPath(item); | ||
232 | if ( QFile::exists(source) ) { | ||
233 | QUriDrag* ud = new QUriDrag(viewport()); | ||
234 | ud->setFilenames( source ); | ||
235 | if ( ud->drag() ) | ||
236 | QMessageBox::information( this, "Drag source", | ||
237 | QString("Delete ")+source, "Not implemented" ); | ||
238 | */ | ||
239 | } | 241 | } |
240 | } | 242 | } |
241 | #endif | 243 | #endif |
242 | } | 244 | } |
243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
244 | { | 246 | { |
245 | 247 | ||
246 | QListViewItem* cn; | 248 | QListViewItem* cn; |
247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
248 | cn = currentItem(); | 250 | cn = currentItem(); |
249 | if ( cn ) { | 251 | if ( cn ) { |
250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
251 | if ( ci ){ | 253 | if ( ci ){ |
252 | if ( e->state() == ShiftButton ) | 254 | if ( e->state() == ShiftButton ) |
253 | ci->setOn( false ); | 255 | ci->setOn( false ); |
254 | else | 256 | else |
255 | ci->setOn( true ); | 257 | ci->setOn( true ); |
256 | cn = cn->nextSibling(); | 258 | cn = cn->nextSibling(); |
257 | if ( cn ) { | 259 | if ( cn ) { |
258 | setCurrentItem ( cn ); | 260 | setCurrentItem ( cn ); |
259 | ensureItemVisible ( cn ); | 261 | ensureItemVisible ( cn ); |
260 | } | 262 | } |
261 | 263 | ||
262 | } | 264 | } |
263 | } | 265 | } |
264 | 266 | ||
265 | return; | 267 | return; |
266 | } | 268 | } |
267 | 269 | ||
268 | // qDebug("KOTodoListView::keyPressEvent "); | 270 | // qDebug("KOTodoListView::keyPressEvent "); |
269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
270 | switch ( e->key() ) { | 272 | switch ( e->key() ) { |
271 | case Qt::Key_Down: | 273 | case Qt::Key_Down: |
272 | case Qt::Key_Up: | 274 | case Qt::Key_Up: |
273 | QListView::keyPressEvent ( e ); | 275 | QListView::keyPressEvent ( e ); |
274 | break; | 276 | break; |
275 | case Qt::Key_Left: | 277 | case Qt::Key_Left: |
276 | case Qt::Key_Right: | 278 | case Qt::Key_Right: |
277 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | 280 | e->accept(); |
279 | return; | 281 | return; |
280 | break; | 282 | break; |
281 | default: | 283 | default: |
282 | e->ignore(); | 284 | e->ignore(); |
283 | break; | 285 | break; |
284 | } | 286 | } |
285 | return; | 287 | return; |
286 | } | 288 | } |
287 | e->ignore(); | 289 | e->ignore(); |
288 | } | 290 | } |
289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
290 | { | 292 | { |
291 | QListView::contentsMouseReleaseEvent(e); | 293 | QListView::contentsMouseReleaseEvent(e); |
292 | mMousePressed = false; | 294 | mMousePressed = false; |
293 | } | 295 | } |
294 | 296 | ||
295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
296 | { | 298 | { |
297 | if (!e) return; | 299 | if (!e) return; |
298 | 300 | ||
299 | QPoint vp = contentsToViewport(e->pos()); | 301 | QPoint vp = contentsToViewport(e->pos()); |
300 | 302 | ||
301 | QListViewItem *item = itemAt(vp); | 303 | QListViewItem *item = itemAt(vp); |
302 | 304 | ||
303 | emit double_Clicked(item); | 305 | emit double_Clicked(item); |
304 | if (!item) return; | 306 | if (!item) return; |
305 | 307 | ||
306 | emit doubleClicked(item,vp,0); | 308 | emit doubleClicked(item,vp,0); |
307 | } | 309 | } |
308 | 310 | ||
309 | ///////////////////////////////////////////////////////////////////////////// | 311 | ///////////////////////////////////////////////////////////////////////////// |
310 | 312 | ||
311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
312 | QLineEdit(parent) | 314 | QLineEdit(parent) |
313 | { | 315 | { |
314 | setText(i18n("Click to add a new Todo")); | 316 | setText(i18n("Click to add a new Todo")); |
315 | } | 317 | } |
316 | 318 | ||
317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
318 | { | 320 | { |
319 | if ( text()==i18n("Click to add a new Todo") ) | 321 | if ( text()==i18n("Click to add a new Todo") ) |
320 | setText(""); | 322 | setText(""); |
321 | QLineEdit::focusInEvent(ev); | 323 | QLineEdit::focusInEvent(ev); |
322 | } | 324 | } |
323 | 325 | ||
324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
325 | { | 327 | { |
326 | setText(i18n("Click to add a new Todo")); | 328 | setText(i18n("Click to add a new Todo")); |
327 | QLineEdit::focusOutEvent(ev); | 329 | QLineEdit::focusOutEvent(ev); |
328 | } | 330 | } |
329 | 331 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 332 | ///////////////////////////////////////////////////////////////////////////// |
331 | 333 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 335 | KOrg::BaseView(calendar,parent,name) |
334 | { | 336 | { |
@@ -396,207 +398,214 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
396 | 398 | ||
397 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 399 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
398 | for (int i = 0; i <= 100; i+=20) { | 400 | for (int i = 0; i <= 100; i+=20) { |
399 | QString label = QString ("%1 %").arg (i); | 401 | QString label = QString ("%1 %").arg (i); |
400 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 402 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
401 | } | 403 | } |
402 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 404 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
403 | 405 | ||
404 | 406 | ||
405 | 407 | ||
406 | mItemPopupMenu = new QPopupMenu(this); | 408 | mItemPopupMenu = new QPopupMenu(this); |
407 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 409 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
408 | SLOT (showTodo())); | 410 | SLOT (showTodo())); |
409 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 411 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
410 | SLOT (editTodo())); | 412 | SLOT (editTodo())); |
411 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 413 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
412 | SLOT (deleteTodo())); | 414 | SLOT (deleteTodo())); |
413 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 415 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
414 | SLOT (cloneTodo())); | 416 | SLOT (cloneTodo())); |
415 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 417 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
416 | SLOT (moveTodo())); | 418 | SLOT (moveTodo())); |
417 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 419 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
418 | SLOT (beamTodo())); | 420 | SLOT (beamTodo())); |
419 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 421 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
420 | SLOT (cancelTodo())); | 422 | SLOT (cancelTodo())); |
421 | mItemPopupMenu->insertSeparator(); | 423 | mItemPopupMenu->insertSeparator(); |
422 | 424 | ||
423 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 425 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
424 | SLOT (newTodo())); | 426 | SLOT (newTodo())); |
425 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 427 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
426 | SLOT (newSubTodo())); | 428 | SLOT (newSubTodo())); |
427 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 429 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
428 | SLOT (unparentTodo()),0,21); | 430 | SLOT (unparentTodo()),0,21); |
429 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 431 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
430 | SLOT (reparentTodo()),0,22); | 432 | SLOT (reparentTodo()),0,22); |
431 | mItemPopupMenu->insertSeparator(); | 433 | mItemPopupMenu->insertSeparator(); |
432 | #if 0 | 434 | #if 0 |
433 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 435 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
434 | this, SLOT( purgeCompleted() ) ); | 436 | this, SLOT( purgeCompleted() ) ); |
435 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 437 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
436 | this, SLOT( toggleCompleted() ),0, 33 ); | 438 | this, SLOT( toggleCompleted() ),0, 33 ); |
437 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 439 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
438 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 440 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
439 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 441 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
440 | this, SLOT( toggleRunning() ),0, 35 ); | 442 | this, SLOT( toggleRunning() ),0, 35 ); |
441 | 443 | ||
442 | #endif | 444 | #endif |
443 | mPopupMenu = new QPopupMenu(this); | 445 | mPopupMenu = new QPopupMenu(this); |
444 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 446 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
445 | SLOT (newTodo()),0,1); | 447 | SLOT (newTodo()),0,1); |
446 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 448 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
447 | this, SLOT(purgeCompleted()),0,2); | 449 | this, SLOT(purgeCompleted()),0,2); |
448 | mPopupMenu->insertItem(i18n("Show Completed"), | 450 | mPopupMenu->insertItem(i18n("Show Completed"), |
449 | this, SLOT( toggleCompleted() ),0,3 ); | 451 | this, SLOT( toggleCompleted() ),0,3 ); |
450 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 452 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
451 | this, SLOT( toggleQuickTodo() ),0,4 ); | 453 | this, SLOT( toggleQuickTodo() ),0,4 ); |
452 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 454 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
453 | this, SLOT( toggleRunning() ),0,5 ); | 455 | this, SLOT( toggleRunning() ),0,5 ); |
454 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 456 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
455 | this, SLOT( setAllOpen() ),0,6 ); | 457 | this, SLOT( setAllOpen() ),0,6 ); |
456 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 458 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
457 | this, SLOT( setAllClose() ),0,7 ); | 459 | this, SLOT( setAllClose() ),0,7 ); |
458 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 460 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
459 | this, SLOT( setAllFlat() ),0,8 ); | 461 | this, SLOT( setAllFlat() ),0,8 ); |
460 | mDocPrefs = new DocPrefs( name ); | 462 | mDocPrefs = new DocPrefs( name ); |
461 | 463 | ||
462 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 464 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
463 | mPopupMenu->setCheckable( true ); | 465 | mPopupMenu->setCheckable( true ); |
464 | mItemPopupMenu->setCheckable( true ); | 466 | mItemPopupMenu->setCheckable( true ); |
465 | 467 | ||
466 | 468 | ||
467 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 469 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
468 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 470 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
469 | 471 | ||
470 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 472 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
471 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 473 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
472 | 474 | ||
473 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 475 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
474 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 476 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
475 | 477 | ||
476 | 478 | ||
477 | // Double clicking conflicts with opening/closing the subtree | 479 | // Double clicking conflicts with opening/closing the subtree |
478 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 480 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
479 | SLOT( editItem( QListViewItem *) ) ); | 481 | SLOT( editItem( QListViewItem *) ) ); |
480 | /* | 482 | /* |
481 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 483 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
482 | const QPoint &,int ) ), | 484 | const QPoint &,int ) ), |
483 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 485 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
484 | */ | 486 | */ |
485 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 487 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
486 | const QPoint &,int ) ), | 488 | const QPoint &,int ) ), |
487 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 489 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
488 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 490 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
489 | SLOT( itemClicked( QListViewItem * ) ) ); | 491 | SLOT( itemClicked( QListViewItem * ) ) ); |
490 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 492 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
491 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 493 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
492 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 494 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
493 | SLOT( updateView() ) ); | 495 | SLOT( updateView() ) ); |
496 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | ||
497 | SLOT( todoModified(Todo *, int) ) ); | ||
494 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 498 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
495 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 499 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
496 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 500 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
497 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 501 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
498 | 502 | ||
499 | #if 0 | 503 | #if 0 |
500 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 504 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
501 | SLOT(selectionChanged(QListViewItem *))); | 505 | SLOT(selectionChanged(QListViewItem *))); |
502 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 506 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
503 | SLOT(selectionChanged(QListViewItem *))); | 507 | SLOT(selectionChanged(QListViewItem *))); |
504 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 508 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
505 | SLOT(selectionChanged(QListViewItem *))); | 509 | SLOT(selectionChanged(QListViewItem *))); |
506 | #endif | 510 | #endif |
511 | |||
512 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | ||
513 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | ||
514 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | ||
515 | |||
507 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 516 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
508 | SLOT( processSelectionChange() ) ); | 517 | SLOT( processSelectionChange() ) ); |
509 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 518 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
510 | SLOT( addQuickTodo() ) ); | 519 | SLOT( addQuickTodo() ) ); |
511 | 520 | ||
512 | } | 521 | } |
513 | 522 | ||
514 | KOTodoView::~KOTodoView() | 523 | KOTodoView::~KOTodoView() |
515 | { | 524 | { |
516 | delete mDocPrefs; | 525 | delete mDocPrefs; |
517 | } | 526 | } |
518 | 527 | ||
519 | void KOTodoView::jumpToDate () | 528 | void KOTodoView::jumpToDate () |
520 | { | 529 | { |
521 | // if (mActiveItem) { | 530 | // if (mActiveItem) { |
522 | // mActiveItem->todo()); | 531 | // mActiveItem->todo()); |
523 | // if ( mActiveItem->todo()->hasDueDate() ) | 532 | // if ( mActiveItem->todo()->hasDueDate() ) |
524 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 533 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
525 | } | 534 | } |
526 | 535 | ||
527 | void KOTodoView::updateView() | 536 | void KOTodoView::updateView() |
528 | { | 537 | { |
529 | pendingSubtodo = 0; | 538 | pendingSubtodo = 0; |
530 | if ( mBlockUpdate ) { | 539 | if ( mBlockUpdate ) { |
531 | //qDebug("blocked "); | 540 | //qDebug("blocked "); |
532 | return; | 541 | return; |
533 | } | 542 | } |
534 | if ( isFlatDisplay ) { | 543 | if ( isFlatDisplay ) { |
535 | setAllFlat(); | 544 | setAllFlat(); |
536 | return; | 545 | return; |
537 | } | 546 | } |
538 | //qDebug("update "); | 547 | //qDebug("update "); |
539 | // kdDebug() << "KOTodoView::updateView()" << endl; | 548 | // kdDebug() << "KOTodoView::updateView()" << endl; |
540 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 549 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
541 | mTodoListView->clear(); | 550 | mTodoListView->clear(); |
542 | if ( mName == "todolistsmall" ) { | 551 | if ( mName == "todolistsmall" ) { |
543 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 552 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
544 | int ps = fo.pointSize() -2; | 553 | int ps = fo.pointSize() -2; |
545 | if ( ps > 12 ) | 554 | if ( ps > 12 ) |
546 | ps -= 2; | 555 | ps -= 2; |
547 | fo.setPointSize( ps ); | 556 | fo.setPointSize( ps ); |
548 | } | 557 | } |
549 | } | 558 | } |
550 | 559 | ||
551 | mTodoListView->setFont( fo ); | 560 | mTodoListView->setFont( fo ); |
552 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 561 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
553 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 562 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
554 | QPtrList<Todo> todoList = calendar()->todos(); | 563 | QPtrList<Todo> todoList = calendar()->todos(); |
555 | 564 | ||
556 | /* | 565 | /* |
557 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 566 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
558 | Event *t; | 567 | Event *t; |
559 | for(t = todoList.first(); t; t = todoList.next()) { | 568 | for(t = todoList.first(); t; t = todoList.next()) { |
560 | kdDebug() << " " << t->getSummary() << endl; | 569 | kdDebug() << " " << t->getSummary() << endl; |
561 | 570 | ||
562 | if (t->getRelatedTo()) { | 571 | if (t->getRelatedTo()) { |
563 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 572 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
564 | } | 573 | } |
565 | 574 | ||
566 | QPtrList<Event> l = t->getRelations(); | 575 | QPtrList<Event> l = t->getRelations(); |
567 | Event *c; | 576 | Event *c; |
568 | for(c=l.first();c;c=l.next()) { | 577 | for(c=l.first();c;c=l.next()) { |
569 | kdDebug() << " - relation: " << c->getSummary() << endl; | 578 | kdDebug() << " - relation: " << c->getSummary() << endl; |
570 | } | 579 | } |
571 | } | 580 | } |
572 | */ | 581 | */ |
573 | 582 | ||
574 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 583 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
575 | // specific order of events. That means that we have to generate parent items | 584 | // specific order of events. That means that we have to generate parent items |
576 | // recursively for proper hierarchical display of Todos. | 585 | // recursively for proper hierarchical display of Todos. |
577 | mTodoMap.clear(); | 586 | mTodoMap.clear(); |
578 | Todo *todo; | 587 | Todo *todo; |
579 | todo = todoList.first();// todo; todo = todoList.next()) { | 588 | todo = todoList.first();// todo; todo = todoList.next()) { |
580 | while ( todo ) { | 589 | while ( todo ) { |
581 | bool next = true; | 590 | bool next = true; |
582 | // qDebug("todo %s ", todo->summary().latin1()); | 591 | // qDebug("todo %s ", todo->summary().latin1()); |
583 | Incidence *incidence = todo->relatedTo(); | 592 | Incidence *incidence = todo->relatedTo(); |
584 | while ( incidence ) { | 593 | while ( incidence ) { |
585 | if ( incidence->type() == "Todo") { | 594 | if ( incidence->type() == "Todo") { |
586 | //qDebug("related %s ",incidence->summary().latin1() ); | 595 | //qDebug("related %s ",incidence->summary().latin1() ); |
587 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 596 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
588 | //qDebug("related not found "); | 597 | //qDebug("related not found "); |
589 | todoList.remove( ); | 598 | todoList.remove( ); |
590 | todo = todoList.current(); | 599 | todo = todoList.current(); |
591 | next = false; | 600 | next = false; |
592 | incidence = 0; | 601 | incidence = 0; |
593 | 602 | ||
594 | } else { | 603 | } else { |
595 | //qDebug("related found "); | 604 | //qDebug("related found "); |
596 | incidence = incidence->relatedTo(); | 605 | incidence = incidence->relatedTo(); |
597 | } | 606 | } |
598 | } else | 607 | } else |
599 | incidence = 0; | 608 | incidence = 0; |
600 | } | 609 | } |
601 | if ( next ) | 610 | if ( next ) |
602 | todo = todoList.next(); | 611 | todo = todoList.next(); |