author | zecke <zecke> | 2002-04-13 16:27:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-13 16:27:19 (UTC) |
commit | def870c6fcccf2b20d7ce3821055391b18243a24 (patch) (unidiff) | |
tree | 006357788654cf0e18c76640bd821cf87731d952 /libopie/tododb.cpp | |
parent | e42465b45553f51cf7c7d24130aa3a90a6be3ddd (diff) | |
download | opie-def870c6fcccf2b20d7ce3821055391b18243a24.zip opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.gz opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.bz2 |
multiple categories
-rw-r--r-- | libopie/tododb.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 10ea2f0..7814c4f 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -12,30 +12,34 @@ class FileToDoResource : public ToDoResource { | |||
12 | public: | 12 | public: |
13 | FileToDoResource() {}; | 13 | FileToDoResource() {}; |
14 | bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ | 14 | bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ |
15 | // prepare the XML | 15 | // prepare the XML |
16 | XMLElement *tasks = new XMLElement( ); | 16 | XMLElement *tasks = new XMLElement( ); |
17 | tasks->setTagName("Tasks" ); | 17 | tasks->setTagName("Tasks" ); |
18 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ | 18 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ |
19 | XMLElement::AttributeMap map; | 19 | XMLElement::AttributeMap map; |
20 | XMLElement *task = new XMLElement(); | 20 | XMLElement *task = new XMLElement(); |
21 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); | 21 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); |
22 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); | 22 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); |
23 | map.insert( "Priority", QString::number( (*it).priority() ) ); | 23 | map.insert( "Priority", QString::number( (*it).priority() ) ); |
24 | if(!(*it).category().isEmpty() ){ | 24 | QArray<int> arrat = (*it).categories(); |
25 | QArray<int> arrat(1); | 25 | QString attr; |
26 | arrat = Qtopia::Record::idsFromString( (*it).category() ); | 26 | for(uint i=0; i < arrat.count(); i++ ){ |
27 | map.insert( "Categories", QString::number( arrat[0] ) ); | 27 | attr.append(QString::number(arrat[i])+";" ); |
28 | }else | 28 | } |
29 | map.insert( "Categories", QString::null ); | 29 | if(!attr.isEmpty() ) // remove the last ; |
30 | attr.remove(attr.length()-1, 1 ); | ||
31 | map.insert( "Categories", attr ); | ||
32 | //else | ||
33 | //map.insert( "Categories", QString::null ); | ||
30 | map.insert( "Description", (*it).description() ); | 34 | map.insert( "Description", (*it).description() ); |
31 | if( (*it).hasDate() ){ | 35 | if( (*it).hasDate() ){ |
32 | map.insert("DateYear", QString::number( (*it).date().year() ) ); | 36 | map.insert("DateYear", QString::number( (*it).date().year() ) ); |
33 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); | 37 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); |
34 | map.insert("DateDay", QString::number( (*it).date().day() ) ); | 38 | map.insert("DateDay", QString::number( (*it).date().day() ) ); |
35 | } | 39 | } |
36 | map.insert("Uid", QString::number( (*it).uid() ) ); | 40 | map.insert("Uid", QString::number( (*it).uid() ) ); |
37 | task->setTagName("Task" ); | 41 | task->setTagName("Task" ); |
38 | task->setAttributes( map ); | 42 | task->setAttributes( map ); |
39 | tasks->appendChild(task); | 43 | tasks->appendChild(task); |
40 | } | 44 | } |
41 | QFile file( name); | 45 | QFile file( name); |
@@ -92,30 +96,27 @@ public: | |||
92 | QDate date( year, month, day ); | 96 | QDate date( year, month, day ); |
93 | event.setDate( date); | 97 | event.setDate( date); |
94 | } | 98 | } |
95 | dummy = element->attribute("Priority" ); | 99 | dummy = element->attribute("Priority" ); |
96 | dumInt = dummy.toInt(&ok ); | 100 | dumInt = dummy.toInt(&ok ); |
97 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 101 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
98 | event.setPriority( dumInt ); | 102 | event.setPriority( dumInt ); |
99 | //description | 103 | //description |
100 | dummy = element->attribute("Description" ); | 104 | dummy = element->attribute("Description" ); |
101 | event.setDescription( dummy ); | 105 | event.setDescription( dummy ); |
102 | // category | 106 | // category |
103 | dummy = element->attribute("Categories" ); | 107 | dummy = element->attribute("Categories" ); |
104 | dumInt = dummy.toInt(&ok ); | 108 | QStringList ids = QStringList::split(";", dummy ); |
105 | if(ok ) { | 109 | event.setCategories( ids ); |
106 | QArray<int> arrat(1); | 110 | |
107 | arrat[0] = dumInt; | ||
108 | event.setCategory( Qtopia::Record::idsToString( arrat ) ); | ||
109 | } | ||
110 | //uid | 111 | //uid |
111 | dummy = element->attribute("Uid" ); | 112 | dummy = element->attribute("Uid" ); |
112 | dumInt = dummy.toInt(&ok ); | 113 | dumInt = dummy.toInt(&ok ); |
113 | if(ok ) event.setUid( dumInt ); | 114 | if(ok ) event.setUid( dumInt ); |
114 | m_todos.append( event ); | 115 | m_todos.append( event ); |
115 | element = element->nextChild(); // next element | 116 | element = element->nextChild(); // next element |
116 | } | 117 | } |
117 | //} | 118 | //} |
118 | }else { | 119 | }else { |
119 | qWarning("could not load" ); | 120 | qWarning("could not load" ); |
120 | } | 121 | } |
121 | delete root; | 122 | delete root; |