From e49230a12104b718c46a34c81b6c0e608c9d40be Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 22 Sep 2002 22:21:51 +0000 Subject: Add XML resources for todolist and compile fixes for RecordList --- (limited to 'libopie2/opiepim') diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index 5707b58..c27acbb 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h @@ -19,56 +19,56 @@ class OPimAccessBackend { public: OPimAccessBackend(); virtual ~OPimAccessBackend(); - + /** * load the resource */ - virtual void load() = 0; - + virtual bool load() = 0; + /** * reload the resource */ - virtual void reload() = 0; - + virtual bool reload() = 0; + /** * save the resource and * all it's changes */ - virtual void save() = 0; - + virtual bool save() = 0; + /** * return an array of * all available uids */ virtual QArray allRecords()const = 0; - + /** * queryByExample for T with the SortOrder * sort */ virtual QArray queryByExample( const T& t, int sort ) = 0; - + /** * find the OPimRecord with uid @param uid * returns T and T.isEmpty() if nothing was found */ - virtual T find(int uid ) = 0; - + virtual T find(int uid )const = 0; + /** * clear the back end */ virtual void clear() = 0; - + /** * add T */ virtual bool add( const T& t ) = 0; - + /** * remove */ virtual bool remove( int uid ) = 0; - + /** * replace a record with T.uid() */ diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp new file mode 100644 index 0000000..baaeecc --- a/dev/null +++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp @@ -0,0 +1,10 @@ + +#include "otodoaccessbackend.h" + +OTodoAccessBackend::OTodoAccessBackend() + : OPimAccessBackend() +{ +} +OTodoAccessBackend::~OTodoAccessBackend() { + +} diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h new file mode 100644 index 0000000..ebe2189 --- a/dev/null +++ b/libopie2/opiepim/backend/otodoaccessbackend.h @@ -0,0 +1,18 @@ +#ifndef OPIE_TODO_ACCESS_BACKEND_H +#define OPIE_TODO_ACCESS_BACKEND_H + +#include "otodo.h" +#include "opimaccessbackend.h" + +class OTodoAccessBackend : public OPimAccessBackend { +public: + OTodoAccessBackend(); + ~OTodoAccessBackend(); + virtual QArray effectiveToDos( const QDate& start, + const QDate& end, + bool includeNoDates ) = 0; + virtual QArray overDue() = 0; + +}; + +#endif diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp new file mode 100644 index 0000000..21756c9 --- a/dev/null +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -0,0 +1,362 @@ +#include + +#include +#include +#include + +#include + +#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 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; + 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 = "\n\n"; + + // for all todos + QMap::Iterator it; + for (it = m_events.begin(); it != m_events.end(); ++it ) { + out+= "\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 += ""; + 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 OTodoAccessXML::allRecords()const { + QArray ids( m_events.count() ); + QMap::ConstIterator it; + int i = 0; + + for ( it = m_events.begin(); it != m_events.end(); ++it ) { + ids[i] = it.key(); + i++; + } + return ids; +} +QArray OTodoAccessXML::queryByExample( const OTodo&, int sort ) { + QArray ids(0); + return ids; +} +OTodo OTodoAccessXML::find( int uid )const { + OTodo todo; + todo.setUid( 0 ); // isEmpty() + QMap::ConstIterator it = m_events.find( uid ); + if ( it != m_events.end() ) + todo = it.data(); + + return todo; +} +void OTodoAccessXML::clear() { + if (m_opened ) + m_changed = true; + + m_events.clear(); +} +bool OTodoAccessXML::add( const OTodo& todo ) { + m_changed = true; + m_events.insert( todo.uid(), todo ); + + return true; +} +bool OTodoAccessXML::remove( int uid ) { + m_changed = true; + m_events.remove( uid ); + + return true; +} +bool OTodoAccessXML::replace( const OTodo& todo) { + m_changed = true; + m_events.replace( todo.uid(), todo ); + + return true; +} +QArray OTodoAccessXML::effectiveToDos( const QDate& start, + const QDate& end, + bool includeNoDates ) { + QArray ids( m_events.count() ); + QMap::Iterator it; + + int i = 0; + for ( it = m_events.begin(); it != m_events.end(); ++it ) { + if ( !it.data().hasDueDate() ) { + if ( includeNoDates ) { + ids[i] = it.key(); + i++; + } + }else if ( it.data().dueDate() >= start && + it.data().dueDate() <= end ) { + ids[i] = it.key(); + i++; + } + } + ids.resize( i ); + return ids; +} +QArray OTodoAccessXML::overDue() { + QArray ids( m_events.count() ); + int i = 0; + + QMap::Iterator it; + for ( it = m_events.begin(); it != m_events.end(); ++it ) { + if ( it.data().isOverdue() ) { + ids[i] = it.key(); + i++; + } + } + ids.resize( i ); + return ids; +} + + +/* private */ +OTodo OTodoAccessXML::todo( QAsciiDict* dict, Opie::XMLElement* element)const { + qWarning("parse to do from XMLElement" ); + OTodo ev; + QMap attributes = element->attributes(); + QMap::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() ); + ev.setCustomField( it.key(), it.data() ); + continue; + } + + switch( *find ) { + case OTodo::Uid: + ev.setUid( it.data().toInt() ); + break; + case OTodo::Category: + ev.setCategories( ev.idsFromString( it.data() ) ); + break; + case OTodo::HasDate: + ev.setHasDueDate( it.data().toInt() ); + break; + case OTodo::Completed: + ev.setCompleted( it.data().toInt() ); + break; + case OTodo::Description: + ev.setDescription( it.data() ); + break; + case OTodo::Summary: + ev.setSummary( it.data() ); + break; + case OTodo::Priority: + ev.setPriority( it.data().toInt() ); + break; + case OTodo::DateDay: + day = it.data().toInt(); + break; + case OTodo::DateMonth: + month = it.data().toInt(); + break; + case OTodo::DateYear: + year = it.data().toInt(); + break; + case OTodo::Progress: + ev.setProgress( it.data().toInt() ); + break; + case OTodo::CrossReference: + { + /* + * A cross refernce looks like + * appname,id;appname,id + * we need to split it up + */ + QStringList refs = QStringList::split(';', it.data() ); + QStringList::Iterator strIt; + for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { + int pos = (*strIt).find(','); + if ( pos > -1 ) + ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); + + } + break; + } + case OTodo::HasAlarmDateTime: + ev.setHasAlarmDateTime( it.data().toInt() ); + break; + case OTodo::AlarmDateTime: { + /* this sounds better ;) zecke */ + ev.setAlarmDateTime( TimeConversion::fromISO8601( it.data().local8Bit() ) ); + break; + } + default: + break; + } + } + if ( ev.hasDueDate() ) { + QDate date( year, month, day ); + ev.setDueDate( date ); + } + + return ev; +} +QString OTodoAccessXML::toString( const OTodo& ev )const { + QString str; + + str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; + str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; + str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; + str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; + + str += "Categories=\"" + toString( ev.categories() ) + "\" "; + str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; + str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; + + if ( ev.hasDueDate() ) { + str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; + str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; + str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; + } + 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 + * I may do #define private protected + * for this case - cough --zecke + */ + /* + QMap extras = ev.extras(); + QMap::Iterator extIt; + for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) + str += extIt.key() + "=\"" + extIt.data() + "\" "; + */ + // cross refernce + QStringList list = ev.relatedApps(); + QStringList::Iterator listIt; + QString refs; + str += "CrossReference=\""; + bool added = false; + for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { + added = true; + QArray ints = ev.relations( (*listIt) ); + for ( uint i = 0; i< ints.count(); i++ ) { + str += (*listIt) + "," + QString::number( i ) + ";"; + } + } + if ( added ) + str = str.remove( str.length()-1, 1 ); + + str += "\" "; + + str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; + + return str; +} +QString OTodoAccessXML::toString( const QArray& ints ) const { + return Qtopia::Record::idsToString( ints ); +} diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h new file mode 100644 index 0000000..be9109d --- a/dev/null +++ b/libopie2/opiepim/backend/otodoaccessxml.h @@ -0,0 +1,53 @@ +#ifndef OPIE_TODO_ACCESS_XML_H +#define OPIE_TODO_ACCESS_XML_H + +#include +#include + +#include "otodoaccessbackend.h" + +namespace Opie { + class XMLElement; +}; + +class OTodoAccessXML : public OTodoAccessBackend { +public: + /** + * fileName if Empty we will use the default path + */ + OTodoAccessXML( const QString& appName, + const QString& fileName = QString::null ); + ~OTodoAccessXML(); + + bool load(); + bool reload(); + bool save(); + + QArray allRecords()const; + QArray queryByExample( const OTodo&, int sort ); + OTodo find( int uid )const; + void clear(); + bool add( const OTodo& ); + bool remove( int uid ); + bool replace( const OTodo& ); + + /* our functions */ + QArray effectiveToDos( const QDate& start, + const QDate& end, + bool includeNoDates ); + QArray overDue(); +private: + OTodo todo( QAsciiDict*, Opie::XMLElement* )const; + QString toString( const OTodo& )const; + QString toString( const QArray& ints ) const; + QMap m_events; + QString m_file; + QString m_app; + bool m_opened : 1; + bool m_changed : 1; + class OTodoAccessXMLPrivate; + OTodoAccessXMLPrivate* d; + +}; + +#endif diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 36f5a99..31ab516 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h @@ -14,7 +14,7 @@ * Library. Either you want to use it's * interface or you want to implement * your own Access lib - * Just create a OPimRecord and inherit from + * Just create a OPimRecord and inherit from * the plugins */ @@ -36,49 +36,49 @@ public: */ OPimAccessTemplate( BackEnd* end); virtual ~OPimAccessTemplate(); - + /** * load from the backend */ - virtual void load(); - + virtual bool load(); + /** * reload from the backend */ - virtual void reload(); - + virtual bool reload(); + /** - * save to the backend + * save to the backend */ - virtual void save(); + virtual bool save(); /** * if the resource was changed externally */ bool wasChangedExternally()const; - + /** * return a List of records * you can iterate over them */ virtual List allRecords()const; - + /** - * queryByExample + * queryByExample */ virtual List queryByExample( const T& t, int sortOrder ); - + /** * find the OPimRecord uid */ - virtual T find( int uid ); + virtual T find( int uid )const; /* invalidate cache here */ /** * clears the backend and invalidates the backend */ virtual void clear() ; - + /** * add T to the backend */ @@ -89,12 +89,12 @@ public: * remove T from the backend */ virtual bool remove( const T& t ); - + /** * remove the OPimRecord with uid */ virtual bool remove( int uid ); - + /** * replace T from backend */ @@ -104,7 +104,8 @@ protected: * invalidate the cache */ void invalidateCache(); - + + void setBackEnd( BackEnd* end ); /** * returns the backend */ @@ -125,16 +126,16 @@ OPimAccessTemplate::~OPimAccessTemplate() { delete m_backEnd; } template -void OPimAccessTemplate::load() { - m_backEnd->load(); +bool OPimAccessTemplate::load() { + return m_backEnd->load(); } template -void OPimAccessTemplate::reload() { - m_backEnd->reload(); +bool OPimAccessTemplate::reload() { + return m_backEnd->reload(); } template -void OPimAccessTemplate::save() { - m_backEnd->save(); +bool OPimAccessTemplate::save() { + return m_backEnd->save(); } template OPimAccessTemplate::List OPimAccessTemplate::allRecords()const { @@ -151,7 +152,7 @@ OPimAccessTemplate::queryByExample( const T& t, int sortOrder ) { return lis; } template -T OPimAccessTemplate::find( int uid ) { +T OPimAccessTemplate::find( int uid ) const{ T t = m_backEnd->find( uid ); return t; } @@ -188,4 +189,8 @@ template bool OPimAccessTemplate::wasChangedExternally()const { return false; } +template +void OPimAccessTemplate::setBackEnd( BackEnd* end ) { + m_backEnd = end; +} #endif diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h index add1de4..f71417b 100644 --- a/libopie2/opiepim/core/otemplatebase.h +++ b/libopie2/opiepim/core/otemplatebase.h @@ -13,7 +13,7 @@ public: }; virtual ~OTemplateBase() { } - virtual T find( int uid ) = 0; + virtual T find( int uid )const = 0; }; diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp new file mode 100644 index 0000000..a65cf5c --- a/dev/null +++ b/libopie2/opiepim/core/otodoaccess.cpp @@ -0,0 +1,71 @@ +#include + +#include + +#include "otodoaccessxml.h" +#include "otodoaccess.h" + + +OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) + : QObject(), OPimAccessTemplate( end ), m_todoBackEnd( end ) +{ + if (end == 0l ) + m_todoBackEnd = new OTodoAccessXML( "Todolist" ); + + setBackEnd( m_todoBackEnd ); +} +OTodoAccess::~OTodoAccess() { + qWarning("~OTodoAccess"); +} +void OTodoAccess::mergeWith( const QValueList& list ) { + QValueList::ConstIterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + replace( (*it) ); + } +} +OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, + const QDate& end, + bool includeNoDates ) { + QArray ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); + + List lis( ints, this ); + return lis; +} +OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, + bool includeNoDates ) { + return effectiveToDos( start, QDate::currentDate(), + includeNoDates ); +} +OTodoAccess::List OTodoAccess::overDue() { + List lis( m_todoBackEnd->overDue(), this ); + return lis; +} +void OTodoAccess::addAlarm( const OTodo& event) { + if (!event.hasAlarmDateTime() ) + return; + + QDateTime now = QDateTime::currentDateTime(); + QDateTime schedule = event.alarmDateTime(); + + if ( schedule > now ){ + AlarmServer::addAlarm( schedule, + "QPE/Application/todolist", + "alarm(QDateTime,int)", event.uid() ); + + } +} +void OTodoAccess::delAlarm( int uid) { + + QDateTime schedule; // Create null DateTime + + // I hope this will remove all scheduled alarms + // with the given uid !? + // If not: I have to rethink how to remove already + // scheduled events... (se) + // it should be fine -zecke + qWarning("Removing alarm for event with uid %d", uid ); + AlarmServer::deleteAlarm( schedule , + "QPE/Application/todolist", + "alarm(QDateTime,int)", uid ); +} + diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h new file mode 100644 index 0000000..c43efe9 --- a/dev/null +++ b/libopie2/opiepim/core/otodoaccess.h @@ -0,0 +1,79 @@ +#ifndef OPIE_TODO_ACCESS_H +#define OPIE_TODO_ACCESS_H + +#include +#include + +#include "otodo.h" +#include "otodoaccessbackend.h" +#include "opimaccesstemplate.h" + + +/** + * OTodoAccess + * the class to get access to + * the todolist + */ +class OTodoAccess : public QObject, public OPimAccessTemplate { + Q_OBJECT +public: + /** + * if you use 0l + * the default resource will be + * icked up + */ + OTodoAccess( OTodoAccessBackend* = 0l); + ~OTodoAccess(); + + + /* our functions here */ + /** + * include todos from start to end + * includeNoDates whether or not to include + * events with no dates + */ + List effectiveToDos( const QDate& start, + const QDate& end, + bool includeNoDates = true ); + + /** + * start + * end date taken from the currentDate() + */ + List effectiveToDos( const QDate& start, + bool includeNoDates = true ); + + + /** + * return overdue OTodos + */ + List overDue(); + /** + * merge a list of OTodos into + * the resource + */ + void mergeWith( const QValueList& ); + + /** + * add an Alarm to the AlarmServer + */ + void addAlarm( const OTodo& ); + + /** + * delete an alarm with the uid from + * the alarm server + */ + void delAlarm( int uid ); + +signals: + /** + * if the OTodoAccess was changed + */ + void signalChanged( const OTodoAccess* ); +private: + OTodoAccessBackend* m_todoBackEnd; + class OTodoAccessPrivate; + OTodoAccessPrivate* d; +}; + +#endif diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 3b30a73..75bb33c 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h @@ -14,28 +14,30 @@ * for(it = list.begin(); it != list.end(); ++it ) * doSomeCoolStuff( (*it) ); */ +template class ORecordList; template class ORecordListIterator { + friend class ORecordList; public: typedef OTemplateBase Base; - + /** * The c'tor used internally from * ORecordList */ ORecordListIterator( const QArray, const Base* ); - + /** * The standard c'tor */ ORecordListIterator(); ~ORecordListIterator(); - + ORecordListIterator( const ORecordListIterator& ); ORecordListIterator &operator=(const ORecordListIterator& ); - + /** - * a * operator ;) + * a * operator ;) * use it like this T = (*it); */ T &operator*(); @@ -59,25 +61,25 @@ private: /** * The recordlist used as a return type * from OPimAccessTemplate - */ + */ template class ORecordList { public: typedef OTemplateBase Base; typedef ORecordListIterator Iterator; - - /** + + /** * c'tor */ ORecordList( const QArray& ids, const Base* ); ~ORecordList(); - + /** * the first iterator */ Iterator begin(); - + /** * the end */ @@ -105,6 +107,7 @@ ORecordListIterator::~ORecordListIterator() { template ORecordListIterator::ORecordListIterator( const ORecordListIterator& it) { + qWarning("ORecordListIterator"); m_uids = it.m_uids; m_current = it.m_current; m_temp = it.m_temp; @@ -125,6 +128,7 @@ ORecordListIterator &ORecordListIterator::operator=( const ORecordListIter template T &ORecordListIterator::operator*() { + qWarning("operator* %d %d", m_current, m_uids[m_current] ); if (!m_end ) m_record = m_temp->find( m_uids[m_current] ); else @@ -135,7 +139,7 @@ T &ORecordListIterator::operator*() { template ORecordListIterator &ORecordListIterator::operator++() { - if (m_current < m_uids.count() ) { + if (m_current < (int)m_uids.count() ) { m_end = false; ++m_current; }else @@ -189,6 +193,7 @@ ORecordList::~ORecordList() { } template ORecordList::Iterator ORecordList::begin() { + qWarning("ORecordList::begin"); Iterator it( m_ids, m_acc ); return it; } @@ -197,5 +202,7 @@ ORecordList::Iterator ORecordList::end() { Iterator it( m_ids, m_acc ); it.m_end = true; it.m_current = m_ids.count(); + + return it; } #endif diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 8239ba6..b3c14e6 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp @@ -36,11 +36,12 @@ OTodo::OTodo(const OTodo &event ) : OPimRecord( event ), data( event.data ) { data->ref(); - //qWarning("ref up"); + qWarning("ref up"); } OTodo::~OTodo() { + qWarning("~OTodo " + data->sum ); if ( data->deref() ) { - //qWarning("OTodo::dereffing"); + qWarning("OTodo::dereffing"); delete data; data = 0l; } @@ -53,9 +54,11 @@ OTodo::OTodo(bool completed, int priority, bool hasDate, QDate date, int uid ) : OPimRecord( uid ) { - //qWarning("OTodoData"); + qWarning("OTodoData " + summary); setCategories( category ); + data = new OTodoData; + data->date = date; data->isCompleted = completed; data->hasDate = hasDate; @@ -74,10 +77,12 @@ OTodo::OTodo(bool completed, int priority, bool hasDate, QDate date, int uid ) : OPimRecord( uid ) { - //qWarning("OTodoData"); + qWarning("OTodoData" + summary); setCategories( idsFromString( category.join(";") ) ); + data = new OTodoData; data->date = date; + data->isCompleted = completed; data->hasDate = hasDate; data->priority = priority; @@ -350,7 +355,7 @@ QMap OTodo::toExtraMap()const { */ void OTodo::changeOrModify() { if ( data->count != 1 ) { - //qWarning("changeOrModify"); + qWarning("changeOrModify"); data->deref(); OTodoData* d2 = new OTodoData(); copy(data, d2 ); diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 75af44c..1443e4f 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h @@ -135,16 +135,6 @@ public: QString recordField(int id )const; /** - * returns a list of apps which have related items - */ - QStringList relatedApps()const; - - /** - * returns all relations for one app - */ - QArray relations( const QString& app )const; - - /** * toMap puts all data into the map. int relates * to ToDoEvent RecordFields enum */ -- cgit v0.9.0.2