summaryrefslogtreecommitdiff
path: root/libopie/tododb.cpp
authorzecke <zecke>2002-04-13 23:18:09 (UTC)
committer zecke <zecke>2002-04-13 23:18:09 (UTC)
commit707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5 (patch) (unidiff)
treed17645bbf5e0318e6e10c3377605c107a110ebd1 /libopie/tododb.cpp
parent0f7ff8056deb70f1c32bdcf46bb2b623063bdc1c (diff)
downloadopie-707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5.zip
opie-707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5.tar.gz
opie-707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5.tar.bz2
PopupMenu for fontsize handling like on the Zaurus
Diffstat (limited to 'libopie/tododb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 7814c4f..3f6dc30 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -3,96 +3,97 @@
3#include <opie/tododb.h> 3#include <opie/tododb.h>
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
9namespace { 9namespace {
10 10
11class FileToDoResource : public ToDoResource { 11class FileToDoResource : public ToDoResource {
12public: 12public:
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 QArray<int> arrat = (*it).categories(); 24 QArray<int> arrat = (*it).categories();
25 QString attr; 25 QString attr;
26 for(uint i=0; i < arrat.count(); i++ ){ 26 for(uint i=0; i < arrat.count(); i++ ){
27 attr.append(QString::number(arrat[i])+";" ); 27 attr.append(QString::number(arrat[i])+";" );
28 } 28 }
29 if(!attr.isEmpty() ) // remove the last ; 29 if(!attr.isEmpty() ) // remove the last ;
30 attr.remove(attr.length()-1, 1 ); 30 attr.remove(attr.length()-1, 1 );
31 map.insert( "Categories", attr ); 31 map.insert( "Categories", attr );
32 //else 32 //else
33 //map.insert( "Categories", QString::null ); 33 //map.insert( "Categories", QString::null );
34 map.insert( "Description", (*it).description() ); 34 map.insert( "Description", (*it).description() );
35 if( (*it).hasDate() ){ 35 if( (*it).hasDate() ){
36 map.insert("DateYear", QString::number( (*it).date().year() ) ); 36 map.insert("DateYear", QString::number( (*it).date().year() ) );
37 map.insert("DateMonth", QString::number( (*it).date().month() ) ); 37 map.insert("DateMonth", QString::number( (*it).date().month() ) );
38 map.insert("DateDay", QString::number( (*it).date().day() ) ); 38 map.insert("DateDay", QString::number( (*it).date().day() ) );
39 } 39 }
40 map.insert("Uid", QString::number( (*it).uid() ) ); 40 map.insert("Uid", QString::number( (*it).uid() ) );
41 task->setTagName("Task" ); 41 task->setTagName("Task" );
42 task->setAttributes( map ); 42 task->setAttributes( map );
43 tasks->appendChild(task); 43 tasks->appendChild(task);
44 } 44 }
45 QFile file( name); 45 QFile file( name);
46 if( file.open(IO_WriteOnly ) ){ 46 if( file.open(IO_WriteOnly ) ){
47 QTextStream stream(&file ); 47 QTextStream stream(&file );
48 stream << "<!DOCTYPE Tasks>" << endl; 48 stream << "<!DOCTYPE Tasks>" << endl;
49 tasks->save(stream ); 49 tasks->save(stream );
50 delete tasks; 50 delete tasks;
51 stream << "</Tasks>" << endl;
51 file.close(); 52 file.close();
52 return true; 53 return true;
53 } 54 }
54 return false; 55 return false;
55 } 56 }
56 QValueList<ToDoEvent> load( const QString &name ){ 57 QValueList<ToDoEvent> load( const QString &name ){
57 qWarning("loading tododb" ); 58 qWarning("loading tododb" );
58 QValueList<ToDoEvent> m_todos; 59 QValueList<ToDoEvent> m_todos;
59 XMLElement *root = XMLElement::load( name ); 60 XMLElement *root = XMLElement::load( name );
60 if(root != 0l ){ // start parsing 61 if(root != 0l ){ // start parsing
61 qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); 62 qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() );
62 //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start 63 //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start
63 XMLElement *element = root->firstChild(); 64 XMLElement *element = root->firstChild();
64 element = element->firstChild(); 65 element = element->firstChild();
65 while( element ){ 66 while( element ){
66 qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); 67 qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() );
67 QString dummy; 68 QString dummy;
68 ToDoEvent event; 69 ToDoEvent event;
69 bool ok; 70 bool ok;
70 int dumInt; 71 int dumInt;
71 // completed 72 // completed
72 dummy = element->attribute("Completed" ); 73 dummy = element->attribute("Completed" );
73 dumInt = dummy.toInt(&ok ); 74 dumInt = dummy.toInt(&ok );
74 if(ok ) event.setCompleted( dumInt == 0 ? false : true ); 75 if(ok ) event.setCompleted( dumInt == 0 ? false : true );
75 // hasDate 76 // hasDate
76 dummy = element->attribute("HasDate" ); 77 dummy = element->attribute("HasDate" );
77 dumInt = dummy.toInt(&ok ); 78 dumInt = dummy.toInt(&ok );
78 if(ok ) event.setHasDate( dumInt == 0 ? false: true ); 79 if(ok ) event.setHasDate( dumInt == 0 ? false: true );
79 // set the date 80 // set the date
80 bool hasDa = dumInt; 81 bool hasDa = dumInt;
81 if ( hasDa ) { //parse the date 82 if ( hasDa ) { //parse the date
82 int year, day, month = 0; 83 int year, day, month = 0;
83 year = day = month; 84 year = day = month;
84 // year 85 // year
85 dummy = element->attribute("DateYear" ); 86 dummy = element->attribute("DateYear" );
86 dumInt = dummy.toInt(&ok ); 87 dumInt = dummy.toInt(&ok );
87 if( ok ) year = dumInt; 88 if( ok ) year = dumInt;
88 // month 89 // month
89 dummy = element->attribute("DateMonth" ); 90 dummy = element->attribute("DateMonth" );
90 dumInt = dummy.toInt(&ok ); 91 dumInt = dummy.toInt(&ok );
91 if(ok ) month = dumInt; 92 if(ok ) month = dumInt;
92 dummy = element->attribute("DateDay" ); 93 dummy = element->attribute("DateDay" );
93 dumInt = dummy.toInt(&ok ); 94 dumInt = dummy.toInt(&ok );
94 if(ok ) day = dumInt; 95 if(ok ) day = dumInt;
95 // set the date 96 // set the date
96 QDate date( year, month, day ); 97 QDate date( year, month, day );
97 event.setDate( date); 98 event.setDate( date);
98 } 99 }