summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp2
-rw-r--r--core/pim/todo/mainwindow.cpp7
-rw-r--r--core/pim/todo/tableview.cpp97
-rw-r--r--core/pim/todo/tableview.h7
-rw-r--r--core/pim/todo/todomanager.cpp2
-rw-r--r--core/pim/todo/todoview.cpp3
-rw-r--r--core/pim/todo/todoview.h2
7 files changed, 86 insertions, 34 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 58ed45c..aeae794 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -10,40 +10,40 @@
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mainwindow.h" 21#include "mainwindow.h"
22 22
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27 27
28void myMessages( QtMsgType, const char* ) { 28void myMessages( QtMsgType, const char* ) {
29 29
30} 30}
31 31
32int main( int argc, char **argv ) 32int main( int argc, char **argv )
33{ 33{
34 qInstallMsgHandler( myMessages ); 34// qInstallMsgHandler( myMessages );
35 QPEApplication a( argc, argv ); 35 QPEApplication a( argc, argv );
36 36
37 QTime time; 37 QTime time;
38 time.start(); 38 time.start();
39 Todo::MainWindow mw; 39 Todo::MainWindow mw;
40 int t = time.elapsed(); 40 int t = time.elapsed();
41 qWarning("QTime %d", t/1000 ); 41 qWarning("QTime %d", t/1000 );
42 mw.setCaption("Opie Todolist"); 42 mw.setCaption("Opie Todolist");
43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); 43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); 44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
45 45
46 a.showMainWidget(&mw); 46 a.showMainWidget(&mw);
47 47
48 return a.exec(); 48 return a.exec();
49} 49}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 48954ce..c9c43d4 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -399,49 +399,48 @@ void MainWindow::slotNewFromTemplate( int id ) {
399 populateCategories(); 399 populateCategories();
400 } 400 }
401} 401}
402void MainWindow::slotNew() { 402void MainWindow::slotNew() {
403 if(m_syncing) { 403 if(m_syncing) {
404 QMessageBox::warning(this, tr("Todo"), 404 QMessageBox::warning(this, tr("Todo"),
405 tr("Can not edit data, currently syncing")); 405 tr("Can not edit data, currently syncing"));
406 return; 406 return;
407 } 407 }
408 408
409 409
410 OTodo todo = currentEditor()->newTodo( currentCatId(), 410 OTodo todo = currentEditor()->newTodo( currentCatId(),
411 this ); 411 this );
412 412
413 if ( currentEditor()->accepted() ) { 413 if ( currentEditor()->accepted() ) {
414 //todo.assignUid(); 414 //todo.assignUid();
415 currentView()->addEvent( todo ); 415 currentView()->addEvent( todo );
416 m_todoMgr.add( todo ); 416 m_todoMgr.add( todo );
417 417
418 // I'm afraid we must call this every time now, otherwise 418 // I'm afraid we must call this every time now, otherwise
419 // spend expensive time comparing all these strings... 419 // spend expensive time comparing all these strings...
420 // but only call if we changed something -zecke 420 // but only call if we changed something -zecke
421 populateCategories(); 421 populateCategories();
422 } 422 }
423
424 raiseCurrentView( ); 423 raiseCurrentView( );
425} 424}
426void MainWindow::slotDuplicate() { 425void MainWindow::slotDuplicate() {
427 if(m_syncing) { 426 if(m_syncing) {
428 QMessageBox::warning(this, tr("Todo"), 427 QMessageBox::warning(this, tr("Todo"),
429 tr("Can not edit data, currently syncing")); 428 tr("Can not edit data, currently syncing"));
430 return; 429 return;
431 } 430 }
432 OTodo ev = m_todoMgr.event( currentView()->current() ); 431 OTodo ev = m_todoMgr.event( currentView()->current() );
433 /* let's generate a new uid */ 432 /* let's generate a new uid */
434 ev.setUid(-1); 433 ev.setUid(-1);
435 m_todoMgr.add( ev ); 434 m_todoMgr.add( ev );
436 435
437 currentView()->addEvent( ev ); 436 currentView()->addEvent( ev );
438 raiseCurrentView(); 437 raiseCurrentView();
439} 438}
440void MainWindow::slotDelete() { 439void MainWindow::slotDelete() {
441 if (!currentView()->current() ) 440 if (!currentView()->current() )
442 return; 441 return;
443 442
444 if(m_syncing) { 443 if(m_syncing) {
445 QMessageBox::warning(this, tr("Todo"), 444 QMessageBox::warning(this, tr("Todo"),
446 tr("Can not edit data, currently syncing")); 445 tr("Can not edit data, currently syncing"));
447 return; 446 return;
@@ -476,102 +475,103 @@ void MainWindow::slotDeleteCompleted() {
476 QMessageBox::warning(this, tr("Todo"), 475 QMessageBox::warning(this, tr("Todo"),
477 tr("Can not edit data, currently syncing")); 476 tr("Can not edit data, currently syncing"));
478 return; 477 return;
479 } 478 }
480 479
481 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 480 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
482 return; 481 return;
483 482
484 // FIXME 483 // FIXME
485 //m_todoMgr.remove( currentView()->completed() ); 484 //m_todoMgr.remove( currentView()->completed() );
486 currentView()->updateView( ); 485 currentView()->updateView( );
487} 486}
488void MainWindow::slotFind() { 487void MainWindow::slotFind() {
489 488
490} 489}
491void MainWindow::slotEdit() { 490void MainWindow::slotEdit() {
492 slotEdit( currentView()->current() ); 491 slotEdit( currentView()->current() );
493} 492}
494/* 493/*
495 * set the category 494 * set the category
496 */ 495 */
497void MainWindow::setCategory( int c) { 496void MainWindow::setCategory( int c) {
498 if ( c <= 0 ) return; 497 if ( c <= 0 ) return;
499 498
499
500 qWarning("Iterating over cats %d", c ); 500 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 502 m_catMenu->setItemChecked(i, c == (int)i );
503 503
504 if (c == 1 ) { 504 if (c == 1 ) {
505 m_curCat = QString::null; 505 m_curCat = QString::null;
506 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 506 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
507 507
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 508 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = tr("Unfiled"); 509 m_curCat = tr("Unfiled");
510 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 510 setCaption( tr("Todo") + " - " + tr("Unfiled") );
511 }else { 511 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 512 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( tr("Todo") + " - " + m_curCat ); 513 setCaption( tr("Todo") + " - " + m_curCat );
514 } 514 }
515 m_catMenu->setItemChecked( c, true ); 515 m_catMenu->setItemChecked( c, true );
516
516 currentView()->setShowCategory( m_curCat ); 517 currentView()->setShowCategory( m_curCat );
517 raiseCurrentView(); 518 raiseCurrentView();
518} 519}
519void MainWindow::slotShowDeadLine( bool dead) { 520void MainWindow::slotShowDeadLine( bool dead) {
520 m_deadline = dead; 521 m_deadline = dead;
521 currentView()->setShowDeadline( dead ); 522 currentView()->setShowDeadline( dead );
522} 523}
523void MainWindow::slotShowCompleted( bool show) { 524void MainWindow::slotShowCompleted( bool show) {
524 m_completed = show; 525 m_completed = show;
525 currentView()->setShowCompleted( m_completed ); 526 currentView()->setShowCompleted( m_completed );
526} 527}
527bool MainWindow::showOverDue()const { 528bool MainWindow::showOverDue()const {
528 return m_overdue; 529 return m_overdue;
529} 530}
530void MainWindow::setDocument( const QString& ) { 531void MainWindow::setDocument( const QString& ) {
531 532
532} 533}
533void MainWindow::slotBeam() { 534void MainWindow::slotBeam() {
534 535
535} 536}
536void MainWindow::beamDone( Ir* ) { 537void MainWindow::beamDone( Ir* ) {
537 538
538} 539}
539 540
540void MainWindow::slotFlush() { 541void MainWindow::slotFlush() {
541 m_syncing = FALSE; 542 m_syncing = FALSE;
542 m_todoMgr.save(); 543 m_todoMgr.save();
543} 544}
544void MainWindow::slotShowDetails() { 545void MainWindow::slotShowDetails() {
545 slotShow( currentView()->current() ); 546 slotShow( currentView()->current() );
546} 547}
547/* 548/*
548 * populate the Categories 549 * populate the Categories
549 * Menu 550 * Menu
550 */ 551 */
551void MainWindow::populateCategories() { 552void MainWindow::populateCategories() {
552 if (m_todoMgr.isLoaded() ) 553 m_todoMgr.load();
553 m_todoMgr.load();
554 554
555 m_catMenu->clear(); 555 m_catMenu->clear();
556 int id, rememberId; 556 int id, rememberId;
557 id = 1; 557 id = 1;
558 rememberId = 1; 558 rememberId = 1;
559 559
560 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 560 m_catMenu->insertItem( tr( "All Categories" ), id++ );
561 m_catMenu->insertSeparator(); 561 m_catMenu->insertSeparator();
562 QStringList categories = m_todoMgr.categories(); 562 QStringList categories = m_todoMgr.categories();
563 categories.append( tr( "Unfiled" ) ); 563 categories.append( tr( "Unfiled" ) );
564 for ( QStringList::Iterator it = categories.begin(); 564 for ( QStringList::Iterator it = categories.begin();
565 it != categories.end(); ++it ) { 565 it != categories.end(); ++it ) {
566 m_catMenu->insertItem( *it, id ); 566 m_catMenu->insertItem( *it, id );
567 if ( *it == currentCategory() ) 567 if ( *it == currentCategory() )
568 rememberId = id; 568 rememberId = id;
569 ++id; 569 ++id;
570 } 570 }
571 setCategory( rememberId ); 571 setCategory( rememberId );
572} 572}
573bool MainWindow::showCompleted()const { 573bool MainWindow::showCompleted()const {
574 return m_completed; 574 return m_completed;
575} 575}
576bool MainWindow::showDeadline()const { 576bool MainWindow::showDeadline()const {
577 return m_deadline; 577 return m_deadline;
@@ -593,46 +593,47 @@ void MainWindow::slotShowDue(bool ov) {
593 currentView()->showOverDue( ov ); 593 currentView()->showOverDue( ov );
594 raiseCurrentView(); 594 raiseCurrentView();
595} 595}
596void MainWindow::slotShow( int uid ) { 596void MainWindow::slotShow( int uid ) {
597 qWarning("slotShow"); 597 qWarning("slotShow");
598 currentShow()->slotShow( event( uid ) ); 598 currentShow()->slotShow( event( uid ) );
599 m_stack->raiseWidget( currentShow()->widget() ); 599 m_stack->raiseWidget( currentShow()->widget() );
600} 600}
601void MainWindow::slotEdit( int uid ) { 601void MainWindow::slotEdit( int uid ) {
602 if(m_syncing) { 602 if(m_syncing) {
603 QMessageBox::warning(this, tr("Todo"), 603 QMessageBox::warning(this, tr("Todo"),
604 tr("Can not edit data, currently syncing")); 604 tr("Can not edit data, currently syncing"));
605 return; 605 return;
606 } 606 }
607 607
608 OTodo todo = m_todoMgr.event( uid ); 608 OTodo todo = m_todoMgr.event( uid );
609 609
610 todo = currentEditor()->edit(this, todo ); 610 todo = currentEditor()->edit(this, todo );
611 611
612 /* if completed */ 612 /* if completed */
613 if ( currentEditor()->accepted() ) { 613 if ( currentEditor()->accepted() ) {
614 qWarning("Replacing now" ); 614 qWarning("Replacing now" );
615 m_todoMgr.update( todo.uid(), todo ); 615 m_todoMgr.update( todo.uid(), todo );
616 currentView()->replaceEvent( todo ); 616 currentView()->replaceEvent( todo );
617 /* a Category might have changed */
617 populateCategories(); 618 populateCategories();
618 } 619 }
619 620
620 raiseCurrentView(); 621 raiseCurrentView();
621} 622}
622/* 623/*
623void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 624void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
624 m_todoMgr.update( uid, ev ); 625 m_todoMgr.update( uid, ev );
625} 626}
626*/ 627*/
627void MainWindow::updateTodo( const OTodo& ev) { 628void MainWindow::updateTodo( const OTodo& ev) {
628 m_todoMgr.update( ev.uid() , ev ); 629 m_todoMgr.update( ev.uid() , ev );
629} 630}
630/* The view changed it's configuration 631/* The view changed it's configuration
631 * update the view menu 632 * update the view menu
632 */ 633 */
633void MainWindow::slotUpdate3( QWidget* ) { 634void MainWindow::slotUpdate3( QWidget* ) {
634 635
635} 636}
636void MainWindow::updateList() { 637void MainWindow::updateList() {
637 m_todoMgr.updateList(); 638 m_todoMgr.updateList();
638} 639}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 5594b13..5d82eb2 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -68,84 +68,85 @@ TableView::TableView( MainWindow* window, QWidget* wid )
68 horizontalHeader()->setLabel(3, tr("Deadline") ); 68 horizontalHeader()->setLabel(3, tr("Deadline") );
69 69
70 if ( todoWindow()->showDeadline() ) 70 if ( todoWindow()->showDeadline() )
71 showColumn( 3); 71 showColumn( 3);
72 else 72 else
73 hideColumn(3 ); 73 hideColumn(3 );
74 74
75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
80 this, SLOT( slotValueChanged(int, int) ) ); 80 this, SLOT( slotValueChanged(int, int) ) );
81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
82 this, SLOT( slotCurrentChanged(int, int) ) ); 82 this, SLOT( slotCurrentChanged(int, int) ) );
83 83
84 m_menuTimer = new QTimer( this ); 84 m_menuTimer = new QTimer( this );
85 connect( m_menuTimer, SIGNAL(timeout()), 85 connect( m_menuTimer, SIGNAL(timeout()),
86 this, SLOT(slotShowMenu()) ); 86 this, SLOT(slotShowMenu()) );
87 87
88 m_enablePaint = true; 88 m_enablePaint = true;
89 setUpdatesEnabled( true ); 89 setUpdatesEnabled( true );
90 viewport()->setUpdatesEnabled( true ); 90 viewport()->setUpdatesEnabled( true );
91 viewport()->update(); 91 viewport()->update();
92 setSortOrder( 0 );
93 setAscending( TRUE );
94 m_first = true;
92} 95}
93/* a new day has started 96/* a new day has started
94 * update the day 97 * update the day
95 */ 98 */
96void TableView::newDay() { 99void TableView::newDay() {
97 clear(); 100 clear();
98 updateView(); 101 updateView();
99} 102}
100TableView::~TableView() { 103TableView::~TableView() {
101 104
102} 105}
103void TableView::slotShowMenu() { 106void TableView::slotShowMenu() {
104 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 107 QPopupMenu *menu = todoWindow()->contextMenu( current() );
105 menu->exec(QCursor::pos() ); 108 menu->exec(QCursor::pos() );
106 delete menu; 109 delete menu;
107} 110}
108QString TableView::type() const { 111QString TableView::type() const {
109 return QString::fromLatin1( tr("Table View") ); 112 return QString::fromLatin1( tr("Table View") );
110} 113}
111int TableView::current() { 114int TableView::current() {
112 int cur = 0; 115 int uid = sorted().uidAt(currentRow() );
113 // FIXME 116 qWarning("uid %d", uid );
114 return cur; 117 return uid;
115} 118}
116QString TableView::currentRepresentation() { 119QString TableView::currentRepresentation() {
117 return text( currentRow(), 2); 120 return text( currentRow(), 2);
118} 121}
119/* show overdue */ 122/* show overdue */
120void TableView::showOverDue( bool ) { 123void TableView::showOverDue( bool ) {
121 clear(); 124 clear();
122 updateView(); 125 updateView();
123} 126}
124 127
125void TableView::updateView( ) { 128void TableView::updateView( ) {
126 setSortOrder( 0 );
127 setAscending( true );
128 sort(); 129 sort();
129 OTodoAccess::List::Iterator it, end; 130 OTodoAccess::List::Iterator it, end;
130 it = sorted().begin(); 131 it = sorted().begin();
131 end = sorted().end(); 132 end = sorted().end();
132 133
133 qWarning("setTodos"); 134 qWarning("setTodos");
134 QTime time; 135 QTime time;
135 time.start(); 136 time.start();
136 m_enablePaint = false; 137 m_enablePaint = false;
137 setUpdatesEnabled( false ); 138 setUpdatesEnabled( false );
138 viewport()->setUpdatesEnabled( false ); 139 viewport()->setUpdatesEnabled( false );
139 140
140 QTime t; 141 QTime t;
141 t.start(); 142 t.start();
142 setNumRows( it.count() ); 143 setNumRows( it.count() );
143 int elc = time.elapsed(); 144 int elc = time.elapsed();
144 qWarning("Adding took %d", elc/1000 ); 145 qWarning("Adding took %d", elc/1000 );
145 setUpdatesEnabled( true ); 146 setUpdatesEnabled( true );
146 viewport()->setUpdatesEnabled( true ); 147 viewport()->setUpdatesEnabled( true );
147 viewport()->update(); 148 viewport()->update();
148 149
149 m_enablePaint = true; 150 m_enablePaint = true;
150 int el = time.elapsed(); 151 int el = time.elapsed();
151 qWarning("adding took %d", el/1000 ); 152 qWarning("adding took %d", el/1000 );
@@ -166,126 +167,131 @@ void TableView::addEvent( const OTodo&) {
166 * and then replace the complete row 167 * and then replace the complete row
167 */ 168 */
168void TableView::replaceEvent( const OTodo& ev) { 169void TableView::replaceEvent( const OTodo& ev) {
169 addEvent( ev ); 170 addEvent( ev );
170} 171}
171/* 172/*
172 * re aligning table can be slow too 173 * re aligning table can be slow too
173 * FIXME: look what performs better 174 * FIXME: look what performs better
174 * either this or the old align table 175 * either this or the old align table
175 */ 176 */
176void TableView::removeEvent( int ) { 177void TableView::removeEvent( int ) {
177 updateView(); 178 updateView();
178} 179}
179void TableView::setShowCompleted( bool b) { 180void TableView::setShowCompleted( bool b) {
180 qWarning("Show Completed %d" + b ); 181 qWarning("Show Completed %d" + b );
181 updateView(); 182 updateView();
182} 183}
183void TableView::setShowDeadline( bool b) { 184void TableView::setShowDeadline( bool b) {
184 qWarning("Show DeadLine %d" + b ); 185 qWarning("Show DeadLine %d" + b );
185 if (b) 186 if (b)
186 showColumn(3 ); 187 showColumn(3 );
187 else 188 else
188 hideColumn(3 ); 189 hideColumn(3 );
189} 190}
190void TableView::setShowCategory( const QString& ) { 191void TableView::setShowCategory( const QString& str) {
191 qWarning("setShowCategory"); 192 qWarning("setShowCategory");
192 updateView(); 193 if ( str != m_oleCat || m_first )
194 updateView();
195
196 m_oleCat = str;
197 m_first = false;
198
193} 199}
194void TableView::clear() { 200void TableView::clear() {
195 setNumRows(0); 201 setNumRows(0);
196} 202}
197void TableView::slotClicked(int row, int col, int, 203void TableView::slotClicked(int row, int col, int,
198 const QPoint& point) { 204 const QPoint& point) {
199 if ( !cellGeometry(row, col ).contains(point ) ) 205 if ( !cellGeometry(row, col ).contains(point ) )
200 return; 206 return;
201 int ui=0; // FIXME = uid(row); 207
208 int ui= sorted().uidAt( row );
202 209
203 210
204 switch( col ) { 211 switch( col ) {
205 case 0: { 212 case 0:{
206 // FIXME 213 int x = point.x() -columnPos( col );
207 CheckItem* item = 0l; 214 int y = point.y() -rowPos( row );
208 /* 215 int w = columnWidth( col );
209 * let's see if we centered clicked 216 int h = rowHeight( row );
210 */ 217 if ( x >= ( w - BoxSize ) / 2 &&
211 if ( item ) { 218 x <= ( w - BoxSize ) / 2 + BoxSize &&
212 int x = point.x() -columnPos( col ); 219 y >= ( h - BoxSize ) / 2 &&
213 int y = point.y() -rowPos( row ); 220 y <= ( h - BoxSize ) / 2 + BoxSize ) {
214 int w = columnWidth( col ); 221 OTodo todo = sorted()[row];
215 int h = rowHeight( row ); 222 todo.setCompleted( !todo.isCompleted() );
216 if ( x >= ( w - OCheckItem::BoxSize ) / 2 && 223 TodoView::update( todo.uid(), todo );
217 x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && 224 updateView();
218 y >= ( h - OCheckItem::BoxSize ) / 2 && 225 }
219 y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize )
220 item->toggle();
221 }
222 } 226 }
223 break; 227 break;
224 228
225 case 1: 229 case 1:
226 break; 230 break;
227 231
228 case 2: { 232 case 2: {
229 m_menuTimer->stop(); 233 m_menuTimer->stop();
230 showTodo( ui ); 234 showTodo( ui );
231 break; 235 break;
232 } 236 }
233 case 3: { 237 case 3: {
234 m_menuTimer->stop(); 238 m_menuTimer->stop();
235 TodoView::edit( ui ); 239 TodoView::edit( ui );
236 break; 240 break;
237 } 241 }
238 } 242 }
239 243
240 244
241} 245}
242void TableView::slotPressed(int row, int col, int, 246void TableView::slotPressed(int row, int col, int,
243 const QPoint& point) { 247 const QPoint& point) {
244 248
245 /* TextColumn column */ 249 /* TextColumn column */
246 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 250 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
247 m_menuTimer->start( 750, TRUE ); 251 m_menuTimer->start( 750, TRUE );
248} 252}
249void TableView::slotValueChanged( int, int ) { 253void TableView::slotValueChanged( int, int ) {
250 qWarning("Value Changed"); 254 qWarning("Value Changed");
251} 255}
252void TableView::slotCurrentChanged(int, int ) { 256void TableView::slotCurrentChanged(int, int ) {
253 m_menuTimer->stop(); 257 m_menuTimer->stop();
254} 258}
255QWidget* TableView::widget() { 259QWidget* TableView::widget() {
256 return this; 260 return this;
257} 261}
258/* 262/*
259 * We need to overwrite sortColumn 263 * We need to overwrite sortColumn
260 * because we want to sort whole row 264 * because we want to sort whole row
261 * based 265 * based
262 * We event want to set the setOrder 266 * We event want to set the setOrder
263 * to a sort() and update() 267 * to a sort() and update()
264 */ 268 */
265void TableView::sortColumn( int row, bool asc, bool ) { 269void TableView::sortColumn( int col, bool asc, bool ) {
266 QTable::sortColumn( row, asc, TRUE ); 270 qWarning("bool %d", asc );
267 271 setSortOrder( col );
272 setAscending( asc );
273 updateView();
268} 274}
269void TableView::viewportPaintEvent( QPaintEvent* e) { 275void TableView::viewportPaintEvent( QPaintEvent* e) {
270 qWarning("Paint event" ); 276 qWarning("Paint event" );
271 if (m_enablePaint ) 277 if (m_enablePaint )
272 QTable::viewportPaintEvent( e ); 278 QTable::viewportPaintEvent( e );
273} 279}
274/* 280/*
275 * This segment is copyrighted by TT 281 * This segment is copyrighted by TT
276 * it was taken from their todolist 282 * it was taken from their todolist
277 * application this code is GPL 283 * application this code is GPL
278 */ 284 */
279void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 285void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
280 const QColorGroup &cg = colorGroup(); 286 const QColorGroup &cg = colorGroup();
281 287
282 p->save(); 288 p->save();
283 289
284 OTodo task = sorted()[row]; 290 OTodo task = sorted()[row];
285 291
286 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 292 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
287 293
288 QPen op = p->pen(); 294 QPen op = p->pen();
289 p->setPen(cg.mid()); 295 p->setPen(cg.mid());
290 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 296 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
291 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 297 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
@@ -336,24 +342,59 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
336 break; 342 break;
337 case 2: 343 case 2:
338 // description field 344 // description field
339 { 345 {
340 QString text = task.summary().isEmpty() ? 346 QString text = task.summary().isEmpty() ?
341 task.description() : 347 task.description() :
342 task.summary(); 348 task.summary();
343 p->drawText(2,2 + fm.ascent(), text); 349 p->drawText(2,2 + fm.ascent(), text);
344 } 350 }
345 break; 351 break;
346 case 3: 352 case 3:
347 { 353 {
348 QString text; 354 QString text;
349 if (task.hasDueDate()) { 355 if (task.hasDueDate()) {
350 text = "HAS"; 356 text = "HAS";
351 } else { 357 } else {
352 text = tr("None"); 358 text = tr("None");
353 } 359 }
354 p->drawText(2,2 + fm.ascent(), text); 360 p->drawText(2,2 + fm.ascent(), text);
355 } 361 }
356 break; 362 break;
357 } 363 }
358 p->restore(); 364 p->restore();
359} 365}
366QWidget* TableView::createEditor(int row, int col, bool )const {
367 switch( col ) {
368 case 1: {
369 /* the priority stuff */
370 QComboBox* combo = new QComboBox( viewport() );
371 combo->insertItem( "1" );
372 combo->insertItem( "2" );
373 combo->insertItem( "3" );
374 combo->insertItem( "4" );
375 combo->insertItem( "5" );
376 combo->setCurrentItem( sorted()[row].priority()-1 );
377 return combo;
378 }
379 case 0:
380 default:
381 return 0l;
382 }
383}
384void TableView::setCellContentFromEditor(int row, int col ) {
385 if ( col == 1 ) {
386 QWidget* wid = cellWidget(row, 1 );
387 if ( wid->inherits("QComboBox") ) {
388 int pri = ((QComboBox*)wid)->currentItem() + 1;
389 OTodo todo = sorted()[row];
390 if ( todo.priority() != pri ) {
391 todo.setPriority( pri );
392 TodoView::update( todo.uid(), todo );
393 updateView();
394 }
395 }
396 }
397}
398void TableView::slotPriority() {
399 setCellContentFromEditor( currentRow(), currentColumn() );
400}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index b608204..bf41aea 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -57,37 +57,44 @@ namespace Todo {
57 void setTodo( int uid, const OTodo& ); 57 void setTodo( int uid, const OTodo& );
58 void addEvent( const OTodo& event ); 58 void addEvent( const OTodo& event );
59 void replaceEvent( const OTodo& ); 59 void replaceEvent( const OTodo& );
60 void removeEvent( int uid ); 60 void removeEvent( int uid );
61 void setShowCompleted( bool ); 61 void setShowCompleted( bool );
62 void setShowDeadline( bool ); 62 void setShowDeadline( bool );
63 63
64 void setShowCategory(const QString& =QString::null ); 64 void setShowCategory(const QString& =QString::null );
65 void newDay(); 65 void newDay();
66 QWidget* widget(); 66 QWidget* widget();
67 void sortColumn(int, bool, bool ); 67 void sortColumn(int, bool, bool );
68 68
69 /* 69 /*
70 * we do our drawing ourselves 70 * we do our drawing ourselves
71 * because we don't want to have 71 * because we don't want to have
72 * 40.000 QTableItems for 10.000 72 * 40.000 QTableItems for 10.000
73 * OTodos where we only show 10 at a time! 73 * OTodos where we only show 10 at a time!
74 */ 74 */
75 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 75 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
76 private: 76 private:
77 /* reimplented for internal reasons */ 77 /* reimplented for internal reasons */
78 void viewportPaintEvent( QPaintEvent* ); 78 void viewportPaintEvent( QPaintEvent* );
79 QTimer *m_menuTimer; 79 QTimer *m_menuTimer;
80 bool m_enablePaint:1; 80 bool m_enablePaint:1;
81 QString m_oleCat;
82 bool m_first : 1;
83
84 protected:
85 QWidget* createEditor(int row, int col, bool initFromCell )const;
86 void setCellContentFromEditor( int row, int col );
81 87
82private slots: 88private slots:
83 void slotShowMenu(); 89 void slotShowMenu();
84 void slotClicked(int, int, int, 90 void slotClicked(int, int, int,
85 const QPoint& ); 91 const QPoint& );
86 void slotPressed(int, int, int, 92 void slotPressed(int, int, int,
87 const QPoint& ); 93 const QPoint& );
88 void slotValueChanged(int, int); 94 void slotValueChanged(int, int);
89 void slotCurrentChanged(int, int ); 95 void slotCurrentChanged(int, int );
96 void slotPriority();
90 }; 97 };
91}; 98};
92 99
93#endif 100#endif
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index ebf9e8a..1f81539 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -26,48 +26,49 @@
26 26
27*/ 27*/
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qpe/categoryselect.h> 29#include <qpe/categoryselect.h>
30 30
31#include "todomanager.h" 31#include "todomanager.h"
32 32
33using namespace Todo; 33using namespace Todo;
34 34
35TodoManager::TodoManager( QObject *obj ) 35TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) { 36 : QObject( obj ) {
37 m_db = 0l; 37 m_db = 0l;
38 QTime time; 38 QTime time;
39 time.start(); 39 time.start();
40 int el = time.elapsed(); 40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 ); 41 qWarning("QTimer for loading %d", el/1000 );
42} 42}
43TodoManager::~TodoManager() { 43TodoManager::~TodoManager() {
44 delete m_db; 44 delete m_db;
45} 45}
46OTodo TodoManager::event(int uid ) { 46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 47 return m_db->find( uid );
48} 48}
49void TodoManager::updateList() { 49void TodoManager::updateList() {
50 qWarning("update list");
50 m_list = m_db->allRecords(); 51 m_list = m_db->allRecords();
51} 52}
52OTodoAccess::List TodoManager::list() const{ 53OTodoAccess::List TodoManager::list() const{
53 return m_list; 54 return m_list;
54} 55}
55OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 56OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
56 return m_db->sorted( asc, so, f, cat ); 57 return m_db->sorted( asc, so, f, cat );
57} 58}
58OTodoAccess::List::Iterator TodoManager::overDue() { 59OTodoAccess::List::Iterator TodoManager::overDue() {
59 int filter = 2 | 1; 60 int filter = 2 | 1;
60 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
61 m_it = m_list.begin(); 62 m_it = m_list.begin();
62 return m_it; 63 return m_it;
63} 64}
64OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
65 const QDate& end ) { 66 const QDate& end ) {
66 m_list = m_db->effectiveToDos( start, end ); 67 m_list = m_db->effectiveToDos( start, end );
67 m_it = m_list.begin(); 68 m_it = m_list.begin();
68 return m_it; 69 return m_it;
69} 70}
70OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { 71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
71 m_list = m_db->queryByExample( ev, query ); 72 m_list = m_db->queryByExample( ev, query );
72 m_it = m_list.begin(); 73 m_it = m_list.begin();
73 return m_it; 74 return m_it;
@@ -97,28 +98,29 @@ bool TodoManager::saveAll() {
97 return m_db->save(); 98 return m_db->save();
98} 99}
99void TodoManager::reload() { 100void TodoManager::reload() {
100 m_db->reload(); 101 m_db->reload();
101} 102}
102QStringList TodoManager::categories() { 103QStringList TodoManager::categories() {
103 m_cat.load(categoryFileName() ); 104 m_cat.load(categoryFileName() );
104 return m_cat.labels( "Todo List"); 105 return m_cat.labels( "Todo List");
105} 106}
106/* 107/*
107 * we rely on load beeing called from populateCategories 108 * we rely on load beeing called from populateCategories
108 */ 109 */
109int TodoManager::catId( const QString& cats ) { 110int TodoManager::catId( const QString& cats ) {
110 return m_cat.id( "Todo List", cats ); 111 return m_cat.id( "Todo List", cats );
111} 112}
112void TodoManager::remove( const QArray<int>& ids) { 113void TodoManager::remove( const QArray<int>& ids) {
113 for (uint i=0; i < ids.size(); i++ ) 114 for (uint i=0; i < ids.size(); i++ )
114 remove( ids[i] ); 115 remove( ids[i] );
115} 116}
116bool TodoManager::isLoaded()const { 117bool TodoManager::isLoaded()const {
117 return (m_db == 0 ); 118 return (m_db == 0 );
118} 119}
119void TodoManager::load() { 120void TodoManager::load() {
120 if (!m_db) { 121 if (!m_db) {
122 qWarning("loading!");
121 m_db = new OTodoAccess(); 123 m_db = new OTodoAccess();
122 m_db->load(); 124 m_db->load();
123 } 125 }
124} 126}
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 06eaaa9..639fa66 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -33,46 +33,47 @@ void TodoView::connectUpdateSmall( QObject* obj,
33void TodoView::connectUpdateBig( QObject* obj, 33void TodoView::connectUpdateBig( QObject* obj,
34 const char* slot ) { 34 const char* slot ) {
35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), 35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
36 obj, slot ); 36 obj, slot );
37} 37}
38void TodoView::connectUpdateView( QObject* obj, 38void TodoView::connectUpdateView( QObject* obj,
39 const char* slot ) { 39 const char* slot ) {
40 QObject::connect( hack, SIGNAL(update(QWidget*) ), 40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
41 obj, slot ); 41 obj, slot );
42} 42}
43void TodoView::connectRemove( QObject* obj, 43void TodoView::connectRemove( QObject* obj,
44 const char* slot ) { 44 const char* slot ) {
45 QObject::connect( hack, SIGNAL(remove(int) ), 45 QObject::connect( hack, SIGNAL(remove(int) ),
46 obj, slot ); 46 obj, slot );
47} 47}
48MainWindow* TodoView::todoWindow() { 48MainWindow* TodoView::todoWindow() {
49 return m_main; 49 return m_main;
50} 50}
51 51
52OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 52OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
53OTodoAccess::List TodoView::list(){ 53OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 54 todoWindow()->updateList();
55 return todoWindow()->list(); 55 return todoWindow()->list();
56} 56}
57OTodoAccess::List TodoView::sorted(){ 57OTodoAccess::List TodoView::sorted()const{
58 return m_sort; 58 return m_sort;
59} 59}
60void TodoView::sort() { 60void TodoView::sort() {
61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
62 qWarning("m_sort.count() = %d", m_sort.count() ); 62 qWarning("m_sort.count() = %d", m_sort.count() );
63} 63}
64void TodoView::sort(int sort) { 64void TodoView::sort(int sort) {
65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); 65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
66} 66}
67void TodoView::setSortOrder( int order ) { 67void TodoView::setSortOrder( int order ) {
68 m_sortOrder = order; 68 m_sortOrder = order;
69} 69}
70void TodoView::setAscending( bool b ) { 70void TodoView::setAscending( bool b ) {
71 qWarning("setAscending %d", b );
71 m_asc = b; 72 m_asc = b;
72} 73}
73void TodoView::update(int uid, const SmallTodo& to ) { 74void TodoView::update(int uid, const SmallTodo& to ) {
74 //m_main->slotUpate1( uid, to ); 75 //m_main->slotUpate1( uid, to );
75} 76}
76void TodoView::update(int uid, const OTodo& ev ) { 77void TodoView::update(int uid, const OTodo& ev ) {
77 m_main->updateTodo( ev ); 78 m_main->updateTodo( ev );
78} 79}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index 9408ef1..e5c77f9 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -136,49 +136,49 @@ namespace Todo {
136 /** 136 /**
137 *d'tor 137 *d'tor
138 */ 138 */
139 virtual ~TodoView(); 139 virtual ~TodoView();
140 140
141 /* connect to the show signal */ 141 /* connect to the show signal */
142 void connectShow(QObject* obj, 142 void connectShow(QObject* obj,
143 const char* slot ); 143 const char* slot );
144 144
145 /* connect to edit */ 145 /* connect to edit */
146 void connectEdit( QObject* obj, 146 void connectEdit( QObject* obj,
147 const char* slot ); 147 const char* slot );
148 void connectUpdateSmall( QObject* obj, 148 void connectUpdateSmall( QObject* obj,
149 const char* slot ); 149 const char* slot );
150 void connectUpdateBig( QObject* obj, 150 void connectUpdateBig( QObject* obj,
151 const char* slot ) ; 151 const char* slot ) ;
152 void connectUpdateView( QObject* obj, 152 void connectUpdateView( QObject* obj,
153 const char* slot ); 153 const char* slot );
154 void connectRemove( QObject* obj, 154 void connectRemove( QObject* obj,
155 const char* slot ); 155 const char* slot );
156 protected: 156 protected:
157 MainWindow* todoWindow(); 157 MainWindow* todoWindow();
158 OTodo event(int uid ); 158 OTodo event(int uid );
159 OTodoAccess::List list(); 159 OTodoAccess::List list();
160 OTodoAccess::List sorted(); 160 OTodoAccess::List sorted()const;
161 void sort(); 161 void sort();
162 void sort(int sort ); 162 void sort(int sort );
163 void setSortOrder( int order ); 163 void setSortOrder( int order );
164 void setAscending( bool ); 164 void setAscending( bool );
165 165
166 /* 166 /*
167 These things needs to be implemented 167 These things needs to be implemented
168 in a implementation 168 in a implementation
169 signals: 169 signals:
170 */ 170 */
171 protected: 171 protected:
172 void showTodo( int uid ) { hack->emitShow(uid); } 172 void showTodo( int uid ) { hack->emitShow(uid); }
173 void edit( int uid ) { hack->emitEdit(uid); } 173 void edit( int uid ) { hack->emitEdit(uid); }
174 void update(int uid, const SmallTodo& to ); 174 void update(int uid, const SmallTodo& to );
175 void update(int uid, const OTodo& ev); 175 void update(int uid, const OTodo& ev);
176 void remove( int uid ) { 176 void remove( int uid ) {
177 hack->emitRemove( uid ); 177 hack->emitRemove( uid );
178 } 178 }
179 private: 179 private:
180 InternQtHack* hack; 180 InternQtHack* hack;
181 MainWindow *m_main; 181 MainWindow *m_main;
182 OTodoAccess::List m_sort; 182 OTodoAccess::List m_sort;
183 bool m_asc : 1; 183 bool m_asc : 1;
184 int m_sortOrder; 184 int m_sortOrder;