author | zecke <zecke> | 2002-09-22 23:32:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-22 23:32:49 (UTC) |
commit | d7098ef25f7f4ebe5678061aa3a3c0bd1f077f7f (patch) (side-by-side diff) | |
tree | 5ff52b48fd514c6f24da6d3204bc98b66c48a652 /libopie2/opiepim/backend | |
parent | 4f142e98ee63e88fa0df61161b93228ee719d551 (diff) | |
download | opie-d7098ef25f7f4ebe5678061aa3a3c0bd1f077f7f.zip opie-d7098ef25f7f4ebe5678061aa3a3c0bd1f077f7f.tar.gz opie-d7098ef25f7f4ebe5678061aa3a3c0bd1f077f7f.tar.bz2 |
Two brown paper bags later OTodo is ok again... pointers can be so fscking awesome
I had problems with QShared because I forgot to copy it in &operator=
And the other one was d = 0
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 21756c9..3a72881 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -7,136 +7,136 @@ #include <opie/xmltree.h> #include "otodoaccessxml.h" OTodoAccessXML::OTodoAccessXML( const QString& appName, const QString& fileName ) : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) { if (!fileName.isEmpty() ) m_file = fileName; else m_file = Global::applicationFileName( "todolist", "todolist.xml" ); } OTodoAccessXML::~OTodoAccessXML() { } bool OTodoAccessXML::load() { m_opened = false; m_changed = false; /* initialize dict */ /* * UPDATE dict if you change anything!!! */ QAsciiDict<int> dict(15); dict.setAutoDelete( TRUE ); dict.insert("Categories" , new int(OTodo::Category) ); dict.insert("Uid" , new int(OTodo::Uid) ); dict.insert("HasDate" , new int(OTodo::HasDate) ); dict.insert("Completed" , new int(OTodo::Completed) ); dict.insert("Description" , new int(OTodo::Description) ); dict.insert("Summary" , new int(OTodo::Summary) ); dict.insert("Priority" , new int(OTodo::Priority) ); dict.insert("DateDay" , new int(OTodo::DateDay) ); dict.insert("DateMonth" , new int(OTodo::DateMonth) ); dict.insert("DateYear" , new int(OTodo::DateYear) ); dict.insert("Progress" , new int(OTodo::Progress) ); dict.insert("Completed", new int(OTodo::Completed) ); dict.insert("CrossReference", new int(OTodo::CrossReference) ); dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); Opie::XMLElement *root = Opie::XMLElement::load( m_file ); int day, year, month; day = year = month = -1; /* if opened */ if ( root != 0l ) { Opie::XMLElement *element = root->firstChild(); if ( element == 0l ) return false; element = element->firstChild(); while ( element ) { if ( element->tagName() != QString::fromLatin1("Task") ) { element = element->nextChild(); continue; } /* here is the right element for a task */ OTodo ev = todo( &dict, element ); m_events.insert( ev.uid(), ev ); element = element->nextChild(); } - return true; }else { qWarning("could not parse"); return false;; } delete root; m_opened = true; + qWarning("Access %d" + m_events.count() ); return true; } bool OTodoAccessXML::reload() { return load(); } bool OTodoAccessXML::save() { if (!m_opened || !m_changed ) return true; QString strNewFile = m_file + ".new"; QFile f( strNewFile ); if (!f.open( IO_WriteOnly|IO_Raw ) ) return false; int written; QString out; out = "<!DOCTYPE Tasks>\n<Tasks>\n"; // for all todos QMap<int, OTodo>::Iterator it; for (it = m_events.begin(); it != m_events.end(); ++it ) { out+= "<Task " + toString( (*it) ) + " />\n"; QCString cstr = out.utf8(); written = f.writeBlock( cstr.data(), cstr.length() ); /* less written then we wanted */ if ( written != (int)cstr.length() ) { f.close(); QFile::remove( strNewFile ); return false; } out = QString::null; } out += "</Tasks>"; QCString cstr = out.utf8(); written = f.writeBlock( cstr.data(), cstr.length() ); if ( written != (int)cstr.length() ) { f.close(); QFile::remove( strNewFile ); return false; } /* flush before renaming */ f.close(); if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { qWarning("error renaming"); QFile::remove( strNewFile ); } m_changed = false; return true; } QArray<int> OTodoAccessXML::allRecords()const { QArray<int> ids( m_events.count() ); QMap<int, OTodo>::ConstIterator it; int i = 0; for ( it = m_events.begin(); it != m_events.end(); ++it ) { ids[i] = it.key(); i++; } return ids; } |