Diffstat (limited to 'libopie/pim/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 81 |
1 files changed, 77 insertions, 4 deletions
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index e0708e1..36f5a99 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h @@ -1,64 +1,134 @@ #ifndef OPIE_PIM_ACCESS_TEMPLATE_H #define OPIE_PIM_ACCESS_TEMPLATE_H #include <qarray.h> #include <opie/opimrecord.h> #include <opie/opimaccessbackend.h> #include <opie/orecordlist.h> #include "otemplatebase.h" +/** + * Thats the frontend to our OPIE PIM + * 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 + * the plugins + */ + template <class T = OPimRecord > class OPimAccessTemplate : public OTemplateBase<T> { public: typedef ORecordList<T> List; typedef OPimAccessBackend<T> BackEnd; + + /** + * our sort order + * should be safe explaining + */ + enum SortOrder { WildCards = 0, IgnoreCase = 1, + RegExp = 2, ExactMatch = 4 }; + + /** + * c'tor BackEnd + */ OPimAccessTemplate( BackEnd* end); virtual ~OPimAccessTemplate(); + + /** + * load from the backend + */ virtual void load(); + + /** + * reload from the backend + */ virtual void reload(); + + /** + * save to the backend + */ virtual void save(); - /* - *do array to Records conversion - * QArray<int> ids + /** + * if the resource was changed externally + */ + bool wasChangedExternally()const; + + /** + * return a List of records + * you can iterate over them */ virtual List allRecords()const; + + /** + * queryByExample + */ virtual List queryByExample( const T& t, int sortOrder ); + + /** + * find the OPimRecord uid + */ virtual T find( int uid ); /* invalidate cache here */ + /** + * clears the backend and invalidates the backend + */ virtual void clear() ; + + /** + * add T to the backend + */ virtual bool add( const T& t ) ; /* only the uid matters */ + /** + * 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 + */ virtual bool replace( const T& t) ; protected: + /** + * invalidate the cache + */ void invalidateCache(); + + /** + * returns the backend + */ BackEnd* backEnd(); BackEnd* m_backEnd; }; template <class T> OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) : OTemplateBase<T>(), m_backEnd( end ) { } template <class T> OPimAccessTemplate<T>::~OPimAccessTemplate() { qWarning("~OPimAccessTemplate<T>"); delete m_backEnd; } template <class T> void OPimAccessTemplate<T>::load() { m_backEnd->load(); } template <class T> void OPimAccessTemplate<T>::reload() { m_backEnd->reload(); } @@ -93,26 +163,29 @@ void OPimAccessTemplate<T>::clear() { template <class T> bool OPimAccessTemplate<T>::add( const T& t ) { return m_backEnd->add( t ); } template <class T> bool OPimAccessTemplate<T>::remove( const T& t ) { return m_backEnd->remove( t.uid() ); } template <class T> bool OPimAccessTemplate<T>::remove( int uid ) { return m_backEnd->remove( uid ); } template <class T> bool OPimAccessTemplate<T>::replace( const T& t ) { return m_backEnd->replace( t ); } template <class T> void OPimAccessTemplate<T>::invalidateCache() { } template <class T> OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { return m_backEnd; } - +template <class T> +bool OPimAccessTemplate<T>::wasChangedExternally()const { + return false; +} #endif |