author | zecke <zecke> | 2002-06-16 16:34:10 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-16 16:34:10 (UTC) |
commit | 3b8192d0f5a41c40092af48df8abc39aa3d1c355 (patch) (unidiff) | |
tree | c1f5e0211a16bb4ceb2d78ec7a76e1bffdae088b /libopie/tododb.cpp | |
parent | 23c2d100ed9070d82f956cdcb7364f5627aa0600 (diff) | |
download | opie-3b8192d0f5a41c40092af48df8abc39aa3d1c355.zip opie-3b8192d0f5a41c40092af48df8abc39aa3d1c355.tar.gz opie-3b8192d0f5a41c40092af48df8abc39aa3d1c355.tar.bz2 |
implement progress
-rw-r--r-- | libopie/tododb.cpp | 8 |
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 | |||
@@ -11,32 +11,33 @@ using namespace Opie; | |||
11 | namespace { | 11 | namespace { |
12 | 12 | ||
13 | class FileToDoResource : public ToDoResource { | 13 | class FileToDoResource : public ToDoResource { |
14 | public: | 14 | 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() ); |
39 | if( (*it).hasDate() ){ | 40 | if( (*it).hasDate() ){ |
40 | map.insert("DateYear", QString::number( (*it).date().year() ) ); | 41 | map.insert("DateYear", QString::number( (*it).date().year() ) ); |
41 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); | 42 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); |
42 | map.insert("DateDay", QString::number( (*it).date().day() ) ); | 43 | map.insert("DateDay", QString::number( (*it).date().day() ) ); |
@@ -69,32 +70,39 @@ public: | |||
69 | XMLElement *element = root->firstChild(); | 70 | XMLElement *element = root->firstChild(); |
70 | element = element->firstChild(); | 71 | element = element->firstChild(); |
71 | while( element ){ | 72 | while( element ){ |
72 | if( element->tagName() != QString::fromLatin1("Task") ){ | 73 | if( element->tagName() != QString::fromLatin1("Task") ){ |
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 ); |
97 | if( ok ) year = dumInt; | 105 | if( ok ) year = dumInt; |
98 | // month | 106 | // month |
99 | dummy = element->attribute("DateMonth" ); | 107 | dummy = element->attribute("DateMonth" ); |
100 | dumInt = dummy.toInt(&ok ); | 108 | dumInt = dummy.toInt(&ok ); |