author | zecke <zecke> | 2003-03-14 08:20:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-03-14 08:20:59 (UTC) |
commit | 7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4 (patch) (unidiff) | |
tree | 9d8cb73a1b6013ab409b496cf2b99503f239c0c9 | |
parent | 08094624777d78bcd09f6ba6e2157599960ef7f3 (diff) | |
download | opie-7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4.zip opie-7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4.tar.gz opie-7e04934c4b7b9f8ad0d74d2da1c7c1273d9fe1d4.tar.bz2 |
Do not crash when trying to edit and there is no data
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 7810285..58981ca 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -441,378 +441,379 @@ void MainWindow::slotDelete() { | |||
441 | QMessageBox::warning(this, QWidget::tr("Todo"), | 441 | QMessageBox::warning(this, QWidget::tr("Todo"), |
442 | QWidget::tr("Can not edit data, currently syncing")); | 442 | QWidget::tr("Can not edit data, currently syncing")); |
443 | return; | 443 | return; |
444 | } | 444 | } |
445 | QString strName = currentView()->currentRepresentation(); | 445 | QString strName = currentView()->currentRepresentation(); |
446 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 446 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
447 | return; | 447 | return; |
448 | 448 | ||
449 | m_todoMgr.remove( currentView()->current() ); | 449 | m_todoMgr.remove( currentView()->current() ); |
450 | currentView()->removeEvent( currentView()->current() ); | 450 | currentView()->removeEvent( currentView()->current() ); |
451 | raiseCurrentView(); | 451 | raiseCurrentView(); |
452 | } | 452 | } |
453 | void MainWindow::slotDeleteAll() { | 453 | void MainWindow::slotDeleteAll() { |
454 | if(m_syncing) { | 454 | if(m_syncing) { |
455 | QMessageBox::warning(this, QWidget::tr("Todo"), | 455 | QMessageBox::warning(this, QWidget::tr("Todo"), |
456 | QWidget::tr("Can not edit data, currently syncing")); | 456 | QWidget::tr("Can not edit data, currently syncing")); |
457 | return; | 457 | return; |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 461 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
462 | return; | 462 | return; |
463 | 463 | ||
464 | m_todoMgr.removeAll(); | 464 | m_todoMgr.removeAll(); |
465 | currentView()->clear(); | 465 | currentView()->clear(); |
466 | 466 | ||
467 | raiseCurrentView(); | 467 | raiseCurrentView(); |
468 | } | 468 | } |
469 | void MainWindow::slotDeleteCompleted() { | 469 | void MainWindow::slotDeleteCompleted() { |
470 | if(m_syncing) { | 470 | if(m_syncing) { |
471 | QMessageBox::warning(this, QWidget::tr("Todo"), | 471 | QMessageBox::warning(this, QWidget::tr("Todo"), |
472 | QWidget::tr("Can not edit data, currently syncing")); | 472 | QWidget::tr("Can not edit data, currently syncing")); |
473 | return; | 473 | return; |
474 | } | 474 | } |
475 | 475 | ||
476 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 476 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
477 | return; | 477 | return; |
478 | 478 | ||
479 | 479 | ||
480 | m_todoMgr.removeCompleted(); | 480 | m_todoMgr.removeCompleted(); |
481 | currentView()->updateView( ); | 481 | currentView()->updateView( ); |
482 | } | 482 | } |
483 | void MainWindow::slotFind() { | 483 | void MainWindow::slotFind() { |
484 | 484 | ||
485 | } | 485 | } |
486 | void MainWindow::slotEdit() { | 486 | void MainWindow::slotEdit() { |
487 | slotEdit( currentView()->current() ); | 487 | slotEdit( currentView()->current() ); |
488 | } | 488 | } |
489 | /* | 489 | /* |
490 | * set the category | 490 | * set the category |
491 | */ | 491 | */ |
492 | void MainWindow::setCategory( int c) { | 492 | void MainWindow::setCategory( int c) { |
493 | if ( c <= 0 ) return; | 493 | if ( c <= 0 ) return; |
494 | 494 | ||
495 | 495 | ||
496 | qWarning("Iterating over cats %d", c ); | 496 | qWarning("Iterating over cats %d", c ); |
497 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 497 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
498 | m_catMenu->setItemChecked(i, c == (int)i ); | 498 | m_catMenu->setItemChecked(i, c == (int)i ); |
499 | 499 | ||
500 | if (c == 1 ) { | 500 | if (c == 1 ) { |
501 | m_curCat = QString::null; | 501 | m_curCat = QString::null; |
502 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 502 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); |
503 | 503 | ||
504 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 504 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
505 | m_curCat = QWidget::tr("Unfiled"); | 505 | m_curCat = QWidget::tr("Unfiled"); |
506 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | 506 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); |
507 | }else { | 507 | }else { |
508 | m_curCat = m_todoMgr.categories()[c-2]; | 508 | m_curCat = m_todoMgr.categories()[c-2]; |
509 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | 509 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); |
510 | } | 510 | } |
511 | m_catMenu->setItemChecked( c, true ); | 511 | m_catMenu->setItemChecked( c, true ); |
512 | 512 | ||
513 | currentView()->setShowCategory( m_curCat ); | 513 | currentView()->setShowCategory( m_curCat ); |
514 | raiseCurrentView(); | 514 | raiseCurrentView(); |
515 | } | 515 | } |
516 | void MainWindow::slotShowDeadLine( bool dead) { | 516 | void MainWindow::slotShowDeadLine( bool dead) { |
517 | m_deadline = dead; | 517 | m_deadline = dead; |
518 | currentView()->setShowDeadline( dead ); | 518 | currentView()->setShowDeadline( dead ); |
519 | } | 519 | } |
520 | void MainWindow::slotShowCompleted( bool show) { | 520 | void MainWindow::slotShowCompleted( bool show) { |
521 | m_completed = show; | 521 | m_completed = show; |
522 | currentView()->setShowCompleted( m_completed ); | 522 | currentView()->setShowCompleted( m_completed ); |
523 | } | 523 | } |
524 | void MainWindow::slotShowQuickTask( bool show ) { | 524 | void MainWindow::slotShowQuickTask( bool show ) { |
525 | m_quicktask = show; | 525 | m_quicktask = show; |
526 | if ( m_quicktask ) | 526 | if ( m_quicktask ) |
527 | m_curQuick->widget()->show(); | 527 | m_curQuick->widget()->show(); |
528 | else | 528 | else |
529 | m_curQuick->widget()->hide(); | 529 | m_curQuick->widget()->hide(); |
530 | } | 530 | } |
531 | bool MainWindow::showOverDue()const { | 531 | bool MainWindow::showOverDue()const { |
532 | return m_overdue; | 532 | return m_overdue; |
533 | } | 533 | } |
534 | void MainWindow::setDocument( const QString& fi) { | 534 | void MainWindow::setDocument( const QString& fi) { |
535 | DocLnk doc(fi); | 535 | DocLnk doc(fi); |
536 | if (doc.isValid() ) | 536 | if (doc.isValid() ) |
537 | receiveFile(doc.file() ); | 537 | receiveFile(doc.file() ); |
538 | else | 538 | else |
539 | receiveFile(fi ); | 539 | receiveFile(fi ); |
540 | } | 540 | } |
541 | 541 | ||
542 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 542 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
543 | void MainWindow::slotBeam() { | 543 | void MainWindow::slotBeam() { |
544 | beam( currentView()->current() ); | 544 | beam( currentView()->current() ); |
545 | } | 545 | } |
546 | void MainWindow::beamDone( Ir* ir) { | 546 | void MainWindow::beamDone( Ir* ir) { |
547 | delete ir; | 547 | delete ir; |
548 | ::unlink( beamfile ); | 548 | ::unlink( beamfile ); |
549 | } | 549 | } |
550 | void MainWindow::receiveFile( const QString& filename ) { | 550 | void MainWindow::receiveFile( const QString& filename ) { |
551 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 551 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
552 | OTodoAccess acc( cal ); | 552 | OTodoAccess acc( cal ); |
553 | acc.load(); | 553 | acc.load(); |
554 | OTodoAccess::List list = acc.allRecords(); | 554 | OTodoAccess::List list = acc.allRecords(); |
555 | 555 | ||
556 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 556 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
557 | 557 | ||
558 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 558 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
559 | message, QMessageBox::Ok, | 559 | message, QMessageBox::Ok, |
560 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 560 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
561 | OTodoAccess::List::Iterator it; | 561 | OTodoAccess::List::Iterator it; |
562 | for ( it = list.begin(); it != list.end(); ++it ) | 562 | for ( it = list.begin(); it != list.end(); ++it ) |
563 | m_todoMgr.add( (*it) ); | 563 | m_todoMgr.add( (*it) ); |
564 | 564 | ||
565 | currentView()->updateView(); | 565 | currentView()->updateView(); |
566 | } | 566 | } |
567 | } | 567 | } |
568 | 568 | ||
569 | void MainWindow::slotFlush() { | 569 | void MainWindow::slotFlush() { |
570 | m_syncing = FALSE; | 570 | m_syncing = FALSE; |
571 | m_todoMgr.save(); | 571 | m_todoMgr.save(); |
572 | } | 572 | } |
573 | void MainWindow::slotShowDetails() { | 573 | void MainWindow::slotShowDetails() { |
574 | slotShow( currentView()->current() ); | 574 | slotShow( currentView()->current() ); |
575 | } | 575 | } |
576 | /* | 576 | /* |
577 | * populate the Categories | 577 | * populate the Categories |
578 | * Menu | 578 | * Menu |
579 | */ | 579 | */ |
580 | void MainWindow::populateCategories() { | 580 | void MainWindow::populateCategories() { |
581 | m_todoMgr.load(); | 581 | m_todoMgr.load(); |
582 | 582 | ||
583 | m_catMenu->clear(); | 583 | m_catMenu->clear(); |
584 | int id, rememberId; | 584 | int id, rememberId; |
585 | id = 1; | 585 | id = 1; |
586 | rememberId = 1; | 586 | rememberId = 1; |
587 | 587 | ||
588 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | 588 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); |
589 | m_catMenu->insertSeparator(); | 589 | m_catMenu->insertSeparator(); |
590 | QStringList categories = m_todoMgr.categories(); | 590 | QStringList categories = m_todoMgr.categories(); |
591 | categories.append( QWidget::tr( "Unfiled" ) ); | 591 | categories.append( QWidget::tr( "Unfiled" ) ); |
592 | for ( QStringList::Iterator it = categories.begin(); | 592 | for ( QStringList::Iterator it = categories.begin(); |
593 | it != categories.end(); ++it ) { | 593 | it != categories.end(); ++it ) { |
594 | m_catMenu->insertItem( *it, id ); | 594 | m_catMenu->insertItem( *it, id ); |
595 | if ( *it == currentCategory() ) | 595 | if ( *it == currentCategory() ) |
596 | rememberId = id; | 596 | rememberId = id; |
597 | ++id; | 597 | ++id; |
598 | } | 598 | } |
599 | setCategory( rememberId ); | 599 | setCategory( rememberId ); |
600 | } | 600 | } |
601 | bool MainWindow::showCompleted()const { | 601 | bool MainWindow::showCompleted()const { |
602 | return m_completed; | 602 | return m_completed; |
603 | } | 603 | } |
604 | bool MainWindow::showDeadline()const { | 604 | bool MainWindow::showDeadline()const { |
605 | return m_deadline; | 605 | return m_deadline; |
606 | } | 606 | } |
607 | bool MainWindow::showQuickTask()const { | 607 | bool MainWindow::showQuickTask()const { |
608 | return m_quicktask; | 608 | return m_quicktask; |
609 | } | 609 | } |
610 | QString MainWindow::currentCategory()const { | 610 | QString MainWindow::currentCategory()const { |
611 | return m_curCat; | 611 | return m_curCat; |
612 | } | 612 | } |
613 | int MainWindow::currentCatId() { | 613 | int MainWindow::currentCatId() { |
614 | return m_todoMgr.catId( m_curCat ); | 614 | return m_todoMgr.catId( m_curCat ); |
615 | } | 615 | } |
616 | ViewBase* MainWindow::currentView() { | 616 | ViewBase* MainWindow::currentView() { |
617 | return m_curView; | 617 | return m_curView; |
618 | } | 618 | } |
619 | void MainWindow::raiseCurrentView() { | 619 | void MainWindow::raiseCurrentView() { |
620 | m_stack->raiseWidget( m_curView->widget() ); | 620 | m_stack->raiseWidget( m_curView->widget() ); |
621 | } | 621 | } |
622 | void MainWindow::slotShowDue(bool ov) { | 622 | void MainWindow::slotShowDue(bool ov) { |
623 | m_overdue = ov; | 623 | m_overdue = ov; |
624 | currentView()->showOverDue( ov ); | 624 | currentView()->showOverDue( ov ); |
625 | raiseCurrentView(); | 625 | raiseCurrentView(); |
626 | } | 626 | } |
627 | void MainWindow::slotShow( int uid ) { | 627 | void MainWindow::slotShow( int uid ) { |
628 | qWarning("slotShow"); | 628 | qWarning("slotShow"); |
629 | currentShow()->slotShow( event( uid ) ); | 629 | currentShow()->slotShow( event( uid ) ); |
630 | m_stack->raiseWidget( currentShow()->widget() ); | 630 | m_stack->raiseWidget( currentShow()->widget() ); |
631 | } | 631 | } |
632 | void MainWindow::slotEdit( int uid ) { | 632 | void MainWindow::slotEdit( int uid ) { |
633 | if (uid == 1 ) return; | ||
633 | if(m_syncing) { | 634 | if(m_syncing) { |
634 | QMessageBox::warning(this, QWidget::tr("Todo"), | 635 | QMessageBox::warning(this, QWidget::tr("Todo"), |
635 | QWidget::tr("Can not edit data, currently syncing")); | 636 | QWidget::tr("Can not edit data, currently syncing")); |
636 | return; | 637 | return; |
637 | } | 638 | } |
638 | 639 | ||
639 | OTodo todo = m_todoMgr.event( uid ); | 640 | OTodo todo = m_todoMgr.event( uid ); |
640 | 641 | ||
641 | todo = currentEditor()->edit(this, todo ); | 642 | todo = currentEditor()->edit(this, todo ); |
642 | 643 | ||
643 | /* if completed */ | 644 | /* if completed */ |
644 | if ( currentEditor()->accepted() ) { | 645 | if ( currentEditor()->accepted() ) { |
645 | qWarning("Replacing now" ); | 646 | qWarning("Replacing now" ); |
646 | m_todoMgr.update( todo.uid(), todo ); | 647 | m_todoMgr.update( todo.uid(), todo ); |
647 | currentView()->replaceEvent( todo ); | 648 | currentView()->replaceEvent( todo ); |
648 | /* a Category might have changed */ | 649 | /* a Category might have changed */ |
649 | populateCategories(); | 650 | populateCategories(); |
650 | } | 651 | } |
651 | 652 | ||
652 | raiseCurrentView(); | 653 | raiseCurrentView(); |
653 | } | 654 | } |
654 | /* | 655 | /* |
655 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 656 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
656 | m_todoMgr.update( uid, ev ); | 657 | m_todoMgr.update( uid, ev ); |
657 | } | 658 | } |
658 | */ | 659 | */ |
659 | void MainWindow::updateTodo( const OTodo& ev) { | 660 | void MainWindow::updateTodo( const OTodo& ev) { |
660 | m_todoMgr.update( ev.uid() , ev ); | 661 | m_todoMgr.update( ev.uid() , ev ); |
661 | } | 662 | } |
662 | /* The view changed it's configuration | 663 | /* The view changed it's configuration |
663 | * update the view menu | 664 | * update the view menu |
664 | */ | 665 | */ |
665 | void MainWindow::slotUpdate3( QWidget* ) { | 666 | void MainWindow::slotUpdate3( QWidget* ) { |
666 | 667 | ||
667 | } | 668 | } |
668 | void MainWindow::updateList() { | 669 | void MainWindow::updateList() { |
669 | m_todoMgr.updateList(); | 670 | m_todoMgr.updateList(); |
670 | } | 671 | } |
671 | void MainWindow::setReadAhead( uint count ) { | 672 | void MainWindow::setReadAhead( uint count ) { |
672 | if (m_todoMgr.todoDB() ) | 673 | if (m_todoMgr.todoDB() ) |
673 | m_todoMgr.todoDB()->setReadAhead( count ); | 674 | m_todoMgr.todoDB()->setReadAhead( count ); |
674 | } | 675 | } |
675 | void MainWindow::slotQuickEntered() { | 676 | void MainWindow::slotQuickEntered() { |
676 | qWarning("entered"); | 677 | qWarning("entered"); |
677 | OTodo todo = quickEditor()->todo(); | 678 | OTodo todo = quickEditor()->todo(); |
678 | if (todo.isEmpty() ) | 679 | if (todo.isEmpty() ) |
679 | return; | 680 | return; |
680 | 681 | ||
681 | m_todoMgr.add( todo ); | 682 | m_todoMgr.add( todo ); |
682 | currentView()->addEvent( todo ); | 683 | currentView()->addEvent( todo ); |
683 | raiseCurrentView(); | 684 | raiseCurrentView(); |
684 | } | 685 | } |
685 | QuickEditBase* MainWindow::quickEditor() { | 686 | QuickEditBase* MainWindow::quickEditor() { |
686 | return m_curQuick; | 687 | return m_curQuick; |
687 | } | 688 | } |
688 | void MainWindow::slotComplete( int uid ) { | 689 | void MainWindow::slotComplete( int uid ) { |
689 | slotComplete( event(uid) ); | 690 | slotComplete( event(uid) ); |
690 | } | 691 | } |
691 | void MainWindow::slotComplete( const OTodo& todo ) { | 692 | void MainWindow::slotComplete( const OTodo& todo ) { |
692 | OTodo to = todo; | 693 | OTodo to = todo; |
693 | to.setCompleted( !to.isCompleted() ); | 694 | to.setCompleted( !to.isCompleted() ); |
694 | to.setCompletedDate( QDate::currentDate() ); | 695 | to.setCompletedDate( QDate::currentDate() ); |
695 | 696 | ||
696 | /* | 697 | /* |
697 | * if the item does recur | 698 | * if the item does recur |
698 | * we need to spin it off | 699 | * we need to spin it off |
699 | * and update the items duedate to the next | 700 | * and update the items duedate to the next |
700 | * possible recurrance of this item... | 701 | * possible recurrance of this item... |
701 | * the spinned off one will loose the | 702 | * the spinned off one will loose the |
702 | */ | 703 | */ |
703 | if ( to.recurrence().doesRecur() && to.isCompleted() ) { | 704 | if ( to.recurrence().doesRecur() && to.isCompleted() ) { |
704 | OTodo to2( to ); | 705 | OTodo to2( to ); |
705 | 706 | ||
706 | /* the spinned off one won't recur anymore */ | 707 | /* the spinned off one won't recur anymore */ |
707 | to.setRecurrence( ORecur() ); | 708 | to.setRecurrence( ORecur() ); |
708 | 709 | ||
709 | ORecur rec = to2.recurrence(); | 710 | ORecur rec = to2.recurrence(); |
710 | rec.setStart( to.dueDate() ); | 711 | rec.setStart( to.dueDate() ); |
711 | to2.setRecurrence( rec ); | 712 | to2.setRecurrence( rec ); |
712 | /* | 713 | /* |
713 | * if there is a next occurence | 714 | * if there is a next occurence |
714 | * from the duedate of the last recurrance | 715 | * from the duedate of the last recurrance |
715 | */ | 716 | */ |
716 | QDate date; | 717 | QDate date; |
717 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 718 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
718 | QDate inval; | 719 | QDate inval; |
719 | /* generate a new uid for the old record */ | 720 | /* generate a new uid for the old record */ |
720 | to.setUid( 1 ); | 721 | to.setUid( 1 ); |
721 | 722 | ||
722 | /* add the old one cause it has a new UID here cause it was spin off */ | 723 | /* add the old one cause it has a new UID here cause it was spin off */ |
723 | m_todoMgr.add( to ); | 724 | m_todoMgr.add( to ); |
724 | 725 | ||
725 | /* | 726 | /* |
726 | * update the due date | 727 | * update the due date |
727 | * start date | 728 | * start date |
728 | * and complete date | 729 | * and complete date |
729 | */ | 730 | */ |
730 | to2.setDueDate( date ); | 731 | to2.setDueDate( date ); |
731 | to2.setStartDate( inval ); | 732 | to2.setStartDate( inval ); |
732 | to2.setCompletedDate( inval ); | 733 | to2.setCompletedDate( inval ); |
733 | to2.setCompleted( false ); | 734 | to2.setCompleted( false ); |
734 | updateTodo( to2 ); | 735 | updateTodo( to2 ); |
735 | }else | 736 | }else |
736 | updateTodo( to ); | 737 | updateTodo( to ); |
737 | }else | 738 | }else |
738 | updateTodo( to ); | 739 | updateTodo( to ); |
739 | 740 | ||
740 | currentView()->updateView(); | 741 | currentView()->updateView(); |
741 | raiseCurrentView(); | 742 | raiseCurrentView(); |
742 | } | 743 | } |
743 | void MainWindow::flush() { | 744 | void MainWindow::flush() { |
744 | slotFlush(); | 745 | slotFlush(); |
745 | } | 746 | } |
746 | void MainWindow::reload() { | 747 | void MainWindow::reload() { |
747 | slotReload(); | 748 | slotReload(); |
748 | } | 749 | } |
749 | int MainWindow::create() { | 750 | int MainWindow::create() { |
750 | int uid = 0; | 751 | int uid = 0; |
751 | if(m_syncing) { | 752 | if(m_syncing) { |
752 | QMessageBox::warning(this, QWidget::tr("Todo"), | 753 | QMessageBox::warning(this, QWidget::tr("Todo"), |
753 | QWidget::tr("Can not edit data, currently syncing")); | 754 | QWidget::tr("Can not edit data, currently syncing")); |
754 | return uid; | 755 | return uid; |
755 | } | 756 | } |
756 | 757 | ||
757 | 758 | ||
758 | OTodo todo = currentEditor()->newTodo( currentCatId(), | 759 | OTodo todo = currentEditor()->newTodo( currentCatId(), |
759 | this ); | 760 | this ); |
760 | 761 | ||
761 | if ( currentEditor()->accepted() ) { | 762 | if ( currentEditor()->accepted() ) { |
762 | //todo.assignUid(); | 763 | //todo.assignUid(); |
763 | uid = todo.uid(); | 764 | uid = todo.uid(); |
764 | m_todoMgr.add( todo ); | 765 | m_todoMgr.add( todo ); |
765 | currentView()->addEvent( todo ); | 766 | currentView()->addEvent( todo ); |
766 | 767 | ||
767 | 768 | ||
768 | // I'm afraid we must call this every time now, otherwise | 769 | // I'm afraid we must call this every time now, otherwise |
769 | // spend expensive time comparing all these strings... | 770 | // spend expensive time comparing all these strings... |
770 | // but only call if we changed something -zecke | 771 | // but only call if we changed something -zecke |
771 | populateCategories(); | 772 | populateCategories(); |
772 | } | 773 | } |
773 | raiseCurrentView( ); | 774 | raiseCurrentView( ); |
774 | 775 | ||
775 | return uid; | 776 | return uid; |
776 | } | 777 | } |
777 | /* delete it silently... */ | 778 | /* delete it silently... */ |
778 | bool MainWindow::remove( int uid ) { | 779 | bool MainWindow::remove( int uid ) { |
779 | if (m_syncing) return false; | 780 | if (m_syncing) return false; |
780 | 781 | ||
781 | return m_todoMgr.remove( uid ); | 782 | return m_todoMgr.remove( uid ); |
782 | } | 783 | } |
783 | void MainWindow::beam( int uid) { | 784 | void MainWindow::beam( int uid) { |
784 | ::unlink( beamfile ); | 785 | ::unlink( beamfile ); |
785 | OTodo todo = event( uid ); | 786 | OTodo todo = event( uid ); |
786 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | 787 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); |
787 | OTodoAccess acc( cal ); | 788 | OTodoAccess acc( cal ); |
788 | acc.load(); | 789 | acc.load(); |
789 | acc.add( todo ); | 790 | acc.add( todo ); |
790 | acc.save(); | 791 | acc.save(); |
791 | Ir* ir = new Ir(this ); | 792 | Ir* ir = new Ir(this ); |
792 | connect(ir, SIGNAL(done(Ir*) ), | 793 | connect(ir, SIGNAL(done(Ir*) ), |
793 | this, SLOT(beamDone(Ir*) ) ); | 794 | this, SLOT(beamDone(Ir*) ) ); |
794 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | 795 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); |
795 | } | 796 | } |
796 | void MainWindow::show( int uid ) { | 797 | void MainWindow::show( int uid ) { |
797 | slotShow( uid ); | 798 | slotShow( uid ); |
798 | } | 799 | } |
799 | void MainWindow::edit( int uid ) { | 800 | void MainWindow::edit( int uid ) { |
800 | slotEdit( uid ); | 801 | slotEdit( uid ); |
801 | } | 802 | } |
802 | void MainWindow::add( const OPimRecord& rec) { | 803 | void MainWindow::add( const OPimRecord& rec) { |
803 | if ( rec.rtti() != OTodo::rtti() ) return; | 804 | if ( rec.rtti() != OTodo::rtti() ) return; |
804 | 805 | ||
805 | const OTodo& todo = static_cast<const OTodo&>(rec); | 806 | const OTodo& todo = static_cast<const OTodo&>(rec); |
806 | 807 | ||
807 | m_todoMgr.add(todo ); | 808 | m_todoMgr.add(todo ); |
808 | currentView()->addEvent( todo ); | 809 | currentView()->addEvent( todo ); |
809 | 810 | ||
810 | 811 | ||
811 | // I'm afraid we must call this every time now, otherwise | 812 | // I'm afraid we must call this every time now, otherwise |
812 | // spend expensive time comparing all these strings... | 813 | // spend expensive time comparing all these strings... |
813 | // but only call if we changed something -zecke | 814 | // but only call if we changed something -zecke |
814 | populateCategories(); | 815 | populateCategories(); |
815 | } | 816 | } |
816 | void MainWindow::slotReturnFromView() { | 817 | void MainWindow::slotReturnFromView() { |
817 | raiseCurrentView(); | 818 | raiseCurrentView(); |
818 | } | 819 | } |
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index ae27fab..d9cda09 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,337 +1,338 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <zecke> | 3 | .=l. Copyright (c) 2002 <zecke> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | 30 | ||
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | #include <qpoint.h> | 34 | #include <qpoint.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <opie/orecur.h> | 40 | #include <opie/orecur.h> |
41 | 41 | ||
42 | #include "mainwindow.h" | 42 | #include "mainwindow.h" |
43 | //#include "tableitems.h" | 43 | //#include "tableitems.h" |
44 | #include "tableview.h" | 44 | #include "tableview.h" |
45 | 45 | ||
46 | using namespace Todo; | 46 | using namespace Todo; |
47 | 47 | ||
48 | namespace { | 48 | namespace { |
49 | static const int BoxSize = 14; | 49 | static const int BoxSize = 14; |
50 | static const int RowHeight = 20; | 50 | static const int RowHeight = 20; |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | void TableView::initConfig() { | 54 | void TableView::initConfig() { |
55 | Config config( "todo" ); | 55 | Config config( "todo" ); |
56 | config.setGroup( "Options" ); | 56 | config.setGroup( "Options" ); |
57 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 57 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
58 | for (int i = 0; i < numCols(); i++ ) { | 58 | for (int i = 0; i < numCols(); i++ ) { |
59 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); | 59 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); |
60 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); | 60 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | TableView::TableView( MainWindow* window, QWidget* wid ) | 64 | TableView::TableView( MainWindow* window, QWidget* wid ) |
65 | : QTable( wid ), TodoView( window ) { | 65 | : QTable( wid ), TodoView( window ) { |
66 | 66 | ||
67 | // Load icons | 67 | // Load icons |
68 | // TODO - probably should be done globally somewhere else, | 68 | // TODO - probably should be done globally somewhere else, |
69 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h | 69 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h |
70 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); | 70 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); |
71 | QString namestr; | 71 | QString namestr; |
72 | for ( unsigned int i = 1; i < 6; i++ ) { | 72 | for ( unsigned int i = 1; i < 6; i++ ) { |
73 | namestr = "todo/priority"; | 73 | namestr = "todo/priority"; |
74 | namestr.append( QString::number( i ) ); | 74 | namestr.append( QString::number( i ) ); |
75 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | 75 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); |
76 | } | 76 | } |
77 | 77 | ||
78 | setUpdatesEnabled( false ); | 78 | setUpdatesEnabled( false ); |
79 | viewport()->setUpdatesEnabled( false ); | 79 | viewport()->setUpdatesEnabled( false ); |
80 | m_enablePaint = false; | 80 | m_enablePaint = false; |
81 | setNumRows(0); | 81 | setNumRows(0); |
82 | setNumCols(4); | 82 | setNumCols(4); |
83 | 83 | ||
84 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); | 84 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); |
85 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); | 85 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); |
86 | horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); | 86 | horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); |
87 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); | 87 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); |
88 | 88 | ||
89 | setShowDeadline( todoWindow()->showDeadline() ); | 89 | setShowDeadline( todoWindow()->showDeadline() ); |
90 | 90 | ||
91 | setSorting( TRUE ); | 91 | setSorting( TRUE ); |
92 | setSelectionMode( NoSelection ); | 92 | setSelectionMode( NoSelection ); |
93 | 93 | ||
94 | setLeftMargin( 0 ); | 94 | setLeftMargin( 0 ); |
95 | verticalHeader()->hide(); | 95 | verticalHeader()->hide(); |
96 | 96 | ||
97 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 97 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
98 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 98 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
99 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 99 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
100 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 100 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
101 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 101 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
102 | this, SLOT( slotValueChanged(int, int) ) ); | 102 | this, SLOT( slotValueChanged(int, int) ) ); |
103 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 103 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
104 | this, SLOT( slotCurrentChanged(int, int) ) ); | 104 | this, SLOT( slotCurrentChanged(int, int) ) ); |
105 | 105 | ||
106 | m_menuTimer = new QTimer( this ); | 106 | m_menuTimer = new QTimer( this ); |
107 | connect( m_menuTimer, SIGNAL(timeout()), | 107 | connect( m_menuTimer, SIGNAL(timeout()), |
108 | this, SLOT(slotShowMenu()) ); | 108 | this, SLOT(slotShowMenu()) ); |
109 | 109 | ||
110 | /* now let's init the config */ | 110 | /* now let's init the config */ |
111 | initConfig(); | 111 | initConfig(); |
112 | 112 | ||
113 | 113 | ||
114 | m_enablePaint = true; | 114 | m_enablePaint = true; |
115 | setUpdatesEnabled( true ); | 115 | setUpdatesEnabled( true ); |
116 | viewport()->setUpdatesEnabled( true ); | 116 | viewport()->setUpdatesEnabled( true ); |
117 | viewport()->update(); | 117 | viewport()->update(); |
118 | setSortOrder( 0 ); | 118 | setSortOrder( 0 ); |
119 | setAscending( TRUE ); | 119 | setAscending( TRUE ); |
120 | m_first = true; | 120 | m_first = true; |
121 | 121 | ||
122 | 122 | ||
123 | } | 123 | } |
124 | /* a new day has started | 124 | /* a new day has started |
125 | * update the day | 125 | * update the day |
126 | */ | 126 | */ |
127 | void TableView::newDay() { | 127 | void TableView::newDay() { |
128 | clear(); | 128 | clear(); |
129 | updateView(); | 129 | updateView(); |
130 | } | 130 | } |
131 | TableView::~TableView() { | 131 | TableView::~TableView() { |
132 | Config config( "todo" ); | 132 | Config config( "todo" ); |
133 | config.setGroup( "Options" ); | 133 | config.setGroup( "Options" ); |
134 | for (int i = 0; i < numCols(); i++ ) | 134 | for (int i = 0; i < numCols(); i++ ) |
135 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); | 135 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); |
136 | } | 136 | } |
137 | void TableView::slotShowMenu() { | 137 | void TableView::slotShowMenu() { |
138 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); | 138 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
139 | menu->exec(QCursor::pos() ); | 139 | menu->exec(QCursor::pos() ); |
140 | delete menu; | 140 | delete menu; |
141 | } | 141 | } |
142 | QString TableView::type() const { | 142 | QString TableView::type() const { |
143 | return QString::fromLatin1( tr("Table View") ); | 143 | return QString::fromLatin1( tr("Table View") ); |
144 | } | 144 | } |
145 | int TableView::current() { | 145 | int TableView::current() { |
146 | if (numRows() == 0 ) return 1; | ||
146 | int uid = sorted().uidAt(currentRow() ); | 147 | int uid = sorted().uidAt(currentRow() ); |
147 | 148 | ||
148 | return uid; | 149 | return uid; |
149 | } | 150 | } |
150 | QString TableView::currentRepresentation() { | 151 | QString TableView::currentRepresentation() { |
151 | OTodo to = sorted()[currentRow()]; | 152 | OTodo to = sorted()[currentRow()]; |
152 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | 153 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; |
153 | } | 154 | } |
154 | /* show overdue */ | 155 | /* show overdue */ |
155 | void TableView::showOverDue( bool ) { | 156 | void TableView::showOverDue( bool ) { |
156 | clear(); | 157 | clear(); |
157 | updateView(); | 158 | updateView(); |
158 | } | 159 | } |
159 | 160 | ||
160 | void TableView::updateView( ) { | 161 | void TableView::updateView( ) { |
161 | qWarning("update view"); | 162 | qWarning("update view"); |
162 | m_row = false; | 163 | m_row = false; |
163 | static int id; | 164 | static int id; |
164 | id = startTimer(4000 ); | 165 | id = startTimer(4000 ); |
165 | /* FIXME we want one page to be read! | 166 | /* FIXME we want one page to be read! |
166 | * | 167 | * |
167 | * Calculate that screensize | 168 | * Calculate that screensize |
168 | */ | 169 | */ |
169 | todoWindow()->setReadAhead( 4 ); | 170 | todoWindow()->setReadAhead( 4 ); |
170 | sort(); | 171 | sort(); |
171 | OTodoAccess::List::Iterator it, end; | 172 | OTodoAccess::List::Iterator it, end; |
172 | it = sorted().begin(); | 173 | it = sorted().begin(); |
173 | end = sorted().end(); | 174 | end = sorted().end(); |
174 | 175 | ||
175 | qWarning("setTodos"); | 176 | qWarning("setTodos"); |
176 | QTime time; | 177 | QTime time; |
177 | time.start(); | 178 | time.start(); |
178 | m_enablePaint = false; | 179 | m_enablePaint = false; |
179 | setUpdatesEnabled( false ); | 180 | setUpdatesEnabled( false ); |
180 | viewport()->setUpdatesEnabled( false ); | 181 | viewport()->setUpdatesEnabled( false ); |
181 | 182 | ||
182 | setNumRows( it.count() ); | 183 | setNumRows( it.count() ); |
183 | if ( it.count() == 0 ) | 184 | if ( it.count() == 0 ) |
184 | killTimer(id); | 185 | killTimer(id); |
185 | 186 | ||
186 | // int elc = time.elapsed(); | 187 | // int elc = time.elapsed(); |
187 | setUpdatesEnabled( true ); | 188 | setUpdatesEnabled( true ); |
188 | viewport()->setUpdatesEnabled( true ); | 189 | viewport()->setUpdatesEnabled( true ); |
189 | viewport()->update(); | 190 | viewport()->update(); |
190 | 191 | ||
191 | m_enablePaint = true; | 192 | m_enablePaint = true; |
192 | // int el = time.elapsed(); | 193 | // int el = time.elapsed(); |
193 | } | 194 | } |
194 | void TableView::setTodo( int, const OTodo&) { | 195 | void TableView::setTodo( int, const OTodo&) { |
195 | sort(); | 196 | sort(); |
196 | 197 | ||
197 | /* repaint */ | 198 | /* repaint */ |
198 | repaint(); | 199 | repaint(); |
199 | } | 200 | } |
200 | void TableView::addEvent( const OTodo&) { | 201 | void TableView::addEvent( const OTodo&) { |
201 | 202 | ||
202 | /* fix problems of not showing the 'Haken' */ | 203 | /* fix problems of not showing the 'Haken' */ |
203 | updateView(); | 204 | updateView(); |
204 | } | 205 | } |
205 | /* | 206 | /* |
206 | * find the event | 207 | * find the event |
207 | * and then replace the complete row | 208 | * and then replace the complete row |
208 | */ | 209 | */ |
209 | void TableView::replaceEvent( const OTodo& ev) { | 210 | void TableView::replaceEvent( const OTodo& ev) { |
210 | addEvent( ev ); | 211 | addEvent( ev ); |
211 | } | 212 | } |
212 | /* | 213 | /* |
213 | * re aligning table can be slow too | 214 | * re aligning table can be slow too |
214 | * FIXME: look what performs better | 215 | * FIXME: look what performs better |
215 | * either this or the old align table | 216 | * either this or the old align table |
216 | */ | 217 | */ |
217 | void TableView::removeEvent( int ) { | 218 | void TableView::removeEvent( int ) { |
218 | updateView(); | 219 | updateView(); |
219 | } | 220 | } |
220 | void TableView::setShowCompleted( bool b) { | 221 | void TableView::setShowCompleted( bool b) { |
221 | qWarning("Show Completed %d" + b ); | 222 | qWarning("Show Completed %d" + b ); |
222 | updateView(); | 223 | updateView(); |
223 | } | 224 | } |
224 | void TableView::setShowDeadline( bool b ) { | 225 | void TableView::setShowDeadline( bool b ) { |
225 | qWarning( "Show DeadLine %d" + b ); | 226 | qWarning( "Show DeadLine %d" + b ); |
226 | if ( b ) | 227 | if ( b ) |
227 | showColumn( 3 ); | 228 | showColumn( 3 ); |
228 | else | 229 | else |
229 | hideColumn( 3 ); | 230 | hideColumn( 3 ); |
230 | 231 | ||
231 | // Try to intelligently size columns | 232 | // Try to intelligently size columns |
232 | // TODO - would use width() below, but doesn't have valid value at time of c'tor | 233 | // TODO - would use width() below, but doesn't have valid value at time of c'tor |
233 | int col2width = 238; | 234 | int col2width = 238; |
234 | int width = m_pic_completed.width(); | 235 | int width = m_pic_completed.width(); |
235 | setColumnWidth( 0, width ); | 236 | setColumnWidth( 0, width ); |
236 | col2width -= width; | 237 | col2width -= width; |
237 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; | 238 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; |
238 | setColumnWidth( 1, width ); | 239 | setColumnWidth( 1, width ); |
239 | col2width -= width; | 240 | col2width -= width; |
240 | if ( b ) { | 241 | if ( b ) { |
241 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; | 242 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; |
242 | setColumnWidth( 3, width ); | 243 | setColumnWidth( 3, width ); |
243 | col2width -= width; | 244 | col2width -= width; |
244 | } | 245 | } |
245 | setColumnWidth( 2, col2width ); | 246 | setColumnWidth( 2, col2width ); |
246 | } | 247 | } |
247 | void TableView::setShowCategory( const QString& str) { | 248 | void TableView::setShowCategory( const QString& str) { |
248 | qWarning("setShowCategory"); | 249 | qWarning("setShowCategory"); |
249 | if ( str != m_oleCat || m_first ) | 250 | if ( str != m_oleCat || m_first ) |
250 | updateView(); | 251 | updateView(); |
251 | 252 | ||
252 | m_oleCat = str; | 253 | m_oleCat = str; |
253 | m_first = false; | 254 | m_first = false; |
254 | 255 | ||
255 | } | 256 | } |
256 | void TableView::clear() { | 257 | void TableView::clear() { |
257 | setNumRows(0); | 258 | setNumRows(0); |
258 | } | 259 | } |
259 | void TableView::slotClicked(int row, int col, int, | 260 | void TableView::slotClicked(int row, int col, int, |
260 | const QPoint& point) { | 261 | const QPoint& point) { |
261 | if ( !cellGeometry(row, col ).contains(point ) ) | 262 | if ( !cellGeometry(row, col ).contains(point ) ) |
262 | return; | 263 | return; |
263 | 264 | ||
264 | int ui= sorted().uidAt( row ); | 265 | int ui= sorted().uidAt( row ); |
265 | 266 | ||
266 | 267 | ||
267 | switch( col ) { | 268 | switch( col ) { |
268 | case 0:{ | 269 | case 0:{ |
269 | int x = point.x() -columnPos( col ); | 270 | int x = point.x() -columnPos( col ); |
270 | int y = point.y() -rowPos( row ); | 271 | int y = point.y() -rowPos( row ); |
271 | int w = columnWidth( col ); | 272 | int w = columnWidth( col ); |
272 | int h = rowHeight( row ); | 273 | int h = rowHeight( row ); |
273 | if ( x >= ( w - BoxSize ) / 2 && | 274 | if ( x >= ( w - BoxSize ) / 2 && |
274 | x <= ( w - BoxSize ) / 2 + BoxSize && | 275 | x <= ( w - BoxSize ) / 2 + BoxSize && |
275 | y >= ( h - BoxSize ) / 2 && | 276 | y >= ( h - BoxSize ) / 2 && |
276 | y <= ( h - BoxSize ) / 2 + BoxSize ) { | 277 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
277 | TodoView::complete(sorted()[row] ); | 278 | TodoView::complete(sorted()[row] ); |
278 | } | 279 | } |
279 | } | 280 | } |
280 | break; | 281 | break; |
281 | 282 | ||
282 | case 1: | 283 | case 1: |
283 | break; | 284 | break; |
284 | 285 | ||
285 | case 2: { | 286 | case 2: { |
286 | m_menuTimer->stop(); | 287 | m_menuTimer->stop(); |
287 | showTodo( ui ); | 288 | showTodo( ui ); |
288 | break; | 289 | break; |
289 | } | 290 | } |
290 | case 3: { | 291 | case 3: { |
291 | m_menuTimer->stop(); | 292 | m_menuTimer->stop(); |
292 | TodoView::edit( ui ); | 293 | TodoView::edit( ui ); |
293 | break; | 294 | break; |
294 | } | 295 | } |
295 | } | 296 | } |
296 | 297 | ||
297 | 298 | ||
298 | } | 299 | } |
299 | void TableView::slotPressed(int row, int col, int, | 300 | void TableView::slotPressed(int row, int col, int, |
300 | const QPoint& point) { | 301 | const QPoint& point) { |
301 | 302 | ||
302 | qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); | 303 | qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); |
303 | m_prevP = point; | 304 | m_prevP = point; |
304 | /* TextColumn column */ | 305 | /* TextColumn column */ |
305 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | 306 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) |
306 | m_menuTimer->start( 750, TRUE ); | 307 | m_menuTimer->start( 750, TRUE ); |
307 | } | 308 | } |
308 | void TableView::slotValueChanged( int, int ) { | 309 | void TableView::slotValueChanged( int, int ) { |
309 | qWarning("Value Changed"); | 310 | qWarning("Value Changed"); |
310 | } | 311 | } |
311 | void TableView::slotCurrentChanged(int, int ) { | 312 | void TableView::slotCurrentChanged(int, int ) { |
312 | m_menuTimer->stop(); | 313 | m_menuTimer->stop(); |
313 | } | 314 | } |
314 | QWidget* TableView::widget() { | 315 | QWidget* TableView::widget() { |
315 | return this; | 316 | return this; |
316 | } | 317 | } |
317 | /* | 318 | /* |
318 | * We need to overwrite sortColumn | 319 | * We need to overwrite sortColumn |
319 | * because we want to sort whole row | 320 | * because we want to sort whole row |
320 | * based | 321 | * based |
321 | * We event want to set the setOrder | 322 | * We event want to set the setOrder |
322 | * to a sort() and update() | 323 | * to a sort() and update() |
323 | */ | 324 | */ |
324 | void TableView::sortColumn( int col, bool asc, bool ) { | 325 | void TableView::sortColumn( int col, bool asc, bool ) { |
325 | qWarning("bool %d", asc ); | 326 | qWarning("bool %d", asc ); |
326 | setSortOrder( col ); | 327 | setSortOrder( col ); |
327 | setAscending( asc ); | 328 | setAscending( asc ); |
328 | updateView(); | 329 | updateView(); |
329 | } | 330 | } |
330 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 331 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
331 | if (m_enablePaint ) | 332 | if (m_enablePaint ) |
332 | QTable::viewportPaintEvent( e ); | 333 | QTable::viewportPaintEvent( e ); |
333 | } | 334 | } |
334 | /* | 335 | /* |
335 | * This segment is copyrighted by TT | 336 | * This segment is copyrighted by TT |
336 | * it was taken from their todolist | 337 | * it was taken from their todolist |
337 | * application this code is GPL | 338 | * application this code is GPL |