-rw-r--r-- | korganizer/kotodoview.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 82c0f4c..00c2d97 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -321,193 +321,193 @@ 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 ( !isVisible() ) { | 405 | if ( !isVisible() ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 411 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | if (! e->isAutoRepeat() ) | 414 | if (! e->isAutoRepeat() ) |
415 | mFlagKeyPressed = true; | 415 | mFlagKeyPressed = true; |
416 | QListViewItem* cn; | 416 | QListViewItem* cn; |
417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 417 | if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { |
418 | cn = currentItem(); | 418 | cn = currentItem(); |
419 | if ( cn ) { | 419 | if ( cn ) { |
420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
421 | if ( ci ){ | 421 | if ( ci ){ |
422 | if ( e->state() == ShiftButton ) | 422 | if ( e->state() == ShiftButton ) |
423 | ci->setOn( false ); | 423 | ci->setOn( false ); |
424 | else | 424 | else |
425 | ci->setOn( true ); | 425 | ci->setOn( true ); |
426 | cn = cn->itemBelow(); | 426 | cn = cn->itemBelow(); |
427 | if ( cn ) { | 427 | if ( cn ) { |
428 | setCurrentItem ( cn ); | 428 | setCurrentItem ( cn ); |
429 | ensureItemVisible ( cn ); | 429 | ensureItemVisible ( cn ); |
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | e->accept(); | 435 | e->accept(); |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | 438 | ||
439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
440 | switch ( e->key() ) { | 440 | switch ( e->key() ) { |
441 | case Qt::Key_Down: | 441 | case Qt::Key_Down: |
442 | case Qt::Key_Up: | 442 | case Qt::Key_Up: |
443 | QListView::keyPressEvent ( e ); | 443 | QListView::keyPressEvent ( e ); |
444 | e->accept(); | 444 | e->accept(); |
445 | break; | 445 | break; |
446 | case Qt::Key_Left: | 446 | case Qt::Key_Left: |
447 | case Qt::Key_Right: | 447 | case Qt::Key_Right: |
448 | QListView::keyPressEvent ( e ); | 448 | QListView::keyPressEvent ( e ); |
449 | e->accept(); | 449 | e->accept(); |
450 | return; | 450 | return; |
451 | break; | 451 | break; |
452 | default: | 452 | default: |
453 | e->ignore(); | 453 | e->ignore(); |
454 | break; | 454 | break; |
455 | } | 455 | } |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | e->ignore(); | 458 | e->ignore(); |
459 | } | 459 | } |
460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | QListView::contentsMouseReleaseEvent(e); | 462 | QListView::contentsMouseReleaseEvent(e); |
463 | mMousePressed = false; | 463 | mMousePressed = false; |
464 | } | 464 | } |
465 | 465 | ||
466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
467 | { | 467 | { |
468 | if (!e) return; | 468 | if (!e) return; |
469 | 469 | ||
470 | QPoint vp = contentsToViewport(e->pos()); | 470 | QPoint vp = contentsToViewport(e->pos()); |
471 | 471 | ||
472 | QListViewItem *item = itemAt(vp); | 472 | QListViewItem *item = itemAt(vp); |
473 | 473 | ||
474 | emit double_Clicked(item); | 474 | emit double_Clicked(item); |
475 | if (!item) return; | 475 | if (!item) return; |
476 | 476 | ||
477 | emit doubleClicked(item,vp,0); | 477 | emit doubleClicked(item,vp,0); |
478 | } | 478 | } |
479 | 479 | ||
480 | ///////////////////////////////////////////////////////////////////////////// | 480 | ///////////////////////////////////////////////////////////////////////////// |
481 | 481 | ||
482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
483 | QLineEdit(parent) | 483 | QLineEdit(parent) |
484 | { | 484 | { |
485 | setText(i18n("Click to add new Todo")); | 485 | setText(i18n("Click to add new Todo")); |
486 | } | 486 | } |
487 | 487 | ||
488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
489 | { | 489 | { |
490 | if ( text()==i18n("Click to add new Todo") ) | 490 | if ( text()==i18n("Click to add new Todo") ) |
491 | setText(""); | 491 | setText(""); |
492 | QLineEdit::focusInEvent(ev); | 492 | QLineEdit::focusInEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
496 | { | 496 | { |
497 | setText(i18n("Click to add new Todo")); | 497 | setText(i18n("Click to add new Todo")); |
498 | QLineEdit::focusOutEvent(ev); | 498 | QLineEdit::focusOutEvent(ev); |
499 | } | 499 | } |
500 | 500 | ||
501 | ///////////////////////////////////////////////////////////////////////////// | 501 | ///////////////////////////////////////////////////////////////////////////// |
502 | 502 | ||
503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
504 | KOrg::BaseView(calendar,parent,name) | 504 | KOrg::BaseView(calendar,parent,name) |
505 | { | 505 | { |
506 | mCategoryPopupMenu = 0; | 506 | mCategoryPopupMenu = 0; |
507 | mPendingUpdateBeforeRepaint = false; | 507 | mPendingUpdateBeforeRepaint = false; |
508 | isFlatDisplay = false; | 508 | isFlatDisplay = false; |
509 | mNavigator = 0; | 509 | mNavigator = 0; |
510 | QBoxLayout *topLayout = new QVBoxLayout(this); | 510 | QBoxLayout *topLayout = new QVBoxLayout(this); |
511 | mName = QString ( name ); | 511 | mName = QString ( name ); |
512 | mBlockUpdate = false; | 512 | mBlockUpdate = false; |
513 | mQuickBar = new QWidget( this ); | 513 | mQuickBar = new QWidget( this ); |
@@ -1599,126 +1599,123 @@ void KOTodoView::addQuickTodoPar( Todo * parentTodo) | |||
1599 | } else { | 1599 | } else { |
1600 | CalFilter * cf = mCalendar->filter(); | 1600 | CalFilter * cf = mCalendar->filter(); |
1601 | if ( cf ) { | 1601 | if ( cf ) { |
1602 | if ( cf->isEnabled()&& cf->showCategories()) { | 1602 | if ( cf->isEnabled()&& cf->showCategories()) { |
1603 | todo->setCategories(cf->categoryList()); | 1603 | todo->setCategories(cf->categoryList()); |
1604 | } | 1604 | } |
1605 | if ( cf->isEnabled() ) | 1605 | if ( cf->isEnabled() ) |
1606 | todo->setSecrecy( cf->getSecrecy()); | 1606 | todo->setSecrecy( cf->getSecrecy()); |
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | mCalendar->addTodo(todo); | 1609 | mCalendar->addTodo(todo); |
1610 | mQuickAdd->setText(""); | 1610 | mQuickAdd->setText(""); |
1611 | todoModified (todo, KOGlobals::EVENTADDED ); | 1611 | todoModified (todo, KOGlobals::EVENTADDED ); |
1612 | updateView(); | 1612 | updateView(); |
1613 | 1613 | ||
1614 | } | 1614 | } |
1615 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1615 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1616 | { | 1616 | { |
1617 | // e->ignore(); | 1617 | // e->ignore(); |
1618 | //return; | 1618 | //return; |
1619 | if ( !isVisible() ) { | 1619 | if ( !isVisible() ) { |
1620 | e->ignore(); | 1620 | e->ignore(); |
1621 | return; | 1621 | return; |
1622 | } | 1622 | } |
1623 | switch ( e->key() ) { | 1623 | switch ( e->key() ) { |
1624 | case Qt::Key_Down: | 1624 | case Qt::Key_Down: |
1625 | case Qt::Key_Up: | 1625 | case Qt::Key_Up: |
1626 | // KOrg::BaseView::keyPressEvent ( e ); | 1626 | // KOrg::BaseView::keyPressEvent ( e ); |
1627 | e->ignore(); | 1627 | e->ignore(); |
1628 | break; | 1628 | break; |
1629 | 1629 | ||
1630 | case Qt::Key_Q: | 1630 | case Qt::Key_Q: |
1631 | 1631 | ||
1632 | 1632 | ||
1633 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { | 1633 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { |
1634 | e->ignore(); | 1634 | e->ignore(); |
1635 | break; | 1635 | break; |
1636 | } | 1636 | } |
1637 | toggleQuickTodo(); | 1637 | toggleQuickTodo(); |
1638 | break; | 1638 | break; |
1639 | case Qt::Key_U: | 1639 | case Qt::Key_U: |
1640 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1640 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1641 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1641 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1642 | unparentTodo(); | 1642 | unparentTodo(); |
1643 | e->accept(); | 1643 | e->accept(); |
1644 | } else | 1644 | } else |
1645 | e->ignore(); | 1645 | e->ignore(); |
1646 | break; | 1646 | break; |
1647 | case Qt::Key_S: | 1647 | case Qt::Key_S: |
1648 | if ( e->state() == Qt::ControlButton ) { | 1648 | if ( e->state() == Qt::ControlButton ) { |
1649 | e->ignore(); | 1649 | e->ignore(); |
1650 | break; | 1650 | break; |
1651 | } | 1651 | } |
1652 | if ( e->state() == Qt::ShiftButton ) { | 1652 | if ( e->state() == Qt::ShiftButton ) { |
1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1654 | reparentTodo(); | 1654 | reparentTodo(); |
1655 | e->accept(); | 1655 | e->accept(); |
1656 | } else | 1656 | } else |
1657 | e->ignore(); | 1657 | e->ignore(); |
1658 | break; | 1658 | break; |
1659 | case Qt::Key_P: | 1659 | case Qt::Key_P: |
1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1662 | if ( pendingSubtodo ) | 1662 | if ( pendingSubtodo ) |
1663 | itemClicked(mActiveItem); | 1663 | itemClicked(mActiveItem); |
1664 | e->accept(); | 1664 | e->accept(); |
1665 | } else | 1665 | } else |
1666 | e->ignore(); | 1666 | e->ignore(); |
1667 | break; | 1667 | break; |
1668 | case Qt::Key_Escape: | 1668 | case Qt::Key_Escape: |
1669 | if ( pendingSubtodo ) { | 1669 | if ( pendingSubtodo ) { |
1670 | itemClicked(0); | 1670 | itemClicked(0); |
1671 | e->accept(); | 1671 | e->accept(); |
1672 | } else | 1672 | } else |
1673 | e->ignore(); | 1673 | e->ignore(); |
1674 | break; | 1674 | break; |
1675 | default: | 1675 | default: |
1676 | e->ignore(); | 1676 | e->ignore(); |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | if ( true ) { | 1679 | if ( true ) { |
1680 | if ( e->key() == Qt::Key_I ) { | 1680 | if ( e->key() == Qt::Key_I ) { |
1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1682 | if ( cn ) { | 1682 | if ( cn ) { |
1683 | mActiveItem = cn; | 1683 | mActiveItem = cn; |
1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1685 | if ( ci ){ | 1685 | if ( ci ){ |
1686 | showTodo(); | 1686 | showTodo(); |
1687 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1687 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1688 | if ( cn ) { | 1688 | if ( cn ) { |
1689 | mTodoListView->setCurrentItem ( cn ); | 1689 | mTodoListView->setCurrentItem ( cn ); |
1690 | mTodoListView->ensureItemVisible ( cn ); | 1690 | mTodoListView->ensureItemVisible ( cn ); |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | } | 1693 | } |
1694 | } | 1694 | } |
1695 | e->accept(); | 1695 | e->accept(); |
1696 | |||
1697 | } | 1696 | } |
1698 | |||
1699 | } | 1697 | } |
1700 | |||
1701 | } | 1698 | } |
1702 | void KOTodoView::updateTodo( Todo * t, int type ) | 1699 | void KOTodoView::updateTodo( Todo * t, int type ) |
1703 | { | 1700 | { |
1704 | if ( mBlockUpdate) | 1701 | if ( mBlockUpdate) |
1705 | return; | 1702 | return; |
1706 | 1703 | ||
1707 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1704 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1708 | itemIterator = mTodoMap.find(t); | 1705 | itemIterator = mTodoMap.find(t); |
1709 | if (itemIterator != mTodoMap.end()) { | 1706 | if (itemIterator != mTodoMap.end()) { |
1710 | (*itemIterator)->construct(); | 1707 | (*itemIterator)->construct(); |
1711 | } else { | 1708 | } else { |
1712 | if ( type == KOGlobals::EVENTADDED ) { | 1709 | if ( type == KOGlobals::EVENTADDED ) { |
1713 | insertTodoItem( t ); | 1710 | insertTodoItem( t ); |
1714 | } | 1711 | } |
1715 | } | 1712 | } |
1716 | 1713 | ||
1717 | } | 1714 | } |
1718 | 1715 | ||
1719 | void KOTodoView::todoModified(Todo * t , int p ) | 1716 | void KOTodoView::todoModified(Todo * t , int p ) |
1720 | { | 1717 | { |
1721 | mBlockUpdate = true; | 1718 | mBlockUpdate = true; |
1722 | emit todoModifiedSignal ( t, p ); | 1719 | emit todoModifiedSignal ( t, p ); |
1723 | mBlockUpdate = false; | 1720 | mBlockUpdate = false; |
1724 | } | 1721 | } |