summaryrefslogtreecommitdiff
path: root/libopie/tododb.cpp
Unidiff
Diffstat (limited to 'libopie/tododb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 6b10ec2..1e40c40 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -15,24 +15,25 @@ public:
15 FileToDoResource() {}; 15 FileToDoResource() {};
16 // FIXME better parsing 16 // FIXME better parsing
17 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ 17 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){
18 // prepare the XML 18 // prepare the XML
19 XMLElement *tasks = new XMLElement( ); 19 XMLElement *tasks = new XMLElement( );
20 tasks->setTagName("Tasks" ); 20 tasks->setTagName("Tasks" );
21 for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ 21 for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){
22 XMLElement::AttributeMap map; 22 XMLElement::AttributeMap map;
23 XMLElement *task = new XMLElement(); 23 XMLElement *task = new XMLElement();
24 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); 24 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) );
25 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); 25 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) );
26 map.insert( "Priority", QString::number( (*it).priority() ) ); 26 map.insert( "Priority", QString::number( (*it).priority() ) );
27 map.insert( "Progress", QString::number( (*it).progress() ) );
27 map.insert( "Summary", (*it).summary() ); 28 map.insert( "Summary", (*it).summary() );
28 QArray<int> arrat = (*it).categories(); 29 QArray<int> arrat = (*it).categories();
29 QString attr; 30 QString attr;
30 for(uint i=0; i < arrat.count(); i++ ){ 31 for(uint i=0; i < arrat.count(); i++ ){
31 attr.append(QString::number(arrat[i])+";" ); 32 attr.append(QString::number(arrat[i])+";" );
32 } 33 }
33 if(!attr.isEmpty() ) // remove the last ; 34 if(!attr.isEmpty() ) // remove the last ;
34 attr.remove(attr.length()-1, 1 ); 35 attr.remove(attr.length()-1, 1 );
35 map.insert( "Categories", attr ); 36 map.insert( "Categories", attr );
36 //else 37 //else
37 //map.insert( "Categories", QString::null ); 38 //map.insert( "Categories", QString::null );
38 map.insert( "Description", (*it).description() ); 39 map.insert( "Description", (*it).description() );
@@ -73,24 +74,31 @@ public:
73 element = element->nextChild(); 74 element = element->nextChild();
74 continue; 75 continue;
75 } 76 }
76 qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); 77 qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() );
77 QString dummy; 78 QString dummy;
78 ToDoEvent event; 79 ToDoEvent event;
79 bool ok; 80 bool ok;
80 int dumInt; 81 int dumInt;
81 // completed 82 // completed
82 dummy = element->attribute("Completed" ); 83 dummy = element->attribute("Completed" );
83 dumInt = dummy.toInt(&ok ); 84 dumInt = dummy.toInt(&ok );
84 if(ok ) event.setCompleted( dumInt == 0 ? false : true ); 85 if(ok ) event.setCompleted( dumInt == 0 ? false : true );
86 // progress
87 dummy = element->attribute("Progress" );
88 {
89 ushort dumShort = dummy.toUShort(&ok);
90 event.setProgress( dumShort );
91
92 }
85 // hasDate 93 // hasDate
86 dummy = element->attribute("HasDate" ); 94 dummy = element->attribute("HasDate" );
87 dumInt = dummy.toInt(&ok ); 95 dumInt = dummy.toInt(&ok );
88 if(ok ) event.setHasDate( dumInt == 0 ? false: true ); 96 if(ok ) event.setHasDate( dumInt == 0 ? false: true );
89 // set the date 97 // set the date
90 bool hasDa = dumInt; 98 bool hasDa = dumInt;
91 if ( hasDa ) { //parse the date 99 if ( hasDa ) { //parse the date
92 int year, day, month = 0; 100 int year, day, month = 0;
93 year = day = month; 101 year = day = month;
94 // year 102 // year
95 dummy = element->attribute("DateYear" ); 103 dummy = element->attribute("DateYear" );
96 dumInt = dummy.toInt(&ok ); 104 dumInt = dummy.toInt(&ok );