Diffstat (limited to 'libopie2/opiepim/core/opimtemplatebase.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimtemplatebase.h | 135 |
1 files changed, 114 insertions, 21 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 | |||
@@ -34,2 +34,4 @@ | |||
34 | #include <opie2/opimcache.h> | 34 | #include <opie2/opimcache.h> |
35 | #include <opie2/opimoccurrence.h> | ||
36 | #include <opie2/opimbackendoccurrence.h> | ||
35 | 37 | ||
@@ -37,14 +39,21 @@ | |||
37 | #include <qarray.h> | 39 | #include <qarray.h> |
40 | #include <qdatetime.h> | ||
38 | 41 | ||
39 | namespace Opie { | 42 | namespace Opie { |
43 | |||
44 | class 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 | */ |
48 | class OPimBasePrivate; | ||
49 | struct OPimBase { | 52 | struct OPimBase { |
53 | //@{ | ||
54 | OPimBase(); | ||
55 | virtual ~OPimBase(); | ||
56 | //@} | ||
57 | |||
58 | //@{ | ||
50 | /** | 59 | /** |
@@ -55,6 +64,13 @@ struct OPimBase { | |||
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; |
@@ -62,11 +78,72 @@ struct OPimBase { | |||
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() | ||
88 | */ | ||
89 | enum QuerySettings { | ||
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 | }; | ||
101 | |||
102 | /** | ||
103 | * Common Attributes for the Sort Order | ||
67 | */ | 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 | |||
141 | protected: | ||
142 | OPimOccurrence::List convertOccurrenceFromBackend( const OPimBackendOccurrence::List& )const; | ||
143 | |||
68 | private: | 144 | private: |
69 | OPimBasePrivate* d; | 145 | OPimBasePrivate* d; |
70 | |||
71 | }; | 146 | }; |
147 | |||
148 | |||
72 | /** | 149 | /** |
@@ -79,9 +156,23 @@ class OTemplateBase : public OPimBase { | |||
79 | public: | 156 | public: |
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; |
@@ -93,3 +184,5 @@ public: | |||
93 | uint current, CacheDirection dir = Forward )const = 0; | 184 | uint current, CacheDirection dir = Forward )const = 0; |
185 | //@} | ||
94 | 186 | ||
187 | //@{ | ||
95 | /** | 188 | /** |
@@ -103,3 +196,3 @@ public: | |||
103 | static T* rec(); | 196 | static T* rec(); |
104 | 197 | //@} | |
105 | 198 | ||
@@ -121,3 +214,4 @@ OPimRecord* OTemplateBase<T>::record(int uid )const { | |||
121 | return t1; | 214 | return t1; |
122 | }; | 215 | } |
216 | |||
123 | template <class T> | 217 | template <class T> |
@@ -126,3 +220,2 @@ T* OTemplateBase<T>::rec() { | |||
126 | } | 220 | } |
127 | |||
128 | } | 221 | } |