-rw-r--r-- | core/pim/todo/todotable.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 52a3087..779b28c 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -551,88 +551,92 @@ void TodoTable::slotCheckPriority(int row, int col ) | |||
551 | 551 | ||
552 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) | 552 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) |
553 | { | 553 | { |
554 | QFile f( journalFileName() ); | 554 | QFile f( journalFileName() ); |
555 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 555 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
556 | return; | 556 | return; |
557 | QString buf; | 557 | QString buf; |
558 | QCString str; | 558 | QCString str; |
559 | buf = "<Task"; | 559 | buf = "<Task"; |
560 | // todo.save( buf ); | 560 | // todo.save( buf ); |
561 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 561 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
562 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id | 562 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id |
563 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 563 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
564 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 564 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
565 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 565 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
566 | QArray<int> arrat = todo.categories(); | 566 | QArray<int> arrat = todo.categories(); |
567 | QString attr; | 567 | QString attr; |
568 | for(uint i=0; i < arrat.count(); i++ ){ | 568 | for(uint i=0; i < arrat.count(); i++ ){ |
569 | attr.append(QString::number(arrat[i])+";" ); | 569 | attr.append(QString::number(arrat[i])+";" ); |
570 | } | 570 | } |
571 | if(!attr.isEmpty() ) // remove the last ; | 571 | if(!attr.isEmpty() ) // remove the last ; |
572 | attr.remove(attr.length()-1, 1 ); | 572 | attr.remove(attr.length()-1, 1 ); |
573 | buf += " Categories=\"" + attr + "\""; | 573 | buf += " Categories=\"" + attr + "\""; |
574 | buf += " Description=\"" + todo.description() + "\""; | 574 | buf += " Description=\"" + todo.description() + "\""; |
575 | buf += " Summary=\"" + todo.summary() + "\""; | ||
575 | if(todo.hasDate() ) { | 576 | if(todo.hasDate() ) { |
576 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 577 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
577 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 578 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
578 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 579 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
579 | } | 580 | } |
580 | buf += "/>\n"; | 581 | buf += "/>\n"; |
581 | str = buf.utf8(); | 582 | str = buf.utf8(); |
582 | f.writeBlock( str.data(), str.length() ); | 583 | f.writeBlock( str.data(), str.length() ); |
583 | f.close(); | 584 | f.close(); |
584 | } | 585 | } |
585 | 586 | ||
586 | void TodoTable::rowHeightChanged( int row ) | 587 | void TodoTable::rowHeightChanged( int row ) |
587 | { | 588 | { |
588 | if ( enablePainting ) | 589 | if ( enablePainting ) |
589 | QTable::rowHeightChanged( row ); | 590 | QTable::rowHeightChanged( row ); |
590 | } | 591 | } |
591 | 592 | ||
592 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) | 593 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
593 | { | 594 | { |
594 | 595 | ||
595 | QList<ToDoEvent> list; | 596 | QList<ToDoEvent> list; |
596 | ToDoDB todoDB; | 597 | ToDoDB todoDB; |
597 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 598 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
598 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 599 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
599 | ToDoEvent *event = new ToDoEvent( (*it) ); | 600 | ToDoEvent *event = new ToDoEvent( (*it) ); |
600 | list.append( event ); | 601 | list.append( event ); |
601 | } | 602 | } |
602 | vaList.clear(); | 603 | vaList.clear(); |
603 | // qDebug("parsing done=%d", t.elapsed() ); | 604 | // qDebug("parsing done=%d", t.elapsed() ); |
604 | if ( list.count() > 0 ) { | 605 | if ( list.count() > 0 ) { |
605 | internalAddEntries( list ); | 606 | internalAddEntries( list ); |
606 | list.clear(); | 607 | list.clear(); |
607 | } | 608 | } |
608 | // qDebug("loading done: t=%d", t.elapsed() ); | 609 | // qDebug("loading done: t=%d", t.elapsed() ); |
609 | } | 610 | } |
610 | 611 | ||
611 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 612 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
612 | { | 613 | { |
613 | QString strTodo; | 614 | QString strTodo = todo.summary(); |
614 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 615 | if( strTodo.isEmpty() ){ |
616 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | ||
617 | //todo.setSummary(strTodo ); | ||
618 | } | ||
615 | if ( row == -1 ) { | 619 | if ( row == -1 ) { |
616 | QMapIterator<CheckItem*, ToDoEvent *> it; | 620 | QMapIterator<CheckItem*, ToDoEvent *> it; |
617 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 621 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
618 | if ( *(*it) == todo ) { | 622 | if ( *(*it) == todo ) { |
619 | row = it.key()->row(); | 623 | row = it.key()->row(); |
620 | it.key()->setChecked( todo.isCompleted() ); | 624 | it.key()->setChecked( todo.isCompleted() ); |
621 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 625 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
622 | item( row, 2 )->setText( strTodo ); | 626 | item( row, 2 )->setText( strTodo ); |
623 | 627 | ||
624 | if (showDeadl){ | 628 | if (showDeadl){ |
625 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 629 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
626 | } | 630 | } |
627 | 631 | ||
628 | *(*it) = todo; | 632 | *(*it) = todo; |
629 | } | 633 | } |
630 | } | 634 | } |
631 | } else { | 635 | } else { |
632 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 636 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
633 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 637 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
634 | delete t; | 638 | delete t; |
635 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 639 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
636 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 640 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
637 | item( row, 2 )->setText( strTodo ); | 641 | item( row, 2 )->setText( strTodo ); |
638 | 642 | ||
@@ -887,48 +891,51 @@ static ToDoEvent xmlToEvent( XMLElement *element ) | |||
887 | int year, day, month = 0; | 891 | int year, day, month = 0; |
888 | year = day = month; | 892 | year = day = month; |
889 | // year | 893 | // year |
890 | dummy = element->attribute("DateYear" ); | 894 | dummy = element->attribute("DateYear" ); |
891 | dumInt = dummy.toInt(&ok ); | 895 | dumInt = dummy.toInt(&ok ); |
892 | if( ok ) year = dumInt; | 896 | if( ok ) year = dumInt; |
893 | // month | 897 | // month |
894 | dummy = element->attribute("DateMonth" ); | 898 | dummy = element->attribute("DateMonth" ); |
895 | dumInt = dummy.toInt(&ok ); | 899 | dumInt = dummy.toInt(&ok ); |
896 | if(ok ) month = dumInt; | 900 | if(ok ) month = dumInt; |
897 | dummy = element->attribute("DateDay" ); | 901 | dummy = element->attribute("DateDay" ); |
898 | dumInt = dummy.toInt(&ok ); | 902 | dumInt = dummy.toInt(&ok ); |
899 | if(ok ) day = dumInt; | 903 | if(ok ) day = dumInt; |
900 | // set the date | 904 | // set the date |
901 | QDate date( year, month, day ); | 905 | QDate date( year, month, day ); |
902 | event.setDate( date); | 906 | event.setDate( date); |
903 | } | 907 | } |
904 | dummy = element->attribute("Priority" ); | 908 | dummy = element->attribute("Priority" ); |
905 | dumInt = dummy.toInt(&ok ); | 909 | dumInt = dummy.toInt(&ok ); |
906 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 910 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
907 | event.setPriority( dumInt ); | 911 | event.setPriority( dumInt ); |
908 | //description | 912 | //description |
909 | dummy = element->attribute("Description" ); | 913 | dummy = element->attribute("Description" ); |
910 | event.setDescription( dummy ); | 914 | event.setDescription( dummy ); |
915 | // summary | ||
916 | dummy = element->attribute("Summary" ); | ||
917 | event.setSummary( dummy ); | ||
911 | // category | 918 | // category |
912 | dummy = element->attribute("Categories" ); | 919 | dummy = element->attribute("Categories" ); |
913 | QStringList ids = QStringList::split(";", dummy ); | 920 | QStringList ids = QStringList::split(";", dummy ); |
914 | event.setCategories( ids ); | 921 | event.setCategories( ids ); |
915 | 922 | ||
916 | //uid | 923 | //uid |
917 | dummy = element->attribute("Uid" ); | 924 | dummy = element->attribute("Uid" ); |
918 | dumInt = dummy.toInt(&ok ); | 925 | dumInt = dummy.toInt(&ok ); |
919 | if(ok ) event.setUid( dumInt ); | 926 | if(ok ) event.setUid( dumInt ); |
920 | return event; | 927 | return event; |
921 | } | 928 | } |
922 | 929 | ||
923 | } | 930 | } |
924 | // int TodoTable::rowHeight( int ) const | 931 | // int TodoTable::rowHeight( int ) const |
925 | // { | 932 | // { |
926 | // return 18; | 933 | // return 18; |
927 | // } | 934 | // } |
928 | 935 | ||
929 | // int TodoTable::rowPos( int row ) const | 936 | // int TodoTable::rowPos( int row ) const |
930 | // { | 937 | // { |
931 | // return 18*row; | 938 | // return 18*row; |
932 | // } | 939 | // } |
933 | 940 | ||
934 | // int TodoTable::rowAt( int pos ) const | 941 | // int TodoTable::rowAt( int pos ) const |