-rw-r--r-- | korganizer/kotodoview.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 82437d8..99402c4 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -164,97 +164,101 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
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 | void KOTodoListView::paintEvent(QPaintEvent* e) | |
213 | { | ||
214 | emit paintNeeded(); | ||
215 | QListView::paintEvent( e); | ||
216 | } | ||
213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 217 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
214 | { | 218 | { |
215 | 219 | ||
216 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
217 | QListView::contentsMouseMoveEvent(e); | 221 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 222 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 223 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 224 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 225 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 226 | if (item) { |
223 | DndFactory factory( mCalendar ); | 227 | DndFactory factory( mCalendar ); |
224 | ICalDrag *vd = factory.createDrag( | 228 | ICalDrag *vd = factory.createDrag( |
225 | ((KOTodoViewItem *)item)->todo(),viewport()); | 229 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | internalDrop = false; | 230 | internalDrop = false; |
227 | // we cannot do any senseful here, because the DnD is still broken in Qt | 231 | // we cannot do any senseful here, because the DnD is still broken in Qt |
228 | if (vd->drag()) { | 232 | if (vd->drag()) { |
229 | if ( !internalDrop ) { | 233 | if ( !internalDrop ) { |
230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 234 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
231 | qDebug("Dnd: External move: Delete drag source "); | 235 | qDebug("Dnd: External move: Delete drag source "); |
232 | } else | 236 | } else |
233 | qDebug("Dnd: Internal move "); | 237 | qDebug("Dnd: Internal move "); |
234 | 238 | ||
235 | } else { | 239 | } else { |
236 | if ( !internalDrop ) { | 240 | if ( !internalDrop ) { |
237 | qDebug("Dnd: External Copy"); | 241 | qDebug("Dnd: External Copy"); |
238 | } else | 242 | } else |
239 | qDebug("DnD: Internal copy: Copy pending"); | 243 | qDebug("DnD: Internal copy: Copy pending"); |
240 | } | 244 | } |
241 | } | 245 | } |
242 | } | 246 | } |
243 | #endif | 247 | #endif |
244 | } | 248 | } |
245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 249 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
246 | { | 250 | { |
247 | 251 | ||
248 | QListViewItem* cn; | 252 | QListViewItem* cn; |
249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 253 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
250 | cn = currentItem(); | 254 | cn = currentItem(); |
251 | if ( cn ) { | 255 | if ( cn ) { |
252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 256 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
253 | if ( ci ){ | 257 | if ( ci ){ |
254 | if ( e->state() == ShiftButton ) | 258 | if ( e->state() == ShiftButton ) |
255 | ci->setOn( false ); | 259 | ci->setOn( false ); |
256 | else | 260 | else |
257 | ci->setOn( true ); | 261 | ci->setOn( true ); |
258 | cn = cn->itemBelow(); | 262 | cn = cn->itemBelow(); |
259 | if ( cn ) { | 263 | if ( cn ) { |
260 | setCurrentItem ( cn ); | 264 | setCurrentItem ( cn ); |
@@ -456,138 +460,147 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
456 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 460 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
457 | this, SLOT( toggleRunning() ),0,5 ); | 461 | this, SLOT( toggleRunning() ),0,5 ); |
458 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 462 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
459 | this, SLOT( setAllOpen() ),0,6 ); | 463 | this, SLOT( setAllOpen() ),0,6 ); |
460 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 464 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
461 | this, SLOT( setAllClose() ),0,7 ); | 465 | this, SLOT( setAllClose() ),0,7 ); |
462 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 466 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
463 | this, SLOT( setAllFlat() ),0,8 ); | 467 | this, SLOT( setAllFlat() ),0,8 ); |
464 | mDocPrefs = new DocPrefs( name ); | 468 | mDocPrefs = new DocPrefs( name ); |
465 | 469 | ||
466 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 470 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
467 | mPopupMenu->setCheckable( true ); | 471 | mPopupMenu->setCheckable( true ); |
468 | mItemPopupMenu->setCheckable( true ); | 472 | mItemPopupMenu->setCheckable( true ); |
469 | 473 | ||
470 | 474 | ||
471 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 475 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
472 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 476 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
473 | 477 | ||
474 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 478 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
475 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 479 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
476 | 480 | ||
477 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 481 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
478 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 482 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
479 | 483 | ||
480 | 484 | ||
481 | // Double clicking conflicts with opening/closing the subtree | 485 | // Double clicking conflicts with opening/closing the subtree |
482 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 486 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
483 | SLOT( editItem( QListViewItem *) ) ); | 487 | SLOT( editItem( QListViewItem *) ) ); |
484 | /* | 488 | /* |
485 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 489 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
486 | const QPoint &,int ) ), | 490 | const QPoint &,int ) ), |
487 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 491 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
488 | */ | 492 | */ |
489 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 493 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
490 | const QPoint &,int ) ), | 494 | const QPoint &,int ) ), |
491 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 495 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
492 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 496 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
493 | SLOT( itemClicked( QListViewItem * ) ) ); | 497 | SLOT( itemClicked( QListViewItem * ) ) ); |
494 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 498 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
495 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 499 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
496 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 500 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
497 | SLOT( updateView() ) ); | 501 | SLOT( updateView() ) ); |
498 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 502 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
499 | SLOT( todoModified(Todo *, int) ) ); | 503 | SLOT( todoModified(Todo *, int) ) ); |
500 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 504 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
501 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 505 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
502 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 506 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
503 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 507 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
508 | connect( mTodoListView, SIGNAL( paintNeeded() ), | ||
509 | SLOT( paintNeeded()) ); | ||
504 | 510 | ||
505 | #if 0 | 511 | #if 0 |
506 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 512 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
507 | SLOT(selectionChanged(QListViewItem *))); | 513 | SLOT(selectionChanged(QListViewItem *))); |
508 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 514 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
509 | SLOT(selectionChanged(QListViewItem *))); | 515 | SLOT(selectionChanged(QListViewItem *))); |
510 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 516 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
511 | SLOT(selectionChanged(QListViewItem *))); | 517 | SLOT(selectionChanged(QListViewItem *))); |
512 | #endif | 518 | #endif |
513 | 519 | ||
514 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 520 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
515 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 521 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
516 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 522 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
517 | 523 | ||
518 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 524 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
519 | SLOT( processSelectionChange() ) ); | 525 | SLOT( processSelectionChange() ) ); |
520 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 526 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
521 | SLOT( addQuickTodo() ) ); | 527 | SLOT( addQuickTodo() ) ); |
522 | 528 | ||
523 | } | 529 | } |
524 | 530 | ||
525 | KOTodoView::~KOTodoView() | 531 | KOTodoView::~KOTodoView() |
526 | { | 532 | { |
527 | delete mDocPrefs; | 533 | delete mDocPrefs; |
528 | } | 534 | } |
529 | 535 | ||
530 | void KOTodoView::jumpToDate () | 536 | void KOTodoView::jumpToDate () |
531 | { | 537 | { |
532 | // if (mActiveItem) { | 538 | // if (mActiveItem) { |
533 | // mActiveItem->todo()); | 539 | // mActiveItem->todo()); |
534 | // if ( mActiveItem->todo()->hasDueDate() ) | 540 | // if ( mActiveItem->todo()->hasDueDate() ) |
535 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 541 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
536 | } | 542 | } |
543 | void KOTodoView::paintNeeded() | ||
544 | { | ||
545 | if ( mPendingUpdateBeforeRepaint ) { | ||
546 | updateView(); | ||
547 | mPendingUpdateBeforeRepaint = false; | ||
548 | } | ||
549 | } | ||
537 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 550 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
538 | { | 551 | { |
539 | if ( mPendingUpdateBeforeRepaint ) { | 552 | if ( mPendingUpdateBeforeRepaint ) { |
540 | updateView(); | 553 | updateView(); |
541 | mPendingUpdateBeforeRepaint = false; | 554 | mPendingUpdateBeforeRepaint = false; |
542 | } | 555 | } |
543 | KOrg::BaseView::paintEvent( pevent); | 556 | KOrg::BaseView::paintEvent( pevent); |
544 | } | 557 | } |
545 | bool mPendingUpdateBeforeRepaint; | 558 | |
546 | void KOTodoView::updateView() | 559 | void KOTodoView::updateView() |
547 | { | 560 | { |
548 | pendingSubtodo = 0; | 561 | pendingSubtodo = 0; |
549 | if ( mBlockUpdate ) { | 562 | if ( mBlockUpdate ) { |
550 | return; | 563 | return; |
551 | } | 564 | } |
552 | if ( !isVisible() ) { | 565 | if ( !isVisible() ) { |
553 | mPendingUpdateBeforeRepaint = true; | 566 | mPendingUpdateBeforeRepaint = true; |
554 | return; | 567 | return; |
555 | } | 568 | } |
556 | //qDebug("KOTodoView::updateView() %x", this); | 569 | //qDebug("KOTodoView::updateView() %x", this); |
557 | if ( isFlatDisplay ) { | 570 | if ( isFlatDisplay ) { |
558 | setAllFlat(); | 571 | setAllFlat(); |
559 | return; | 572 | return; |
560 | } | 573 | } |
561 | //qDebug("update "); | 574 | //qDebug("update "); |
562 | // kdDebug() << "KOTodoView::updateView()" << endl; | 575 | // kdDebug() << "KOTodoView::updateView()" << endl; |
563 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 576 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
564 | mTodoListView->clear(); | 577 | mTodoListView->clear(); |
565 | if ( mName == "todolistsmall" ) { | 578 | if ( mName == "todolistsmall" ) { |
566 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 579 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
567 | int ps = fo.pointSize() -2; | 580 | int ps = fo.pointSize() -2; |
568 | if ( ps > 12 ) | 581 | if ( ps > 12 ) |
569 | ps -= 2; | 582 | ps -= 2; |
570 | fo.setPointSize( ps ); | 583 | fo.setPointSize( ps ); |
571 | } | 584 | } |
572 | } | 585 | } |
573 | 586 | ||
574 | mTodoListView->setFont( fo ); | 587 | mTodoListView->setFont( fo ); |
575 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 588 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
576 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 589 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
577 | QPtrList<Todo> todoList = calendar()->todos(); | 590 | QPtrList<Todo> todoList = calendar()->todos(); |
578 | 591 | ||
579 | /* | 592 | /* |
580 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 593 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
581 | Event *t; | 594 | Event *t; |
582 | for(t = todoList.first(); t; t = todoList.next()) { | 595 | for(t = todoList.first(); t; t = todoList.next()) { |
583 | kdDebug() << " " << t->getSummary() << endl; | 596 | kdDebug() << " " << t->getSummary() << endl; |
584 | 597 | ||
585 | if (t->getRelatedTo()) { | 598 | if (t->getRelatedTo()) { |
586 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 599 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
587 | } | 600 | } |
588 | 601 | ||
589 | QPtrList<Event> l = t->getRelations(); | 602 | QPtrList<Event> l = t->getRelations(); |
590 | Event *c; | 603 | Event *c; |
591 | for(c=l.first();c;c=l.next()) { | 604 | for(c=l.first();c;c=l.next()) { |
592 | kdDebug() << " - relation: " << c->getSummary() << endl; | 605 | kdDebug() << " - relation: " << c->getSummary() << endl; |
593 | } | 606 | } |