summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimtemplatebase.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimtemplatebase.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h139
1 files changed, 116 insertions, 23 deletions
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
@@ -32,43 +32,120 @@
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimrecord.h> 33#include <opie2/opimrecord.h>
34#include <opie2/opimcache.h> 34#include <opie2/opimcache.h>
35#include <opie2/opimoccurrence.h>
36#include <opie2/opimbackendoccurrence.h>
35 37
36/* QT */ 38/* QT */
37#include <qarray.h> 39#include <qarray.h>
40#include <qdatetime.h>
38 41
39namespace Opie { 42namespace Opie {
43
44class OPimBasePrivate;
45
40/** 46/**
41 * Templates do not have a base class, This is why 47 * This is the base class for all our Interfaces to the
42 * we've this class 48 * PIM Records. It is pointer based and can be used
43 * this is here to give us the possibility 49 * generically for all types of Records.
44 * to have a common base class 50 *
45 * You may not want to use that interface internaly
46 * POOR mans interface
47 */ 51 */
48class OPimBasePrivate;
49struct OPimBase { 52struct OPimBase {
53 //@{
54 OPimBase();
55 virtual ~OPimBase();
56 //@}
57
58 //@{
50 /** 59 /**
51 * return the rtti 60 * return the rtti
52 */ 61 */
53 virtual int rtti() const = 0; 62 virtual int rtti() const = 0;
54 virtual OPimRecord* record()const = 0; 63 virtual OPimRecord* record()const = 0;
55 virtual OPimRecord* record(int uid)const = 0; 64 virtual OPimRecord* record(int uid)const = 0;
65 //@}
66
67 //@{
56 virtual bool add( const OPimRecord& ) = 0; 68 virtual bool add( const OPimRecord& ) = 0;
57 virtual bool add( const OPimRecord* ) = 0; 69 virtual bool add( const OPimRecord* ) = 0;
70
58 virtual bool remove( int uid ) = 0; 71 virtual bool remove( int uid ) = 0;
59 virtual bool remove( const OPimRecord& ) = 0; 72 virtual bool remove( const OPimRecord& ) = 0;
73 //@}
74
75 //@{
60 virtual void clear() = 0; 76 virtual void clear() = 0;
61 virtual bool load() = 0; 77 virtual bool load() = 0;
62 virtual bool save() = 0; 78 virtual bool save() = 0;
63 virtual QArray<int> records()const = 0; 79 //@}
64 /* 80
65 * ADD editing here? 81 //@{
66 * -zecke 82 virtual QArray<UID> records()const = 0;
83
84 /** Constants for query.
85 * Use this constants to set the query parameters.
86 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
87 * @see queryByExample()
67 */ 88 */
68private: 89 enum QuerySettings {
69 OPimBasePrivate* d; 90 WildCards = 0x0001, /** Use Wildcards */
91 IgnoreCase = 0x0002, /** Ignore the Case */
92 RegExp = 0x0004, /** Do a Regular Expression match */
93 ExactMatch = 0x0008, /** It needs to exactly match */
94 MatchOne = 0x0010, /** Only one Entry must match */
95 DateDiff = 0x0020, /** Find all entries from today until given date */
96 DateYear = 0x0040, /** The year matches */
97 DateMonth = 0x0080, /** The month matches */
98 DateDay = 0x0100, /** The day matches */
99 LastItem = 0xffff /** the last possible name */
100 };
70 101
102 /**
103 * Common Attributes for the Sort Order
104 */
105 enum SortOrderBase {
106 SortSummary = 0, /** Sort by a Summary of the records */
107 SortByCategory = 1, /** Sort by Category */
108 SortByDate = 2, /** Sort by Date */
109 SortCustom = 10, /** The First available sort number for the OPimAccessTemplates */
110 LastSortOrderBase = 0xffff /** make this enum 16bit large */
111 };
112
113 /**
114 * Sort with the help of the \sa sorted function
115 * a list of Items.
116 * The Item you provide in SortOrder will be used
117 * for sorting.
118 *
119 * @see sorted
120 */
121 enum SortFilterBase {
122 FilterCategory = 1,
123 FilterCustom = 1024,
124 LastSortFilterBase = 0xffffffff
125 };
126
127 virtual UIDArray matchRegexpSimple( const QRegExp& r )const = 0;
128 virtual UIDArray queryByExampleSimple( const OPimRecord*, int settings,
129 const QDateTime& d = QDateTime() )const = 0;
130 virtual UIDArray sortedSimple( const UIDArray& uid, bool ascending,
131 int sortOrder, int sortFilter, int cat)const = 0;
132 virtual UIDArray sortedSimple( const UIDArray& uid, bool ascending,
133 int sortOrder, int sortFilter, const QArray<UID>& cats )const = 0;
134 virtual UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, int cat)const = 0;
135 virtual UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, const QArray<UID>& cats )const = 0;
136 virtual OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const = 0;
137 virtual OPimOccurrence::List occurrences( const QDateTime& dt )const = 0;
138 //@}
139
140
141protected:
142 OPimOccurrence::List convertOccurrenceFromBackend( const OPimBackendOccurrence::List& )const;
143
144private:
145 OPimBasePrivate* d;
71}; 146};
147
148
72/** 149/**
73 * internal template base 150 * internal template base
74 * Attention: T needs to implement the copy c'tor!!! 151 * Attention: T needs to implement the copy c'tor!!!
@@ -77,13 +154,27 @@ class OTemplateBasePrivate;
77template <class T = OPimRecord> 154template <class T = OPimRecord>
78class OTemplateBase : public OPimBase { 155class OTemplateBase : public OPimBase {
79public: 156public:
80 /** Look ahead direction of cache */ 157 /**
81 enum CacheDirection { Forward=0, Reverse }; 158 * The Direction for ReadAhead/ReadBehind which will
82 159 * be used by the backends to Cache Items in
83 OTemplateBase() { 160 * advance.
161 * For example if you know that you will access the
162 * next ten items you can give the backend a hint
163 * to read ahead or read before.
164 */
165 enum CacheDirection {
166 Forward=0, /** Go forward when caching (++ to the index) */
167 Reverse /** Go backward when caching (-- to the index) */
84 }; 168 };
85 virtual ~OTemplateBase() { 169
86 } 170
171 //@{
172 OTemplateBase() {};
173 virtual ~OTemplateBase() {}
174 //@}
175
176
177 //@{
87 virtual T find( int uid )const = 0; 178 virtual T find( int uid )const = 0;
88 179
89 /** 180 /**
@@ -91,7 +182,9 @@ public:
91 */ 182 */
92 virtual T find( int uid, const QArray<int>& items, 183 virtual T find( int uid, const QArray<int>& items,
93 uint current, CacheDirection dir = Forward )const = 0; 184 uint current, CacheDirection dir = Forward )const = 0;
185 //@}
94 186
187 //@{
95 /** 188 /**
96 * Put element into Cache 189 * Put element into Cache
97 */ 190 */
@@ -101,10 +194,10 @@ public:
101 OPimRecord* record()const; 194 OPimRecord* record()const;
102 OPimRecord* record(int uid )const; 195 OPimRecord* record(int uid )const;
103 static T* rec(); 196 static T* rec();
197 //@}
104 198
105
106private: 199private:
107 OTemplateBasePrivate *d; 200 OTemplateBasePrivate *d;
108}; 201};
109 202
110 203
@@ -119,12 +212,12 @@ OPimRecord* OTemplateBase<T>::record(int uid )const {
119 T* t1 = new T(t2); 212 T* t1 = new T(t2);
120 213
121 return t1; 214 return t1;
122}; 215}
216
123template <class T> 217template <class T>
124T* OTemplateBase<T>::rec() { 218T* OTemplateBase<T>::rec() {
125 return new T; 219 return new T;
126} 220}
127
128} 221}
129 222
130#endif 223#endif