summaryrefslogtreecommitdiff
path: root/core/pim/todo/todotable.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/todotable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todotable.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp
index 779b28c..15f733b 100644
--- a/core/pim/todo/todotable.cpp
+++ b/core/pim/todo/todotable.cpp
@@ -210,64 +210,65 @@ void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bo
210 if( m_hasDate && !m_completed ){ 210 if( m_hasDate && !m_completed ){
211 if( m_off < 0 ){ 211 if( m_off < 0 ){
212 cg2.setColor(QColorGroup::Text, QColor(red ) ); 212 cg2.setColor(QColorGroup::Text, QColor(red ) );
213 }else if( m_off == 0 ){ 213 }else if( m_off == 0 ){
214 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined 214 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
215 }else if( m_off > 0){ 215 }else if( m_off > 0){
216 cg2.setColor(QColorGroup::Text, QColor(green ) ); 216 cg2.setColor(QColorGroup::Text, QColor(green ) );
217 } 217 }
218 } 218 }
219 QTableItem::paint(p, cg2, cr, selected ); 219 QTableItem::paint(p, cg2, cr, selected );
220 cg2.setColor(QColorGroup::Text, text ); 220 cg2.setColor(QColorGroup::Text, text );
221} 221}
222TodoTable::TodoTable( QWidget *parent, const char *name ) 222TodoTable::TodoTable( QWidget *parent, const char *name )
223// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR 223// #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR
224// : QTable( 0, 3, parent, name, TRUE ), 224// : QTable( 0, 3, parent, name, TRUE ),
225// #else 225// #else
226 : QTable( 0, 4, parent, name ), 226 : QTable( 0, 4, parent, name ),
227// #endif 227// #endif
228 showComp( true ), 228 showComp( true ),
229 enablePainting( true ), 229 enablePainting( true ),
230 mCat( 0 ), 230 mCat( 0 ),
231 currFindRow( -2 ), 231 currFindRow( -2 ),
232 showDeadl( true) 232 showDeadl( true)
233{ 233{
234 setNumRows(0);
234 mCat.load( categoryFileName() ); 235 mCat.load( categoryFileName() );
235 setSorting( TRUE ); 236 setSorting( TRUE );
236 setSelectionMode( NoSelection ); 237 setSelectionMode( NoSelection );
237 setColumnStretchable( 2, TRUE ); 238 setColumnStretchable( 2, TRUE );
238 setColumnWidth( 0, 20 ); 239 setColumnWidth( 0, 20 );
239 setColumnWidth( 1, 35 ); 240 setColumnWidth( 1, 35 );
240 241
241 setLeftMargin( 0 ); 242 setLeftMargin( 0 );
242 verticalHeader()->hide(); 243 verticalHeader()->hide();
243 horizontalHeader()->setLabel( 0, tr( "C." ) ); 244 horizontalHeader()->setLabel( 0, tr( "C." ) );
244 horizontalHeader()->setLabel( 1, tr( "Prior." ) ); 245 horizontalHeader()->setLabel( 1, tr( "Prior." ) );
245 horizontalHeader()->setLabel( 2, tr( "Description" ) ); 246 horizontalHeader()->setLabel( 2, tr( "Description" ) );
246 247
247 setColumnStretchable( 3, FALSE ); 248 setColumnStretchable( 3, FALSE );
248 setColumnWidth( 3, 20 ); 249 setColumnWidth( 3, 20 );
249 horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); 250 horizontalHeader()->setLabel( 3, tr( "Deadline" ) );
250 251
251 if (showDeadl){ 252 if (showDeadl){
252 showColumn (3); 253 showColumn (3);
253 }else{ 254 }else{
254 hideColumn (3); 255 hideColumn (3);
255 } 256 }
256 257
257 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), 258 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
258 this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); 259 this, SLOT( slotClicked( int, int, int, const QPoint & ) ) );
259 connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), 260 connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ),
260 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); 261 this, SLOT( slotPressed( int, int, int, const QPoint & ) ) );
261 connect( this, SIGNAL( valueChanged( int, int ) ), 262 connect( this, SIGNAL( valueChanged( int, int ) ),
262 this, SLOT( slotCheckPriority( int, int ) ) ); 263 this, SLOT( slotCheckPriority( int, int ) ) );
263 connect( this, SIGNAL( currentChanged( int, int ) ), 264 connect( this, SIGNAL( currentChanged( int, int ) ),
264 this, SLOT( slotCurrentChanged( int, int ) ) ); 265 this, SLOT( slotCurrentChanged( int, int ) ) );
265 266
266 menuTimer = new QTimer( this ); 267 menuTimer = new QTimer( this );
267 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); 268 connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) );
268 269
269 mDayTimer = new QTimer( this ); 270 mDayTimer = new QTimer( this );
270 connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); 271 connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) );
271 mDay = QDate::currentDate(); 272 mDay = QDate::currentDate();
272} 273}
273 274
@@ -292,49 +293,49 @@ void TodoTable::slotClicked( int row, int col, int, const QPoint &pos )
292 CheckItem *i = static_cast<CheckItem*>(item( row, col )); 293 CheckItem *i = static_cast<CheckItem*>(item( row, col ));
293 if ( i ) { 294 if ( i ) {
294 int x = pos.x() - columnPos( col ); 295 int x = pos.x() - columnPos( col );
295 int y = pos.y() - rowPos( row ); 296 int y = pos.y() - rowPos( row );
296 int w = columnWidth( col ); 297 int w = columnWidth( col );
297 int h = rowHeight( row ); 298 int h = rowHeight( row );
298 if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && 299 if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize &&
299 y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { 300 y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) {
300 i->toggle(); 301 i->toggle();
301 } 302 }
302 emit signalDoneChanged( i->isChecked() ); 303 emit signalDoneChanged( i->isChecked() );
303 } 304 }
304 } 305 }
305 break; 306 break;
306 case 1: 307 case 1:
307 break; 308 break;
308 case 2: 309 case 2:
309 // Show detailed view of the selected entry 310 // Show detailed view of the selected entry
310 { 311 {
311 menuTimer->stop(); 312 menuTimer->stop();
312 ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; 313 ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))];
313 emit showDetails( *todo ); 314 emit showDetails( *todo );
314 } 315 }
315 break; 316 break;
316 case 3: 317 case 3:
317 // may as well edit it... 318 // may as well edit it...
318 menuTimer->stop(); 319 menuTimer->stop();
319 emit signalEdit(); 320 emit signalEdit();
320 break; 321 break;
321 } 322 }
322} 323}
323 324
324void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) 325void TodoTable::slotPressed( int row, int col, int, const QPoint &pos )
325{ 326{
326 if ( col == 2 && cellGeometry( row, col ).contains(pos) ) 327 if ( col == 2 && cellGeometry( row, col ).contains(pos) )
327 menuTimer->start( 750, TRUE ); 328 menuTimer->start( 750, TRUE );
328} 329}
329 330
330void TodoTable::slotShowMenu() 331void TodoTable::slotShowMenu()
331{ 332{
332 emit signalShowMenu( QCursor::pos() ); 333 emit signalShowMenu( QCursor::pos() );
333} 334}
334 335
335void TodoTable::slotCurrentChanged( int, int ) 336void TodoTable::slotCurrentChanged( int, int )
336{ 337{
337 menuTimer->stop(); 338 menuTimer->stop();
338} 339}
339 340
340void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) 341void TodoTable::internalAddEntries( QList<ToDoEvent> &list )
@@ -417,62 +418,65 @@ bool TodoTable::save( const QString &fn )
417 418
418 // remove the journal 419 // remove the journal
419 QFile::remove( journalFileName() ); 420 QFile::remove( journalFileName() );
420 return true; 421 return true;
421} 422}
422 423
423void TodoTable::load( const QString &fn ) 424void TodoTable::load( const QString &fn )
424{ 425{
425 if ( QFile::exists(journalFileName()) ) { 426 if ( QFile::exists(journalFileName()) ) {
426 applyJournal(); 427 applyJournal();
427 QFile::remove(journalFileName() ); 428 QFile::remove(journalFileName() );
428 } 429 }
429 loadFile( fn ); 430 loadFile( fn );
430// QTable::sortColumn(2,TRUE,TRUE); 431// QTable::sortColumn(2,TRUE,TRUE);
431// QTable::sortColumn(1,TRUE,TRUE); 432// QTable::sortColumn(1,TRUE,TRUE);
432 QTable::sortColumn(0,TRUE,TRUE); 433 QTable::sortColumn(0,TRUE,TRUE);
433 setCurrentCell( 0, 2 ); 434 setCurrentCell( 0, 2 );
434 setSorting(true ); 435 setSorting(true );
435 mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? 436 mDayTimer->start( 60 * 1000 ); // gone in 60 seconds?
436} 437}
437void TodoTable::updateVisible() 438void TodoTable::updateVisible()
438{ 439{
439 if ( !isUpdatesEnabled() ) 440 if ( !isUpdatesEnabled() )
440 return; 441 return;
441 442
442 if (showDeadl){ 443 if (showDeadl){
443 showColumn (3); 444 showColumn (3);
444 adjustColumn(3); 445 adjustColumn(3);
445 }else{ 446 }else{
446 hideColumn (3); 447 hideColumn (3);
447 adjustColumn(2); 448 adjustColumn(2);
448 } 449 }
449 450
450 int visible = 0; 451 int visible = 0;
451 int id = mCat.id( "Todo List", showCat ); 452 int id = mCat.id( "Todo List", showCat );
452 for ( int row = 0; row < numRows(); row++ ) { 453 for ( int row = 0; row < numRows(); row++ ) {
453 CheckItem *ci = (CheckItem *)item( row, 0 ); 454 CheckItem *ci = (CheckItem *)item( row, 0 );
454 ToDoEvent *t = todoList[ci]; 455 ToDoEvent *t = todoList[ci];
456 if (!t)
457 continue;
458
455 QArray<int> vlCats = t->categories(); 459 QArray<int> vlCats = t->categories();
456 bool hide = false; 460 bool hide = false;
457 if ( !showComp && ci->isChecked() ) 461 if ( !showComp && ci->isChecked() )
458 hide = true; 462 hide = true;
459 if ( !showCat.isEmpty() ) { 463 if ( !showCat.isEmpty() ) {
460 if ( showCat == tr( "Unfiled" ) ) { 464 if ( showCat == tr( "Unfiled" ) ) {
461 if ( vlCats.count() > 0 ) 465 if ( vlCats.count() > 0 )
462 hide = true; 466 hide = true;
463 } else { 467 } else {
464 // do some comparing, we have to reverse our idea here... which idea? - zecke 468 // do some comparing, we have to reverse our idea here... which idea? - zecke
465 if ( !hide ) { 469 if ( !hide ) {
466 hide = true; 470 hide = true;
467 for ( uint it = 0; it < vlCats.count(); ++it ) { 471 for ( uint it = 0; it < vlCats.count(); ++it ) {
468 if ( vlCats[it] == id ) { 472 if ( vlCats[it] == id ) {
469 hide = false; 473 hide = false;
470 break; 474 break;
471 } 475 }
472 } 476 }
473 } 477 }
474 } 478 }
475 } 479 }
476 if ( hide ) { 480 if ( hide ) {
477 if ( currentRow() == row ) 481 if ( currentRow() == row )
478 setCurrentCell( -1, 0 ); 482 setCurrentCell( -1, 0 );
@@ -578,49 +582,49 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action )
578 buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; 582 buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\"";
579 buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; 583 buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\"";
580 } 584 }
581 buf += "/>\n"; 585 buf += "/>\n";
582 str = buf.utf8(); 586 str = buf.utf8();
583 f.writeBlock( str.data(), str.length() ); 587 f.writeBlock( str.data(), str.length() );
584 f.close(); 588 f.close();
585} 589}
586 590
587void TodoTable::rowHeightChanged( int row ) 591void TodoTable::rowHeightChanged( int row )
588{ 592{
589 if ( enablePainting ) 593 if ( enablePainting )
590 QTable::rowHeightChanged( row ); 594 QTable::rowHeightChanged( row );
591} 595}
592 596
593void TodoTable::loadFile( const QString &/*we use the standard*/ ) 597void TodoTable::loadFile( const QString &/*we use the standard*/ )
594{ 598{
595 599
596 QList<ToDoEvent> list; 600 QList<ToDoEvent> list;
597 ToDoDB todoDB; 601 ToDoDB todoDB;
598 QValueList<ToDoEvent> vaList = todoDB.rawToDos(); 602 QValueList<ToDoEvent> vaList = todoDB.rawToDos();
599 for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ 603 for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){
600 ToDoEvent *event = new ToDoEvent( (*it) ); 604 ToDoEvent *event = new ToDoEvent( (*it) );
601 list.append( event ); 605 list.append( event );
602 } 606 }
603 vaList.clear(); 607 vaList.clear();
604 // qDebug("parsing done=%d", t.elapsed() ); 608 // qDebug("parsing done=%d", t.elapsed() );
605 if ( list.count() > 0 ) { 609 if ( list.count() > 0 ) {
606 internalAddEntries( list ); 610 internalAddEntries( list );
607 list.clear(); 611 list.clear();
608 } 612 }
609// qDebug("loading done: t=%d", t.elapsed() ); 613// qDebug("loading done: t=%d", t.elapsed() );
610} 614}
611 615
612void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) 616void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row )
613{ 617{
614 QString strTodo = todo.summary(); 618 QString strTodo = todo.summary();
615 if( strTodo.isEmpty() ){ 619 if( strTodo.isEmpty() ){
616 strTodo = todo.description().left(40).simplifyWhiteSpace(); 620 strTodo = todo.description().left(40).simplifyWhiteSpace();
617 //todo.setSummary(strTodo ); 621 //todo.setSummary(strTodo );
618 } 622 }
619 if ( row == -1 ) { 623 if ( row == -1 ) {
620 QMapIterator<CheckItem*, ToDoEvent *> it; 624 QMapIterator<CheckItem*, ToDoEvent *> it;
621 for ( it = todoList.begin(); it != todoList.end(); ++it ) { 625 for ( it = todoList.begin(); it != todoList.end(); ++it ) {
622 if ( *(*it) == todo ) { 626 if ( *(*it) == todo ) {
623 row = it.key()->row(); 627 row = it.key()->row();
624 it.key()->setChecked( todo.isCompleted() ); 628 it.key()->setChecked( todo.isCompleted() );
625 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); 629 static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) );
626 item( row, 2 )->setText( strTodo ); 630 item( row, 2 )->setText( strTodo );
@@ -660,49 +664,49 @@ void TodoTable::journalFreeRemoveEntry( int row )
660 664
661void TodoTable::keyPressEvent( QKeyEvent *e ) 665void TodoTable::keyPressEvent( QKeyEvent *e )
662{ 666{
663 if ( e->key() == Key_Space || e->key() == Key_Return ) { 667 if ( e->key() == Key_Space || e->key() == Key_Return ) {
664 switch ( currentColumn() ) { 668 switch ( currentColumn() ) {
665 case 0: { 669 case 0: {
666 CheckItem *i = static_cast<CheckItem*>(item(currentRow(), 670 CheckItem *i = static_cast<CheckItem*>(item(currentRow(),
667 currentColumn())); 671 currentColumn()));
668 if ( i ) 672 if ( i )
669 i->toggle(); 673 i->toggle();
670 break; 674 break;
671 } 675 }
672 case 1: 676 case 1:
673 break; 677 break;
674 case 2:{ 678 case 2:{
675 ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; 679 ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))];
676 emit showDetails(*todo); 680 emit showDetails(*todo);
677 break; 681 break;
678 } 682 }
679 case 3: 683 case 3:
680 // Future: Let us change the dueDate directly... 684 // Future: Let us change the dueDate directly...
681 emit signalEdit(); 685 emit signalEdit();
682 default: 686 default:
683 break; 687 break;
684 } 688 }
685 } else 689 } else
686 QTable::keyPressEvent( e ); 690 QTable::keyPressEvent( e );
687} 691}
688 692
689 693
690QStringList TodoTable::categories() 694QStringList TodoTable::categories()
691{ 695{
692 // This is called seldom, so calling a load in here 696 // This is called seldom, so calling a load in here
693 // should be fine. 697 // should be fine.
694 mCat.load( categoryFileName() ); 698 mCat.load( categoryFileName() );
695 QStringList categoryList = mCat.labels( "Todo List" ); 699 QStringList categoryList = mCat.labels( "Todo List" );
696 return categoryList; 700 return categoryList;
697} 701}
698 702
699void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, 703void TodoTable::slotDoFind( const QString &findString, bool caseSensitive,
700 bool backwards, int category ) 704 bool backwards, int category )
701{ 705{
702 // we have to iterate through the table, this gives the illusion that 706 // we have to iterate through the table, this gives the illusion that
703 // sorting is actually being used. 707 // sorting is actually being used.
704 if ( currFindRow < -1 ) 708 if ( currFindRow < -1 )
705 currFindRow = currentRow() - 1; 709 currFindRow = currentRow() - 1;
706 clearSelection( TRUE ); 710 clearSelection( TRUE );
707 int rows, 711 int rows,
708 row; 712 row;
@@ -737,49 +741,49 @@ void TodoTable::slotDoFind( const QString &findString, bool caseSensitive,
737 emit signalNotFound(); 741 emit signalNotFound();
738 wrapAround = !wrapAround; 742 wrapAround = !wrapAround;
739 } else { 743 } else {
740 currFindRow = row; 744 currFindRow = row;
741 QTableSelection foundSelection; 745 QTableSelection foundSelection;
742 foundSelection.init( currFindRow, 0 ); 746 foundSelection.init( currFindRow, 0 );
743 foundSelection.expandTo( currFindRow, numCols() - 1 ); 747 foundSelection.expandTo( currFindRow, numCols() - 1 );
744 addSelection( foundSelection ); 748 addSelection( foundSelection );
745 setCurrentCell( currFindRow, numCols() - 1 ); 749 setCurrentCell( currFindRow, numCols() - 1 );
746 // we should always be able to wrap around and find this again, 750 // we should always be able to wrap around and find this again,
747 // so don't give confusing not found message... 751 // so don't give confusing not found message...
748 wrapAround = true; 752 wrapAround = true;
749 } 753 }
750} 754}
751 755
752int TodoTable::showCategoryId() const 756int TodoTable::showCategoryId() const
753{ 757{
754 int id; 758 int id;
755 id = -1; 759 id = -1;
756 // if allcategories are selected, you get unfiled... 760 // if allcategories are selected, you get unfiled...
757 if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) 761 if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) )
758 id = mCat.id( "Todo List", showCat ); 762 id = mCat.id( "Todo List", showCat );
759 return id; 763 return id;
760} 764}
761void TodoTable::applyJournal() 765void TodoTable::applyJournal()
762{ 766{
763 // we need to hack 767 // we need to hack
764 QFile file( journalFileName() ); 768 QFile file( journalFileName() );
765 if( file.open(IO_ReadOnly ) ) { 769 if( file.open(IO_ReadOnly ) ) {
766 QByteArray ar = file.readAll(); 770 QByteArray ar = file.readAll();
767 file.close(); 771 file.close();
768 QFile file2( journalFileName() + "_new" ); 772 QFile file2( journalFileName() + "_new" );
769 if( file2.open(IO_WriteOnly ) ){ 773 if( file2.open(IO_WriteOnly ) ){
770 QTextStream str(&file2 ); 774 QTextStream str(&file2 );
771 str << QString::fromLatin1("<Tasks>") << endl; 775 str << QString::fromLatin1("<Tasks>") << endl;
772 str << ar.data(); 776 str << ar.data();
773 str << QString::fromLatin1("</Tasks>") << endl; 777 str << QString::fromLatin1("</Tasks>") << endl;
774 file2.close(); 778 file2.close();
775 } 779 }
776 XMLElement *root = XMLElement::load(journalFileName()+ "_new"); 780 XMLElement *root = XMLElement::load(journalFileName()+ "_new");
777 XMLElement *el = root->firstChild(); 781 XMLElement *el = root->firstChild();
778 el = el->firstChild(); 782 el = el->firstChild();
779 ToDoDB tododb; // allready loaded ;) 783 ToDoDB tododb; // allready loaded ;)
780 bool ok; 784 bool ok;
781 int action; 785 int action;
782 QString dummy; 786 QString dummy;
783 while( el ){ 787 while( el ){
784 dummy = el->attribute("Action" ); 788 dummy = el->attribute("Action" );
785 action = dummy.toInt(&ok ); 789 action = dummy.toInt(&ok );
@@ -788,49 +792,49 @@ void TodoTable::applyJournal()
788 switch( action){ 792 switch( action){
789 case ACTION_ADD: 793 case ACTION_ADD:
790 tododb.addEvent(ev ); 794 tododb.addEvent(ev );
791 break; 795 break;
792 case ACTION_REMOVE: 796 case ACTION_REMOVE:
793 tododb.removeEvent( ev ); 797 tododb.removeEvent( ev );
794 break; 798 break;
795 case ACTION_REPLACE: 799 case ACTION_REPLACE:
796 tododb.replaceEvent( ev ); 800 tododb.replaceEvent( ev );
797 break; 801 break;
798 } 802 }
799 } 803 }
800 el = el->nextChild(); 804 el = el->nextChild();
801 } 805 }
802 QFile::remove(journalFileName()+ "_new" ); 806 QFile::remove(journalFileName()+ "_new" );
803 tododb.save(); 807 tododb.save();
804 } 808 }
805} 809}
806void TodoTable::slotCheckDay() 810void TodoTable::slotCheckDay()
807{ 811{
808 QDate date = QDate::currentDate(); 812 QDate date = QDate::currentDate();
809 if( mDay.daysTo(date )!= 0 ){ 813 if( mDay.daysTo(date )!= 0 ){
810 setPaintingEnabled( FALSE ); 814 setPaintingEnabled( FALSE );
811 for(int i=0; i < numRows(); i++ ){ 815 for(int i=0; i < numRows(); i++ ){
812 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; 816 ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))];
813 static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); 817 static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t );
814 818
815 } 819 }
816 setPaintingEnabled( TRUE ); 820 setPaintingEnabled( TRUE );
817 mDay = date; 821 mDay = date;
818 } 822 }
819 mDayTimer->start( 60 * 1000 ); // 60 seconds 823 mDayTimer->start( 60 * 1000 ); // 60 seconds
820} 824}
821// check Action and decide 825// check Action and decide
822/* 826/*
823void TodoTable::doApply(XMLElement *el ) 827void TodoTable::doApply(XMLElement *el )
824{ 828{
825 QString dummy; 829 QString dummy;
826 bool ok; 830 bool ok;
827 int action; 831 int action;
828 dummy = el->attribute("Action" ); 832 dummy = el->attribute("Action" );
829 action = dummy.toInt(&ok ); 833 action = dummy.toInt(&ok );
830 ToDoEvent ev = xmlToEvent( el ); 834 ToDoEvent ev = xmlToEvent( el );
831 if( ok ){ 835 if( ok ){
832 switch( action ){ 836 switch( action ){
833 case ACTION_ADD: 837 case ACTION_ADD:
834 addEntry( ev ); 838 addEntry( ev );
835 break; 839 break;
836 case ACTION_REMOVE:{ // find an entry with the same uid and remove it then 840 case ACTION_REMOVE:{ // find an entry with the same uid and remove it then
@@ -897,49 +901,49 @@ static ToDoEvent xmlToEvent( XMLElement *element )
897 // month 901 // month
898 dummy = element->attribute("DateMonth" ); 902 dummy = element->attribute("DateMonth" );
899 dumInt = dummy.toInt(&ok ); 903 dumInt = dummy.toInt(&ok );
900 if(ok ) month = dumInt; 904 if(ok ) month = dumInt;
901 dummy = element->attribute("DateDay" ); 905 dummy = element->attribute("DateDay" );
902 dumInt = dummy.toInt(&ok ); 906 dumInt = dummy.toInt(&ok );
903 if(ok ) day = dumInt; 907 if(ok ) day = dumInt;
904 // set the date 908 // set the date
905 QDate date( year, month, day ); 909 QDate date( year, month, day );
906 event.setDate( date); 910 event.setDate( date);
907 } 911 }
908 dummy = element->attribute("Priority" ); 912 dummy = element->attribute("Priority" );
909 dumInt = dummy.toInt(&ok ); 913 dumInt = dummy.toInt(&ok );
910 if(!ok ) dumInt = ToDoEvent::NORMAL; 914 if(!ok ) dumInt = ToDoEvent::NORMAL;
911 event.setPriority( dumInt ); 915 event.setPriority( dumInt );
912 //description 916 //description
913 dummy = element->attribute("Description" ); 917 dummy = element->attribute("Description" );
914 event.setDescription( dummy ); 918 event.setDescription( dummy );
915 // summary 919 // summary
916 dummy = element->attribute("Summary" ); 920 dummy = element->attribute("Summary" );
917 event.setSummary( dummy ); 921 event.setSummary( dummy );
918 // category 922 // category
919 dummy = element->attribute("Categories" ); 923 dummy = element->attribute("Categories" );
920 QStringList ids = QStringList::split(";", dummy ); 924 QStringList ids = QStringList::split(";", dummy );
921 event.setCategories( ids ); 925 event.setCategories( ids );
922 926
923 //uid 927 //uid
924 dummy = element->attribute("Uid" ); 928 dummy = element->attribute("Uid" );
925 dumInt = dummy.toInt(&ok ); 929 dumInt = dummy.toInt(&ok );
926 if(ok ) event.setUid( dumInt ); 930 if(ok ) event.setUid( dumInt );
927 return event; 931 return event;
928} 932}
929 933
930} 934}
931// int TodoTable::rowHeight( int ) const 935// int TodoTable::rowHeight( int ) const
932// { 936// {
933// return 18; 937// return 18;
934// } 938// }
935 939
936// int TodoTable::rowPos( int row ) const 940// int TodoTable::rowPos( int row ) const
937// { 941// {
938// return 18*row; 942// return 18*row;
939// } 943// }
940 944
941// int TodoTable::rowAt( int pos ) const 945// int TodoTable::rowAt( int pos ) const
942// { 946// {
943// return QMIN( pos/18, numRows()-1 ); 947// return QMIN( pos/18, numRows()-1 );
944// } 948// }
945 949