summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccessxml.cpp
authorzecke <zecke>2002-09-23 21:38:23 (UTC)
committer zecke <zecke>2002-09-23 21:38:23 (UTC)
commite0b04701b3c9182ba22f56e329f98c57af4e1fe2 (patch) (unidiff)
treed5fa6fbae48d61aca7fefc09375fdcaf99ef4cb5 /libopie2/opiepim/backend/otodoaccessxml.cpp
parent47e87e10fada298a1027cf20d4d7f31a66dc1359 (diff)
downloadopie-e0b04701b3c9182ba22f56e329f98c57af4e1fe2.zip
opie-e0b04701b3c9182ba22f56e329f98c57af4e1fe2.tar.gz
opie-e0b04701b3c9182ba22f56e329f98c57af4e1fe2.tar.bz2
Updates
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 3a72881..5fe733c 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -21,7 +21,7 @@ OTodoAccessXML::~OTodoAccessXML() {
21 21
22} 22}
23bool OTodoAccessXML::load() { 23bool OTodoAccessXML::load() {
24 m_opened = false; 24 m_opened = true;
25 m_changed = false; 25 m_changed = false;
26 /* initialize dict */ 26 /* initialize dict */
27 /* 27 /*
@@ -69,21 +69,23 @@ bool OTodoAccessXML::load() {
69 element = element->nextChild(); 69 element = element->nextChild();
70 } 70 }
71 }else { 71 }else {
72 qWarning("could not parse"); 72// qWarning("could not parse");
73 return false;; 73 return false;;
74 } 74 }
75 delete root; 75 delete root;
76 76
77 m_opened = true; 77// qWarning("Access %d" + m_events.count() );
78 qWarning("Access %d" + m_events.count() );
79 return true; 78 return true;
80} 79}
81bool OTodoAccessXML::reload() { 80bool OTodoAccessXML::reload() {
82 return load(); 81 return load();
83} 82}
84bool OTodoAccessXML::save() { 83bool OTodoAccessXML::save() {
85 if (!m_opened || !m_changed ) 84// qWarning("saving");
85 if (!m_opened || !m_changed ) {
86// qWarning("not saving");
86 return true; 87 return true;
88 }
87 QString strNewFile = m_file + ".new"; 89 QString strNewFile = m_file + ".new";
88 QFile f( strNewFile ); 90 QFile f( strNewFile );
89 if (!f.open( IO_WriteOnly|IO_Raw ) ) 91 if (!f.open( IO_WriteOnly|IO_Raw ) )
@@ -122,7 +124,7 @@ bool OTodoAccessXML::save() {
122 f.close(); 124 f.close();
123 125
124 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 126 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
125 qWarning("error renaming"); 127// qWarning("error renaming");
126 QFile::remove( strNewFile ); 128 QFile::remove( strNewFile );
127 } 129 }
128 130
@@ -160,6 +162,7 @@ void OTodoAccessXML::clear() {
160 m_events.clear(); 162 m_events.clear();
161} 163}
162bool OTodoAccessXML::add( const OTodo& todo ) { 164bool OTodoAccessXML::add( const OTodo& todo ) {
165// qWarning("add");
163 m_changed = true; 166 m_changed = true;
164 m_events.insert( todo.uid(), todo ); 167 m_events.insert( todo.uid(), todo );
165 168
@@ -217,7 +220,7 @@ QArray<int> OTodoAccessXML::overDue() {
217 220
218/* private */ 221/* private */
219OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const { 222OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const {
220 qWarning("parse to do from XMLElement" ); 223// qWarning("parse to do from XMLElement" );
221 OTodo ev; 224 OTodo ev;
222 QMap<QString, QString> attributes = element->attributes(); 225 QMap<QString, QString> attributes = element->attributes();
223 QMap<QString, QString>::Iterator it; 226 QMap<QString, QString>::Iterator it;
@@ -228,7 +231,7 @@ OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)con
228 for ( it = attributes.begin(); it != attributes.end(); ++it ) { 231 for ( it = attributes.begin(); it != attributes.end(); ++it ) {
229 find = (*dict)[ it.key() ]; 232 find = (*dict)[ it.key() ];
230 if (!find ) { 233 if (!find ) {
231 qWarning("Unknown option" + it.key() ); 234// qWarning("Unknown option" + it.key() );
232 ev.setCustomField( it.key(), it.data() ); 235 ev.setCustomField( it.key(), it.data() );
233 continue; 236 continue;
234 } 237 }
@@ -320,6 +323,7 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
320 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 323 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
321 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 324 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
322 } 325 }
326// qWarning( "Uid %d", ev.uid() );
323 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 327 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
324 328
325// append the extra options 329// append the extra options