summaryrefslogtreecommitdiff
path: root/libopie/tododb.cpp
Unidiff
Diffstat (limited to 'libopie/tododb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index fe8b8bf..6b10ec2 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -4,34 +4,36 @@
4#include <opie/xmltree.h> 4#include <opie/xmltree.h>
5#include <opie/todoresource.h> 5#include <opie/todoresource.h>
6#include <qpe/palmtoprecord.h> 6#include <qpe/palmtoprecord.h>
7#include <qpe/global.h> 7#include <qpe/global.h>
8 8
9using namespace Opie; 9using namespace Opie;
10 10
11namespace { 11namespace {
12 12
13class FileToDoResource : public ToDoResource { 13class FileToDoResource : public ToDoResource {
14public: 14public:
15 FileToDoResource() {}; 15 FileToDoResource() {};
16 // FIXME better parsing
16 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ 17 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){
17 // prepare the XML 18 // prepare the XML
18 XMLElement *tasks = new XMLElement( ); 19 XMLElement *tasks = new XMLElement( );
19 tasks->setTagName("Tasks" ); 20 tasks->setTagName("Tasks" );
20 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 ){
21 XMLElement::AttributeMap map; 22 XMLElement::AttributeMap map;
22 XMLElement *task = new XMLElement(); 23 XMLElement *task = new XMLElement();
23 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); 24 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) );
24 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); 25 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) );
25 map.insert( "Priority", QString::number( (*it).priority() ) ); 26 map.insert( "Priority", QString::number( (*it).priority() ) );
27 map.insert( "Summary", (*it).summary() );
26 QArray<int> arrat = (*it).categories(); 28 QArray<int> arrat = (*it).categories();
27 QString attr; 29 QString attr;
28 for(uint i=0; i < arrat.count(); i++ ){ 30 for(uint i=0; i < arrat.count(); i++ ){
29 attr.append(QString::number(arrat[i])+";" ); 31 attr.append(QString::number(arrat[i])+";" );
30 } 32 }
31 if(!attr.isEmpty() ) // remove the last ; 33 if(!attr.isEmpty() ) // remove the last ;
32 attr.remove(attr.length()-1, 1 ); 34 attr.remove(attr.length()-1, 1 );
33 map.insert( "Categories", attr ); 35 map.insert( "Categories", attr );
34 //else 36 //else
35 //map.insert( "Categories", QString::null ); 37 //map.insert( "Categories", QString::null );
36 map.insert( "Description", (*it).description() ); 38 map.insert( "Description", (*it).description() );
37 if( (*it).hasDate() ){ 39 if( (*it).hasDate() ){
@@ -102,29 +104,31 @@ public:
102 if(ok ) day = dumInt; 104 if(ok ) day = dumInt;
103 // set the date 105 // set the date
104 QDate date( year, month, day ); 106 QDate date( year, month, day );
105 event.setDate( date); 107 event.setDate( date);
106 } 108 }
107 dummy = element->attribute("Priority" ); 109 dummy = element->attribute("Priority" );
108 dumInt = dummy.toInt(&ok ); 110 dumInt = dummy.toInt(&ok );
109 if(!ok ) dumInt = ToDoEvent::NORMAL; 111 if(!ok ) dumInt = ToDoEvent::NORMAL;
110 event.setPriority( dumInt ); 112 event.setPriority( dumInt );
111 //description 113 //description
112 dummy = element->attribute("Description" ); 114 dummy = element->attribute("Description" );
113 event.setDescription( dummy ); 115 event.setDescription( dummy );
116 dummy = element->attribute("Summary" );
117 event.setSummary( dummy );
114 // category 118 // category
115 dummy = element->attribute("Categories" ); 119 dummy = element->attribute("Categories" );
116 QStringList ids = QStringList::split(";", dummy ); 120 QStringList ids = QStringList::split(";", dummy );
117 event.setCategories( ids ); 121 event.setCategories( ids );
118 122
119 //uid 123 //uid
120 dummy = element->attribute("Uid" ); 124 dummy = element->attribute("Uid" );
121 dumInt = dummy.toInt(&ok ); 125 dumInt = dummy.toInt(&ok );
122 if(ok ) event.setUid( dumInt ); 126 if(ok ) event.setUid( dumInt );
123 m_todos.append( event ); 127 m_todos.append( event );
124 element = element->nextChild(); // next element 128 element = element->nextChild(); // next element
125 } 129 }
126 //} 130 //}
127 }else { 131 }else {
128 qWarning("could not load" ); 132 qWarning("could not load" );
129 } 133 }
130 delete root; 134 delete root;
@@ -172,25 +176,25 @@ QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to,
172 } 176 }
173 } 177 }
174 return events; 178 return events;
175} 179}
176QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, 180QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from,
177 bool all) 181 bool all)
178{ 182{
179 return effectiveToDos( from, QDate::currentDate(), all ); 183 return effectiveToDos( from, QDate::currentDate(), all );
180} 184}
181QValueList<ToDoEvent> ToDoDB::overDue() 185QValueList<ToDoEvent> ToDoDB::overDue()
182{ 186{
183 QValueList<ToDoEvent> events; 187 QValueList<ToDoEvent> events;
184 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ 188 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
185 if( (*it).isOverdue() ) 189 if( (*it).isOverdue() )
186 events.append((*it) ); 190 events.append((*it) );
187 } 191 }
188 return events; 192 return events;
189} 193}
190QValueList<ToDoEvent> ToDoDB::rawToDos() 194QValueList<ToDoEvent> ToDoDB::rawToDos()
191{ 195{
192 return m_todos; 196 return m_todos;
193} 197}
194void ToDoDB::addEvent( const ToDoEvent &event ) 198void ToDoDB::addEvent( const ToDoEvent &event )
195{ 199{
196 m_todos.append( event ); 200 m_todos.append( event );
@@ -229,25 +233,25 @@ void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events )
229 } 233 }
230} 234}
231void ToDoDB::setFileName(const QString &file ) 235void ToDoDB::setFileName(const QString &file )
232{ 236{
233 m_fileName =file; 237 m_fileName =file;
234} 238}
235QString ToDoDB::fileName()const 239QString ToDoDB::fileName()const
236{ 240{
237 return m_fileName; 241 return m_fileName;
238} 242}
239void ToDoDB::load() 243void ToDoDB::load()
240{ 244{
241 m_todos = m_res->load( m_fileName ); 245 m_todos = m_res->load( m_fileName );
242} 246}
243bool ToDoDB::save() 247bool ToDoDB::save()
244{ 248{
245 return m_res->save( m_fileName, m_todos ); 249 return m_res->save( m_fileName, m_todos );
246} 250}
247 251
248 252
249 253
250 254
251 255
252 256
253 257