summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ChangeLog1
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h1
2 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiepim/ChangeLog b/libopie2/opiepim/ChangeLog
index a1b4db0..84517fb 100644
--- a/libopie2/opiepim/ChangeLog
+++ b/libopie2/opiepim/ChangeLog
@@ -1,33 +1,34 @@
12005-03.19 Stefan Eilers <stefan@eilers-online.net> 12005-03.19 Stefan Eilers <stefan@eilers-online.net>
2 * Minor update for sorted(). Now ignoring any category search if "DoNotShowWithCategory" filter is activated. 2 * Minor update for sorted(). Now ignoring any category search if "DoNotShowWithCategory" filter is activated.
3 * Fixing uninitialized member variable, caused crash of backend
32005-03-18 Stefan Eilers <stefan@eilers-online.net> 42005-03-18 Stefan Eilers <stefan@eilers-online.net>
4 * Rewrote generic sorted filter and added filter for "DoNotShowWithCategory", needed by addressbook (other filters need to be added!) 5 * Rewrote generic sorted filter and added filter for "DoNotShowWithCategory", needed by addressbook (other filters need to be added!)
52005-01-16 Stefan Eilers <stefan@eilers-online.net> 62005-01-16 Stefan Eilers <stefan@eilers-online.net>
6 * Added new OPimEventSortVector class, improved OPimSortVector 7 * Added new OPimEventSortVector class, improved OPimSortVector
7 * OPimAccessBackend now supports generic sorting. 8 * OPimAccessBackend now supports generic sorting.
82005-01-03 Stefan Eilers <stefan@eilers-online.net> 92005-01-03 Stefan Eilers <stefan@eilers-online.net>
9 * Fixing bug in API documentation 10 * Fixing bug in API documentation
10 * Moving hasQuerySettings() and querySettings() to OPimAccessTemplate to be available for all frontends 11 * Moving hasQuerySettings() and querySettings() to OPimAccessTemplate to be available for all frontends
112004-12-28 Stefan Eilers <stefan@eilers-online.net> 122004-12-28 Stefan Eilers <stefan@eilers-online.net>
12 * Make improved query by example accessable via frontend 13 * Make improved query by example accessable via frontend
13 * Some API documentation improvement 14 * Some API documentation improvement
14 * Cleanup of backend api.. 15 * Cleanup of backend api..
15 * Fixing bug #1501 16 * Fixing bug #1501
162004-11-23 Stefan Eilers <stefan@eilers-online.net> 172004-11-23 Stefan Eilers <stefan@eilers-online.net>
17 * Implement fast and full featured version of sorted() for addressbook 18 * Implement fast and full featured version of sorted() for addressbook
18 * Implement generic queryByExample for all Addressboook backends. It allows incremental search. 19 * Implement generic queryByExample for all Addressboook backends. It allows incremental search.
19 * Update of API Documentation 20 * Update of API Documentation
202004-11-18 Holger Freyther <freyther@handhelds.org> 212004-11-18 Holger Freyther <freyther@handhelds.org>
21 * Every Access can give a set of Occurrences for a period or a datetime 22 * Every Access can give a set of Occurrences for a period or a datetime
22 * QueryByExample, Find, Sort can be generically accessed by OPimBase 23 * QueryByExample, Find, Sort can be generically accessed by OPimBase
23 pointer interface 24 pointer interface
24 * OPimBackendOccurrence gets split up to OPimOccurrences by 25 * OPimBackendOccurrence gets split up to OPimOccurrences by
25 OPimTemplateBase 26 OPimTemplateBase
26 * Add safeCast to various OPimRecords 27 * Add safeCast to various OPimRecords
27 * Kill memleak in OPimTodo 28 * Kill memleak in OPimTodo
28 * Add SortVector implementations for OPimTodo and OPimContact 29 * Add SortVector implementations for OPimTodo and OPimContact
29 30
30 2004-??-??The Opie Team <opie@handhelds.org> 31 2004-??-??The Opie Team <opie@handhelds.org>
31 * Implemented some important modifications to allow to use OPimRecords as it is, without 32 * Implemented some important modifications to allow to use OPimRecords as it is, without
32 have to cast them. This makes it possible to write applications which handling pim 33 have to cast them. This makes it possible to write applications which handling pim
33 data in a generic manner (see opimconvertion tool) (eilers) \ No newline at end of file 34 data in a generic manner (see opimconvertion tool) (eilers) \ No newline at end of file
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 6666fd6..71f81f4 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -49,192 +49,193 @@ class OPimAccessBackendPrivate;
49 * For example we can use SQL queries instead of self made 49 * For example we can use SQL queries instead of self made
50 * query which is first more efficent and also uses less memory. 50 * query which is first more efficent and also uses less memory.
51 */ 51 */
52template <class T = OPimRecord> 52template <class T = OPimRecord>
53class OPimAccessBackend { 53class OPimAccessBackend {
54public: 54public:
55 typedef OTemplateBase<T> Frontend; 55 typedef OTemplateBase<T> Frontend;
56 56
57 //@{ 57 //@{
58 OPimAccessBackend(int access = 0); 58 OPimAccessBackend(int access = 0);
59 virtual ~OPimAccessBackend(); 59 virtual ~OPimAccessBackend();
60 //@} 60 //@}
61 61
62 //@{ 62 //@{
63 virtual bool load() = 0; 63 virtual bool load() = 0;
64 virtual bool reload() = 0; 64 virtual bool reload() = 0;
65 virtual bool save() = 0; 65 virtual bool save() = 0;
66 virtual void clear() = 0; 66 virtual void clear() = 0;
67 //@} 67 //@}
68 68
69 //@{ 69 //@{
70 // FIXME: Uncommented some of the abstract functions below. This should be removed as they are implemented in 70 // FIXME: Uncommented some of the abstract functions below. This should be removed as they are implemented in
71 // all typespecifc backenends (eilers) 71 // all typespecifc backenends (eilers)
72 /** 72 /**
73 * Return all possible settings for queryByExample() 73 * Return all possible settings for queryByExample()
74 * @return All settings provided by the current backend 74 * @return All settings provided by the current backend
75 * (i.e.: query_WildCards & query_IgnoreCase) 75 * (i.e.: query_WildCards & query_IgnoreCase)
76 * See implementation in the specific backends for contacts, todo and dates. 76 * See implementation in the specific backends for contacts, todo and dates.
77 */ 77 */
78 virtual const uint querySettings() const = 0; 78 virtual const uint querySettings() const = 0;
79 79
80 /** 80 /**
81 * Check whether settings are correct for queryByExample() 81 * Check whether settings are correct for queryByExample()
82 * See implementation in the specific backends for OPimContactAccess, OPimTodoAccess and ODateBookAccess. 82 * See implementation in the specific backends for OPimContactAccess, OPimTodoAccess and ODateBookAccess.
83 * @return <i>true</i> if the given settings are correct and possible. 83 * @return <i>true</i> if the given settings are correct and possible.
84 */ 84 */
85 virtual bool hasQuerySettings (uint querySettings) const = 0; 85 virtual bool hasQuerySettings (uint querySettings) const = 0;
86 //@} 86 //@}
87 87
88 88
89 //@{ 89 //@{
90 virtual UIDArray allRecords()const = 0; 90 virtual UIDArray allRecords()const = 0;
91 virtual UIDArray matchRegexp(const QRegExp &r) const; 91 virtual UIDArray matchRegexp(const QRegExp &r) const;
92 virtual UIDArray queryByExample( const UIDArray&, const T& t, 92 virtual UIDArray queryByExample( const UIDArray&, const T& t,
93 int settings, const QDateTime& d = QDateTime() )const = 0; 93 int settings, const QDateTime& d = QDateTime() )const = 0;
94 virtual UIDArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() )const; 94 virtual UIDArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() )const;
95 virtual UIDArray queryByExample( const OPimRecord* rec, int settings, const QDateTime& d = QDateTime() )const; 95 virtual UIDArray queryByExample( const OPimRecord* rec, int settings, const QDateTime& d = QDateTime() )const;
96 virtual UIDArray sorted( const UIDArray&, bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const = 0; 96 virtual UIDArray sorted( const UIDArray&, bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const = 0;
97 virtual UIDArray sorted( bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const; 97 virtual UIDArray sorted( bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const;
98 virtual OPimBackendOccurrence::List occurrences( const QDate& start, const QDate& end)const; 98 virtual OPimBackendOccurrence::List occurrences( const QDate& start, const QDate& end)const;
99 virtual OPimBackendOccurrence::List occurrences( const QDateTime& dt )const; 99 virtual OPimBackendOccurrence::List occurrences( const QDateTime& dt )const;
100 //@} 100 //@}
101 101
102 102
103 //@{ 103 //@{
104 virtual T find(UID uid )const = 0; 104 virtual T find(UID uid )const = 0;
105 virtual T find(UID uid, const QArray<UID>& items, 105 virtual T find(UID uid, const QArray<UID>& items,
106 uint current, typename Frontend::CacheDirection )const ; 106 uint current, typename Frontend::CacheDirection )const ;
107 //@} 107 //@}
108 108
109 109
110 //@{ 110 //@{
111 virtual bool add( const T& t ) = 0; 111 virtual bool add( const T& t ) = 0;
112 virtual bool remove( UID uid ) = 0; 112 virtual bool remove( UID uid ) = 0;
113 virtual bool replace( const T& t ) = 0; 113 virtual bool replace( const T& t ) = 0;
114 //@} 114 //@}
115 115
116 116
117 117
118 void setFrontend( Frontend* front ); 118 void setFrontend( Frontend* front );
119 119
120 /** 120 /**
121 * set the read ahead count 121 * set the read ahead count
122 */ 122 */
123 void setReadAhead( uint count ); 123 void setReadAhead( uint count );
124protected: 124protected:
125 //@{ 125 //@{
126 int access()const; 126 int access()const;
127 void cache( const T& t )const; 127 void cache( const T& t )const;
128 void setSaneCacheSize( int ); 128 void setSaneCacheSize( int );
129 uint readAhead()const; 129 uint readAhead()const;
130 //@} 130 //@}
131 131
132private: 132private:
133 OPimAccessBackendPrivate *d; 133 OPimAccessBackendPrivate *d;
134 Frontend* m_front; 134 Frontend* m_front;
135 uint m_read; 135 uint m_read;
136 int m_acc; 136 int m_acc;
137 137
138}; 138};
139 139
140template <class T> 140template <class T>
141OPimAccessBackend<T>::OPimAccessBackend(int acc) 141OPimAccessBackend<T>::OPimAccessBackend(int acc)
142 : m_acc( acc ) 142 : m_acc( acc )
143{ 143{
144 m_front = 0l; 144 m_front = 0l;
145 m_read = 20;
145} 146}
146template <class T> 147template <class T>
147OPimAccessBackend<T>::~OPimAccessBackend() { 148OPimAccessBackend<T>::~OPimAccessBackend() {
148 149
149} 150}
150 151
151/* 152/*
152 * Slow but default matchRegexp Implementation 153 * Slow but default matchRegexp Implementation
153 * Create a Big Enough QArray and then iterate 154 * Create a Big Enough QArray and then iterate
154 * over all Records and matchRegexp them. 155 * over all Records and matchRegexp them.
155 * At the end we will resize the array to the actual 156 * At the end we will resize the array to the actual
156 * number of items 157 * number of items
157 */ 158 */
158template <class T> 159template <class T>
159UIDArray OPimAccessBackend<T>::matchRegexp( const QRegExp& reg )const { 160UIDArray OPimAccessBackend<T>::matchRegexp( const QRegExp& reg )const {
160 UIDArray all_rec = allRecords(); 161 UIDArray all_rec = allRecords();
161 UIDArray result( all_rec.count() ); 162 UIDArray result( all_rec.count() );
162 uint used_records = 0, all_rec_count = all_rec.count(); 163 uint used_records = 0, all_rec_count = all_rec.count();
163 164
164 for ( uint i = 0; i < all_rec_count; ++i ) 165 for ( uint i = 0; i < all_rec_count; ++i )
165 if (find( all_rec[i], all_rec, i, Frontend::Forward ).match( reg ) ) 166 if (find( all_rec[i], all_rec, i, Frontend::Forward ).match( reg ) )
166 result[used_records++] = all_rec[i]; 167 result[used_records++] = all_rec[i];
167 168
168 /* shrink to fit */ 169 /* shrink to fit */
169 result.resize( used_records ); 170 result.resize( used_records );
170 return result; 171 return result;
171} 172}
172 173
173template <class T> 174template <class T>
174UIDArray OPimAccessBackend<T>::queryByExample( const T& rec, int settings, 175UIDArray OPimAccessBackend<T>::queryByExample( const T& rec, int settings,
175 const QDateTime& datetime )const { 176 const QDateTime& datetime )const {
176 177
177 return queryByExample( allRecords(), rec, settings, datetime ); 178 return queryByExample( allRecords(), rec, settings, datetime );
178} 179}
179 180
180template <class T> 181template <class T>
181UIDArray OPimAccessBackend<T>::queryByExample( const OPimRecord* rec, int settings, 182UIDArray OPimAccessBackend<T>::queryByExample( const OPimRecord* rec, int settings,
182 const QDateTime& datetime )const { 183 const QDateTime& datetime )const {
183 T* tmp_rec = T::safeCast( rec ); 184 T* tmp_rec = T::safeCast( rec );
184 UIDArray ar; 185 UIDArray ar;
185 if ( tmp_rec ) 186 if ( tmp_rec )
186 ar = queryByExample( *tmp_rec, settings, datetime ); 187 ar = queryByExample( *tmp_rec, settings, datetime );
187 188
188 return ar; 189 return ar;
189} 190}
190 191
191template <class T> 192template <class T>
192UIDArray OPimAccessBackend<T>::sorted( bool asc, int order, int filter, 193UIDArray OPimAccessBackend<T>::sorted( bool asc, int order, int filter,
193 const QArray<int>& cats )const { 194 const QArray<int>& cats )const {
194 return sorted( allRecords(), asc, order, filter, cats ); 195 return sorted( allRecords(), asc, order, filter, cats );
195} 196}
196 197
197template<class T> 198template<class T>
198OPimBackendOccurrence::List OPimAccessBackend<T>::occurrences( const QDate&, 199OPimBackendOccurrence::List OPimAccessBackend<T>::occurrences( const QDate&,
199 const QDate& )const { 200 const QDate& )const {
200 return OPimBackendOccurrence::List(); 201 return OPimBackendOccurrence::List();
201} 202}
202 203
203template<class T> 204template<class T>
204OPimBackendOccurrence::List OPimAccessBackend<T>::occurrences( const QDateTime& dt )const { 205OPimBackendOccurrence::List OPimAccessBackend<T>::occurrences( const QDateTime& dt )const {
205 QDate date = dt.date(); 206 QDate date = dt.date();
206 return occurrences( date, date ); 207 return occurrences( date, date );
207} 208}
208 209
209template <class T> 210template <class T>
210void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 211void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
211 m_front = fr; 212 m_front = fr;
212} 213}
213template <class T> 214template <class T>
214void OPimAccessBackend<T>::cache( const T& t )const { 215void OPimAccessBackend<T>::cache( const T& t )const {
215 if ( m_front ) 216 if ( m_front )
216 m_front->cache( t ); 217 m_front->cache( t );
217} 218}
218 219
219template <class T> 220template <class T>
220void OPimAccessBackend<T>::setSaneCacheSize( int size) { 221void OPimAccessBackend<T>::setSaneCacheSize( int size) {
221 if ( m_front ) 222 if ( m_front )
222 m_front->setSaneCacheSize( size ); 223 m_front->setSaneCacheSize( size );
223} 224}
224template <class T> 225template <class T>
225T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 226T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
226 uint, typename Frontend::CacheDirection ) const{ 227 uint, typename Frontend::CacheDirection ) const{
227 qDebug( "*** Lookahead feature not supported. Fallback to default find!!" ); 228 qDebug( "*** Lookahead feature not supported. Fallback to default find!!" );
228 return find( uid ); 229 return find( uid );
229} 230}
230template <class T> 231template <class T>
231void OPimAccessBackend<T>::setReadAhead( uint count ) { 232void OPimAccessBackend<T>::setReadAhead( uint count ) {
232 m_read = count; 233 m_read = count;
233} 234}
234template <class T> 235template <class T>
235uint OPimAccessBackend<T>::readAhead()const { 236uint OPimAccessBackend<T>::readAhead()const {
236 return m_read; 237 return m_read;
237} 238}
238template <class T> 239template <class T>
239int OPimAccessBackend<T>::access()const { 240int OPimAccessBackend<T>::access()const {
240 return m_acc; 241 return m_acc;