author | zecke <zecke> | 2002-04-25 16:11:10 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-25 16:11:10 (UTC) |
commit | e944a214e0efeccd2eb9cc479ad8893427c6b81d (patch) (unidiff) | |
tree | 263f754a34d23738dac6c3dea9dbcb0ce8b6bb3e | |
parent | 48dbc8fb69a5d19f466ea757207e42c3861b4dee (diff) | |
download | opie-e944a214e0efeccd2eb9cc479ad8893427c6b81d.zip opie-e944a214e0efeccd2eb9cc479ad8893427c6b81d.tar.gz opie-e944a214e0efeccd2eb9cc479ad8893427c6b81d.tar.bz2 |
This should fix the Umlaut problem
-rw-r--r-- | libopie/tododb.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index c486723..33fa177 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -1,95 +1,96 @@ | |||
1 | 1 | ||
2 | #include <qdir.h> | 2 | #include <qdir.h> |
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 | ||
9 | namespace { | 9 | namespace { |
10 | 10 | ||
11 | class FileToDoResource : public ToDoResource { | 11 | 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 | 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.setEncoding( QTextStream::UnicodeUTF8 ); | ||
48 | stream << "<!DOCTYPE Tasks>" << endl; | 49 | stream << "<!DOCTYPE Tasks>" << endl; |
49 | tasks->save(stream ); | 50 | tasks->save(stream ); |
50 | delete tasks; | 51 | delete tasks; |
51 | stream << "</Tasks>" << endl; | 52 | stream << "</Tasks>" << endl; |
52 | file.close(); | 53 | file.close(); |
53 | return true; | 54 | return true; |
54 | } | 55 | } |
55 | return false; | 56 | return false; |
56 | } | 57 | } |
57 | QValueList<ToDoEvent> load( const QString &name ){ | 58 | QValueList<ToDoEvent> load( const QString &name ){ |
58 | qWarning("loading tododb" ); | 59 | qWarning("loading tododb" ); |
59 | QValueList<ToDoEvent> m_todos; | 60 | QValueList<ToDoEvent> m_todos; |
60 | XMLElement *root = XMLElement::load( name ); | 61 | XMLElement *root = XMLElement::load( name ); |
61 | if(root != 0l ){ // start parsing | 62 | if(root != 0l ){ // start parsing |
62 | qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); | 63 | qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); |
63 | //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start | 64 | //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start |
64 | XMLElement *element = root->firstChild(); | 65 | XMLElement *element = root->firstChild(); |
65 | element = element->firstChild(); | 66 | element = element->firstChild(); |
66 | while( element ){ | 67 | while( element ){ |
67 | if( element->tagName() != QString::fromLatin1("Task") ){ | 68 | if( element->tagName() != QString::fromLatin1("Task") ){ |
68 | element = element->nextChild(); | 69 | element = element->nextChild(); |
69 | continue; | 70 | continue; |
70 | } | 71 | } |
71 | qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); | 72 | qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); |
72 | QString dummy; | 73 | QString dummy; |
73 | ToDoEvent event; | 74 | ToDoEvent event; |
74 | bool ok; | 75 | bool ok; |
75 | int dumInt; | 76 | int dumInt; |
76 | // completed | 77 | // completed |
77 | dummy = element->attribute("Completed" ); | 78 | dummy = element->attribute("Completed" ); |
78 | dumInt = dummy.toInt(&ok ); | 79 | dumInt = dummy.toInt(&ok ); |
79 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); | 80 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); |
80 | // hasDate | 81 | // hasDate |
81 | dummy = element->attribute("HasDate" ); | 82 | dummy = element->attribute("HasDate" ); |
82 | dumInt = dummy.toInt(&ok ); | 83 | dumInt = dummy.toInt(&ok ); |
83 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); | 84 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); |
84 | // set the date | 85 | // set the date |
85 | bool hasDa = dumInt; | 86 | bool hasDa = dumInt; |
86 | if ( hasDa ) { //parse the date | 87 | if ( hasDa ) { //parse the date |
87 | int year, day, month = 0; | 88 | int year, day, month = 0; |
88 | year = day = month; | 89 | year = day = month; |
89 | // year | 90 | // year |
90 | dummy = element->attribute("DateYear" ); | 91 | dummy = element->attribute("DateYear" ); |
91 | dumInt = dummy.toInt(&ok ); | 92 | dumInt = dummy.toInt(&ok ); |
92 | if( ok ) year = dumInt; | 93 | if( ok ) year = dumInt; |
93 | // month | 94 | // month |
94 | dummy = element->attribute("DateMonth" ); | 95 | dummy = element->attribute("DateMonth" ); |
95 | dumInt = dummy.toInt(&ok ); | 96 | dumInt = dummy.toInt(&ok ); |