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) (side-by-side diff)
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
@@ -18,13 +18,13 @@ OTodoAccessXML::OTodoAccessXML( const QString& appName,
m_file = Global::applicationFileName( "todolist", "todolist.xml" );
}
OTodoAccessXML::~OTodoAccessXML() {
}
bool OTodoAccessXML::load() {
- m_opened = false;
+ m_opened = true;
m_changed = false;
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
*/
QAsciiDict<int> dict(15);
@@ -66,27 +66,29 @@ bool OTodoAccessXML::load() {
OTodo ev = todo( &dict, element );
m_events.insert( ev.uid(), ev );
element = element->nextChild();
}
}else {
- qWarning("could not parse");
+// qWarning("could not parse");
return false;;
}
delete root;
- m_opened = true;
- qWarning("Access %d" + m_events.count() );
+// qWarning("Access %d" + m_events.count() );
return true;
}
bool OTodoAccessXML::reload() {
return load();
}
bool OTodoAccessXML::save() {
- if (!m_opened || !m_changed )
+// qWarning("saving");
+ if (!m_opened || !m_changed ) {
+// qWarning("not saving");
return true;
+ }
QString strNewFile = m_file + ".new";
QFile f( strNewFile );
if (!f.open( IO_WriteOnly|IO_Raw ) )
return false;
int written;
@@ -119,13 +121,13 @@ bool OTodoAccessXML::save() {
return false;
}
/* flush before renaming */
f.close();
if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
- qWarning("error renaming");
+// qWarning("error renaming");
QFile::remove( strNewFile );
}
m_changed = false;
return true;
}
@@ -157,12 +159,13 @@ void OTodoAccessXML::clear() {
if (m_opened )
m_changed = true;
m_events.clear();
}
bool OTodoAccessXML::add( const OTodo& todo ) {
+// qWarning("add");
m_changed = true;
m_events.insert( todo.uid(), todo );
return true;
}
bool OTodoAccessXML::remove( int uid ) {
@@ -214,24 +217,24 @@ QArray<int> OTodoAccessXML::overDue() {
return ids;
}
/* private */
OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const {
- qWarning("parse to do from XMLElement" );
+// qWarning("parse to do from XMLElement" );
OTodo ev;
QMap<QString, QString> attributes = element->attributes();
QMap<QString, QString>::Iterator it;
int *find=0;
int day, month, year;
day = month = year = -1;
for ( it = attributes.begin(); it != attributes.end(); ++it ) {
find = (*dict)[ it.key() ];
if (!find ) {
- qWarning("Unknown option" + it.key() );
+// qWarning("Unknown option" + it.key() );
ev.setCustomField( it.key(), it.data() );
continue;
}
switch( *find ) {
case OTodo::Uid:
@@ -317,12 +320,13 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
if ( ev.hasDueDate() ) {
str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
}
+// qWarning( "Uid %d", ev.uid() );
str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
// append the extra options
/* FIXME Qtopia::Record this is currently not
* possible you can set custom fields
* but don' iterate over the list