summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp4
-rw-r--r--core/pim/todo/todotable.cpp98
-rw-r--r--core/pim/todo/todotable.h43
3 files changed, 87 insertions, 58 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 33f13aa..a34bcf2 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -101,25 +101,24 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
101 "before you enter any data") ); 101 "before you enter any data") );
102 102
103 setCentralWidget( table ); 103 setCentralWidget( table );
104 setToolBarsMovable( FALSE ); 104 setToolBarsMovable( FALSE );
105 105
106// qDebug("after load: t=%d", t.elapsed() ); 106// qDebug("after load: t=%d", t.elapsed() );
107 107
108 Config config( "todo" ); 108 Config config( "todo" );
109 config.setGroup( "View" ); 109 config.setGroup( "View" );
110 bool complete = config.readBoolEntry( "ShowComplete", true ); 110 bool complete = config.readBoolEntry( "ShowComplete", true );
111 table->setShowCompleted( complete ); 111 table->setShowCompleted( complete );
112 112
113 /* added 20.01.2k2 by se */
114 bool showdeadline = config.readBoolEntry("ShowDeadLine", true); 113 bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
115 table->setShowDeadline (showdeadline); 114 table->setShowDeadline (showdeadline);
116 115
117 QString category = config.readEntry( "Category", QString::null ); 116 QString category = config.readEntry( "Category", QString::null );
118 table->setShowCategory( category ); 117 table->setShowCategory( category );
119 118
120 QPEToolBar *bar = new QPEToolBar( this ); 119 QPEToolBar *bar = new QPEToolBar( this );
121 bar->setHorizontalStretchable( TRUE ); 120 bar->setHorizontalStretchable( TRUE );
122 121
123 QPEMenuBar *mb = new QPEMenuBar( bar ); 122 QPEMenuBar *mb = new QPEMenuBar( bar );
124 123
125 catMenu = new QPopupMenu( this ); 124 catMenu = new QPopupMenu( this );
@@ -172,25 +171,24 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
172 a->addTo( edit ); 171 a->addTo( edit );
173 if ( table->numRows() ) 172 if ( table->numRows() )
174 a->setEnabled( TRUE ); 173 a->setEnabled( TRUE );
175 else 174 else
176 a->setEnabled( FALSE ); 175 a->setEnabled( FALSE );
177 176
178 //a->setEnabled( FALSE ); 177 //a->setEnabled( FALSE );
179 findAction = a; 178 findAction = a;
180// qDebug("mainwindow #2: t=%d", t.elapsed() ); 179// qDebug("mainwindow #2: t=%d", t.elapsed() );
181 180
182 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); 181 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE );
183 182
184 /* added 20.01.2k2 by se */
185 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); 183 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
186 184
187 catMenu->setCheckable( true ); 185 catMenu->setCheckable( true );
188 populateCategories(); 186 populateCategories();
189 187
190 mb->insertItem( tr( "Task" ), edit ); 188 mb->insertItem( tr( "Task" ), edit );
191 mb->insertItem( tr( "View" ), catMenu ); 189 mb->insertItem( tr( "View" ), catMenu );
192 190
193 resize( 200, 300 ); 191 resize( 200, 300 );
194 if ( table->numRows() > 0 ) 192 if ( table->numRows() > 0 )
195 currentEntryChanged( 0, 0 ); 193 currentEntryChanged( 0, 0 );
196 connect( table, SIGNAL( signalEdit() ), 194 connect( table, SIGNAL( signalEdit() ),
@@ -355,25 +353,25 @@ void TodoWindow::setCategory( int c )
355 } 353 }
356 table->setPaintingEnabled( true ); 354 table->setPaintingEnabled( true );
357} 355}
358 356
359void TodoWindow::populateCategories() 357void TodoWindow::populateCategories()
360{ 358{
361 catMenu->clear(); 359 catMenu->clear();
362 360
363 completedAction->addTo( catMenu ); 361 completedAction->addTo( catMenu );
364 completedAction->setOn( table->showCompleted() ); 362 completedAction->setOn( table->showCompleted() );
365 showdeadlineAction->addTo( catMenu ); 363 showdeadlineAction->addTo( catMenu );
366 showdeadlineAction->setOn( table->showDeadline() ); 364 showdeadlineAction->setOn( table->showDeadline() );
367 365 catMenu->insertSeparator();
368 int id, rememberId; 366 int id, rememberId;
369 id = 1; 367 id = 1;
370 catMenu->insertItem( tr( "All Categories" ), id++ ); 368 catMenu->insertItem( tr( "All Categories" ), id++ );
371// catMenu->insertSeparator(); 369// catMenu->insertSeparator();
372 QStringList categories = table->categories(); 370 QStringList categories = table->categories();
373 categories.append( tr( "Unfiled" ) ); 371 categories.append( tr( "Unfiled" ) );
374 for ( QStringList::Iterator it = categories.begin(); 372 for ( QStringList::Iterator it = categories.begin();
375 it != categories.end(); ++it ) { 373 it != categories.end(); ++it ) {
376 catMenu->insertItem( *it, id ); 374 catMenu->insertItem( *it, id );
377 if ( *it == table->showCategory() ) 375 if ( *it == table->showCategory() )
378 rememberId = id; 376 rememberId = id;
379 ++id; 377 ++id;
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
index 3cd0c0e..2acd03c 100644
--- a/core/pim/todo/todotable.cpp
+++ b/core/pim/todo/todotable.cpp
@@ -151,27 +151,75 @@ void ComboItem::setText( const QString &s )
151{ 151{
152 if ( cb ) 152 if ( cb )
153 cb->setCurrentItem( s.toInt() - 1 ); 153 cb->setCurrentItem( s.toInt() - 1 );
154 QTableItem::setText( s ); 154 QTableItem::setText( s );
155} 155}
156 156
157QString ComboItem::text() const 157QString ComboItem::text() const
158{ 158{
159 if ( cb ) 159 if ( cb )
160 return cb->currentText(); 160 return cb->currentText();
161 return QTableItem::text(); 161 return QTableItem::text();
162} 162}
163 163DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev )
164 164 : QTableItem(t, Never, QString::null )
165 165{
166 setToDoEvent( ev );
167}
168QString DueTextItem::key() const
169{
170 QString key;
171 if( m_hasDate ){
172 if(m_off == 0 ){
173 key.append("b");
174 }else if( m_off > 0 ){
175 key.append("c");
176 }else if( m_off < 0 ){
177 key.append("a");
178 }
179 key.append(QString::number(m_off ) );
180 }else{
181 key.append("d");
182 }
183 return key;
184}
185void DueTextItem::setToDoEvent( const ToDoEvent *ev )
186{
187 m_hasDate = ev->hasDate();
188 m_completed = ev->isCompleted();
189 if( ev->hasDate() ){
190 QDate today = QDate::currentDate();
191 m_off = today.daysTo(ev->date() );
192 setText( QString::number(m_off) + " day(s) " );
193 }else{
194 setText("n.d." );
195 m_off = 0;
196 }
197}
198void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected )
199{
200 QColorGroup cg2(cg);
201 QColor text = cg.text();
202 if( m_hasDate && !m_completed ){
203 if( m_off < 0 ){
204 cg2.setColor(QColorGroup::Text, QColor(red ) );
205 }else if( m_off == 0 ){
206 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
207 }else if( m_off > 0){
208 cg2.setColor(QColorGroup::Text, QColor(green ) );
209 }
210 }
211 QTableItem::paint(p, cg2, cr, selected );
212 cg2.setColor(QColorGroup::Text, text );
213}
166TodoTable::TodoTable( QWidget *parent, const char *name ) 214TodoTable::TodoTable( QWidget *parent, const char *name )
167// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR 215// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
168// : QTable( 0, 3, parent, name, TRUE ), 216// : QTable( 0, 3, parent, name, TRUE ),
169// #else 217// #else
170 : QTable( 0, 4, parent, name ), 218 : QTable( 0, 4, parent, name ),
171// #endif 219// #endif
172 showComp( true ), 220 showComp( true ),
173 enablePainting( true ), 221 enablePainting( true ),
174 mCat( 0 ), 222 mCat( 0 ),
175 currFindRow( -2 ), 223 currFindRow( -2 ),
176 showDeadl( true) 224 showDeadl( true)
177{ 225{
@@ -238,31 +286,31 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
238 if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && 286 if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize &&
239 y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { 287 y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) {
240 i->toggle(); 288 i->toggle();
241 } 289 }
242 emit signalDoneChanged( i->isChecked() ); 290 emit signalDoneChanged( i->isChecked() );
243 } 291 }
244 } 292 }
245 break; 293 break;
246 case 1: 294 case 1:
247 break; 295 break;
248 case 2: 296 case 2:
249 // may as well edit it... 297 // may as well edit it...
250 menuTimer->stop(); 298 // menuTimer->stop();
251// emit signalEdit(); 299// emit signalEdit();
252 break; 300 // fall through
253 case 3: /* added 20.01.2k2 by se */ 301 case 3:
254 // may as well edit it... 302 // may as well edit it...
255 menuTimer->stop(); 303 menuTimer->stop();
256 emit signalEdit(); 304 // emit signalEdit();
257 break; 305 break;
258 } 306 }
259} 307}
260 308
261void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) 309void TodoTable::slotPressed( int row, int col, int, const QPoint &pos )
262{ 310{
263 if ( col == 2 && cellGeometry( row, col ).contains(pos) ) 311 if ( col == 2 && cellGeometry( row, col ).contains(pos) )
264 menuTimer->start( 750, TRUE ); 312 menuTimer->start( 750, TRUE );
265} 313}
266 314
267void TodoTable::slotShowMenu() 315void TodoTable::slotShowMenu()
268{ 316{
@@ -359,57 +407,55 @@ bool TodoTable::save( const QString &fn )
359 407
360void TodoTable::load( const QString &fn ) 408void TodoTable::load( const QString &fn )
361{ 409{
362 loadFile( fn, false ); 410 loadFile( fn, false );
363 if ( QFile::exists(journalFileName()) ) { 411 if ( QFile::exists(journalFileName()) ) {
364 loadFile( journalFileName(), true ); 412 loadFile( journalFileName(), true );
365 save( fn ); 413 save( fn );
366 } 414 }
367// QTable::sortColumn(2,TRUE,TRUE); 415// QTable::sortColumn(2,TRUE,TRUE);
368// QTable::sortColumn(1,TRUE,TRUE); 416// QTable::sortColumn(1,TRUE,TRUE);
369 QTable::sortColumn(0,TRUE,TRUE); 417 QTable::sortColumn(0,TRUE,TRUE);
370 setCurrentCell( 0, 2 ); 418 setCurrentCell( 0, 2 );
419 setSorting(true );
371} 420}
372 421
373void TodoTable::updateVisible() 422void TodoTable::updateVisible()
374{ 423{
375 if ( !isUpdatesEnabled() ) 424 if ( !isUpdatesEnabled() )
376 return; 425 return;
377 426
378// qDebug("--> updateVisible!");
379
380 /* added 20.01.2k2 by se */
381 if (showDeadl){ 427 if (showDeadl){
382 showColumn (3); 428 showColumn (3);
383 adjustColumn(3); 429 adjustColumn(3);
384 }else{ 430 }else{
385 hideColumn (3); 431 hideColumn (3);
386 adjustColumn(2); 432 adjustColumn(2);
387 } 433 }
388 434
389 int visible = 0; 435 int visible = 0;
390 int id = mCat.id( "Todo List", showCat ); 436 int id = mCat.id( "Todo List", showCat );
391 for ( int row = 0; row < numRows(); row++ ) { 437 for ( int row = 0; row < numRows(); row++ ) {
392 CheckItem *ci = (CheckItem *)item( row, 0 ); 438 CheckItem *ci = (CheckItem *)item( row, 0 );
393 ToDoEvent *t = todoList[ci]; 439 ToDoEvent *t = todoList[ci];
394 QArray<int> vlCats = t->categories(); 440 QArray<int> vlCats = t->categories();
395 bool hide = false; 441 bool hide = false;
396 if ( !showComp && ci->isChecked() ) 442 if ( !showComp && ci->isChecked() )
397 hide = true; 443 hide = true;
398 if ( !showCat.isEmpty() ) { 444 if ( !showCat.isEmpty() ) {
399 if ( showCat == tr( "Unfiled" ) ) { 445 if ( showCat == tr( "Unfiled" ) ) {
400 if ( vlCats.count() > 0 ) 446 if ( vlCats.count() > 0 )
401 hide = true; 447 hide = true;
402 } else { 448 } else {
403 // do some comparing, we have to reverse our idea here... 449 // do some comparing, we have to reverse our idea here... which idea - zecke
404 if ( !hide ) { 450 if ( !hide ) {
405 hide = true; 451 hide = true;
406 for ( uint it = 0; it < vlCats.count(); ++it ) { 452 for ( uint it = 0; it < vlCats.count(); ++it ) {
407 if ( vlCats[it] == id ) { 453 if ( vlCats[it] == id ) {
408 hide = false; 454 hide = false;
409 break; 455 break;
410 } 456 }
411 } 457 }
412 } 458 }
413 } 459 }
414 } 460 }
415 if ( hide ) { 461 if ( hide ) {
@@ -457,56 +503,56 @@ void TodoTable::clear()
457 } 503 }
458 todoList.clear(); 504 todoList.clear();
459 for ( int r = 0; r < numRows(); ++r ) { 505 for ( int r = 0; r < numRows(); ++r ) {
460 for ( int c = 0; c < numCols(); ++c ) { 506 for ( int c = 0; c < numCols(); ++c ) {
461 if ( cellWidget( r, c ) ) 507 if ( cellWidget( r, c ) )
462 clearCellWidget( r, c ); 508 clearCellWidget( r, c );
463 clearCell( r, c ); 509 clearCell( r, c );
464 } 510 }
465 } 511 }
466 setNumRows( 0 ); 512 setNumRows( 0 );
467} 513}
468 514
469void TodoTable::sortColumn( int col, bool /*ascending*/, bool /*wholeRows*/ ) 515void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ )
470{ 516{
471 // The default for wholeRows is false, however 517 // The default for wholeRows is false, however
472 // for this todo table we want to exchange complete 518 // for this todo table we want to exchange complete
473 // rows when sorting. Also, we always want ascending, since 519 // rows when sorting. Also, we always want ascending, since
474 // the values have a logical order. 520 // the values have a logical order.
475 QTable::sortColumn( col, TRUE, TRUE ); 521 QTable::sortColumn( col, ascending, TRUE );
476 updateVisible(); 522 updateVisible();
477} 523}
478 524
479void TodoTable::slotCheckPriority(int row, int col ) 525void TodoTable::slotCheckPriority(int row, int col )
480{ 526{
481 // kludgey work around to make forward along the updated priority... 527 // kludgey work around to make forward along the updated priority...
482 if ( col == 1 ) { 528 if ( col == 1 ) {
483 // let everyone know!! 529 // let everyone know!!
484 ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); 530 ComboItem* i = static_cast<ComboItem*>( item( row, col ) );
485 emit signalPriorityChanged( i->text().toInt() ); 531 emit signalPriorityChanged( i->text().toInt() );
486 } 532 }
487} 533}
488 534
489 535
490void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action, int row ) 536void TodoTable::updateJournal( const ToDoEvent &/*todo*/, journal_action action, int row )
491{ 537{
492 QFile f( journalFileName() ); 538 QFile f( journalFileName() );
493 if ( !f.open(IO_WriteOnly|IO_Append) ) 539 if ( !f.open(IO_WriteOnly|IO_Append) )
494 return; 540 return;
495 QString buf; 541 QString buf;
496 QCString str; 542 QCString str;
497 buf = "<Task"; 543 buf = "<Task";
498 // todo.save( buf ); 544 // todo.save( buf );
499 buf += " Action=\"" + QString::number( int(action) ) + "\""; 545 buf += " Action=\"" + QString::number( int(action) ) + "\"";
500 buf += " Row=\"" + QString::number( row ) + "\""; 546 buf += " Row=\"" + QString::number( row ) + "\""; // better write the id
501 buf += "/>\n"; 547 buf += "/>\n";
502 str = buf.utf8(); 548 str = buf.utf8();
503 f.writeBlock( str.data(), str.length() ); 549 f.writeBlock( str.data(), str.length() );
504 f.close(); 550 f.close();
505} 551}
506 552
507void TodoTable::rowHeightChanged( int row ) 553void TodoTable::rowHeightChanged( int row )
508{ 554{
509 if ( enablePainting ) 555 if ( enablePainting )
510 QTable::rowHeightChanged( row ); 556 QTable::rowHeightChanged( row );
511} 557}
512 558
@@ -532,59 +578,41 @@ void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
532{ 578{
533 QString strTodo; 579 QString strTodo;
534 strTodo = todo.description().left(40).simplifyWhiteSpace(); 580 strTodo = todo.description().left(40).simplifyWhiteSpace();
535 if ( row == -1 ) { 581 if ( row == -1 ) {
536 QMapIterator<CheckItem*, ToDoEvent *> it; 582 QMapIterator<CheckItem*, ToDoEvent *> it;
537 for ( it = todoList.begin(); it != todoList.end(); ++it ) { 583 for ( it = todoList.begin(); it != todoList.end(); ++it ) {
538 if ( *(*it) == todo ) { 584 if ( *(*it) == todo ) {
539 row = it.key()->row(); 585 row = it.key()->row();
540 it.key()->setChecked( todo.isCompleted() ); 586 it.key()->setChecked( todo.isCompleted() );
541 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); 587 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
542 item( row, 2 )->setText( strTodo ); 588 item( row, 2 )->setText( strTodo );
543 589
544 /* added 20.01.2k2 by se */
545 if (showDeadl){ 590 if (showDeadl){
546 if (todo.hasDate()){ 591 static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
547 QDate *today = new QDate (QDate::currentDate());
548 if (today){
549 item (row, 3)->setText (tr ("%1").arg(today->daysTo(todo.date())));
550 delete (today);
551 }
552 }else{
553 item (row, 3)->setText ("n.d.");
554 }
555 } 592 }
556 593
557 *(*it) = todo; 594 *(*it) = todo;
558 } 595 }
559 } 596 }
560 } else { 597 } else {
561 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; 598 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))];
562 todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); 599 todoList.remove( static_cast<CheckItem*>(item(row, 0)) );
563 delete t; 600 delete t;
564 static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); 601 static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() );
565 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); 602 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
566 item( row, 2 )->setText( strTodo ); 603 item( row, 2 )->setText( strTodo );
567 604
568 /* added 20.01.2k2 by se */
569 if (showDeadl){ 605 if (showDeadl){
570 if (todo.hasDate()){ 606 static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo );
571 QDate *today = new QDate (QDate::currentDate());
572 if (today){
573 item (row, 3)->setText (tr ("%1").arg(today->daysTo(todo.date())));
574 delete (today);
575 }
576 }else{
577 item (row, 3)->setText ("n.d.");
578 }
579 } 607 }
580 608
581 todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); 609 todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) );
582 } 610 }
583} 611}
584 612
585void TodoTable::journalFreeRemoveEntry( int row ) 613void TodoTable::journalFreeRemoveEntry( int row )
586{ 614{
587 CheckItem *chk; 615 CheckItem *chk;
588 chk = static_cast<CheckItem*>(item(row, 0 )); 616 chk = static_cast<CheckItem*>(item(row, 0 ));
589 if ( !chk ) 617 if ( !chk )
590 return; 618 return;
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h
index 288ff90..32df514 100644
--- a/core/pim/todo/todotable.h
+++ b/core/pim/todo/todotable.h
@@ -68,46 +68,58 @@ private:
68 68
69}; 69};
70 70
71class TodoTextItem : public QTableItem 71class TodoTextItem : public QTableItem
72{ 72{
73public: 73public:
74 TodoTextItem( QTable *t, const QString & str ) 74 TodoTextItem( QTable *t, const QString & str )
75 :QTableItem( t, QTableItem::Never, str ) {} 75 :QTableItem( t, QTableItem::Never, str ) {}
76 76
77 QString key () const { return Qtopia::buildSortKey( text() ); } 77 QString key () const { return Qtopia::buildSortKey( text() ); }
78}; 78};
79 79
80class DueTextItem : public QTableItem
81{
82 public:
83 DueTextItem( QTable *t, ToDoEvent *ev );
84 QString key() const;
85 void setToDoEvent( const ToDoEvent *ev );
86 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected );
87 private:
88 int m_off;
89 bool m_hasDate:1;
90 bool m_completed:1;
91
92};
80 93
81 94
82enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 95enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
83 96
84class TodoTable : public QTable 97class TodoTable : public QTable
85{ 98{
86 Q_OBJECT 99 Q_OBJECT
87 100
88public: 101public:
89 TodoTable( QWidget *parent = 0, const char * name = 0 ); 102 TodoTable( QWidget *parent = 0, const char * name = 0 );
90 void addEntry( const ToDoEvent &todo ); 103 void addEntry( const ToDoEvent &todo );
91 void clearFindRow() { currFindRow = -2; } 104 void clearFindRow() { currFindRow = -2; }
92 105
93 ToDoEvent currentEntry() const; 106 ToDoEvent currentEntry() const;
94 void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); 107 void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false );
95 108
96 QStringList categories(); 109 QStringList categories();
97 110
98 void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } 111 void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); }
99 bool showCompleted() const { return showComp; } 112 bool showCompleted() const { return showComp; }
100 113
101 /* added 20.01.2k2 by se */
102 void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} 114 void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();}
103 bool showDeadline() const { return showDeadl;} 115 bool showDeadline() const { return showDeadl;}
104 116
105 void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } 117 void setShowCategory( const QString &c ) { showCat = c; updateVisible(); }
106 const QString &showCategory() const { return showCat; } 118 const QString &showCategory() const { return showCat; }
107 int showCategoryId() const; 119 int showCategoryId() const;
108 120
109 bool save( const QString &fn ); 121 bool save( const QString &fn );
110 void load( const QString &fn ); 122 void load( const QString &fn );
111 void clear(); 123 void clear();
112 void removeCurrentEntry(); 124 void removeCurrentEntry();
113 125
@@ -154,77 +166,68 @@ private slots:
154 166
155private: 167private:
156 friend class TodoWindow; 168 friend class TodoWindow;
157 169
158 QMap<CheckItem*, ToDoEvent *> todoList; 170 QMap<CheckItem*, ToDoEvent *> todoList;
159 QStringList categoryList; 171 QStringList categoryList;
160 bool showComp; 172 bool showComp;
161 QString showCat; 173 QString showCat;
162 QTimer *menuTimer; 174 QTimer *menuTimer;
163 bool enablePainting; 175 bool enablePainting;
164 Categories mCat; 176 Categories mCat;
165 int currFindRow; 177 int currFindRow;
166 178 bool showDeadl:1;
167 /* added 20.01.2k2 by se */
168 bool showDeadl;
169}; 179};
170 180
171 181
172inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) 182inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row )
173{ 183{
174 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') 184 QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A')
175 + todo->priority() ) 185 + todo->priority() )
176 + Qtopia::buildSortKey( todo->description() ); 186 + Qtopia::buildSortKey( todo->description() );
177 CheckItem *chk = new CheckItem( this, sortKey ); 187 CheckItem *chk = new CheckItem( this, sortKey );
178 chk->setChecked( todo->isCompleted() ); 188 chk->setChecked( todo->isCompleted() );
179 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); 189 ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent );
180 cmb->setText( QString::number( todo->priority() ) ); 190 cmb->setText( QString::number( todo->priority() ) );
181 QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); 191 QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() );
182 ti->setReplaceable( false ); 192 ti->setReplaceable( false );
183 193
184 /* added 20.01.2k2 by se */ 194 DueTextItem *due = new DueTextItem(this, todo );
185 QTableItem *dl = NULL; 195 setItem( row, 3, due);
186 if (todo->hasDate()){
187 QDate *today = new QDate (QDate::currentDate());
188 if (today){
189 dl = new TodoTextItem (this, tr ("%1").
190 arg(today->daysTo(todo->date())));
191 delete (today);
192 }
193 }else{
194 dl = new TodoTextItem (this,"n.d.");
195 }
196 setItem( row, 3, dl);
197 196
198 setItem( row, 0, chk ); 197 setItem( row, 0, chk );
199 setItem( row, 1, cmb ); 198 setItem( row, 1, cmb );
200 setItem( row, 2, ti ); 199 setItem( row, 2, ti );
201 200
202 201
203 todoList.insert( chk, todo ); 202 todoList.insert( chk, todo );
204} 203}
205 204
206inline void TodoTable::realignTable( int row ) 205inline void TodoTable::realignTable( int row )
207{ 206{
208 QTableItem *ti1, 207 QTableItem *ti1,
209 *ti2, 208 *ti2,
210 *ti3; 209 *ti3,
210 *ti4;
211 int totalRows = numRows(); 211 int totalRows = numRows();
212 for ( int curr = row; curr < totalRows - 1; curr++ ) { 212 for ( int curr = row; curr < totalRows - 1; curr++ ) {
213 // this is bad, we must take the item out and then 213 // this is bad, we must take the item out and then
214 // set it. In the end, it behaves no worse (time wise) 214 // set it. In the end, it behaves no worse (time wise)
215 // then the old way of saving the entries to file, clearing 215 // then the old way of saving the entries to file, clearing
216 // the table re-reading in the file and resetting the table 216 // the table re-reading in the file and resetting the table
217 ti1 = item( curr + 1, 0 ); 217 ti1 = item( curr + 1, 0 );
218 ti2 = item( curr + 1, 1 ); 218 ti2 = item( curr + 1, 1 );
219 ti3 = item( curr + 1, 2 ); 219 ti3 = item( curr + 1, 2 );
220 ti4 = item( curr + 1, 3 );
220 takeItem( ti1 ); 221 takeItem( ti1 );
221 takeItem( ti2 ); 222 takeItem( ti2 );
222 takeItem( ti3 ); 223 takeItem( ti3 );
224 takeItem( ti4 );
223 setItem( curr, 0, ti1 ); 225 setItem( curr, 0, ti1 );
224 setItem( curr, 1, ti2 ); 226 setItem( curr, 1, ti2 );
225 setItem( curr, 2, ti3 ); 227 setItem( curr, 2, ti3 );
228 setItem( curr, 3, ti4 );
226 } 229 }
227 setNumRows( totalRows - 1 ); 230 setNumRows( totalRows - 1 );
228} 231}
229 232
230#endif 233#endif