author | zautrix <zautrix> | 2005-07-03 16:29:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-03 16:29:54 (UTC) |
commit | fede36a3c30dd88b7a41bd0eb2f87414bb574e6e (patch) (unidiff) | |
tree | 5b46ad7cef0ea61022edff382326ef7fb46a5215 | |
parent | 9be5bd1c7e9ee829dd73f5b4a36a2f4331edf68e (diff) | |
download | kdepimpi-fede36a3c30dd88b7a41bd0eb2f87414bb574e6e.zip kdepimpi-fede36a3c30dd88b7a41bd0eb2f87414bb574e6e.tar.gz kdepimpi-fede36a3c30dd88b7a41bd0eb2f87414bb574e6e.tar.bz2 |
ggg
-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 4f42c83..86e1bd9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -204,769 +204,769 @@ void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | |||
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 405 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 407 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (! e->isAutoRepeat() ) | 410 | if (! e->isAutoRepeat() ) |
411 | mFlagKeyPressed = true; | 411 | mFlagKeyPressed = true; |
412 | QListViewItem* cn; | 412 | QListViewItem* cn; |
413 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 413 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
414 | cn = currentItem(); | 414 | cn = currentItem(); |
415 | if ( cn ) { | 415 | if ( cn ) { |
416 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 416 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
417 | if ( ci ){ | 417 | if ( ci ){ |
418 | if ( e->state() == ShiftButton ) | 418 | if ( e->state() == ShiftButton ) |
419 | ci->setOn( false ); | 419 | ci->setOn( false ); |
420 | else | 420 | else |
421 | ci->setOn( true ); | 421 | ci->setOn( true ); |
422 | cn = cn->itemBelow(); | 422 | cn = cn->itemBelow(); |
423 | if ( cn ) { | 423 | if ( cn ) { |
424 | setCurrentItem ( cn ); | 424 | setCurrentItem ( cn ); |
425 | ensureItemVisible ( cn ); | 425 | ensureItemVisible ( cn ); |
426 | } | 426 | } |
427 | 427 | ||
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | 433 | ||
434 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 434 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
435 | switch ( e->key() ) { | 435 | switch ( e->key() ) { |
436 | case Qt::Key_Down: | 436 | case Qt::Key_Down: |
437 | case Qt::Key_Up: | 437 | case Qt::Key_Up: |
438 | QListView::keyPressEvent ( e ); | 438 | QListView::keyPressEvent ( e ); |
439 | break; | 439 | break; |
440 | case Qt::Key_Left: | 440 | case Qt::Key_Left: |
441 | case Qt::Key_Right: | 441 | case Qt::Key_Right: |
442 | QListView::keyPressEvent ( e ); | 442 | QListView::keyPressEvent ( e ); |
443 | e->accept(); | 443 | e->accept(); |
444 | return; | 444 | return; |
445 | break; | 445 | break; |
446 | default: | 446 | default: |
447 | e->ignore(); | 447 | e->ignore(); |
448 | break; | 448 | break; |
449 | } | 449 | } |
450 | return; | 450 | return; |
451 | } | 451 | } |
452 | e->ignore(); | 452 | e->ignore(); |
453 | } | 453 | } |
454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
455 | { | 455 | { |
456 | QListView::contentsMouseReleaseEvent(e); | 456 | QListView::contentsMouseReleaseEvent(e); |
457 | mMousePressed = false; | 457 | mMousePressed = false; |
458 | } | 458 | } |
459 | 459 | ||
460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | if (!e) return; | 462 | if (!e) return; |
463 | 463 | ||
464 | QPoint vp = contentsToViewport(e->pos()); | 464 | QPoint vp = contentsToViewport(e->pos()); |
465 | 465 | ||
466 | QListViewItem *item = itemAt(vp); | 466 | QListViewItem *item = itemAt(vp); |
467 | 467 | ||
468 | emit double_Clicked(item); | 468 | emit double_Clicked(item); |
469 | if (!item) return; | 469 | if (!item) return; |
470 | 470 | ||
471 | emit doubleClicked(item,vp,0); | 471 | emit doubleClicked(item,vp,0); |
472 | } | 472 | } |
473 | 473 | ||
474 | ///////////////////////////////////////////////////////////////////////////// | 474 | ///////////////////////////////////////////////////////////////////////////// |
475 | 475 | ||
476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
477 | QLineEdit(parent) | 477 | QLineEdit(parent) |
478 | { | 478 | { |
479 | setText(i18n("Click to add a new Todo")); | 479 | setText(i18n("Click to add a new Todo")); |
480 | } | 480 | } |
481 | 481 | ||
482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
483 | { | 483 | { |
484 | if ( text()==i18n("Click to add a new Todo") ) | 484 | if ( text()==i18n("Click to add a new Todo") ) |
485 | setText(""); | 485 | setText(""); |
486 | QLineEdit::focusInEvent(ev); | 486 | QLineEdit::focusInEvent(ev); |
487 | } | 487 | } |
488 | 488 | ||
489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
490 | { | 490 | { |
491 | setText(i18n("Click to add a new Todo")); | 491 | setText(i18n("Click to add a new Todo")); |
492 | QLineEdit::focusOutEvent(ev); | 492 | QLineEdit::focusOutEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | ///////////////////////////////////////////////////////////////////////////// | 495 | ///////////////////////////////////////////////////////////////////////////// |
496 | 496 | ||
497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
498 | KOrg::BaseView(calendar,parent,name) | 498 | KOrg::BaseView(calendar,parent,name) |
499 | { | 499 | { |
500 | mCategoryPopupMenu = 0; | 500 | mCategoryPopupMenu = 0; |
501 | mPendingUpdateBeforeRepaint = false; | 501 | mPendingUpdateBeforeRepaint = false; |
502 | isFlatDisplay = false; | 502 | isFlatDisplay = false; |
503 | mNavigator = 0; | 503 | mNavigator = 0; |
504 | QBoxLayout *topLayout = new QVBoxLayout(this); | 504 | QBoxLayout *topLayout = new QVBoxLayout(this); |
505 | mName = QString ( name ); | 505 | mName = QString ( name ); |
506 | mBlockUpdate = false; | 506 | mBlockUpdate = false; |
507 | mQuickAdd = new KOQuickTodo(this); | 507 | mQuickAdd = new KOQuickTodo(this); |
508 | topLayout->addWidget(mQuickAdd); | 508 | topLayout->addWidget(mQuickAdd); |
509 | 509 | ||
510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
511 | 511 | ||
512 | mTodoListView = new KOTodoListView(calendar,this, name ); | 512 | mTodoListView = new KOTodoListView(calendar,this, name ); |
513 | topLayout->addWidget(mTodoListView); | 513 | topLayout->addWidget(mTodoListView); |
514 | //mTodoListView->header()->setMaximumHeight(30); | 514 | //mTodoListView->header()->setMaximumHeight(30); |
515 | mTodoListView->setRootIsDecorated(true); | 515 | mTodoListView->setRootIsDecorated(true); |
516 | mTodoListView->setAllColumnsShowFocus(true); | 516 | mTodoListView->setAllColumnsShowFocus(true); |
517 | 517 | ||
518 | mTodoListView->setShowSortIndicator(true); | 518 | mTodoListView->setShowSortIndicator(true); |
519 | 519 | ||
520 | mTodoListView->addColumn(i18n("Todo")); | 520 | mTodoListView->addColumn(i18n("Todo")); |
521 | mTodoListView->addColumn(i18n("Prio")); | 521 | mTodoListView->addColumn(i18n("Prio")); |
522 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 522 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
523 | mTodoListView->addColumn(i18n("Complete")); | 523 | mTodoListView->addColumn(i18n("Complete")); |
524 | mTodoListView->setColumnAlignment(2,AlignCenter); | 524 | mTodoListView->setColumnAlignment(2,AlignCenter); |
525 | 525 | ||
526 | mTodoListView->addColumn(i18n("Due Date")); | 526 | mTodoListView->addColumn(i18n("Due Date")); |
527 | mTodoListView->setColumnAlignment(3,AlignLeft); | 527 | mTodoListView->setColumnAlignment(3,AlignLeft); |
528 | mTodoListView->addColumn(i18n("Due Time")); | 528 | mTodoListView->addColumn(i18n("Due Time")); |
529 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 529 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
530 | 530 | ||
531 | mTodoListView->addColumn(i18n("Start Date")); | 531 | mTodoListView->addColumn(i18n("Start Date")); |
532 | mTodoListView->setColumnAlignment(5,AlignLeft); | 532 | mTodoListView->setColumnAlignment(5,AlignLeft); |
533 | mTodoListView->addColumn(i18n("Start Time")); | 533 | mTodoListView->addColumn(i18n("Start Time")); |
534 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 534 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
535 | 535 | ||
536 | mTodoListView->addColumn(i18n("Cancelled")); | 536 | mTodoListView->addColumn(i18n("Cancelled")); |
537 | mTodoListView->addColumn(i18n("Categories")); | 537 | mTodoListView->addColumn(i18n("Categories")); |
538 | mTodoListView->addColumn(i18n("Calendar")); | 538 | mTodoListView->addColumn(i18n("Calendar")); |
539 | #if 0 | 539 | #if 0 |
540 | mTodoListView->addColumn(i18n("Sort Id")); | 540 | mTodoListView->addColumn(i18n("Sort Id")); |
541 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 541 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
542 | #endif | 542 | #endif |
543 | 543 | ||
544 | mTodoListView->setMinimumHeight( 60 ); | 544 | mTodoListView->setMinimumHeight( 60 ); |
545 | mTodoListView->setItemsRenameable( true ); | 545 | mTodoListView->setItemsRenameable( true ); |
546 | mTodoListView->setRenameable( 0 ); | 546 | mTodoListView->setRenameable( 0 ); |
547 | mTodoListView->setColumnWidth( 0, 120 ); | 547 | mTodoListView->setColumnWidth( 0, 120 ); |
548 | int iii = 0; | 548 | int iii = 0; |
549 | for ( iii = 0; iii< 10 ; ++iii ) | 549 | for ( iii = 0; iii< 10 ; ++iii ) |
550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
551 | 551 | ||
552 | 552 | ||
553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
554 | 554 | ||
555 | mPriorityPopupMenu = new QPopupMenu(this); | 555 | mPriorityPopupMenu = new QPopupMenu(this); |
556 | for (int i = 1; i <= 5; i++) { | 556 | for (int i = 1; i <= 5; i++) { |
557 | QString label = QString ("%1").arg (i); | 557 | QString label = QString ("%1").arg (i); |
558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
559 | } | 559 | } |
560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
561 | 561 | ||
562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
563 | for (int i = 0; i <= 100; i+=20) { | 563 | for (int i = 0; i <= 100; i+=20) { |
564 | QString label = QString ("%1 %").arg (i); | 564 | QString label = QString ("%1 %").arg (i); |
565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
566 | } | 566 | } |
567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
568 | 568 | ||
569 | 569 | ||
570 | mCategoryPopupMenu = new QPopupMenu (this); | 570 | mCategoryPopupMenu = new QPopupMenu (this); |
571 | mCategoryPopupMenu->setCheckable (true); | 571 | mCategoryPopupMenu->setCheckable (true); |
572 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 572 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
573 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 573 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
574 | 574 | ||
575 | mCalPopupMenu = new QPopupMenu (this); | 575 | mCalPopupMenu = new QPopupMenu (this); |
576 | mCalPopupMenu->setCheckable (true); | 576 | mCalPopupMenu->setCheckable (true); |
577 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 577 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
578 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 578 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | 582 | ||
583 | mItemPopupMenu = new QPopupMenu(this); | 583 | mItemPopupMenu = new QPopupMenu(this); |
584 | mItemPopupMenu->insertItem(i18n("Show"), this, | 584 | mItemPopupMenu->insertItem(i18n("Show"), this, |
585 | SLOT (showTodo())); | 585 | SLOT (showTodo())); |
586 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 586 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
587 | SLOT (editTodo())); | 587 | SLOT (editTodo())); |
588 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 588 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
589 | SLOT (deleteTodo())); | 589 | SLOT (deleteTodo())); |
590 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 590 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
591 | SLOT (cloneTodo())); | 591 | SLOT (cloneTodo())); |
592 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 592 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
593 | SLOT (moveTodo())); | 593 | SLOT (moveTodo())); |
594 | #ifndef DESKTOP_VERSION | 594 | #ifndef DESKTOP_VERSION |
595 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 595 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
596 | SLOT (beamTodo())); | 596 | SLOT (beamTodo())); |
597 | #endif | 597 | #endif |
598 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 598 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
599 | SLOT (cancelTodo())); | 599 | SLOT (cancelTodo())); |
600 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 600 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
601 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 601 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
602 | mItemPopupMenu->insertSeparator(); | 602 | mItemPopupMenu->insertSeparator(); |
603 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 603 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
604 | SLOT (toggleRunningItem())); | 604 | SLOT (toggleRunningItem())); |
605 | mItemPopupMenu->insertSeparator(); | 605 | mItemPopupMenu->insertSeparator(); |
606 | /* | 606 | /* |
607 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 607 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
608 | SLOT (newTodo())); | 608 | SLOT (newTodo())); |
609 | */ | 609 | */ |
610 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 610 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
611 | SLOT (newSubTodo())); | 611 | SLOT (newSubTodo())); |
612 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 612 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
613 | SLOT (unparentTodo()),0,21); | 613 | SLOT (unparentTodo()),0,21); |
614 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 614 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
615 | SLOT (reparentTodo()),0,22); | 615 | SLOT (reparentTodo()),0,22); |
616 | mItemPopupMenu->insertSeparator(); | 616 | mItemPopupMenu->insertSeparator(); |
617 | #if 0 | 617 | #if 0 |
618 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 618 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
619 | this, SLOT( purgeCompleted() ) ); | 619 | this, SLOT( purgeCompleted() ) ); |
620 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 620 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
621 | this, SLOT( toggleCompleted() ),0, 33 ); | 621 | this, SLOT( toggleCompleted() ),0, 33 ); |
622 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 622 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
623 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 623 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
624 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 624 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
625 | this, SLOT( toggleRunning() ),0, 35 ); | 625 | this, SLOT( toggleRunning() ),0, 35 ); |
626 | 626 | ||
627 | #endif | 627 | #endif |
628 | mPopupMenu = new QPopupMenu(this); | 628 | mPopupMenu = new QPopupMenu(this); |
629 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 629 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
630 | SLOT (newTodo()),0,1); | 630 | SLOT (newTodo()),0,1); |
631 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 631 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
632 | this, SLOT(purgeCompleted()),0,2); | 632 | this, SLOT(purgeCompleted()),0,2); |
633 | mPopupMenu->insertItem(i18n("Show Completed"), | 633 | mPopupMenu->insertItem(i18n("Show Completed"), |
634 | this, SLOT( toggleCompleted() ),0,3 ); | 634 | this, SLOT( toggleCompleted() ),0,3 ); |
635 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 635 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
636 | this, SLOT( toggleRunning() ),0,5 ); | 636 | this, SLOT( toggleRunning() ),0,5 ); |
637 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 637 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
638 | this, SLOT( setAllOpen() ),0,6 ); | 638 | this, SLOT( setAllOpen() ),0,6 ); |
639 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 639 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
640 | this, SLOT( setAllClose() ),0,7 ); | 640 | this, SLOT( setAllClose() ),0,7 ); |
641 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 641 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
642 | this, SLOT( setAllFlat() ),0,8 ); | 642 | this, SLOT( setAllFlat() ),0,8 ); |
643 | mPopupMenu->insertSeparator(); | 643 | mPopupMenu->insertSeparator(); |
644 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 644 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
645 | this, SLOT( toggleQuickTodo() ),0,4 ); | 645 | this, SLOT( toggleQuickTodo() ),0,4 ); |
646 | mDocPrefs = new DocPrefs( name ); | 646 | mDocPrefs = new DocPrefs( name ); |
647 | 647 | ||
648 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 648 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
649 | mPopupMenu->setCheckable( true ); | 649 | mPopupMenu->setCheckable( true ); |
650 | mItemPopupMenu->setCheckable( true ); | 650 | mItemPopupMenu->setCheckable( true ); |
651 | 651 | ||
652 | 652 | ||
653 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 653 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
654 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 654 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
655 | 655 | ||
656 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 656 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
657 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 657 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
658 | 658 | ||
659 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 659 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
660 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 660 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
661 | 661 | ||
662 | 662 | ||
663 | // Double clicking conflicts with opening/closing the subtree | 663 | // Double clicking conflicts with opening/closing the subtree |
664 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 664 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
665 | SLOT( editItem( QListViewItem *) ) ); | 665 | SLOT( editItem( QListViewItem *) ) ); |
666 | /* | 666 | /* |
667 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 667 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
668 | const QPoint &,int ) ), | 668 | const QPoint &,int ) ), |
669 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 669 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
670 | */ | 670 | */ |
671 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 671 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
672 | const QPoint &,int ) ), | 672 | const QPoint &,int ) ), |
673 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 673 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
674 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 674 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
675 | SLOT( itemClicked( QListViewItem * ) ) ); | 675 | SLOT( itemClicked( QListViewItem * ) ) ); |
676 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 676 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
677 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 677 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
678 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 678 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
679 | SLOT( updateView() ) ); | 679 | SLOT( updateView() ) ); |
680 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 680 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
681 | SLOT( todoModified(Todo *, int) ) ); | 681 | SLOT( todoModified(Todo *, int) ) ); |
682 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 682 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
683 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 683 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
684 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 684 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
685 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 685 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
686 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 686 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
687 | SLOT( paintNeeded()) ); | 687 | SLOT( paintNeeded()) ); |
688 | 688 | ||
689 | #if 0 | 689 | #if 0 |
690 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 690 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
691 | SLOT(selectionChanged(QListViewItem *))); | 691 | SLOT(selectionChanged(QListViewItem *))); |
692 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 692 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
693 | SLOT(selectionChanged(QListViewItem *))); | 693 | SLOT(selectionChanged(QListViewItem *))); |
694 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 694 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
695 | SLOT(selectionChanged(QListViewItem *))); | 695 | SLOT(selectionChanged(QListViewItem *))); |
696 | #endif | 696 | #endif |
697 | 697 | ||
698 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 698 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
699 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 699 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
700 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 700 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
701 | 701 | ||
702 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 702 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
703 | SLOT( processSelectionChange() ) ); | 703 | SLOT( processSelectionChange() ) ); |
704 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 704 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
705 | SLOT( addQuickTodo() ) ); | 705 | SLOT( addQuickTodo() ) ); |
706 | 706 | ||
707 | } | 707 | } |
708 | 708 | ||
709 | KOTodoView::~KOTodoView() | 709 | KOTodoView::~KOTodoView() |
710 | { | 710 | { |
711 | 711 | ||
712 | #if QT_VERSION >= 0x030000 | 712 | #if QT_VERSION >= 0x030000 |
713 | 713 | ||
714 | #else | 714 | #else |
715 | delete mKOTodoViewWhatsThis; | 715 | delete mKOTodoViewWhatsThis; |
716 | #endif | 716 | #endif |
717 | 717 | ||
718 | delete mDocPrefs; | 718 | delete mDocPrefs; |
719 | } | 719 | } |
720 | QString KOTodoView::getWhatsThisText(QPoint p) | 720 | QString KOTodoView::getWhatsThisText(QPoint p) |
721 | { | 721 | { |
722 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 722 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
723 | if ( item ) | 723 | if ( item ) |
724 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 724 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
725 | KOPrefs::instance()->mWTshowDetails, | 725 | KOPrefs::instance()->mWTshowDetails, |
726 | KOPrefs::instance()->mWTshowCreated, | 726 | KOPrefs::instance()->mWTshowCreated, |
727 | KOPrefs::instance()->mWTshowChanged); | 727 | KOPrefs::instance()->mWTshowChanged); |
728 | return i18n("That is the todo view" ); | 728 | return i18n("That is the todo view" ); |
729 | 729 | ||
730 | } | 730 | } |
731 | 731 | ||
732 | void KOTodoView::jumpToDate () | 732 | void KOTodoView::jumpToDate () |
733 | { | 733 | { |
734 | // if (mActiveItem) { | 734 | // if (mActiveItem) { |
735 | // mActiveItem->todo()); | 735 | // mActiveItem->todo()); |
736 | // if ( mActiveItem->todo()->hasDueDate() ) | 736 | // if ( mActiveItem->todo()->hasDueDate() ) |
737 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 737 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
738 | } | 738 | } |
739 | void KOTodoView::paintNeeded() | 739 | void KOTodoView::paintNeeded() |
740 | { | 740 | { |
741 | if ( mPendingUpdateBeforeRepaint ) { | 741 | if ( mPendingUpdateBeforeRepaint ) { |
742 | updateView(); | 742 | updateView(); |
743 | mPendingUpdateBeforeRepaint = false; | 743 | mPendingUpdateBeforeRepaint = false; |
744 | } | 744 | } |
745 | } | 745 | } |
746 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 746 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
747 | { | 747 | { |
748 | if ( mPendingUpdateBeforeRepaint ) { | 748 | if ( mPendingUpdateBeforeRepaint ) { |
749 | updateView(); | 749 | updateView(); |
750 | mPendingUpdateBeforeRepaint = false; | 750 | mPendingUpdateBeforeRepaint = false; |
751 | } | 751 | } |
752 | KOrg::BaseView::paintEvent( pevent); | 752 | KOrg::BaseView::paintEvent( pevent); |
753 | } | 753 | } |
754 | 754 | ||
755 | void KOTodoView::updateView() | 755 | void KOTodoView::updateView() |
756 | { | 756 | { |
757 | pendingSubtodo = 0; | 757 | pendingSubtodo = 0; |
758 | if ( mBlockUpdate ) { | 758 | if ( mBlockUpdate ) { |
759 | return; | 759 | return; |
760 | } | 760 | } |
761 | if ( !isVisible() ) { | 761 | if ( !isVisible() ) { |
762 | mPendingUpdateBeforeRepaint = true; | 762 | mPendingUpdateBeforeRepaint = true; |
763 | return; | 763 | return; |
764 | } | 764 | } |
765 | //qDebug("KOTodoView::updateView() %x", this); | 765 | //qDebug("KOTodoView::updateView() %x", this); |
766 | if ( isFlatDisplay ) { | 766 | if ( isFlatDisplay ) { |
767 | displayAllFlat(); | 767 | displayAllFlat(); |
768 | return; | 768 | return; |
769 | } | 769 | } |
770 | storeCurrentItem(); | 770 | storeCurrentItem(); |
771 | //qDebug("update "); | 771 | //qDebug("update "); |
772 | // kdDebug() << "KOTodoView::updateView()" << endl; | 772 | // kdDebug() << "KOTodoView::updateView()" << endl; |
773 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 773 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
774 | 774 | ||
775 | 775 | ||
776 | mTodoListView->clear(); | 776 | mTodoListView->clear(); |
777 | if ( mName == "todolistsmall" ) { | 777 | if ( mName == "todolistsmall" ) { |
778 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 778 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
779 | int ps = fo.pointSize() -2; | 779 | int ps = fo.pointSize() -2; |
780 | if ( ps > 12 ) | 780 | if ( ps > 12 ) |
781 | ps -= 2; | 781 | ps -= 2; |
782 | fo.setPointSize( ps ); | 782 | fo.setPointSize( ps ); |
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | mTodoListView->setFont( fo ); | 786 | mTodoListView->setFont( fo ); |
787 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 787 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
788 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 788 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
789 | QPtrList<Todo> todoList = calendar()->todos(); | 789 | QPtrList<Todo> todoList = calendar()->todos(); |
790 | 790 | ||
791 | /* | 791 | /* |
792 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 792 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
793 | Event *t; | 793 | Event *t; |
794 | for(t = todoList.first(); t; t = todoList.next()) { | 794 | for(t = todoList.first(); t; t = todoList.next()) { |
795 | kdDebug() << " " << t->getSummary() << endl; | 795 | kdDebug() << " " << t->getSummary() << endl; |
796 | 796 | ||
797 | if (t->getRelatedTo()) { | 797 | if (t->getRelatedTo()) { |
798 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 798 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
799 | } | 799 | } |
800 | 800 | ||
801 | QPtrList<Event> l = t->getRelations(); | 801 | QPtrList<Event> l = t->getRelations(); |
802 | Event *c; | 802 | Event *c; |
803 | for(c=l.first();c;c=l.next()) { | 803 | for(c=l.first();c;c=l.next()) { |
804 | kdDebug() << " - relation: " << c->getSummary() << endl; | 804 | kdDebug() << " - relation: " << c->getSummary() << endl; |
805 | } | 805 | } |
806 | } | 806 | } |
807 | */ | 807 | */ |
808 | 808 | ||
809 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 809 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
810 | // specific order of events. That means that we have to generate parent items | 810 | // specific order of events. That means that we have to generate parent items |
811 | // recursively for proper hierarchical display of Todos. | 811 | // recursively for proper hierarchical display of Todos. |
812 | mTodoMap.clear(); | 812 | mTodoMap.clear(); |
813 | Todo *todo; | 813 | Todo *todo; |
814 | todo = todoList.first();// todo; todo = todoList.next()) { | 814 | todo = todoList.first();// todo; todo = todoList.next()) { |
815 | while ( todo ) { | 815 | while ( todo ) { |
816 | bool next = true; | 816 | bool next = true; |
817 | // qDebug("todo %s ", todo->summary().latin1()); | 817 | // qDebug("todo %s ", todo->summary().latin1()); |
818 | Incidence *incidence = todo->relatedTo(); | 818 | Incidence *incidence = todo->relatedTo(); |
819 | while ( incidence ) { | 819 | while ( incidence ) { |
820 | if ( incidence->typeID() == todoID ) { | 820 | if ( incidence->typeID() == todoID ) { |
821 | //qDebug("related %s ",incidence->summary().latin1() ); | 821 | //qDebug("related %s ",incidence->summary().latin1() ); |
822 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 822 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
823 | //qDebug("related not found "); | 823 | //qDebug("related not found "); |
824 | todoList.remove( ); | 824 | todoList.remove( ); |
825 | todo = todoList.current(); | 825 | todo = todoList.current(); |
826 | next = false; | 826 | next = false; |
827 | incidence = 0; | 827 | incidence = 0; |
828 | 828 | ||
829 | } else { | 829 | } else { |
830 | //qDebug("related found "); | 830 | //qDebug("related found "); |
831 | incidence = incidence->relatedTo(); | 831 | incidence = incidence->relatedTo(); |
832 | } | 832 | } |
833 | } else | 833 | } else |
834 | incidence = 0; | 834 | incidence = 0; |
835 | } | 835 | } |
836 | if ( next ) | 836 | if ( next ) |
837 | todo = todoList.next(); | 837 | todo = todoList.next(); |
838 | } | 838 | } |
839 | 839 | ||
840 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 840 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
841 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 841 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
842 | { | 842 | { |
843 | insertTodoItem(todo); | 843 | insertTodoItem(todo); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | // Restore opened/closed state | 846 | // Restore opened/closed state |
847 | mTodoListView->blockSignals( true ); | 847 | mTodoListView->blockSignals( true ); |
848 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 848 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
849 | mTodoListView->blockSignals( false ); | 849 | mTodoListView->blockSignals( false ); |
850 | resetCurrentItem(); | 850 | resetCurrentItem(); |
851 | } | 851 | } |
852 | 852 | ||
853 | void KOTodoView::storeCurrentItem() | 853 | void KOTodoView::storeCurrentItem() |
854 | { | 854 | { |
855 | mCurItem = 0; | 855 | mCurItem = 0; |
856 | mCurItemRootParent = 0; | 856 | mCurItemRootParent = 0; |
857 | mCurItemParent = 0; | 857 | mCurItemParent = 0; |
858 | mCurItemAbove = 0; | 858 | mCurItemAbove = 0; |
859 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 859 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
860 | if (mActiveItem) { | 860 | if (mActiveItem) { |
861 | mCurItem = mActiveItem->todo(); | 861 | mCurItem = mActiveItem->todo(); |
862 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 862 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
863 | if ( activeItemAbove ) | 863 | if ( activeItemAbove ) |
864 | mCurItemAbove = activeItemAbove->todo(); | 864 | mCurItemAbove = activeItemAbove->todo(); |
865 | mCurItemRootParent = mCurItem; | 865 | mCurItemRootParent = mCurItem; |
866 | mCurItemParent = mCurItemRootParent->relatedTo(); | 866 | mCurItemParent = mCurItemRootParent->relatedTo(); |
867 | while ( mCurItemRootParent->relatedTo() != 0 ) | 867 | while ( mCurItemRootParent->relatedTo() != 0 ) |
868 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 868 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
869 | } | 869 | } |
870 | mActiveItem = 0; | 870 | mActiveItem = 0; |
871 | } | 871 | } |
872 | 872 | ||
873 | void KOTodoView::resetCurrentItem() | 873 | void KOTodoView::resetCurrentItem() |
874 | { | 874 | { |
875 | //mTodoListView->setFocus(); | 875 | //mTodoListView->setFocus(); |
876 | KOTodoViewItem* foundItem = 0; | 876 | KOTodoViewItem* foundItem = 0; |
877 | KOTodoViewItem* foundItemRoot = 0; | 877 | KOTodoViewItem* foundItemRoot = 0; |
878 | KOTodoViewItem* foundItemParent = 0; | 878 | KOTodoViewItem* foundItemParent = 0; |
879 | KOTodoViewItem* foundItemAbove = 0; | 879 | KOTodoViewItem* foundItemAbove = 0; |
880 | if ( mTodoListView->firstChild () ) { | 880 | if ( mTodoListView->firstChild () ) { |
881 | if ( mCurItem ) { | 881 | if ( mCurItem ) { |
882 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 882 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
883 | while ( item ) { | 883 | while ( item ) { |
884 | if ( item->todo() == mCurItem ) { | 884 | if ( item->todo() == mCurItem ) { |
885 | foundItem = item; | 885 | foundItem = item; |
886 | break; | 886 | break; |
887 | } else if ( item->todo() == mCurItemAbove ) { | 887 | } else if ( item->todo() == mCurItemAbove ) { |
888 | foundItemAbove = item; | 888 | foundItemAbove = item; |
889 | 889 | ||
890 | } | 890 | } |
891 | if ( item->todo() == mCurItemRootParent ) { | 891 | if ( item->todo() == mCurItemRootParent ) { |
892 | foundItemRoot = item; | 892 | foundItemRoot = item; |
893 | } | 893 | } |
894 | if ( item->todo() == mCurItemParent ) { | 894 | if ( item->todo() == mCurItemParent ) { |
895 | foundItemParent = item; | 895 | foundItemParent = item; |
896 | } | 896 | } |
897 | item = (KOTodoViewItem*)item->itemBelow(); | 897 | item = (KOTodoViewItem*)item->itemBelow(); |
898 | } | 898 | } |
899 | if ( ! foundItem ) { | 899 | if ( ! foundItem ) { |
900 | if ( foundItemParent ) { | 900 | if ( foundItemParent ) { |
901 | foundItem = foundItemParent; | 901 | foundItem = foundItemParent; |
902 | } else { | 902 | } else { |
903 | if ( foundItemRoot ) | 903 | if ( foundItemRoot ) |
904 | foundItem = foundItemRoot; | 904 | foundItem = foundItemRoot; |
905 | else | 905 | else |
906 | foundItem = foundItemAbove; | 906 | foundItem = foundItemAbove; |
907 | } | 907 | } |
908 | } | 908 | } |
909 | } | 909 | } |
910 | if ( foundItem ) { | 910 | if ( foundItem ) { |
911 | mTodoListView->setSelected ( foundItem, true ); | 911 | mTodoListView->setSelected ( foundItem, true ); |
912 | mTodoListView->setCurrentItem( foundItem ); | 912 | mTodoListView->setCurrentItem( foundItem ); |
913 | mTodoListView->ensureItemVisible( foundItem ); | 913 | mTodoListView->ensureItemVisible( foundItem ); |
914 | } else { | 914 | } else { |
915 | if ( mTodoListView->firstChild () ) { | 915 | if ( mTodoListView->firstChild () ) { |
916 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 916 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
917 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 917 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
918 | } | 918 | } |
919 | } | 919 | } |
920 | } | 920 | } |
921 | processSelectionChange(); | 921 | processSelectionChange(); |
922 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 922 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
923 | } | 923 | } |
924 | void KOTodoView::resetFocusToList() | 924 | void KOTodoView::resetFocusToList() |
925 | { | 925 | { |
926 | topLevelWidget()->setActiveWindow(); | 926 | topLevelWidget()->setActiveWindow(); |
927 | mTodoListView->setFocus(); | 927 | mTodoListView->setFocus(); |
928 | } | 928 | } |
929 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 929 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
930 | bool KOTodoView::checkTodo( Todo * todo ) | 930 | bool KOTodoView::checkTodo( Todo * todo ) |
931 | { | 931 | { |
932 | 932 | ||
933 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 933 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
934 | return false; | 934 | return false; |
935 | if ( !todo->isCompleted() ) { | 935 | if ( !todo->isCompleted() ) { |
936 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 936 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
937 | return true; | 937 | return true; |
938 | } | 938 | } |
939 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 939 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
940 | if ( todo->hasStartDate() ) | 940 | if ( todo->hasStartDate() ) |
941 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 941 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
942 | return false; | 942 | return false; |
943 | if ( todo->hasDueDate() ) | 943 | if ( todo->hasDueDate() ) |
944 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 944 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
945 | return false; | 945 | return false; |
946 | } | 946 | } |
947 | return true; | 947 | return true; |
948 | } | 948 | } |
949 | 949 | ||
950 | void KOTodoView::restoreItemState( QListViewItem *item ) | 950 | void KOTodoView::restoreItemState( QListViewItem *item ) |
951 | { | 951 | { |
952 | pendingSubtodo = 0; | 952 | pendingSubtodo = 0; |
953 | while( item ) { | 953 | while( item ) { |
954 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 954 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
955 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 955 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
956 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 956 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
957 | item = item->nextSibling(); | 957 | item = item->nextSibling(); |
958 | } | 958 | } |
959 | } | 959 | } |
960 | 960 | ||
961 | 961 | ||
962 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 962 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
963 | KOTodoView::insertTodoItem(Todo *todo) | 963 | KOTodoView::insertTodoItem(Todo *todo) |
964 | { | 964 | { |
965 | 965 | ||
966 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 966 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
967 | // TODO: Check, if dynmaic cast is necessary | 967 | // TODO: Check, if dynmaic cast is necessary |
968 | 968 | ||
969 | pendingSubtodo = 0; | 969 | pendingSubtodo = 0; |
970 | Incidence *incidence = todo->relatedTo(); | 970 | Incidence *incidence = todo->relatedTo(); |
971 | while ( incidence && !incidence->calEnabled() ) | 971 | while ( incidence && !incidence->calEnabled() ) |
972 | incidence = incidence->relatedTo(); | 972 | incidence = incidence->relatedTo(); |