summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp17
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
@@ -188,49 +188,53 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
188} 188}
189 189
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 190void 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 212void KOTodoListView::paintEvent(QPaintEvent* e)
213{
214 emit paintNeeded();
215 QListView::paintEvent( e);
216}
213void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 217void 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 ) {
@@ -480,90 +484,99 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
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
525KOTodoView::~KOTodoView() 531KOTodoView::~KOTodoView()
526{ 532{
527 delete mDocPrefs; 533 delete mDocPrefs;
528} 534}
529 535
530void KOTodoView::jumpToDate () 536void 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}
543void KOTodoView::paintNeeded()
544{
545 if ( mPendingUpdateBeforeRepaint ) {
546 updateView();
547 mPendingUpdateBeforeRepaint = false;
548 }
549}
537void KOTodoView::paintEvent(QPaintEvent * pevent) 550void 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
546void KOTodoView::updateView() 559void 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;