-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 | |||
@@ -585,96 +585,97 @@ void MainWindow::populateCategories() { | |||
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 | ||
@@ -746,73 +747,73 @@ void MainWindow::flush() { | |||
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 | |||
@@ -98,96 +98,97 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
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 | } |