summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-18 21:45:49 (UTC)
committer zecke <zecke>2004-11-18 21:45:49 (UTC)
commit7484344ff5be1f7c54e51715776d0e3cadeb1ed0 (patch) (side-by-side diff)
tree96f427f7a1fb1c8ca0a6efbd72b51e916cb1651d
parent3302eb30390e6053637929316670da3e8fbe279e (diff)
downloadopie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.zip
opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.gz
opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.bz2
Big PIM API Update Core Part (1/2 of what should be implemented):
OPimRecords: -Add a so called safeCast using the rtti value OPimTodo: -Fix memleak with OPimState OPimOccurrence: -New class. Every 'Access' can give occurrences for a period of time Move Documentation
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/core.pro3
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp7
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h57
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp35
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h11
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h351
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp24
-rw-r--r--libopie2/opiepim/core/opimcontact.h4
-rw-r--r--libopie2/opiepim/core/opimevent.cpp19
-rw-r--r--libopie2/opiepim/core/opimevent.h24
-rw-r--r--libopie2/opiepim/core/opimglobal.h18
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp5
-rw-r--r--libopie2/opiepim/core/opimoccurrence.cpp319
-rw-r--r--libopie2/opiepim/core/opimoccurrence.h142
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp23
-rw-r--r--libopie2/opiepim/core/opimrecord.h11
-rw-r--r--libopie2/opiepim/core/opimrecordlist.h17
-rw-r--r--libopie2/opiepim/core/opimresolver.h2
-rw-r--r--libopie2/opiepim/core/opimstate.h6
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.cpp112
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h139
-rw-r--r--libopie2/opiepim/core/opimtimezone.cpp44
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp127
-rw-r--r--libopie2/opiepim/core/opimtodo.h13
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp23
-rw-r--r--libopie2/opiepim/core/otodoaccess.h36
26 files changed, 1244 insertions, 328 deletions
diff --git a/libopie2/opiepim/core/core.pro b/libopie2/opiepim/core/core.pro
index b1b5655..f943318 100644
--- a/libopie2/opiepim/core/core.pro
+++ b/libopie2/opiepim/core/core.pro
@@ -14,2 +14,3 @@ HEADERS += \
core/opimnotifymanager.h \
+ core/opimoccurrence.h \
core/opimrecord.h \
@@ -37,2 +38,3 @@ SOURCES += \
core/opimnotifymanager.cpp \
+ core/opimoccurrence.cpp \
core/opimrecord.cpp \
@@ -41,2 +43,3 @@ SOURCES += \
core/opimstate.cpp \
+ core/opimtemplatebase.cpp \
core/opimtimezone.cpp \
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 771d855..9bbc820 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -72,3 +72,2 @@ OPimContactAccess::OPimContactAccess ( const QString appname, const QString ,
if( end == 0 ) {
- owarn << "Using BackendFactory !" << oendl;
end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname );
@@ -130,2 +129,4 @@ bool OPimContactAccess::hasQuerySettings ( int querySettings ) const
}
+
+#if 0
OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
@@ -135,2 +136,3 @@ OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortO
}
+#endif
@@ -146,9 +148,6 @@ void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
if ( msg == "addressbookUpdated()" ){
- owarn << "OPimContactAccess: Received addressbokUpdated()" << oendl;
emit signalChanged ( this );
} else if ( msg == "flush()" ) {
- owarn << "OPimContactAccess: Received flush()" << oendl;
save ();
} else if ( msg == "reload()" ) {
- owarn << "OPimContactAccess: Received reload()" << oendl;
reload ();
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index 4429b6f..691ece2 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -62,2 +62,22 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
public:
+ enum SortFilter {
+ DoNotShowNoneChildren = FilterCustom<<1,
+ DoNotShowNoneAnniversary = FilterCustom<<2,
+ DoNotShowNoneBirthday = FilterCustom<<3,
+ DoNotShowNoHomeAddress = FilterCustom<<4,
+ DoNotShowNoBusinessAddress = FilterCustom<<5
+ };
+
+ enum SortOrder {
+ SortTitle = SortCustom,
+ SortFirstName,
+ SortMiddleName,
+ SortSuffix,
+ SortEmail,
+ SortNickname,
+ SortAnniversary,
+ SortBirthday,
+ SortGender
+ };
+
/**
@@ -77,30 +97,5 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
OPimContactAccess (const QString appname, const QString filename = 0l,
- OPimContactAccessBackend* backend = 0l, bool handlesync = true);
- ~OPimContactAccess ();
+ OPimContactAccessBackend* backend = 0l, bool handlesync = true);
+ ~OPimContactAccess ();
- /** Constants for query.
- * Use this constants to set the query parameters.
- * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
- * @see queryByExample()
- */
- enum QuerySettings {
- WildCards = 0x0001,
- IgnoreCase = 0x0002,
- RegExp = 0x0004,
- ExactMatch = 0x0008,
- MatchOne = 0x0010, // Only one Entry must match
- DateDiff = 0x0020, // Find all entries from today until given date
- DateYear = 0x0040, // The year matches
- DateMonth = 0x0080, // The month matches
- DateDay = 0x0100, // The day matches
- };
-
-
- /** Return all Contacts in a sorted manner.
- * @param ascending true: Sorted in acending order.
- * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
- * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
- * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
- */
- List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
@@ -128,5 +123,5 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
*/
- bool save();
-
- /**
+ bool save();
+
+ /**
* Return identification of used records
@@ -146,4 +141,2 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
private:
- // class OPimContactAccessPrivate;
- // OPimContactAccessPrivate* d;
OPimContactAccessBackend *m_backEnd;
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
index 440ee0a..32fbb7d 100644
--- a/libopie2/opiepim/core/odatebookaccess.cpp
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -41,3 +41,3 @@ namespace Opie {
*/
-ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
+ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access )
: OPimAccessTemplate<OPimEvent>( back )
@@ -53,11 +53,2 @@ ODateBookAccess::~ODateBookAccess() {
-/**
- * @return all events available
- */
-ODateBookAccess::List ODateBookAccess::rawEvents()const {
- QArray<int> ints = m_backEnd->rawEvents();
-
- List lis( ints, this );
- return lis;
-}
@@ -84,17 +75,2 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const {
/**
- * @return dates in the time span between from and to
- * @param from Include all events from...
- * @param to Include all events to...
- */
-OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const {
- return m_backEnd->effectiveEvents( from, to );
-}
-/**
- * @return all events at a given datetime
- */
-OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const {
- return m_backEnd->effectiveEvents( start );
-}
-
-/**
* @return non repeating dates in the time span between from and to
@@ -103,4 +79,4 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& st
*/
-OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const {
- return m_backEnd->effectiveNonRepeatingEvents( from, to );
+OPimOccurrence::List ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const {
+ return OPimBase::convertOccurrenceFromBackend( m_backEnd->effectiveNonRepeatingEvents( from, to ) );
}
@@ -109,5 +85,6 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const Q
*/
-OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const {
- return m_backEnd->effectiveNonRepeatingEvents( start );
+OPimOccurrence::List ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const {
+ return OPimBase::convertOccurrenceFromBackend( m_backEnd->effectiveNonRepeatingEvents( start ) );
}
+
int ODateBookAccess::rtti() const
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h
index c6c3598..0be8606 100644
--- a/libopie2/opiepim/core/odatebookaccess.h
+++ b/libopie2/opiepim/core/odatebookaccess.h
@@ -51,5 +51,2 @@ public:
- /* return all events */
- List rawEvents()const;
-
/* return repeating events */
@@ -61,8 +58,6 @@ public:
/* return non repeating events (from,to) */
- OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const;
- OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const;
- OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const;
- OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const;
+ OPimOccurrence::List effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const;
+ OPimOccurrence::List effectiveNonRepeatingEvents( const QDateTime& start ) const;
- /**
+ /**
* Return identification of used records
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index f936d4e..2deb92a 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -3,3 +3,3 @@
Copyright (C) Holger Freyther <zecke@handhelds.org>
- Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
+ Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -42,2 +42,3 @@
#include <qarray.h>
+#include <qdatetime.h>
@@ -58,2 +59,5 @@ class OPimAccessTemplate : public OTemplateBase<T> {
public:
+ /**
+ *
+ */
enum Access {
@@ -66,116 +70,64 @@ public:
- /**
- * c'tor BackEnd
- * enum Access a small hint on how to handle the backend
- */
+ //@{
OPimAccessTemplate( BackEnd* end);
-
virtual ~OPimAccessTemplate();
+ //@}
- /**
- * load from the backend
- */
+ //@{
bool load();
-
- /** Reload database.
- * You should execute this function if the external database
- * was changed.
- * This function will load the external database and afterwards
- * rejoin the local changes. Therefore the local database will be set consistent.
- */
virtual bool reload();
-
- /** Save contacts database.
- * Save is more a "commit". After calling this function, all changes are public available.
- * @return true if successful
- */
bool save();
+ void clear() ;
+ //@}
+
- /**
- * if the resource was changed externally
- * You should use the signal handling instead of polling possible changes !
- * zecke: Do you implement a signal for otodoaccess ?
- */
bool wasChangedExternally()const;
- /**
- * return a List of records
- * you can iterate over them
- */
+ //@{
virtual List allRecords()const;
-
- /**
- * return a List of records
- * that match the regex
- */
virtual List matchRegexp( const QRegExp &r ) const;
-
- /**
- * queryByExample.
- * @see otodoaccess, ocontactaccess
- */
virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
+ virtual T find( UID uid )const;
+ virtual T find( UID uid, const QArray<int>&,
+ uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
+ virtual List sorted( const List&, bool ascending, int sortOrder,
+ int sortFilter, int cat )const;
+ virtual List sorted( const List&, bool ascending, int sortOrder,
+ int sortFilter, const QArray<UID>& cats )const;
+ virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const;
+ virtual List sorted( bool ascending, int sortOrder, int sortOrder,
+ const QArray<UID>& cats )const;
+ //@}
/**
- * find the OPimRecord uid
- */
- T find( int uid )const;
-
- /**
- * read ahead cache find method ;)
- */
- T find( int uid, const QArray<int>&,
- uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
-
-
- /* invalidate cache here */
- /**
- * clears the backend and invalidates the backend
+ * (Re)Implementation
*/
- void clear() ;
-
- /**
- * add T to the backend
- * @param t The item to add.
- * @return <i>true</i> if added successfully.
- */
- virtual bool add( const T& t ) ;
-
+ //@{
+ UIDArray matchRegexpSimple( const QRegExp& r )const;
+ UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const;
+ UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder,
+ int sortFilter, int cat )const;
+ UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder,
+ int sortFilter, const QArray<int>& )const;
+ UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter,
+ int cat )const;
+ UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter,
+ const QArray<int>& )const;
+ OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const;
+ OPimOccurrence::List occurrences( const QDateTime& dt )const;
+ //@}
+
+ //@{
+ virtual bool add( const T& t ) ;
bool add( const OPimRecord& );
- /**
- * Add an Opie PimRecord.
- * Info: Take this if you are working with OPimRecords and you need to add it into any database.
- * But take care that the accessing database is compatible to the real type of OPimRecord !!
- * Otherwise this access will be rejected !
- */
bool add( const OPimRecord* );
-
-
- /* only the uid matters */
- /**
- * remove T from the backend
- * @param t The item to remove
- * @return <i>true</i> if successful.
- */
virtual bool remove( const T& t );
-
- /**
- * remove the OPimRecord with uid
- * @param uid The ID of the item to remove
- * @return <i>true</i> if successful.
- */
- bool remove( int uid );
+ bool remove( UID uid );
bool remove( const OPimRecord& );
-
- /**
- * replace T from backend
- * @param t The item to replace
- * @return <i>true</i> if successful.
- */
virtual bool replace( const T& t) ;
+ //@}
+
void setReadAhead( uint count );
- /**
- * @internal
- */
+ virtual T cacheFind( int uid )const;
void cache( const T& )const;
@@ -183,3 +135,3 @@ public:
- QArray<int> records()const;
+ QArray<UID> records()const;
protected:
@@ -204,2 +156,6 @@ private:
+/**
+ * c'tor BackEnd
+ * enum Access a small hint on how to handle the backend
+ */
template <class T>
@@ -213,5 +169,8 @@ template <class T>
OPimAccessTemplate<T>::~OPimAccessTemplate() {
- owarn << "~OPimAccessTemplate<T>" << oendl;
delete m_backEnd;
}
+
+/**
+ * load from the backend
+ */
template <class T>
@@ -221,2 +180,9 @@ bool OPimAccessTemplate<T>::load() {
}
+
+/** Reload database.
+ * You should execute this function if the external database
+ * was changed.
+ * This function will load the external database and afterwards
+ * rejoin the local changes. Therefore the local database will be set consistent.
+ */
template <class T>
@@ -226,2 +192,8 @@ bool OPimAccessTemplate<T>::reload() {
}
+
+/**
+ * Save contacts database.
+ * Save is more a "commit". After calling this function, all changes are public available.
+ * @return true if successful
+ */
template <class T>
@@ -230,2 +202,8 @@ bool OPimAccessTemplate<T>::save() {
}
+
+
+/**
+ * return a List of records
+ * you can iterate over them
+ */
template <class T>
@@ -236,2 +214,7 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
}
+
+/**
+ * return a List of records
+ * that match the regex
+ */
template <class T>
@@ -242,2 +225,6 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const Q
}
+
+/**
+ * find the OPimRecord uid
+ */
template <class T>
@@ -246,2 +233,8 @@ QArray<int> OPimAccessTemplate<T>::records()const {
}
+
+
+/**
+ * queryByExample.
+ * @see otodoaccess, ocontactaccess
+ */
template <class T>
@@ -254,4 +247,5 @@ OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime
}
+
template <class T>
-T OPimAccessTemplate<T>::find( int uid ) const{
+T OPimAccessTemplate<T>::find( UID uid ) const{
// First search in cache..
@@ -267,3 +261,12 @@ T OPimAccessTemplate<T>::find( int uid ) const{
template <class T>
-T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
+T OPimAccessTemplate<T>::cacheFind( int uid ) const
+{
+ return m_cache.find( uid );
+}
+
+/**
+ * read ahead cache find method ;)
+ */
+template <class T>
+T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar,
uint current, typename OTemplateBase<T>::CacheDirection dir )const {
@@ -274,6 +277,5 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
*/
- // owarn << "find it now " << uid << oendl;
- if ( m_cache.contains( uid ) ) {
+ if (m_cache.contains( uid ) )
return m_cache.find( uid );
- }
+
@@ -283,2 +285,6 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
}
+
+/**
+ * clears the backend and invalidates the backend
+ */
template <class T>
@@ -288,2 +294,9 @@ void OPimAccessTemplate<T>::clear() {
}
+
+
+/**
+ * add T to the backend
+ * @param t The item to add.
+ * @return <i>true</i> if added successfully.
+ */
template <class T>
@@ -307,2 +320,8 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) {
+/**
+ * Add an Opie PimRecord.
+ * Info: Take this if you are working with OPimRecords and you need to add it into any database.
+ * But take care that the accessing database is compatible to the real type of OPimRecord !!
+ * Otherwise this access will be rejected !
+ */
template <class T>
@@ -320,2 +339,7 @@ bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
+/**
+ * remove T from the backend
+ * @param t The item to remove
+ * @return <i>true</i> if successful.
+ */
template <class T>
@@ -324,4 +348,10 @@ bool OPimAccessTemplate<T>::remove( const T& t ) {
}
+
+/**
+ * remove the OPimRecord with uid
+ * @param uid The ID of the item to remove
+ * @return <i>true</i> if successful.
+ */
template <class T>
-bool OPimAccessTemplate<T>::remove( int uid ) {
+bool OPimAccessTemplate<T>::remove( UID uid ) {
m_cache.remove( uid );
@@ -333,2 +363,8 @@ bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) {
}
+
+/**
+ * replace T from backend
+ * @param t The item to replace
+ * @return <i>true</i> if successful.
+ */
template <class T>
@@ -338,2 +374,6 @@ bool OPimAccessTemplate<T>::replace( const T& t ) {
}
+
+/**
+ * @internal
+ */
template <class T>
@@ -346,2 +386,8 @@ typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
}
+
+/**
+ * if the resource was changed externally
+ * You should use the signal handling instead of polling possible changes !
+ * zecke: Do you implement a signal for otodoaccess ?
+ */
template <class T>
@@ -370,2 +416,105 @@ void OPimAccessTemplate<T>::setReadAhead( uint count ) {
+
+template <class T>
+typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( const OPimAccessTemplate::List& lst,
+ bool ascending, int sortOrder,
+ int sortFilter, int cat )const {
+ QArray<int> cats( 1 );
+ cats[0] = cat;
+ UIDArray ints = m_backEnd->sorted( lst.uids(), ascending, sortOrder,
+ sortFilter, cats );
+ return List(ints, this);
+}
+
+template<class T>
+typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( const OPimAccessTemplate::List& lst,
+ bool ascending, int sortOrder,
+ int sortFilter, const QArray<UID>& cats )const {
+ UIDArray ints = m_backEnd->sorted( lst.uids(), ascending, sortOrder,
+ sortFilter, cats );
+ return List(ints, this);
+}
+
+template<class T>
+typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( bool ascending, int sortOrder,
+ int sortFilter, int cat )const {
+ QArray<int> cats( 1 );
+ cats[0] = cat;
+ UIDArray ints = m_backEnd->sorted( ascending, sortOrder,
+ sortFilter, cats );
+ return List(ints, this);
+}
+
+template<class T>
+typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( bool ascending, int sortOrder,
+ int sortFilter, const QArray<UID>& cats )const {
+ UIDArray ints = m_backEnd->sorted( ascending, sortOrder,
+ sortFilter, cats );
+ return List(ints, this);
+}
+
+template <class T>
+OPimOccurrence::List OPimAccessTemplate<T>::occurrences( const QDate& start,
+ const QDate& end ) const {
+ /*
+ * Some magic involved to go from single OPimBackendOccurrence
+ * to multiple OPimOccurrence's
+ */
+ return OPimBase::convertOccurrenceFromBackend( m_backEnd->occurrences( start, end ) );
+}
+
+template<class T>
+OPimOccurrence::List OPimAccessTemplate<T>::occurrences( const QDateTime& dt )const {
+ return OPimBase::convertOccurrenceFromBackend( m_backEnd->occurrences( dt ) );
+}
+
+/*
+ *Implementations!!
+ */
+template <class T>
+UIDArray OPimAccessTemplate<T>::matchRegexpSimple( const QRegExp &r )const {
+ return m_backEnd->matchRegexp( r );
+}
+
+template <class T>
+UIDArray OPimAccessTemplate<T>::queryByExampleSimple( const OPimRecord* rec,
+ int settings,
+ const QDateTime& d )const {
+ return m_backEnd->queryByExample( rec, settings, d );
+}
+
+template <class T>
+UIDArray OPimAccessTemplate<T>::sortedSimple( const UIDArray& lst,
+ bool ascending,
+ int sortOrder, int sortFilter,
+ int cat ) const{
+ QArray<int> cats( 1 );
+ cats[0] = cat;
+ return m_backEnd->sorted( lst, ascending, sortOrder, sortFilter, cats );
+}
+
+template <class T>
+UIDArray OPimAccessTemplate<T>::sortedSimple( const UIDArray& lst,
+ bool ascending,
+ int sortOrder, int sortFilter,
+ const QArray<int>& cats ) const{
+ return m_backEnd->sorted( lst, ascending, sortOrder, sortFilter, cats );
+}
+
+template <class T>
+UIDArray OPimAccessTemplate<T>::sortedSimple( bool ascending,
+ int sortOrder, int sortFilter,
+ int cat ) const{
+ QArray<int> cats( 1 );
+ cats[0] = cat;
+
+ return m_backEnd->sorted( ascending, sortOrder, sortFilter, cats );
+}
+
+template <class T>
+UIDArray OPimAccessTemplate<T>::sortedSimple( bool ascending,
+ int sortOrder, int sortFilter,
+ const QArray<int>& cats ) const{
+ return m_backEnd->sorted( ascending, sortOrder, sortFilter, cats );
+}
}
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp
index 36e9a93..64f195b 100644
--- a/libopie2/opiepim/core/opimcontact.cpp
+++ b/libopie2/opiepim/core/opimcontact.cpp
@@ -83,3 +83,2 @@ OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap
{
- owarn << "Invalid UID found. Generate new one.." << oendl;
setUid( uidGen().generate() );
@@ -1140,3 +1139,2 @@ void OPimContact::setBirthday( const QDate &v )
{
- owarn << "Remove Birthday" << oendl;
replace( Qtopia::Birthday, QString::null );
@@ -1159,3 +1157,2 @@ void OPimContact::setAnniversary( const QDate &v )
{
- owarn << "Remove Anniversary" << oendl;
replace( Qtopia::Anniversary, QString::null );
@@ -1175,3 +1172,2 @@ QDate OPimContact::birthday() const
QString str = find( Qtopia::Birthday );
- // owarn << "Birthday " << str << oendl;
if ( !str.isEmpty() )
@@ -1190,3 +1186,2 @@ QDate OPimContact::anniversary() const
QString str = find( Qtopia::Anniversary );
- // owarn << "Anniversary " << str << oendl;
if ( !str.isEmpty() )
@@ -1284,2 +1279,21 @@ int OPimContact::rtti() const
+/**
+ * \brief Cast to OPimContact or on failure return 0l
+ *
+ * This method tries to cast from a OPimRecord to a
+ * OPimContact it uses. If the OPimRecord is from type
+ * OPimContact the case will suceed and a pointer to
+ * OPimContact is returned otherwise a Null Pointer is returned.
+ *
+ *
+ * @see OPimTodo::safeCast()
+ * @see OPimEvent::safeCast()
+ * @return Return a OPimContact or a Null Pointer
+ */
+OPimContact* OPimContact::safeCast( const OPimRecord* rec ) {
+ return( rec && rec->rtti() == OPimResolver::AddressBook ) ?
+ static_cast<OPimContact*>( const_cast<OPimRecord*>(rec) ) :
+ 0l;
+}
+
diff --git a/libopie2/opiepim/core/opimcontact.h b/libopie2/opiepim/core/opimcontact.h
index 6891dd6..6fa2c4b 100644
--- a/libopie2/opiepim/core/opimcontact.h
+++ b/libopie2/opiepim/core/opimcontact.h
@@ -230,3 +230,7 @@ class QPC_EXPORT OPimContact : public OPimRecord
QString emails() const { return find( Qtopia::Emails ); }
+
+ //@{
int rtti() const;
+ static OPimContact* safeCast( const OPimRecord* );
+ //@}
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index 7bc6c32..1b553d8 100644
--- a/libopie2/opiepim/core/opimevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -491,2 +491,21 @@ int OPimEvent::rtti() const
+/**
+ * \brief Cast safely to OPimEvent from OPimRecord
+ *
+ * Safely cast from OPimRecord to OPimEvent. If the
+ * OPimRecord is not of type OPimEvent Null will be
+ * returned.
+ *
+ * @param rec The OPimRecord to be casted to OPimEvent
+ *
+ * @see OPimTodo::safeCast
+ * @return OPimEvent or Null Pointer
+ */
+OPimEvent* OPimEvent::safeCast( const OPimRecord* rec) {
+ return ( rec && rec->rtti() == OPimResolver::DateBook ) ?
+ static_cast<OPimEvent*>( const_cast<OPimRecord*>(rec) ) :
+ 0l;
+}
+
+
diff --git a/libopie2/opiepim/core/opimevent.h b/libopie2/opiepim/core/opimevent.h
index 5553cac..32f648f 100644
--- a/libopie2/opiepim/core/opimevent.h
+++ b/libopie2/opiepim/core/opimevent.h
@@ -120,2 +120,3 @@ class OPimEvent : public OPimRecord
+ //@{
QString description() const;
@@ -125,6 +126,10 @@ class OPimEvent : public OPimRecord
void setLocation( const QString& loc );
+ //@}
+ //@{
bool hasNotifiers() const;
OPimNotifyManager &notifiers() const;
+ //@}
+ //@{
OPimRecurrence recurrence() const;
@@ -132,5 +137,8 @@ class OPimEvent : public OPimRecord
bool hasRecurrence() const;
+ //@}
+ //@{
QString note() const;
void setNote( const QString& note );
+ //@}
@@ -163,4 +171,3 @@ class OPimEvent : public OPimRecord
- virtual bool match( const QRegExp& ) const;
-
+ //@{
/** For exception to recurrence here is a list of children... */
@@ -170,2 +177,3 @@ class OPimEvent : public OPimRecord
void removeChild( int uid );
+ //@}
@@ -177,2 +185,4 @@ class OPimEvent : public OPimRecord
/* needed reimp */
+ //@{ Reimplementations
+ virtual bool match( const QRegExp& ) const;
QString toRichText() const;
@@ -185,8 +195,12 @@ class OPimEvent : public OPimRecord
- int rtti() const;
-
bool loadFromStream( QDataStream& );
bool saveToStream( QDataStream& ) const;
+ //@}
+
+ //@{
+ int rtti() const;
+ static OPimEvent* safeCast( const OPimRecord* );
+ //@}
- /* bool operator==( const OPimEvent& );
+ /* bool operator==( const OPimEvent& );
bool operator!=( const OPimEvent& );
diff --git a/libopie2/opiepim/core/opimglobal.h b/libopie2/opiepim/core/opimglobal.h
index 3925c89..9d319a1 100644
--- a/libopie2/opiepim/core/opimglobal.h
+++ b/libopie2/opiepim/core/opimglobal.h
@@ -31,3 +31,15 @@
+#include <qarray.h>
+
namespace Opie{
+
+/**
+ * The unique identifier for every
+ * PIM record. For now it is a negative
+ * int but we could change it to long or QUuid
+ * in the future
+ */
+typedef int UID;
+typedef QArray<UID> UIDArray;
+
namespace Pim{
@@ -35,4 +47,4 @@ namespace Pim{
- /**
- * Contains global types and enums for the PIM-API
+ /**
+ * Contains global types and enums for the PIM-API
*/
@@ -46,3 +58,3 @@ class OPimGlobal{
};
-
+
enum DatabaseStyle {
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index 516dc79..77cd922 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -166,3 +166,2 @@ bool OPimNotifyManager::isEmpty() const
{
- owarn << "is Empty called on OPimNotifyManager " << m_rem.count() << " " << m_al.count() << "" << oendl;
if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
@@ -194,3 +193,2 @@ QString OPimNotifyManager::alarmsToString() const
// now write the list
- owarn << "als: " << als.join( "____________" ) << "" << oendl;
str = als.join( ";" );
@@ -228,5 +226,2 @@ void OPimNotifyManager::alarmsFromString( const QString& str )
QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty
- owarn << "alarm: " << alarm.join( "___" ) << "" << oendl;
- owarn << "alarm[0]: " << alarm[ 0 ] << " "
- << OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString() << oendl;
OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ),
diff --git a/libopie2/opiepim/core/opimoccurrence.cpp b/libopie2/opiepim/core/opimoccurrence.cpp
new file mode 100644
index 0000000..14ab5cf
--- a/dev/null
+++ b/libopie2/opiepim/core/opimoccurrence.cpp
@@ -0,0 +1,319 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) 2003, 2004 Holger Freyther <zecke@handhelds.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "opimoccurrence.h"
+#include <opie2/opimtemplatebase.h>
+#include <opie2/private/opimoccurrence_p.h>
+
+
+/* QT */
+#include <qshared.h>
+
+
+namespace Opie {
+
+OPimOccurrence::OPimOccurrence( OPimOccurrence::Data* _data,
+ enum OPimOccurrence::Position pos )
+ : m_pos( pos ), data( _data )
+{}
+
+/**
+ * \brief Copy constructor
+ */
+OPimOccurrence::OPimOccurrence( const OPimOccurrence& oc )
+ : data( oc.data )
+{
+ /*
+ * Increment the reference count
+ */
+ data->ref();
+
+ /*
+ * copy the other information
+ */
+ m_start = oc.m_start;
+ m_end = oc.m_end;
+ m_occurrence = oc.m_occurrence;
+ m_isAllDay = oc.m_isAllDay;
+ m_pos = oc.m_pos;
+}
+
+OPimOccurrence::OPimOccurrence()
+ : m_isAllDay( false ), m_pos( StartEnd )
+{
+ /* simple convient c'tor */
+ data = new OPimOccurrence::Data();
+}
+
+OPimOccurrence::~OPimOccurrence() {
+ deref();
+}
+
+/**
+ * \brief Copy Operator
+ */
+OPimOccurrence& OPimOccurrence::operator=( const OPimOccurrence& oc ) {
+ /* guard against self assignment */
+ if ( this == &oc ) return *this;
+
+ oc.data->ref();
+ deref();
+ data = oc.data;
+
+
+ /*
+ * copy the other information
+ */
+ m_start = oc.m_start;
+ m_end = oc.m_end;
+ m_occurrence = oc.m_occurrence;
+ m_isAllDay = oc.m_isAllDay;
+ m_pos = oc.m_pos;
+
+ return *this;
+}
+
+
+/**
+ * @internal
+ */
+void OPimOccurrence::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0;
+ }
+}
+
+/**
+ * \brief Set the Occurrence to be All Day on a specified QDate
+ *
+ * If no QTime is associated to a OPimOccurrence use this Method
+ * to set the Period of this Occurrence. When using this Method
+ * later calls to \sa isAllDay() will return true.
+ * The Occurrence will be set to occurr on \par from.
+ *
+ * @param from The Day this OPimOccurrence occurs
+ *
+ */
+void OPimOccurrence::setPeriod( const QDate& from ) {
+ m_occurrence = from;
+ m_start = m_end = QTime(); // assign invalid value just in case
+ m_isAllDay = true;
+}
+
+/**
+ * \brief Set the period of this Occurrence with a QTime associated (overloaded)
+ *
+ * Set the period of time for this Occurrence. Each Ocurrence is limited
+ * to one day. Using this Method will make \sa isAllDay() return false.
+ * If \par from and \par to are on two different days the QDate of the
+ * \par from QDateTime will be used.
+ *
+ * @param from The Start Date Time of the Occurrence
+ * @param to The End Date Time of the Occurrence
+ */
+void OPimOccurrence::setPeriod( const QDateTime& from, const QDateTime& to ) {
+ m_occurrence = from.date();
+ m_start = from.time();
+ m_end = to.time();
+ m_isAllDay = false;
+}
+
+/**
+ * \brief Set the period of this Occurrence with a QTime associated
+ *
+ * @param from The QDate of the Occurrence
+ * @param start The Start QTime of the Occurrence
+ * @param end The End QTime of the Occurrence
+ */
+void OPimOccurrence::setPeriod( const QDate& from, const QTime& start,
+ const QTime& end ) {
+ m_occurrence = from;
+ m_start = start;
+ m_end = end;
+ m_isAllDay = false;
+}
+
+
+/**
+ * \brief Is a QTime associated to the OPimOccurrence
+ *
+ * @return Return true if no QTime is associated
+ */
+bool OPimOccurrence::isAllDay()const {
+ return m_isAllDay;
+}
+
+
+/**
+ * \brief Return the QDate where this OPimOccurrence takes place
+ * @return the QDate where this OPimOccurrence occurrs.
+ */
+QDate OPimOccurrence::date()const {
+ return m_occurrence;
+}
+
+
+/**
+ * \brief Return the start time of the OPimOccurrence
+ *
+ * @return Return the Start Time of the OPimOccurrence. It is
+ * invalid if \sa isAllDay() returns true.
+ */
+QTime OPimOccurrence::startTime()const {
+ return m_start;
+}
+
+QTime OPimOccurrence::endTime()const {
+ return m_end;
+}
+
+QDateTime OPimOccurrence::startDateTime()const {
+ return QDateTime( m_occurrence, m_start );
+}
+
+QDateTime OPimOccurrence::endDateTime()const {
+ return QDateTime( m_occurrence, m_end );
+}
+
+
+QString OPimOccurrence::summary()const {
+ return data->summary;
+}
+
+QString OPimOccurrence::location()const {
+ return data->location;
+}
+
+QString OPimOccurrence::note()const {
+ return data->note;
+}
+
+
+/**
+ * -1 if no time is associated
+ * otherwise the length of the occurrence in hours
+ */
+int OPimOccurrence::length()const {
+ if ( m_isAllDay )
+ return -1;
+ else
+ return ( m_end.hour() * 60 - m_start.hour() * 60 )
+ + QABS( m_start.minute() - m_end.minute() );
+}
+
+enum OPimOccurrence::Position OPimOccurrence::position()const {
+ return m_pos;
+}
+
+void OPimOccurrence::setPosition( enum OPimOccurrence::Position& pos ) {
+ m_pos = pos;
+}
+
+
+Opie::Core::OSharedPointer<OPimRecord> OPimOccurrence::record()const {
+ if ( !data->record && data->backend )
+ data->record = data->backend->record( data->uid );
+ return data->record;
+}
+
+template<class Record> Record OPimOccurrence::internalToRecord()const {
+ Record target;
+
+ /* If it is not loaded, try to load it using OPimBase */
+ if ( !data->record && data->backend )
+ data->record = data->backend->record( data->uid );
+
+ Record *ta = Record::safeCast( data->record );
+ if ( ta )
+ target = *ta;
+
+
+ return target;
+}
+
+OPimEvent OPimOccurrence::toEvent()const {
+ return internalToRecord<OPimEvent>();
+}
+
+OPimTodo OPimOccurrence::toTodo()const {
+ return internalToRecord<OPimTodo>();
+}
+
+OPimContact OPimOccurrence::toContact()const {
+ return internalToRecord<OPimContact>();
+}
+
+bool OPimOccurrence::operator<( const OPimOccurrence& oc )const {
+ if ( m_occurrence < oc.m_occurrence )
+ return true;
+ if ( m_occurrence == oc.m_occurrence )
+ return m_start < oc.m_start;
+ else
+ return false;
+}
+
+bool OPimOccurrence::operator<=( const OPimOccurrence& oc )const {
+ return ( m_occurrence <= oc.m_occurrence );
+}
+
+bool OPimOccurrence::operator==( const OPimOccurrence& oc )const {
+ if ( data->uid != oc.data->uid )
+ return false;
+ if ( m_occurrence != oc.m_occurrence )
+ return false;
+ if ( m_isAllDay != oc.m_isAllDay )
+ return false;
+ if ( m_isAllDay && oc.m_isAllDay )
+ if ( m_start != oc.m_start ||
+ m_end != oc.m_end )
+ return false;
+ if ( data->summary != oc.data->summary )
+ return false;
+ if ( data->note != oc.data->note )
+ return false;
+ if ( data->location != oc.data->location )
+ return false;
+
+ return true;
+}
+
+bool OPimOccurrence::operator!=( const OPimOccurrence& oc )const {
+ return !( *this == oc );
+}
+
+bool OPimOccurrence::operator>( const OPimOccurrence& oc )const {
+ return !( *this <= oc );
+}
+
+bool OPimOccurrence::operator>=( const OPimOccurrence& oc )const {
+ return !( *this < oc );
+}
+
+}
diff --git a/libopie2/opiepim/core/opimoccurrence.h b/libopie2/opiepim/core/opimoccurrence.h
new file mode 100644
index 0000000..902638b
--- a/dev/null
+++ b/libopie2/opiepim/core/opimoccurrence.h
@@ -0,0 +1,142 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) 2003, 2004 Holger Freyther <zecke@handhelds.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef OPIE_PIM_OCCURRENCE_H
+#define OPIE_PIM_OCCURRENCE_H
+
+#include <opie2/osharedpointer.h>
+#include <opie2/opimrecord.h>
+#include <opie2/opimevent.h>
+#include <opie2/opimtodo.h>
+#include <opie2/opimcontact.h>
+
+#include <qdatetime.h>
+#include <qstringlist.h>
+
+namespace Opie {
+
+template<class T> class OPimAccessTemplate;
+/**
+ * \brief An OPimOccurrence represents a occurence for one day of a OPimRecord
+ *
+ * An OPimOccurrence represents the occurrence of one OPimRecord
+ * for a period of Time for one day. An occurrence can spawn
+ * more then one day and then is splitted into multiple OPimOccurrence.
+ * By attributes you can find if a OPimOccurrence is the beginning and
+ * end, begin, end or is midway of a multiday occurrence.
+ *
+ */
+class OPimOccurrence {
+ friend class OPimBase;
+public:
+ typedef QValueList<OPimOccurrence> List;
+ /**
+ * The position of the OPimOccurrence in a possible
+ * MultiDay Occurrence.
+ */
+ enum Position {
+ MidWay, /* This OPimOccurrence is somewhere in between Start and End */
+ Start, /* This OPimOccurrence is the Start of a multi day Occurrence */
+ End, /* This OPimOccurrence is the End of a multi day Occurrence */
+ StartEnd /* This OPimOccurrence only spans one day */
+ };
+
+ //@{
+ OPimOccurrence();
+ OPimOccurrence( const OPimOccurrence& );
+ ~OPimOccurrence();
+ //@}
+
+ //@{
+ void setPeriod( const QDate& from );
+ void setPeriod( const QDateTime& from, const QDateTime& to );
+ void setPeriod( const QDate& from, const QTime& start, const QTime& end );
+ //@}
+
+ //@{
+ bool isAllDay()const;
+ QDate date()const;
+ QTime startTime()const;
+ QTime endTime()const;
+ QDateTime startDateTime()const;
+ QDateTime endDateTime()const;
+ //@}
+
+ //@{
+ QString summary()const;
+ QString location()const;
+ QString note()const;
+ //@}
+
+ //@{
+ int length()const;
+ Position position()const;
+ void setPosition( enum Position& );
+ //@}
+
+ //@{
+ Opie::Core::OSharedPointer<OPimRecord> record()const;
+ OPimEvent toEvent()const;
+ OPimTodo toTodo()const;
+ OPimContact toContact()const;
+ //@}
+
+
+ //@{
+ bool operator< ( const OPimOccurrence& )const;
+ bool operator<=( const OPimOccurrence& )const;
+ bool operator==( const OPimOccurrence& )const;
+ bool operator!=( const OPimOccurrence& )const;
+ bool operator> ( const OPimOccurrence& )const;
+ bool operator>=( const OPimOccurrence& )const;
+ OPimOccurrence &operator=( const OPimOccurrence& );
+ //@}
+
+private:
+ QDate m_occurrence;
+ QTime m_start, m_end;
+ bool m_isAllDay : 1;
+ enum Position m_pos;
+
+ void deref();
+ inline void changeOrModify();
+
+ struct Private;
+ struct Data;
+
+ Data *data;
+ Private *d;
+
+private: // ctor
+ OPimOccurrence( OPimOccurrence::Data *, enum Position );
+ template<class T> T internalToRecord()const;
+};
+}
+
+#endif
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 6546d99..60946e0 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -102,4 +102,2 @@ void OPimRecord::addCategoryName( const QString& )
catDB.load( categoryFileName() );
-
-
}
@@ -113,16 +111,2 @@ bool OPimRecord::isEmpty() const
-/*QString OPimRecord::crossToString()const {
- QString str;
- QMap<QString, QArray<int> >::ConstIterator it;
- for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
- QArray<int> id = it.data();
- for ( uint i = 0; i < id.size(); ++i ) {
- str += it.key() + "," + QString::number( i ) + ";";
- }
- }
- str = str.remove( str.length()-1, 1); // strip the ;
- //owarn << "IDS " + str << oendl;
-
- return str;
- }*/
/* if uid = 1 assign a new one */
@@ -272,2 +256,9 @@ void OPimRecord::setExtraMap( const QMap<QString, QString>& map )
+#if 0
+QString OPimRecord::recordAttributeTranslated( int field )const
+{
+ return recordAttributeTranslated()[field];
+}
+#endif
+
}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 127439a..363cc78 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -34,2 +34,4 @@
#include <opie2/opimxrefmanager.h>
+#include <opie2/opimglobal.h>
+
/*
@@ -62,3 +64,3 @@ class OPimRecord : public Qtopia::Record
*/
- OPimRecord( int uid = 0 );
+ OPimRecord( UID uid = 0 );
~OPimRecord();
@@ -140,2 +142,3 @@ class OPimRecord : public Qtopia::Record
+//@{
/**
@@ -143,3 +146,7 @@ class OPimRecord : public Qtopia::Record
*/
- virtual QString recordField( int ) const = 0;
+ virtual QString recordField( int ) const = 0;
+// virtual QArray<int> recordAttributes()const = 0;
+// virtual QMap<int,QString> recordAttributesTranslated() const = 0;
+// QString recordAttributeTranslated(int field)const;
+//@}
diff --git a/libopie2/opiepim/core/opimrecordlist.h b/libopie2/opiepim/core/opimrecordlist.h
index 1d5027f..0459f41 100644
--- a/libopie2/opiepim/core/opimrecordlist.h
+++ b/libopie2/opiepim/core/opimrecordlist.h
@@ -43,2 +43,3 @@ namespace Opie
+template<class T> class OPimAccessTemplate;
class OPimRecordListIteratorPrivate;
@@ -122,2 +123,3 @@ class OPimRecordList
{
+ template<class> friend class OPimAccessTemplate;
public:
@@ -129,6 +131,5 @@ class OPimRecordList
*/
- OPimRecordList ()
- {}
+ OPimRecordList (){}
OPimRecordList( const QArray<int>& ids,
- const Base* );
+ const Base* );
~OPimRecordList();
@@ -162,2 +163,5 @@ class OPimRecordList
*/
+ protected:
+ UIDArray uids()const;
+
private:
@@ -192,3 +196,2 @@ OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<
{
- //owarn << "OPimRecordListIterator copy c'tor" << oendl;
m_uids = it.m_uids;
@@ -218,3 +221,2 @@ T OPimRecordListIterator<T>::operator*()
{
- //owarn << "operator* " << m_current << " " << m_uids[m_current] << oendl;
if ( !m_end )
@@ -401,2 +403,7 @@ bool OPimRecordList<T>::remove( int uid )
+template<class T>
+UIDArray OPimRecordList<T>::uids()const {
+ return m_ids;
+}
+
}
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h
index 0a6dddf..088474b 100644
--- a/libopie2/opiepim/core/opimresolver.h
+++ b/libopie2/opiepim/core/opimresolver.h
@@ -47,4 +47,2 @@ namespace Opie {
* and to more stuff
- * THE PERFORMANCE will depend on THE BACKEND
- * USING XML is a waste of memory!!!!!
*/
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h
index 8336b3e..ae1e0d2 100644
--- a/libopie2/opiepim/core/opimstate.h
+++ b/libopie2/opiepim/core/opimstate.h
@@ -40,8 +40,2 @@ namespace Opie {
*/
-/*
- * in c a simple struct would be enough ;)
- * g_new_state();
- * g_do_some_thing( state_t* );
- * ;)
- */
class OPimState {
diff --git a/libopie2/opiepim/core/opimtemplatebase.cpp b/libopie2/opiepim/core/opimtemplatebase.cpp
new file mode 100644
index 0000000..0a07320
--- a/dev/null
+++ b/libopie2/opiepim/core/opimtemplatebase.cpp
@@ -0,0 +1,112 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) 2004 Holger Freyther <zecke@handhelds.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "opimtemplatebase.h"
+
+#include <opie2/opimoccurrence.h>
+#include <opie2/private/opimoccurrence_p.h>
+
+namespace Opie {
+
+static void setPeriod( OPimOccurrence& oc, bool period, const QDate& d,
+ const QTime& s, const QTime& t ) {
+ if ( period )
+ oc.setPeriod( d );
+ else
+ oc.setPeriod( d, s, t );
+}
+
+// namespace Opie {
+OPimBase::OPimBase() {}
+OPimBase::~OPimBase() {}
+
+/**
+ * @internal Convert internal Occurrence representation
+ * to the external
+ */
+OPimOccurrence::List OPimBase::convertOccurrenceFromBackend( const OPimBackendOccurrence::List& lst )const {
+ OPimOccurrence::List oc_lst;
+
+ /*
+ * Split multiday events up. Create the internal data structure
+ * and then iterate over the days and create the OPimOccurrecne.
+ */
+ for ( OPimBackendOccurrence::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) {
+ OPimBackendOccurrence boc = *it;
+
+ /*
+ * Create the Shared Data Structure
+ */
+ OPimOccurrence::Data *data = new OPimOccurrence::Data();
+ data->summary = boc.summary();
+ data->location = boc.location();
+ data->note = boc.note();
+ data->uid = boc.uid();
+ data->backend = const_cast<OPimBase*>(this);
+
+ QDateTime start = boc.startDateTime();
+ QDateTime end = boc.endDateTime();
+
+ /*
+ * Start and End are on the same day
+ * Start and End are on two different ways.
+ * - Add Start and End and the days inbetween
+ */
+ int dto = start.daysTo( end );
+ bool allDay = boc.isAllDay();
+
+ if ( dto == 0 ) {
+ OPimOccurrence oc = OPimOccurrence( data, OPimOccurrence::StartEnd );
+ setPeriod( oc, allDay, start.date(), start.time(), end.time() );
+ oc_lst.append( oc );
+ }else {
+
+ OPimOccurrence oc = OPimOccurrence( data, OPimOccurrence::Start );
+ setPeriod( oc, allDay, start.date(), start.time(), QTime(23,59,59));
+ oc_lst.append( oc );
+
+ QDate next = start.addDays( 1 ).date();
+ while ( next != end.date() ) {
+ oc = OPimOccurrence( data, OPimOccurrence::MidWay );
+ setPeriod( oc, allDay, next, QTime(0, 0, 0), QTime(23, 59, 59));
+ oc_lst.append( oc );
+ next = next.addDays( 1 );
+ }
+
+ oc = OPimOccurrence( data, OPimOccurrence::End );
+ setPeriod( oc, allDay, end.date(), QTime(0, 0, 0 ), end.time() );
+ oc_lst.append( oc );
+ }
+ }
+
+ return oc_lst;
+}
+// }
+
+}
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index 787486c..b238a68 100644
--- a/libopie2/opiepim/core/opimtemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h
@@ -34,2 +34,4 @@
#include <opie2/opimcache.h>
+#include <opie2/opimoccurrence.h>
+#include <opie2/opimbackendoccurrence.h>
@@ -37,14 +39,21 @@
#include <qarray.h>
+#include <qdatetime.h>
namespace Opie {
+
+class OPimBasePrivate;
+
/**
- * Templates do not have a base class, This is why
- * we've this class
- * this is here to give us the possibility
- * to have a common base class
- * You may not want to use that interface internaly
- * POOR mans interface
+ * This is the base class for all our Interfaces to the
+ * PIM Records. It is pointer based and can be used
+ * generically for all types of Records.
+ *
*/
-class OPimBasePrivate;
struct OPimBase {
+ //@{
+ OPimBase();
+ virtual ~OPimBase();
+ //@}
+
+ //@{
/**
@@ -55,6 +64,13 @@ struct OPimBase {
virtual OPimRecord* record(int uid)const = 0;
+ //@}
+
+ //@{
virtual bool add( const OPimRecord& ) = 0;
virtual bool add( const OPimRecord* ) = 0;
+
virtual bool remove( int uid ) = 0;
virtual bool remove( const OPimRecord& ) = 0;
+ //@}
+
+ //@{
virtual void clear() = 0;
@@ -62,11 +78,72 @@ struct OPimBase {
virtual bool save() = 0;
- virtual QArray<int> records()const = 0;
- /*
- * ADD editing here?
- * -zecke
+ //@}
+
+ //@{
+ virtual QArray<UID> records()const = 0;
+
+ /** Constants for query.
+ * Use this constants to set the query parameters.
+ * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
+ * @see queryByExample()
*/
-private:
- OPimBasePrivate* d;
+ enum QuerySettings {
+ WildCards = 0x0001, /** Use Wildcards */
+ IgnoreCase = 0x0002, /** Ignore the Case */
+ RegExp = 0x0004, /** Do a Regular Expression match */
+ ExactMatch = 0x0008, /** It needs to exactly match */
+ MatchOne = 0x0010, /** Only one Entry must match */
+ DateDiff = 0x0020, /** Find all entries from today until given date */
+ DateYear = 0x0040, /** The year matches */
+ DateMonth = 0x0080, /** The month matches */
+ DateDay = 0x0100, /** The day matches */
+ LastItem = 0xffff /** the last possible name */
+ };
+ /**
+ * Common Attributes for the Sort Order
+ */
+ enum SortOrderBase {
+ SortSummary = 0, /** Sort by a Summary of the records */
+ SortByCategory = 1, /** Sort by Category */
+ SortByDate = 2, /** Sort by Date */
+ SortCustom = 10, /** The First available sort number for the OPimAccessTemplates */
+ LastSortOrderBase = 0xffff /** make this enum 16bit large */
+ };
+
+ /**
+ * Sort with the help of the \sa sorted function
+ * a list of Items.
+ * The Item you provide in SortOrder will be used
+ * for sorting.
+ *
+ * @see sorted
+ */
+ enum SortFilterBase {
+ FilterCategory = 1,
+ FilterCustom = 1024,
+ LastSortFilterBase = 0xffffffff
+ };
+
+ virtual UIDArray matchRegexpSimple( const QRegExp& r )const = 0;
+ virtual UIDArray queryByExampleSimple( const OPimRecord*, int settings,
+ const QDateTime& d = QDateTime() )const = 0;
+ virtual UIDArray sortedSimple( const UIDArray& uid, bool ascending,
+ int sortOrder, int sortFilter, int cat)const = 0;
+ virtual UIDArray sortedSimple( const UIDArray& uid, bool ascending,
+ int sortOrder, int sortFilter, const QArray<UID>& cats )const = 0;
+ virtual UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, int cat)const = 0;
+ virtual UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, const QArray<UID>& cats )const = 0;
+ virtual OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const = 0;
+ virtual OPimOccurrence::List occurrences( const QDateTime& dt )const = 0;
+ //@}
+
+
+protected:
+ OPimOccurrence::List convertOccurrenceFromBackend( const OPimBackendOccurrence::List& )const;
+
+private:
+ OPimBasePrivate* d;
};
+
+
/**
@@ -79,9 +156,23 @@ class OTemplateBase : public OPimBase {
public:
- /** Look ahead direction of cache */
- enum CacheDirection { Forward=0, Reverse };
-
- OTemplateBase() {
+ /**
+ * The Direction for ReadAhead/ReadBehind which will
+ * be used by the backends to Cache Items in
+ * advance.
+ * For example if you know that you will access the
+ * next ten items you can give the backend a hint
+ * to read ahead or read before.
+ */
+ enum CacheDirection {
+ Forward=0, /** Go forward when caching (++ to the index) */
+ Reverse /** Go backward when caching (-- to the index) */
};
- virtual ~OTemplateBase() {
- }
+
+
+ //@{
+ OTemplateBase() {};
+ virtual ~OTemplateBase() {}
+ //@}
+
+
+ //@{
virtual T find( int uid )const = 0;
@@ -93,3 +184,5 @@ public:
uint current, CacheDirection dir = Forward )const = 0;
+ //@}
+ //@{
/**
@@ -103,6 +196,6 @@ public:
static T* rec();
+ //@}
-
private:
- OTemplateBasePrivate *d;
+ OTemplateBasePrivate *d;
};
@@ -121,3 +214,4 @@ OPimRecord* OTemplateBase<T>::record(int uid )const {
return t1;
-};
+}
+
template <class T>
@@ -126,3 +220,2 @@ T* OTemplateBase<T>::rec() {
}
-
}
diff --git a/libopie2/opiepim/core/opimtimezone.cpp b/libopie2/opiepim/core/opimtimezone.cpp
index 5b32b1f..1dc36b4 100644
--- a/libopie2/opiepim/core/opimtimezone.cpp
+++ b/libopie2/opiepim/core/opimtimezone.cpp
@@ -42,3 +42,24 @@ namespace Opie
-QDateTime utcTime( time_t t )
+/*
+ * Save the old timeZone in a secure way (NULL Pointer check),
+ * set the new timeZone from the parameter, call tzset
+ * and then return the old timezone
+ */
+static QString setTimeZone( const QString& zone) {
+ QString old;
+ char *org = ::getenv( "TZ" );
+ if( org )
+ old = QString::fromLocal8Bit( org );
+
+ ::setenv( "TZ", zone.local8Bit(), true );
+ ::tzset();
+
+ return old;
+}
+
+static void resetTimeZone( const QString& zone ) {
+ ::setenv( "TZ", zone.local8Bit(), true );
+}
+
+static QDateTime utcTime( time_t t )
{
@@ -51,12 +72,9 @@ QDateTime utcTime( time_t t )
-QDateTime utcTime( time_t t, const QString& zone )
+static QDateTime utcTime( time_t t, const QString& zone )
{
- QCString org = ::getenv( "TZ" );
-#ifndef Q_OS_MACX // Following line causes bus errors on Mac
-
- ::setenv( "TZ", zone.latin1(), true );
- ::tzset();
+#ifndef Q_OS_MACX // Following line causes bus errors on Mac
+ QString old = setTimeZone( zone );
tm* broken = ::localtime( &t );
- ::setenv( "TZ", org, true );
+ resetTimeZone( old );
#else
@@ -75,3 +93,3 @@ QDateTime utcTime( time_t t, const QString& zone )
-time_t to_Time_t( const QDateTime& utc, const QString& str )
+static time_t to_Time_t( const QDateTime& utc, const QString& str )
{
@@ -88,10 +106,6 @@ time_t to_Time_t( const QDateTime& utc, const QString& str )
- QCString org = ::getenv( "TZ" );
#ifndef Q_OS_MACX // Following line causes bus errors on Mac
-
- ::setenv( "TZ", str.latin1(), true );
- ::tzset();
-
+ QString old = setTimeZone( str );
time_t ti = ::mktime( &broken );
- ::setenv( "TZ", org, true );
+ resetTimeZone( old );
#else
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index 27b36a6..16ca987 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -66,2 +66,3 @@ struct OPimTodo::OPimTodoData : public QShared
delete notifiers;
+ delete state;
}
@@ -89,3 +90,2 @@ OPimTodo::OPimTodo( const OPimTodo &event )
data->ref();
- // owarn << "ref up" << oendl;
}
@@ -96,6 +96,4 @@ OPimTodo::~OPimTodo()
- // owarn << "~OPimTodo " << oendl;
if ( data->deref() )
{
- // owarn << "OPimTodo::dereffing" << oendl;
delete data;
@@ -114,3 +112,2 @@ OPimTodo::OPimTodo( bool completed, int priority,
{
- // owarn << "OPimTodoData " + summary << oendl;
setCategories( category );
@@ -137,3 +134,2 @@ OPimTodo::OPimTodo( bool completed, int priority,
{
- // owarn << "OPimTodoData" + summary << oendl;
setCategories( idsFromString( category.join( ";" ) ) );
@@ -189,3 +185,14 @@ bool OPimTodo::hasDueDate() const
-
+/**
+ * \brief Does this Todo have a start date
+ *
+ * Does this Todo have a start date. The decision
+ * is based on if the internal startDate isValid
+ * in the sense of QDate::isValid.
+ *
+ * @return True if the startDate isValid
+ * @see startDate
+ * @see setStartDate
+ * @see QDate::isValid()
+ */
bool OPimTodo::hasStartDate() const
@@ -195,3 +202,12 @@ bool OPimTodo::hasStartDate() const
-
+/**
+ * \brief Does this Todo have a Date when it was completed
+ *
+ * As in \sa hasStartDate() it is determined if there
+ * is a completed date by looking if the internal date
+ * isValid \sa QDate::isValid.
+ *
+ * @see hasStartDate
+ * @return True if the completedDate is set and valid.
+ */
bool OPimTodo::hasCompletedDate() const
@@ -310,3 +326,2 @@ void OPimTodo::setDescription( const QString &desc )
{
- // owarn << "desc " + desc << oendl;
changeOrModify();
@@ -382,3 +397,3 @@ void OPimTodo::setMaintainer( const OPimMaintainer& pim )
-bool OPimTodo::isOverdue( )
+bool OPimTodo::isOverdue( )const
{
@@ -595,6 +610,4 @@ void OPimTodo::deref()
- // owarn << "deref in ToDoEvent" << oendl;
if ( data->deref() )
{
- // owarn << "deleting" << oendl;
delete data;
@@ -610,3 +623,2 @@ OPimTodo &OPimTodo::operator=( const OPimTodo &item )
OPimRecord::operator=( item );
- //owarn << "operator= ref " << oendl;
item.data->ref();
@@ -653,3 +665,2 @@ void OPimTodo::changeOrModify()
{
- owarn << "changeOrModify" << oendl;
data->deref();
@@ -701,5 +712,74 @@ QString OPimTodo::type() const
-QString OPimTodo::recordField( int /*id*/ ) const
+QString OPimTodo::recordField( int id) const
{
- return QString::null;
+ QString res;
+ Q_UNUSED( id )
+#if 0
+ switch( id ) {
+ case HasDate:
+ res = (hasDueDate() ?
+ QObject::tr( "Has a due-date" )
+ : QObject::tr( "No due-date" ));
+ break;
+ case Completed:
+ res = ( isCompleted() ?
+ QObject::tr( "Completed" ) :
+ QObject::tr( "Not completed" ));
+ break;
+ case Description:
+ res = description();
+ break;
+ case Summary:
+ res = summary();
+ break;
+ case Priority:
+ res = QString::number( priority() );
+ break;
+ case DateDay:
+ res = QString::number( dueDate().day() );
+ break;
+ case DateMonth:
+ res = QString::number( dueDate().month() );
+ break;
+ case DateYear:
+ res = QString::number( dueDate().year() );
+ break;
+ case Progress:
+ res = QString::number( progress() );
+ break;
+ case State:
+ res = QString::number( state().state() );
+ break;
+ case Recurrence:
+ res = ( hasRecurrence() ?
+ QString::null /*recurrence().summary()*/ :
+ QObject::tr("No reccurrence"));
+ break;
+ case Alarms:
+ break;
+ case Reminders:
+ break;
+ case Maintainer:
+ break;
+ case StartDate:
+ res = ( hasStartDate() ?
+ /*TimeString::()*/ QString::null :
+ QObject::tr( "No start-date" ) );
+ break;
+ case CompletedDate:
+ res = ( hasCompletedDate() ?
+ /*TimeString::()*/ QString::null :
+ QObject::tr( "No completed-date" ) );
+ break;
+ case DueDate:
+ res = ( hasDueDate() ?
+ /*TimeString::()*/ QString::null :
+ QObject::tr( "No due-date" );
+ break;
+ default:
+ res = OPimRecord::recordField( id );
+ }
+
+#endif
+ return res;
}
@@ -712,2 +792,19 @@ int OPimTodo::rtti() const
+/**
+ * \brief Provide a SafeCast to OPimTodo from a OPimRecord
+ *
+ * Provide a safe cast that will return 0 if the record
+ * type is not OPimTodo. In the other case it will
+ * be casted to OPimTodo and returned
+ *
+ * @param rec The OPimRecord to be casted
+ *
+ * @return a pointer to OPimTodo or 0l
+ */
+OPimTodo* OPimTodo::safeCast( const OPimRecord* rec ) {
+ return (rec && rec->rtti() == OPimResolver::TodoList ) ?
+ static_cast<OPimTodo*>( const_cast<OPimRecord*>(rec) ) :
+ 0l;
+}
+
}
diff --git a/libopie2/opiepim/core/opimtodo.h b/libopie2/opiepim/core/opimtodo.h
index e17fe6a..f4f9926 100644
--- a/libopie2/opiepim/core/opimtodo.h
+++ b/libopie2/opiepim/core/opimtodo.h
@@ -72,7 +72,8 @@ class OPimTodo : public OPimRecord
Alarms,
- Reminders,
- Notifiers,
+ Reminders,
Maintainer,
StartDate,
- CompletedDate
+ CompletedDate,
+//ADDITIONAL FOR RECORDFIELD
+ DueDate,
};
@@ -284,3 +285,3 @@ class OPimTodo : public OPimRecord
- bool isOverdue();
+ bool isOverdue()const;
@@ -297,3 +298,7 @@ class OPimTodo : public OPimRecord
+ //@{
int rtti() const;
+ static OPimTodo* safeCast( const OPimRecord* );
+ //@}
+
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index 26a68a0..4ad5950 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -52,4 +52,4 @@ OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
OPimTodoAccess::~OPimTodoAccess() {
-// owarn << "~OPimTodoAccess" << oendl;
}
+
void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) {
@@ -62,3 +62,3 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
const QDate& end,
- bool includeNoDates ) {
+ bool includeNoDates )const {
QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
@@ -69,3 +69,3 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
- bool includeNoDates ) {
+ bool includeNoDates )const {
return effectiveToDos( start, QDate::currentDate(),
@@ -73,3 +73,3 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
}
-OPimTodoAccess::List OPimTodoAccess::overDue() {
+OPimTodoAccess::List OPimTodoAccess::overDue()const {
List lis( m_todoBackEnd->overDue(), this );
@@ -77,9 +77,3 @@ OPimTodoAccess::List OPimTodoAccess::overDue() {
}
-/* sort order */
-OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
- QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
- filter, cat );
- OPimTodoAccess::List list( ints, this );
- return list;
-}
+
void OPimTodoAccess::removeAllCompleted() {
@@ -87,9 +81,2 @@ void OPimTodoAccess::removeAllCompleted() {
}
-QBitArray OPimTodoAccess::backendSupport( const QString& ) const{
- return m_todoBackEnd->supports();
-}
-bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{
- return backendSupport(ar).testBit( attr );
-}
-
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h
index 3f5af30..8338586 100644
--- a/libopie2/opiepim/core/otodoaccess.h
+++ b/libopie2/opiepim/core/otodoaccess.h
@@ -48,9 +48,7 @@ class OPimTodoAccess : public QObject, public OPimAccessTemplate<OPimTodo> {
public:
- enum SortOrder { Completed = 0,
+ enum SortOrder { Completed = SortCustom,
Priority,
- Description,
Deadline };
- enum SortFilter{ Category =1,
- OnlyOverDue= 2,
- DoNotShowCompleted =4 };
+ enum SortFilter{ OnlyOverDue= FilterCustom,
+ DoNotShowCompleted = FilterCustom<<1 };
/**
@@ -72,3 +70,3 @@ public:
const QDate& end,
- bool includeNoDates = true );
+ bool includeNoDates = true )const;
@@ -79,3 +77,3 @@ public:
List effectiveToDos( const QDate& start,
- bool includeNoDates = true );
+ bool includeNoDates = true )const;
@@ -85,8 +83,3 @@ public:
*/
- List overDue();
-
- /**
- *
- */
- List sorted( bool ascending, int sortOrder, int sortFilter, int cat );
+ List overDue()const;
@@ -104,19 +97,2 @@ public:
/**
- * request information about what a backend supports.
- * Supports in the sense of beeing able to store.
- * This is related to the enum in OPimTodo
- *
- * @param backend Will be used in the future when we support multiple backend
- */
- QBitArray backendSupport( const QString& backend = QString::null )const;
-
- /**
- * see above but for a specefic attribute. This method was added for convience
- * @param attr The attribute to be queried for
- * @param backend Will be used in the future when we support multiple backends
- */
- bool backendSupports( int attr, const QString& backend = QString::null )const;
-
-
- /**
* Return identification of used records