author | eilers <eilers> | 2005-01-03 16:44:42 (UTC) |
---|---|---|
committer | eilers <eilers> | 2005-01-03 16:44:42 (UTC) |
commit | 310c7dce0c9043f66725bc79449fe958a12ad459 (patch) (unidiff) | |
tree | 9d789c21b1fb88bdd8a1ad7470867b91c70276b2 | |
parent | 0b3bbec6703c021a188c865e822f536bfa3045fc (diff) | |
download | opie-310c7dce0c9043f66725bc79449fe958a12ad459.zip opie-310c7dce0c9043f66725bc79449fe958a12ad459.tar.gz opie-310c7dce0c9043f66725bc79449fe958a12ad459.tar.bz2 |
Fixing stupid API documentation error.
Moving hasQuerySettings() and querySettings up to OPimAccessTemplate to
be available for all frontends..
-rw-r--r-- | libopie2/opiepim/ChangeLog | 3 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | 1 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessbackend.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessbackend.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 9 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.h | 15 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 43 |
7 files changed, 40 insertions, 35 deletions
diff --git a/libopie2/opiepim/ChangeLog b/libopie2/opiepim/ChangeLog index 2007744..320b189 100644 --- a/libopie2/opiepim/ChangeLog +++ b/libopie2/opiepim/ChangeLog | |||
@@ -1,23 +1,26 @@ | |||
1 | 2005-01-03 Stefan Eilers <stefan@eilers-online.net> | ||
2 | * Fixing bug in API documentation | ||
3 | * Moving hasQuerySettings() and querySettings() to OPimAccessTemplate to be available for all frontends | ||
1 | 2004-12-28 Stefan Eilers <stefan@eilers-online.net> | 4 | 2004-12-28 Stefan Eilers <stefan@eilers-online.net> |
2 | * Make improved query by example accessable via frontend | 5 | * Make improved query by example accessable via frontend |
3 | * Some API documentation improvement | 6 | * Some API documentation improvement |
4 | * Cleanup of backend api.. | 7 | * Cleanup of backend api.. |
5 | * Fixing bug #1501 | 8 | * Fixing bug #1501 |
6 | 2004-11-23 Stefan Eilers <stefan@eilers-online.net> | 9 | 2004-11-23 Stefan Eilers <stefan@eilers-online.net> |
7 | * Implement fast and full featured version of sorted() for addressbook | 10 | * Implement fast and full featured version of sorted() for addressbook |
8 | * Implement generic queryByExample for all Addressboook backends. It allows incremental search. | 11 | * Implement generic queryByExample for all Addressboook backends. It allows incremental search. |
9 | * Update of API Documentation | 12 | * Update of API Documentation |
10 | 2004-11-18 Holger Freyther <freyther@handhelds.org> | 13 | 2004-11-18 Holger Freyther <freyther@handhelds.org> |
11 | * Every Access can give a set of Occurrences for a period or a datetime | 14 | * Every Access can give a set of Occurrences for a period or a datetime |
12 | * QueryByExample, Find, Sort can be generically accessed by OPimBase | 15 | * QueryByExample, Find, Sort can be generically accessed by OPimBase |
13 | pointer interface | 16 | pointer interface |
14 | * OPimBackendOccurrence gets split up to OPimOccurrences by | 17 | * OPimBackendOccurrence gets split up to OPimOccurrences by |
15 | OPimTemplateBase | 18 | OPimTemplateBase |
16 | * Add safeCast to various OPimRecords | 19 | * Add safeCast to various OPimRecords |
17 | * Kill memleak in OPimTodo | 20 | * Kill memleak in OPimTodo |
18 | * Add SortVector implementations for OPimTodo and OPimContact | 21 | * Add SortVector implementations for OPimTodo and OPimContact |
19 | 22 | ||
20 | 2004-??-??The Opie Team <opie@handhelds.org> | 23 | 2004-??-??The Opie Team <opie@handhelds.org> |
21 | * Implemented some important modifications to allow to use OPimRecords as it is, without | 24 | * Implemented some important modifications to allow to use OPimRecords as it is, without |
22 | have to cast them. This makes it possible to write applications which handling pim | 25 | have to cast them. This makes it possible to write applications which handling pim |
23 | data in a generic manner (see opimconvertion tool) (eilers) \ No newline at end of file | 26 | data in a generic manner (see opimconvertion tool) (eilers) \ No newline at end of file |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp index 41b714e..629e4da 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | |||
@@ -115,192 +115,193 @@ ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { | |||
115 | } | 115 | } |
116 | 116 | ||
117 | void ODateBookAccessBackend_SQL::initFields() | 117 | void ODateBookAccessBackend_SQL::initFields() |
118 | { | 118 | { |
119 | 119 | ||
120 | // This map contains the translation of the fieldtype id's to | 120 | // This map contains the translation of the fieldtype id's to |
121 | // the names of the table columns | 121 | // the names of the table columns |
122 | m_fieldMap.insert( OPimEvent::FUid, "uid" ); | 122 | m_fieldMap.insert( OPimEvent::FUid, "uid" ); |
123 | m_fieldMap.insert( OPimEvent::FCategories, "Categories" ); | 123 | m_fieldMap.insert( OPimEvent::FCategories, "Categories" ); |
124 | m_fieldMap.insert( OPimEvent::FDescription, "Description" ); | 124 | m_fieldMap.insert( OPimEvent::FDescription, "Description" ); |
125 | m_fieldMap.insert( OPimEvent::FLocation, "Location" ); | 125 | m_fieldMap.insert( OPimEvent::FLocation, "Location" ); |
126 | m_fieldMap.insert( OPimEvent::FType, "Type" ); | 126 | m_fieldMap.insert( OPimEvent::FType, "Type" ); |
127 | m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" ); | 127 | m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" ); |
128 | m_fieldMap.insert( OPimEvent::FSound, "Sound" ); | 128 | m_fieldMap.insert( OPimEvent::FSound, "Sound" ); |
129 | m_fieldMap.insert( OPimEvent::FRType, "RType" ); | 129 | m_fieldMap.insert( OPimEvent::FRType, "RType" ); |
130 | m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" ); | 130 | m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" ); |
131 | m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" ); | 131 | m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" ); |
132 | m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" ); | 132 | m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" ); |
133 | m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" ); | 133 | m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" ); |
134 | m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" ); | 134 | m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" ); |
135 | m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" ); | 135 | m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" ); |
136 | m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" ); | 136 | m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" ); |
137 | m_fieldMap.insert( OPimEvent::FStart, "Start" ); | 137 | m_fieldMap.insert( OPimEvent::FStart, "Start" ); |
138 | m_fieldMap.insert( OPimEvent::FEnd, "End" ); | 138 | m_fieldMap.insert( OPimEvent::FEnd, "End" ); |
139 | m_fieldMap.insert( OPimEvent::FNote, "Note" ); | 139 | m_fieldMap.insert( OPimEvent::FNote, "Note" ); |
140 | m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); | 140 | m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); |
141 | m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" ); | 141 | m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" ); |
142 | m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" ); | 142 | m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" ); |
143 | 143 | ||
144 | // Create a map that maps the column name to the id | 144 | // Create a map that maps the column name to the id |
145 | QMapConstIterator<int, QString> it; | 145 | QMapConstIterator<int, QString> it; |
146 | for ( it = m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 146 | for ( it = m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
147 | m_reverseFieldMap.insert( it.data(), it.key() ); | 147 | m_reverseFieldMap.insert( it.data(), it.key() ); |
148 | } | 148 | } |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | bool ODateBookAccessBackend_SQL::load() | 152 | bool ODateBookAccessBackend_SQL::load() |
153 | { | 153 | { |
154 | if (!m_driver->open() ) | 154 | if (!m_driver->open() ) |
155 | return false; | 155 | return false; |
156 | 156 | ||
157 | // Don't expect that the database exists. | 157 | // Don't expect that the database exists. |
158 | // It is save here to create the table, even if it | 158 | // It is save here to create the table, even if it |
159 | // do exist. ( Is that correct for all databases ?? ) | 159 | // do exist. ( Is that correct for all databases ?? ) |
160 | QString qu = "create table datebook( uid INTEGER PRIMARY KEY "; | 160 | QString qu = "create table datebook( uid INTEGER PRIMARY KEY "; |
161 | 161 | ||
162 | QMap<int, QString>::Iterator it; | 162 | QMap<int, QString>::Iterator it; |
163 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 163 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
164 | qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); | 164 | qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); |
165 | } | 165 | } |
166 | qu += " );"; | 166 | qu += " );"; |
167 | 167 | ||
168 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; | 168 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; |
169 | 169 | ||
170 | OSQLRawQuery raw( qu ); | 170 | OSQLRawQuery raw( qu ); |
171 | OSQLResult res = m_driver->query( &raw ); | 171 | OSQLResult res = m_driver->query( &raw ); |
172 | if ( res.state() != OSQLResult::Success ) | 172 | if ( res.state() != OSQLResult::Success ) |
173 | return false; | 173 | return false; |
174 | 174 | ||
175 | update(); | 175 | update(); |
176 | 176 | ||
177 | return true; | 177 | return true; |
178 | } | 178 | } |
179 | 179 | ||
180 | void ODateBookAccessBackend_SQL::update() | 180 | void ODateBookAccessBackend_SQL::update() |
181 | { | 181 | { |
182 | 182 | ||
183 | QString qu = "select uid from datebook"; | 183 | QString qu = "select uid from datebook"; |
184 | OSQLRawQuery raw( qu ); | 184 | OSQLRawQuery raw( qu ); |
185 | OSQLResult res = m_driver->query( &raw ); | 185 | OSQLResult res = m_driver->query( &raw ); |
186 | if ( res.state() != OSQLResult::Success ){ | 186 | if ( res.state() != OSQLResult::Success ){ |
187 | // m_uids.clear(); | 187 | // m_uids.clear(); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | 190 | ||
191 | m_uids = extractUids( res ); | 191 | m_uids = extractUids( res ); |
192 | 192 | ||
193 | } | 193 | } |
194 | 194 | ||
195 | bool ODateBookAccessBackend_SQL::reload() | 195 | bool ODateBookAccessBackend_SQL::reload() |
196 | { | 196 | { |
197 | return load(); | 197 | return load(); |
198 | } | 198 | } |
199 | 199 | ||
200 | bool ODateBookAccessBackend_SQL::save() | 200 | bool ODateBookAccessBackend_SQL::save() |
201 | { | 201 | { |
202 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) | 202 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) |
203 | } | 203 | } |
204 | 204 | ||
205 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const | 205 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const |
206 | { | 206 | { |
207 | return m_uids; | 207 | return m_uids; |
208 | } | 208 | } |
209 | 209 | ||
210 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) { | 210 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) { |
211 | qDebug( "Accessing ODateBookAccessBackend_SQL::queryByExample() which is not implemented!" ); | ||
211 | return QArray<int>(); | 212 | return QArray<int>(); |
212 | } | 213 | } |
213 | 214 | ||
214 | void ODateBookAccessBackend_SQL::clear() | 215 | void ODateBookAccessBackend_SQL::clear() |
215 | { | 216 | { |
216 | QString qu = "drop table datebook;"; | 217 | QString qu = "drop table datebook;"; |
217 | qu += "drop table custom_data;"; | 218 | qu += "drop table custom_data;"; |
218 | 219 | ||
219 | OSQLRawQuery raw( qu ); | 220 | OSQLRawQuery raw( qu ); |
220 | OSQLResult res = m_driver->query( &raw ); | 221 | OSQLResult res = m_driver->query( &raw ); |
221 | 222 | ||
222 | reload(); | 223 | reload(); |
223 | } | 224 | } |
224 | 225 | ||
225 | 226 | ||
226 | OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ | 227 | OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ |
227 | odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl; | 228 | odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl; |
228 | 229 | ||
229 | QString qu = "select *"; | 230 | QString qu = "select *"; |
230 | qu += "from datebook where uid = " + QString::number(uid); | 231 | qu += "from datebook where uid = " + QString::number(uid); |
231 | 232 | ||
232 | odebug << "Query: " << qu << "" << oendl; | 233 | odebug << "Query: " << qu << "" << oendl; |
233 | 234 | ||
234 | OSQLRawQuery raw( qu ); | 235 | OSQLRawQuery raw( qu ); |
235 | OSQLResult res = m_driver->query( &raw ); | 236 | OSQLResult res = m_driver->query( &raw ); |
236 | 237 | ||
237 | OSQLResultItem resItem = res.first(); | 238 | OSQLResultItem resItem = res.first(); |
238 | 239 | ||
239 | // Create Map for date event and insert UID | 240 | // Create Map for date event and insert UID |
240 | QMap<int,QString> dateEventMap; | 241 | QMap<int,QString> dateEventMap; |
241 | dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); | 242 | dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); |
242 | 243 | ||
243 | // Now insert the data out of the columns into the map. | 244 | // Now insert the data out of the columns into the map. |
244 | QMapConstIterator<int, QString> it; | 245 | QMapConstIterator<int, QString> it; |
245 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 246 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
246 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); | 247 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); |
247 | } | 248 | } |
248 | 249 | ||
249 | // Last step: Put map into date event, add custom map and return it | 250 | // Last step: Put map into date event, add custom map and return it |
250 | OPimEvent retDate( dateEventMap ); | 251 | OPimEvent retDate( dateEventMap ); |
251 | retDate.setExtraMap( requestCustom( uid ) ); | 252 | retDate.setExtraMap( requestCustom( uid ) ); |
252 | 253 | ||
253 | odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl; | 254 | odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl; |
254 | return retDate; | 255 | return retDate; |
255 | } | 256 | } |
256 | 257 | ||
257 | // FIXME: Speed up update of uid's.. | 258 | // FIXME: Speed up update of uid's.. |
258 | bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev ) | 259 | bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev ) |
259 | { | 260 | { |
260 | QMap<int,QString> eventMap = ev.toMap(); | 261 | QMap<int,QString> eventMap = ev.toMap(); |
261 | 262 | ||
262 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); | 263 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); |
263 | QMap<int, QString>::Iterator it; | 264 | QMap<int, QString>::Iterator it; |
264 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 265 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
265 | if ( !eventMap[it.key()].isEmpty() ) | 266 | if ( !eventMap[it.key()].isEmpty() ) |
266 | qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] ); | 267 | qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] ); |
267 | else | 268 | else |
268 | qu += QString( ",\"\"" ); | 269 | qu += QString( ",\"\"" ); |
269 | } | 270 | } |
270 | qu += " );"; | 271 | qu += " );"; |
271 | 272 | ||
272 | // Add custom entries | 273 | // Add custom entries |
273 | int id = 0; | 274 | int id = 0; |
274 | QMap<QString, QString> customMap = ev.toExtraMap(); | 275 | QMap<QString, QString> customMap = ev.toExtraMap(); |
275 | for( QMap<QString, QString>::Iterator it = customMap.begin(); | 276 | for( QMap<QString, QString>::Iterator it = customMap.begin(); |
276 | it != customMap.end(); ++it ){ | 277 | it != customMap.end(); ++it ){ |
277 | qu += "insert into custom_data VALUES(" | 278 | qu += "insert into custom_data VALUES(" |
278 | + QString::number( ev.uid() ) | 279 | + QString::number( ev.uid() ) |
279 | + "," | 280 | + "," |
280 | + QString::number( id++ ) | 281 | + QString::number( id++ ) |
281 | + ",'" | 282 | + ",'" |
282 | + it.key() //.latin1() | 283 | + it.key() //.latin1() |
283 | + "'," | 284 | + "'," |
284 | + "0" // Priority for future enhancements | 285 | + "0" // Priority for future enhancements |
285 | + ",'" | 286 | + ",'" |
286 | + it.data() //.latin1() | 287 | + it.data() //.latin1() |
287 | + "');"; | 288 | + "');"; |
288 | } | 289 | } |
289 | 290 | ||
290 | OSQLRawQuery raw( qu ); | 291 | OSQLRawQuery raw( qu ); |
291 | OSQLResult res = m_driver->query( &raw ); | 292 | OSQLResult res = m_driver->query( &raw ); |
292 | if ( res.state() != OSQLResult::Success ){ | 293 | if ( res.state() != OSQLResult::Success ){ |
293 | return false; | 294 | return false; |
294 | } | 295 | } |
295 | 296 | ||
296 | // Update list of uid's | 297 | // Update list of uid's |
297 | update(); | 298 | update(); |
298 | 299 | ||
299 | return true; | 300 | return true; |
300 | } | 301 | } |
301 | 302 | ||
302 | // FIXME: Speed up update of uid's.. | 303 | // FIXME: Speed up update of uid's.. |
303 | bool ODateBookAccessBackend_SQL::remove( int uid ) | 304 | bool ODateBookAccessBackend_SQL::remove( int uid ) |
304 | { | 305 | { |
305 | QString qu = "DELETE from datebook where uid = " | 306 | QString qu = "DELETE from datebook where uid = " |
306 | + QString::number( uid ) + ";"; | 307 | + QString::number( uid ) + ";"; |
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp index f979976..c7ce123 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.cpp +++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp | |||
@@ -1,153 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/otodoaccessbackend.h> | 30 | #include <opie2/otodoaccessbackend.h> |
31 | #include <opie2/private/opimtodosortvector.h> | 31 | #include <opie2/private/opimtodosortvector.h> |
32 | #include <opie2/otodoaccess.h> | 32 | #include <opie2/otodoaccess.h> |
33 | 33 | ||
34 | #include <qintdict.h> | 34 | #include <qintdict.h> |
35 | 35 | ||
36 | namespace Opie { | 36 | namespace Opie { |
37 | OPimTodoAccessBackend::OPimTodoAccessBackend() | 37 | OPimTodoAccessBackend::OPimTodoAccessBackend() |
38 | : OPimAccessBackend<OPimTodo>() | 38 | : OPimAccessBackend<OPimTodo>() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | OPimTodoAccessBackend::~OPimTodoAccessBackend() { | 41 | OPimTodoAccessBackend::~OPimTodoAccessBackend() { |
42 | 42 | ||
43 | } | 43 | } |
44 | 44 | ||
45 | const uint OPimTodoAccessBackend::querySettings() const | 45 | const uint OPimTodoAccessBackend::querySettings() const |
46 | { | 46 | { |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | bool OPimTodoAccessBackend::hasQuerySettings (uint querySettings) const | 50 | bool OPimTodoAccessBackend::hasQuerySettings (uint querySettings) const |
51 | { | 51 | { |
52 | return false; | 52 | return false; |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | UIDArray OPimTodoAccessBackend::queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings, | 56 | UIDArray OPimTodoAccessBackend::queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings, |
57 | const QDateTime& endperiod )const | 57 | const QDateTime& startperiod )const |
58 | { | 58 | { |
59 | qDebug( "Accessing OPimTodoAccessBackend::queryByExample() which is not implemented!" ); | 59 | qDebug( "Accessing OPimTodoAccessBackend::queryByExample() which is not implemented!" ); |
60 | return UIDArray(); | 60 | return UIDArray(); |
61 | 61 | ||
62 | // odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl; | 62 | // odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl; |
63 | 63 | ||
64 | // UIDArray m_currentQuery( uid_array.count() ); | 64 | // UIDArray m_currentQuery( uid_array.count() ); |
65 | // uint arraycounter = 0; | 65 | // uint arraycounter = 0; |
66 | 66 | ||
67 | // for( uint it = 0; it < uid_array.count(); ++it ){ | 67 | // for( uint it = 0; it < uid_array.count(); ++it ){ |
68 | // /* Search all fields and compare them with query object. Store them into list | 68 | // /* Search all fields and compare them with query object. Store them into list |
69 | // * if all fields matches. | 69 | // * if all fields matches. |
70 | // */ | 70 | // */ |
71 | // } | 71 | // } |
72 | 72 | ||
73 | 73 | ||
74 | } | 74 | } |
75 | 75 | ||
76 | UIDArray OPimTodoAccessBackend::sorted( const UIDArray& events, bool asc, | 76 | UIDArray OPimTodoAccessBackend::sorted( const UIDArray& events, bool asc, |
77 | int sortOrder, int sortFilter, | 77 | int sortOrder, int sortFilter, |
78 | const QArray<int>& categories )const { | 78 | const QArray<int>& categories )const { |
79 | odebug << "Using Unaccelerated TodoList sorted Implementation" << oendl; | 79 | odebug << "Using Unaccelerated TodoList sorted Implementation" << oendl; |
80 | Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder ); | 80 | Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder ); |
81 | int item = 0; | 81 | int item = 0; |
82 | 82 | ||
83 | bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false; | 83 | bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false; |
84 | bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false; | 84 | bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false; |
85 | bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false; | 85 | bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false; |
86 | bool catPassed = false; | 86 | bool catPassed = false; |
87 | int cat; | 87 | int cat; |
88 | 88 | ||
89 | for ( uint i = 0; i < events.count(); ++i ) { | 89 | for ( uint i = 0; i < events.count(); ++i ) { |
90 | OPimTodo todo = find( events[i], events, i, Frontend::Forward ); | 90 | OPimTodo todo = find( events[i], events, i, Frontend::Forward ); |
91 | if ( todo.isEmpty() ) | 91 | if ( todo.isEmpty() ) |
92 | continue; | 92 | continue; |
93 | 93 | ||
94 | /* show category */ | 94 | /* show category */ |
95 | /* -1 == unfiled */ | 95 | /* -1 == unfiled */ |
96 | catPassed = false; | 96 | catPassed = false; |
97 | for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) { | 97 | for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) { |
98 | cat = categories[cat_nu]; | 98 | cat = categories[cat_nu]; |
99 | if ( bCat && cat == -1 ) { | 99 | if ( bCat && cat == -1 ) { |
100 | if(!todo.categories().isEmpty() ) | 100 | if(!todo.categories().isEmpty() ) |
101 | continue; | 101 | continue; |
102 | } else if ( bCat && cat != 0) | 102 | } else if ( bCat && cat != 0) |
103 | if (!todo.categories().contains( cat ) ) | 103 | if (!todo.categories().contains( cat ) ) |
104 | continue; | 104 | continue; |
105 | catPassed = true; | 105 | catPassed = true; |
106 | break; | 106 | break; |
107 | } | 107 | } |
108 | 108 | ||
109 | /* | 109 | /* |
110 | * If none of the Categories matched | 110 | * If none of the Categories matched |
111 | * continue | 111 | * continue |
112 | */ | 112 | */ |
113 | if ( !catPassed ) | 113 | if ( !catPassed ) |
114 | continue; | 114 | continue; |
115 | if ( !todo.isOverdue() && bOnly ) | 115 | if ( !todo.isOverdue() && bOnly ) |
116 | continue; | 116 | continue; |
117 | if (todo.isCompleted() && comp ) | 117 | if (todo.isCompleted() && comp ) |
118 | continue; | 118 | continue; |
119 | 119 | ||
120 | vector.insert(item++, todo ); | 120 | vector.insert(item++, todo ); |
121 | } | 121 | } |
122 | 122 | ||
123 | vector.resize( item ); | 123 | vector.resize( item ); |
124 | /* sort it now */ | 124 | /* sort it now */ |
125 | vector.sort(); | 125 | vector.sort(); |
126 | /* now get the uids */ | 126 | /* now get the uids */ |
127 | UIDArray array( vector.count() ); | 127 | UIDArray array( vector.count() ); |
128 | for (uint i= 0; i < vector.count(); i++ ) | 128 | for (uint i= 0; i < vector.count(); i++ ) |
129 | array[i] = vector.uidAt( i ); | 129 | array[i] = vector.uidAt( i ); |
130 | 130 | ||
131 | return array; | 131 | return array; |
132 | } | 132 | } |
133 | 133 | ||
134 | OPimBackendOccurrence::List OPimTodoAccessBackend::occurrences( const QDate& start, | 134 | OPimBackendOccurrence::List OPimTodoAccessBackend::occurrences( const QDate& start, |
135 | const QDate& end )const { | 135 | const QDate& end )const { |
136 | OPimBackendOccurrence::List lst; | 136 | OPimBackendOccurrence::List lst; |
137 | UIDArray effective = effectiveToDos( start, end, false ); | 137 | UIDArray effective = effectiveToDos( start, end, false ); |
138 | UIDArray overdue = overDue(); | 138 | UIDArray overdue = overDue(); |
139 | uint count = effective.count(); | 139 | uint count = effective.count(); |
140 | int uid; | 140 | int uid; |
141 | QIntDict<int> hash; | 141 | QIntDict<int> hash; |
142 | hash.setAutoDelete( true ); | 142 | hash.setAutoDelete( true ); |
143 | OPimTodo todo; | 143 | OPimTodo todo; |
144 | 144 | ||
145 | for ( uint i = 0; i < count; ++i ) { | 145 | for ( uint i = 0; i < count; ++i ) { |
146 | uid = effective[i]; | 146 | uid = effective[i]; |
147 | todo = find( uid, effective, i, Frontend::Forward ); | 147 | todo = find( uid, effective, i, Frontend::Forward ); |
148 | /* | 148 | /* |
149 | * If isOverdue but in the 'normal' range we will fill | 149 | * If isOverdue but in the 'normal' range we will fill |
150 | * the hash so we won't have duplicates in OPimBackendOccurrence | 150 | * the hash so we won't have duplicates in OPimBackendOccurrence |
151 | */ | 151 | */ |
152 | if ( todo.isOverdue() ) | 152 | if ( todo.isOverdue() ) |
153 | hash.insert( uid, new int(6) ); | 153 | hash.insert( uid, new int(6) ); |
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h index 870ee57..06cece3 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.h +++ b/libopie2/opiepim/backend/otodoaccessbackend.h | |||
@@ -1,92 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_TODO_ACCESS_BACKEND_H | 29 | #ifndef OPIE_TODO_ACCESS_BACKEND_H |
30 | #define OPIE_TODO_ACCESS_BACKEND_H | 30 | #define OPIE_TODO_ACCESS_BACKEND_H |
31 | 31 | ||
32 | #include <qbitarray.h> | 32 | #include <qbitarray.h> |
33 | 33 | ||
34 | #include <opie2/opimtodo.h> | 34 | #include <opie2/opimtodo.h> |
35 | #include <opie2/opimaccessbackend.h> | 35 | #include <opie2/opimaccessbackend.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | class OPimTodoAccessBackend : public OPimAccessBackend<OPimTodo> { | 38 | class OPimTodoAccessBackend : public OPimAccessBackend<OPimTodo> { |
39 | public: | 39 | public: |
40 | OPimTodoAccessBackend(); | 40 | OPimTodoAccessBackend(); |
41 | ~OPimTodoAccessBackend(); | 41 | ~OPimTodoAccessBackend(); |
42 | virtual UIDArray effectiveToDos( const QDate& start, | 42 | virtual UIDArray effectiveToDos( const QDate& start, |
43 | const QDate& end, | 43 | const QDate& end, |
44 | bool includeNoDates )const = 0; | 44 | bool includeNoDates )const = 0; |
45 | virtual UIDArray overDue()const = 0; | 45 | virtual UIDArray overDue()const = 0; |
46 | virtual void removeAllCompleted() = 0; | 46 | virtual void removeAllCompleted() = 0; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Common and probably inefficent implementation | 49 | * Common and probably inefficent implementation |
50 | * for queryByExample, matchRegexp, sorted | 50 | * for queryByExample, matchRegexp, sorted |
51 | * and occurrences | 51 | * and occurrences |
52 | */ | 52 | */ |
53 | //@{ | 53 | //@{ |
54 | /** | 54 | /** |
55 | * Return all possible settings. | 55 | * Return all possible settings. |
56 | * @return All settings provided by the current backend | 56 | * @return All settings provided by the current backend |
57 | * (i.e.: query_WildCards & query_IgnoreCase) | 57 | * (i.e.: query_WildCards & query_IgnoreCase) |
58 | */ | 58 | */ |
59 | const uint querySettings() const; | 59 | const uint querySettings() const; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Check whether settings are correct. | 62 | * Check whether settings are correct. |
63 | * @return <i>true</i> if the given settings are correct and possible. | 63 | * @return <i>true</i> if the given settings are correct and possible. |
64 | */ | 64 | */ |
65 | bool hasQuerySettings (uint querySettings) const; | 65 | bool hasQuerySettings (uint querySettings) const; |
66 | 66 | ||
67 | UIDArray queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings, const QDateTime& endperiod = QDateTime() )const; | 67 | UIDArray queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings, const QDateTime& startperiod = QDateTime() )const; |
68 | UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const; | 68 | UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const; |
69 | OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const; | 69 | OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const; |
70 | //@} | 70 | //@} |
71 | 71 | ||
72 | private: | 72 | private: |
73 | class Private; | 73 | class Private; |
74 | Private *d; | 74 | Private *d; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | /** | 80 | /** |
81 | * \fn Opie::OPimBackendOccurrence::List Opie::OPimTodoAccessBackend::occurrences(const QDate& start,const QDate& end)const | 81 | * \fn Opie::OPimBackendOccurrence::List Opie::OPimTodoAccessBackend::occurrences(const QDate& start,const QDate& end)const |
82 | * \brief Return occurrences for a period of time | 82 | * \brief Return occurrences for a period of time |
83 | * | 83 | * |
84 | * This method will return the 'effective' Todos and also | 84 | * This method will return the 'effective' Todos and also |
85 | * 'Overdue' Todos. Overdues will be shown on the 'current' | 85 | * 'Overdue' Todos. Overdues will be shown on the 'current' |
86 | * day if it is in the range or on \par start. If the overdue | 86 | * day if it is in the range or on \par start. If the overdue |
87 | * is inside the 'Effective Todos' we will skip the | 87 | * is inside the 'Effective Todos' we will skip the |
88 | * special overdue handling. | 88 | * special overdue handling. |
89 | * | 89 | * |
90 | * | 90 | * |
91 | */ | 91 | */ |
92 | #endif | 92 | #endif |
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 9bbc820..9d18d47 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -25,139 +25,130 @@ | |||
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: XML-Backend: Automatic reload if something was changed... | 31 | * ToDo: XML-Backend: Automatic reload if something was changed... |
32 | * | 32 | * |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <opie2/ocontactaccess.h> | 36 | #include <opie2/ocontactaccess.h> |
37 | #include <opie2/obackendfactory.h> | 37 | #include <opie2/obackendfactory.h> |
38 | 38 | ||
39 | /* OPIE */ | 39 | /* OPIE */ |
40 | #include <opie2/ocontactaccessbackend_xml.h> | 40 | #include <opie2/ocontactaccessbackend_xml.h> |
41 | #include <opie2/opimresolver.h> | 41 | #include <opie2/opimresolver.h> |
42 | #include <opie2/opimglobal.h> | 42 | #include <opie2/opimglobal.h> |
43 | #include <opie2/odebug.h> | 43 | #include <opie2/odebug.h> |
44 | 44 | ||
45 | //#include <qpe/qcopenvelope_qws.h> | 45 | //#include <qpe/qcopenvelope_qws.h> |
46 | #include <qpe/global.h> | 46 | #include <qpe/global.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | #include <qasciidict.h> | 49 | #include <qasciidict.h> |
50 | #include <qdatetime.h> | 50 | #include <qdatetime.h> |
51 | #include <qfile.h> | 51 | #include <qfile.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qlist.h> | 53 | #include <qlist.h> |
54 | #include <qcopchannel_qws.h> | 54 | #include <qcopchannel_qws.h> |
55 | 55 | ||
56 | /* STD */ | 56 | /* STD */ |
57 | #include <errno.h> | 57 | #include <errno.h> |
58 | #include <fcntl.h> | 58 | #include <fcntl.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | 61 | ||
62 | 62 | ||
63 | namespace Opie { | 63 | namespace Opie { |
64 | 64 | ||
65 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | 65 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , |
66 | OPimContactAccessBackend* end, bool autosync ): | 66 | OPimContactAccessBackend* end, bool autosync ): |
67 | OPimAccessTemplate<OPimContact>( end ) | 67 | OPimAccessTemplate<OPimContact>( end ) |
68 | { | 68 | { |
69 | /* take care of the backend. If there is no one defined, we | 69 | /* take care of the backend. If there is no one defined, we |
70 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 70 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
71 | */ | 71 | */ |
72 | if( end == 0 ) { | 72 | if( end == 0 ) { |
73 | end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); | 73 | end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); |
74 | } | 74 | } |
75 | // Set backend locally and in template | 75 | // Set backend locally and in template |
76 | m_backEnd = end; | 76 | m_backEnd = end; |
77 | OPimAccessTemplate<OPimContact>::setBackEnd (end); | 77 | OPimAccessTemplate<OPimContact>::setBackEnd (end); |
78 | 78 | ||
79 | 79 | ||
80 | /* Connect signal of external db change to function */ | 80 | /* Connect signal of external db change to function */ |
81 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 81 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
82 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), | 82 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
83 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); | 83 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
84 | if ( autosync ){ | 84 | if ( autosync ){ |
85 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 85 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
86 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), | 86 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
87 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); | 87 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | } | 91 | } |
92 | OPimContactAccess::~OPimContactAccess () | 92 | OPimContactAccess::~OPimContactAccess () |
93 | { | 93 | { |
94 | /* The user may forget to save the changed database, therefore try to | 94 | /* The user may forget to save the changed database, therefore try to |
95 | * do it for him.. | 95 | * do it for him.. |
96 | */ | 96 | */ |
97 | save(); | 97 | save(); |
98 | // delete m_backEnd; is done by template.. | 98 | // delete m_backEnd; is done by template.. |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | bool OPimContactAccess::save () | 102 | bool OPimContactAccess::save () |
103 | { | 103 | { |
104 | /* If the database was changed externally, we could not save the | 104 | /* If the database was changed externally, we could not save the |
105 | * Data. This will remove added items which is unacceptable ! | 105 | * Data. This will remove added items which is unacceptable ! |
106 | * Therefore: Reload database and merge the data... | 106 | * Therefore: Reload database and merge the data... |
107 | */ | 107 | */ |
108 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) | 108 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) |
109 | reload(); | 109 | reload(); |
110 | 110 | ||
111 | bool status = OPimAccessTemplate<OPimContact>::save(); | 111 | bool status = OPimAccessTemplate<OPimContact>::save(); |
112 | if ( !status ) return false; | 112 | if ( !status ) return false; |
113 | 113 | ||
114 | /* Now tell everyone that new data is available. | 114 | /* Now tell everyone that new data is available. |
115 | */ | 115 | */ |
116 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 116 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
117 | 117 | ||
118 | return true; | 118 | return true; |
119 | } | 119 | } |
120 | 120 | ||
121 | const uint OPimContactAccess::querySettings() | ||
122 | { | ||
123 | return ( m_backEnd->querySettings() ); | ||
124 | } | ||
125 | |||
126 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const | ||
127 | { | ||
128 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | ||
129 | } | ||
130 | 121 | ||
131 | #if 0 | 122 | #if 0 |
132 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 123 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
133 | { | 124 | { |
134 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 125 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
135 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); | 126 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); |
136 | } | 127 | } |
137 | #endif | 128 | #endif |
138 | 129 | ||
139 | 130 | ||
140 | bool OPimContactAccess::wasChangedExternally()const | 131 | bool OPimContactAccess::wasChangedExternally()const |
141 | { | 132 | { |
142 | return ( m_backEnd->wasChangedExternally() ); | 133 | return ( m_backEnd->wasChangedExternally() ); |
143 | } | 134 | } |
144 | 135 | ||
145 | 136 | ||
146 | void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 137 | void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
147 | { | 138 | { |
148 | if ( msg == "addressbookUpdated()" ){ | 139 | if ( msg == "addressbookUpdated()" ){ |
149 | emit signalChanged ( this ); | 140 | emit signalChanged ( this ); |
150 | } else if ( msg == "flush()" ) { | 141 | } else if ( msg == "flush()" ) { |
151 | save (); | 142 | save (); |
152 | } else if ( msg == "reload()" ) { | 143 | } else if ( msg == "reload()" ) { |
153 | reload (); | 144 | reload (); |
154 | emit signalChanged ( this ); | 145 | emit signalChanged ( this ); |
155 | } | 146 | } |
156 | } | 147 | } |
157 | 148 | ||
158 | int OPimContactAccess::rtti() const | 149 | int OPimContactAccess::rtti() const |
159 | { | 150 | { |
160 | return OPimResolver::AddressBook; | 151 | return OPimResolver::AddressBook; |
161 | } | 152 | } |
162 | 153 | ||
163 | } | 154 | } |
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index 5051321..9a2ecaf 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -23,155 +23,140 @@ | |||
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: Define enum for query settings | 31 | * ToDo: Define enum for query settings |
32 | * ===================================================================== | 32 | * ===================================================================== |
33 | */ | 33 | */ |
34 | #ifndef _OCONTACTACCESS_H | 34 | #ifndef _OCONTACTACCESS_H |
35 | #define _OCONTACTACCESS_H | 35 | #define _OCONTACTACCESS_H |
36 | 36 | ||
37 | #include <qobject.h> | 37 | #include <qobject.h> |
38 | 38 | ||
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | 40 | ||
41 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
42 | #include <qfileinfo.h> | 42 | #include <qfileinfo.h> |
43 | 43 | ||
44 | #include <opie2/opimcontact.h> | 44 | #include <opie2/opimcontact.h> |
45 | #include <opie2/ocontactaccessbackend.h> | 45 | #include <opie2/ocontactaccessbackend.h> |
46 | #include <opie2/opimaccesstemplate.h> | 46 | #include <opie2/opimaccesstemplate.h> |
47 | 47 | ||
48 | namespace Opie { | 48 | namespace Opie { |
49 | /** | 49 | /** |
50 | * Class to access the contacts database. | 50 | * Class to access the contacts database. |
51 | * This is just a frontend for the real database handling which is | 51 | * This is just a frontend for the real database handling which is |
52 | * done by the backend. | 52 | * done by the backend. |
53 | * This class is used to access the Contacts on a system. This class as any OPIE PIM | 53 | * This class is used to access the Contacts on a system. This class as any OPIE PIM |
54 | * class is backend independent. | 54 | * class is backend independent. |
55 | * @author Stefan Eilers, Holger Freyther | 55 | * @author Stefan Eilers, Holger Freyther |
56 | * @see OPimAccessTemplate | 56 | * @see OPimAccessTemplate |
57 | */ | 57 | */ |
58 | class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | 58 | class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | 61 | ||
62 | public: | 62 | public: |
63 | /** | 63 | /** |
64 | * Filter for sorted() | 64 | * Filter for sorted() |
65 | * @see SortFilterBase in OPimBase | 65 | * @see SortFilterBase in OPimBase |
66 | */ | 66 | */ |
67 | enum SortFilter { | 67 | enum SortFilter { |
68 | /** Don't return entries who don't have children */ | 68 | /** Don't return entries who don't have children */ |
69 | DoNotShowWithoutChildren = FilterCustom<<1, | 69 | DoNotShowWithoutChildren = FilterCustom<<1, |
70 | /** Don't return entries who don't have an anniversary */ | 70 | /** Don't return entries who don't have an anniversary */ |
71 | DoNotShowWithoutAnniversary = FilterCustom<<2, | 71 | DoNotShowWithoutAnniversary = FilterCustom<<2, |
72 | /** Don't return entries who don't have a birthday */ | 72 | /** Don't return entries who don't have a birthday */ |
73 | DoNotShowWithoutBirthday = FilterCustom<<3, | 73 | DoNotShowWithoutBirthday = FilterCustom<<3, |
74 | /** Don't return entries who don't have a home address */ | 74 | /** Don't return entries who don't have a home address */ |
75 | DoNotShowWithoutHomeAddress = FilterCustom<<4, | 75 | DoNotShowWithoutHomeAddress = FilterCustom<<4, |
76 | /** Don't return entries who don't have a business address */ | 76 | /** Don't return entries who don't have a business address */ |
77 | DoNotShowWithoutBusinessAddress = FilterCustom<<5, | 77 | DoNotShowWithoutBusinessAddress = FilterCustom<<5, |
78 | /** Don't return entries which hava any category */ | 78 | /** Don't return entries which hava any category */ |
79 | DoNotShowWithCategory = FilterCustom << 6 | 79 | DoNotShowWithCategory = FilterCustom << 6 |
80 | }; | 80 | }; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Sort order for sorted() | 83 | * Sort order for sorted() |
84 | * @see SortOrderBase in OPimBase | 84 | * @see SortOrderBase in OPimBase |
85 | */ | 85 | */ |
86 | enum SortOrder { | 86 | enum SortOrder { |
87 | SortTitle = SortCustom, | 87 | SortTitle = SortCustom, |
88 | SortFirstName, | 88 | SortFirstName, |
89 | SortMiddleName, | 89 | SortMiddleName, |
90 | SortLastName, | 90 | SortLastName, |
91 | SortSuffix, | 91 | SortSuffix, |
92 | SortEmail, | 92 | SortEmail, |
93 | SortNickname, | 93 | SortNickname, |
94 | SortFileAsName, | 94 | SortFileAsName, |
95 | SortAnniversary, | 95 | SortAnniversary, |
96 | SortBirthday, | 96 | SortBirthday, |
97 | SortGender | 97 | SortGender |
98 | }; | 98 | }; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Create Database with contacts (addressbook). | 101 | * Create Database with contacts (addressbook). |
102 | * @param appname Name of application which wants access to the database | 102 | * @param appname Name of application which wants access to the database |
103 | * (i.e. "todolist") | 103 | * (i.e. "todolist") |
104 | * @param filename The name of the database file. If not set, the default one | 104 | * @param filename The name of the database file. If not set, the default one |
105 | * is used. | 105 | * is used. |
106 | * @param backend Pointer to an alternative Backend. If not set, we will use | 106 | * @param backend Pointer to an alternative Backend. If not set, we will use |
107 | * the default backend. | 107 | * the default backend. |
108 | * @param handlesync If <b>true</b> the database stores the current state | 108 | * @param handlesync If <b>true</b> the database stores the current state |
109 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 109 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
110 | * which are used before and after synchronisation. If the application wants | 110 | * which are used before and after synchronisation. If the application wants |
111 | * to react itself, it should be disabled by setting it to <b>false</b> | 111 | * to react itself, it should be disabled by setting it to <b>false</b> |
112 | * @see OPimContactAccessBackend | 112 | * @see OPimContactAccessBackend |
113 | */ | 113 | */ |
114 | OPimContactAccess (const QString appname, const QString filename = 0l, | 114 | OPimContactAccess (const QString appname, const QString filename = 0l, |
115 | OPimContactAccessBackend* backend = 0l, bool handlesync = true); | 115 | OPimContactAccessBackend* backend = 0l, bool handlesync = true); |
116 | ~OPimContactAccess (); | 116 | ~OPimContactAccess (); |
117 | 117 | ||
118 | 118 | ||
119 | /** | ||
120 | * Return all possible settings for queryByExample(). | ||
121 | * @return All settings provided by the current backend | ||
122 | * (i.e.: WildCards & IgnoreCase) | ||
123 | * @see QuerySettings in OPimBase for details of the parameter, queryByExample() | ||
124 | */ | ||
125 | const uint querySettings(); | ||
126 | |||
127 | /** | ||
128 | * Check whether settings are correct for queryByExample(). | ||
129 | * @return <i>true</i> if the given settings are correct and possible. | ||
130 | * @see QuerySettings in OPimBase for details of the parameter | ||
131 | */ | ||
132 | bool hasQuerySettings ( int querySettings ) const; | ||
133 | |||
134 | /** | 119 | /** |
135 | * if the resource was changed externally. | 120 | * if the resource was changed externally. |
136 | * You should use the signal instead of polling possible changes ! | 121 | * You should use the signal instead of polling possible changes ! |
137 | */ | 122 | */ |
138 | bool wasChangedExternally()const; | 123 | bool wasChangedExternally()const; |
139 | 124 | ||
140 | 125 | ||
141 | /** Save contacts database. | 126 | /** Save contacts database. |
142 | * Save is more a "commit". After calling this function, all changes are public available. | 127 | * Save is more a "commit". After calling this function, all changes are public available. |
143 | * @return true if successful | 128 | * @return true if successful |
144 | */ | 129 | */ |
145 | bool save(); | 130 | bool save(); |
146 | 131 | ||
147 | /** | 132 | /** |
148 | * Return identification of used records | 133 | * Return identification of used records |
149 | */ | 134 | */ |
150 | int rtti() const; | 135 | int rtti() const; |
151 | 136 | ||
152 | signals: | 137 | signals: |
153 | /* Signal is emitted if the database was changed. Therefore | 138 | /* Signal is emitted if the database was changed. Therefore |
154 | * we may need to reload to stay consistent. | 139 | * we may need to reload to stay consistent. |
155 | * @param which Pointer to the database who created this event. This pointer | 140 | * @param which Pointer to the database who created this event. This pointer |
156 | * is useful if an application has to handle multiple databases at the same time. | 141 | * is useful if an application has to handle multiple databases at the same time. |
157 | * @see reload() | 142 | * @see reload() |
158 | */ | 143 | */ |
159 | void signalChanged ( const OPimContactAccess *which ); | 144 | void signalChanged ( const OPimContactAccess *which ); |
160 | 145 | ||
161 | 146 | ||
162 | private: | 147 | private: |
163 | OPimContactAccessBackend *m_backEnd; | 148 | OPimContactAccessBackend *m_backEnd; |
164 | bool m_loading:1; | 149 | bool m_loading:1; |
165 | 150 | ||
166 | private slots: | 151 | private slots: |
167 | void copMessage( const QCString &msg, const QByteArray &data ); | 152 | void copMessage( const QCString &msg, const QByteArray &data ); |
168 | 153 | ||
169 | private: | 154 | private: |
170 | class Private; | 155 | class Private; |
171 | Private *d; | 156 | Private *d; |
172 | 157 | ||
173 | }; | 158 | }; |
174 | 159 | ||
175 | } | 160 | } |
176 | 161 | ||
177 | #endif | 162 | #endif |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 3875f09..823f03d 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,406 +1,431 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Holger Freyther <zecke@handhelds.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 30 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
31 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 31 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
35 | #include <opie2/opimaccessbackend.h> | 35 | #include <opie2/opimaccessbackend.h> |
36 | #include <opie2/opimrecordlist.h> | 36 | #include <opie2/opimrecordlist.h> |
37 | 37 | ||
38 | #include <opie2/opimtemplatebase.h> | 38 | #include <opie2/opimtemplatebase.h> |
39 | #include <opie2/odebug.h> | 39 | #include <opie2/odebug.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qarray.h> | 42 | #include <qarray.h> |
43 | #include <qdatetime.h> | 43 | #include <qdatetime.h> |
44 | 44 | ||
45 | namespace Opie { | 45 | namespace Opie { |
46 | 46 | ||
47 | class OPimAccessTemplatePrivate; | 47 | class OPimAccessTemplatePrivate; |
48 | /** | 48 | /** |
49 | * Thats the frontend to our OPIE PIM | 49 | * Thats the frontend to our OPIE PIM |
50 | * Library. Either you want to use it's | 50 | * Library. Either you want to use it's |
51 | * interface or you want to implement | 51 | * interface or you want to implement |
52 | * your own Access lib | 52 | * your own Access lib |
53 | * Just create a OPimRecord and inherit from | 53 | * Just create a OPimRecord and inherit from |
54 | * the templates | 54 | * the templates |
55 | */ | 55 | */ |
56 | 56 | ||
57 | template <class T = OPimRecord > | 57 | template <class T = OPimRecord > |
58 | class OPimAccessTemplate : public OTemplateBase<T> { | 58 | class OPimAccessTemplate : public OTemplateBase<T> { |
59 | public: | 59 | public: |
60 | /** | 60 | /** |
61 | * | 61 | * |
62 | */ | 62 | */ |
63 | enum Access { | 63 | enum Access { |
64 | Random = 0, | 64 | Random = 0, |
65 | SortedAccess | 65 | SortedAccess |
66 | }; | 66 | }; |
67 | typedef OPimRecordList<T> List; | 67 | typedef OPimRecordList<T> List; |
68 | typedef OPimAccessBackend<T> BackEnd; | 68 | typedef OPimAccessBackend<T> BackEnd; |
69 | typedef OPimCache<T> Cache; | 69 | typedef OPimCache<T> Cache; |
70 | 70 | ||
71 | //@{ | 71 | //@{ |
72 | OPimAccessTemplate( BackEnd* end); | 72 | OPimAccessTemplate( BackEnd* end); |
73 | virtual ~OPimAccessTemplate(); | 73 | virtual ~OPimAccessTemplate(); |
74 | //@} | 74 | //@} |
75 | 75 | ||
76 | //@{ | 76 | //@{ |
77 | bool load(); | 77 | bool load(); |
78 | virtual bool reload(); | 78 | virtual bool reload(); |
79 | bool save(); | 79 | bool save(); |
80 | void clear() ; | 80 | void clear() ; |
81 | //@} | 81 | //@} |
82 | 82 | ||
83 | 83 | ||
84 | bool wasChangedExternally()const; | 84 | bool wasChangedExternally()const; |
85 | 85 | ||
86 | //@{ | 86 | //@{ |
87 | virtual List allRecords()const; | 87 | virtual List allRecords()const; |
88 | virtual List matchRegexp( const QRegExp &r ) const; | 88 | virtual List matchRegexp( const QRegExp &r ) const; |
89 | 89 | ||
90 | /** | ||
91 | * Return all possible settings for queryByExample(). | ||
92 | * @return All settings provided by the current backend | ||
93 | * (i.e.: WildCards & IgnoreCase) | ||
94 | * @see QuerySettings in OPimBase for details of the parameter, queryByExample() | ||
95 | */ | ||
96 | const uint querySettings(); | ||
97 | |||
98 | /** | ||
99 | * Check whether settings are correct for queryByExample(). | ||
100 | * @return <i>true</i> if the given settings are correct and possible. | ||
101 | * @see QuerySettings in OPimBase for details of the parameter | ||
102 | */ | ||
103 | bool hasQuerySettings ( int querySettings ) const; | ||
104 | |||
90 | /** | 105 | /** |
91 | * Query by example search interface. | 106 | * Query by example search interface. |
92 | * "Query by Example" provides a very powerful search engine. Use the query object | 107 | * "Query by Example" provides a very powerful search engine. Use the query object |
93 | * (this may be a contact, a todo or databook event) | 108 | * (this may be a contact, a todo or databook event) |
94 | * as a search mask which is converted into a query regarding the querySettings. If a time period is needed | 109 | * as a search mask which is converted into a query regarding the querySettings. If a time period is needed |
95 | * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the endperiod (the last parameter). | 110 | * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the startperiod (the last parameter). |
96 | * @see QuerySettings in class OPimBase | 111 | * @see QuerySettings in class OPimBase |
97 | * @param query The object which contains the query set | 112 | * @param query The object which contains the query set |
98 | * @param querySettings This parameter defines what should be searched and how the query should be interpreted | 113 | * @param querySettings This parameter defines what should be searched and how the query should be interpreted |
99 | * @param endperiod Defines the end of a period for some special queries. | 114 | * @param startperiod Defines the start of a period for some special queries. |
100 | */ | 115 | */ |
101 | virtual List queryByExample( const T& query, int querySettings, const QDateTime& endperiod = QDateTime() ); | 116 | virtual List queryByExample( const T& query, int querySettings, const QDateTime& startperiod = QDateTime() ); |
102 | 117 | ||
103 | /** | 118 | /** |
104 | * Generic query by example search interface. This is a special version which handles generic OPimRecord types. They are converted | 119 | * Generic query by example search interface. This is a special version which handles generic OPimRecord types. They are converted |
105 | * automatically into the right datatype. | 120 | * automatically into the right datatype. |
106 | * "Query by Example" provides a very powerful search engine. Use the query object (this may be a contact, a todo or databook event) | 121 | * "Query by Example" provides a very powerful search engine. Use the query object (this may be a contact, a todo or databook event) |
107 | * as a search mask which is converted into a query regarding the querySettings. If a time period is needed | 122 | * as a search mask which is converted into a query regarding the querySettings. If a time period is needed |
108 | * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the endperiod (the last parameter). | 123 | * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the startperiod (the last parameter). |
109 | * @see QuerySettings in class OPimBase | 124 | * @see QuerySettings in class OPimBase |
110 | * @param query The object which contains the query set | 125 | * @param query The object which contains the query set |
111 | * @param querySettings This parameter defines what should be searched and how the query should be interpreted | 126 | * @param querySettings This parameter defines what should be searched and how the query should be interpreted |
112 | * @param endperiod Defines the end of a period for some special queries. | 127 | * @param startperiod Defines the start of a period for some special queries. |
113 | */ | 128 | */ |
114 | virtual List queryByExample( const OPimRecord* query, int querySettings, const QDateTime& endperiod = QDateTime() ); | 129 | virtual List queryByExample( const OPimRecord* query, int querySettings, const QDateTime& startperiod = QDateTime() ); |
115 | /** | 130 | /** |
116 | * Incremental query by example search interface. Providing incremental search, this one provides the feature | 131 | * Incremental query by example search interface. Providing incremental search, this one provides the feature |
117 | * to search in a list of records which may be returned by an other search. | 132 | * to search in a list of records which may be returned by an other search. |
118 | * "Query by Example" provides a very powerful search engine. Use the query object (this may be a contact, a todo or databook event) | 133 | * "Query by Example" provides a very powerful search engine. Use the query object (this may be a contact, a todo or databook event) |
119 | * as a search mask which is converted into a query regarding the querySettings. If a time period is needed | 134 | * as a search mask which is converted into a query regarding the querySettings. If a time period is needed |
120 | * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the endperiod (the last parameter). | 135 | * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the startperiod (the last parameter). |
121 | * @see QuerySettings in class OPimBase | 136 | * @see QuerySettings in class OPimBase |
122 | * @param uidlist List of uid's which should be incorporated into the next search | 137 | * @param uidlist List of uid's which should be incorporated into the next search |
123 | * @param query The object which contains the query set | 138 | * @param query The object which contains the query set |
124 | * @param querySettings This parameter defines what should be searched and how the query should be interpreted | 139 | * @param querySettings This parameter defines what should be searched and how the query should be interpreted |
125 | * @param endperiod Defines the end of a period for some special queries. | 140 | * @param startperiod Defines the start of a period for some special queries. |
126 | */ | 141 | */ |
127 | virtual List queryByExample( const OPimAccessTemplate::List& uidlist, const T& query, int querySettings, | 142 | virtual List queryByExample( const OPimAccessTemplate::List& uidlist, const T& query, int querySettings, |
128 | const QDateTime& endperiod = QDateTime() ); | 143 | const QDateTime& startperiod = QDateTime() ); |
129 | 144 | ||
130 | virtual T find( UID uid )const; | 145 | virtual T find( UID uid )const; |
131 | virtual T find( UID uid, const QArray<int>&, | 146 | virtual T find( UID uid, const QArray<int>&, |
132 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 147 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
133 | //@} | 148 | //@} |
134 | 149 | ||
135 | /** | 150 | /** |
136 | * Get sorted lists.. | 151 | * Get sorted lists.. |
137 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | 152 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: |
138 | * @param list of UID's received by allRecords() or others... | 153 | * @param list of UID's received by allRecords() or others... |
139 | * @param sortOrder Setting the sort order defined by enum SortOrder | 154 | * @param sortOrder Setting the sort order defined by enum SortOrder |
140 | * @param ascending Sort in ascending order if true, otherwise descending | 155 | * @param ascending Sort in ascending order if true, otherwise descending |
141 | * @param sortFilter Setting the sort filter defined by enum SortFilter | 156 | * @param sortFilter Setting the sort filter defined by enum SortFilter |
142 | * @param cat number of category. | 157 | * @param cat number of category. |
143 | */ | 158 | */ |
144 | virtual List sorted( const List& list, bool ascending, int sortOrder, | 159 | virtual List sorted( const List& list, bool ascending, int sortOrder, |
145 | int sortFilter, int cat )const; | 160 | int sortFilter, int cat )const; |
146 | 161 | ||
147 | /** | 162 | /** |
148 | * Get sorted lists.. | 163 | * Get sorted lists.. |
149 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | 164 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: |
150 | * @param list of UID's received by allRecords() or others... | 165 | * @param list of UID's received by allRecords() or others... |
151 | * @param sortOrder Setting the sort order defined by enum SortOrder | 166 | * @param sortOrder Setting the sort order defined by enum SortOrder |
152 | * @param ascending Sort in ascending order if true, otherwise descending | 167 | * @param ascending Sort in ascending order if true, otherwise descending |
153 | * @param sortFilter Setting the sort filter defined by enum SortFilter | 168 | * @param sortFilter Setting the sort filter defined by enum SortFilter |
154 | * @param cats List of categories. | 169 | * @param cats List of categories. |
155 | */ | 170 | */ |
156 | virtual List sorted( const List& list, bool ascending, int sortOrder, | 171 | virtual List sorted( const List& list, bool ascending, int sortOrder, |
157 | int sortFilter, const QArray<UID>& cats )const; | 172 | int sortFilter, const QArray<UID>& cats )const; |
158 | 173 | ||
159 | /** | 174 | /** |
160 | * Get sorted lists.. | 175 | * Get sorted lists.. |
161 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | 176 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: |
162 | * @param ascending Sort in ascending order if true, otherwise descending | 177 | * @param ascending Sort in ascending order if true, otherwise descending |
163 | * @param sortOrder Setting the sort order defined by enum SortOrder | 178 | * @param sortOrder Setting the sort order defined by enum SortOrder |
164 | * @param sortFilter Setting the sort filter defined by enum SortFilter | 179 | * @param sortFilter Setting the sort filter defined by enum SortFilter |
165 | * @param cat number of category. | 180 | * @param cat number of category. |
166 | */ | 181 | */ |
167 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; | 182 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; |
168 | 183 | ||
169 | /** | 184 | /** |
170 | * Get sorted lists.. | 185 | * Get sorted lists.. |
171 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | 186 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: |
172 | * @param ascending Sort in ascending order if true, otherwise descending | 187 | * @param ascending Sort in ascending order if true, otherwise descending |
173 | * @param sortOrder Setting the sort order defined by enum SortOrder | 188 | * @param sortOrder Setting the sort order defined by enum SortOrder |
174 | * @param sortFilter Setting the sort filter defined by enum SortFilter | 189 | * @param sortFilter Setting the sort filter defined by enum SortFilter |
175 | * @param cats List of categories. | 190 | * @param cats List of categories. |
176 | */ | 191 | */ |
177 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, | 192 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, |
178 | const QArray<UID>& cats )const; | 193 | const QArray<UID>& cats )const; |
179 | /** | 194 | /** |
180 | * (Re)Implementation | 195 | * (Re)Implementation |
181 | */ | 196 | */ |
182 | //@{ | 197 | //@{ |
183 | UIDArray matchRegexpSimple( const QRegExp& r )const; | 198 | UIDArray matchRegexpSimple( const QRegExp& r )const; |
184 | UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const; | 199 | UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const; |
185 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, | 200 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
186 | int sortFilter, int cat )const; | 201 | int sortFilter, int cat )const; |
187 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, | 202 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
188 | int sortFilter, const QArray<int>& )const; | 203 | int sortFilter, const QArray<int>& )const; |
189 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, | 204 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, |
190 | int cat )const; | 205 | int cat )const; |
191 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, | 206 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, |
192 | const QArray<int>& )const; | 207 | const QArray<int>& )const; |
193 | OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const; | 208 | OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const; |
194 | OPimOccurrence::List occurrences( const QDateTime& dt )const; | 209 | OPimOccurrence::List occurrences( const QDateTime& dt )const; |
195 | //@} | 210 | //@} |
196 | 211 | ||
197 | //@{ | 212 | //@{ |
198 | virtual bool add( const T& t ) ; | 213 | virtual bool add( const T& t ) ; |
199 | bool add( const OPimRecord& ); | 214 | bool add( const OPimRecord& ); |
200 | bool add( const OPimRecord* ); | 215 | bool add( const OPimRecord* ); |
201 | virtual bool remove( const T& t ); | 216 | virtual bool remove( const T& t ); |
202 | bool remove( UID uid ); | 217 | bool remove( UID uid ); |
203 | bool remove( const OPimRecord& ); | 218 | bool remove( const OPimRecord& ); |
204 | virtual bool replace( const T& t) ; | 219 | virtual bool replace( const T& t) ; |
205 | 220 | ||
206 | //@} | 221 | //@} |
207 | 222 | ||
208 | void setReadAhead( uint count ); | 223 | void setReadAhead( uint count ); |
209 | void cache( const T& )const; | 224 | void cache( const T& )const; |
210 | void setSaneCacheSize( int ); | 225 | void setSaneCacheSize( int ); |
211 | 226 | ||
212 | QArray<UID> records()const; | 227 | QArray<UID> records()const; |
213 | protected: | 228 | protected: |
214 | /** | 229 | /** |
215 | * invalidate the cache | 230 | * invalidate the cache |
216 | */ | 231 | */ |
217 | void invalidateCache(); | 232 | void invalidateCache(); |
218 | 233 | ||
219 | void setBackEnd( BackEnd* end ); | 234 | void setBackEnd( BackEnd* end ); |
220 | /** | 235 | /** |
221 | * returns the backend | 236 | * returns the backend |
222 | */ | 237 | */ |
223 | BackEnd* backEnd(); | 238 | BackEnd* backEnd(); |
224 | BackEnd* m_backEnd; | 239 | BackEnd* m_backEnd; |
225 | 240 | ||
226 | Cache m_cache; | 241 | Cache m_cache; |
227 | 242 | ||
228 | private: | 243 | private: |
229 | OPimAccessTemplatePrivate *d; | 244 | OPimAccessTemplatePrivate *d; |
230 | 245 | ||
231 | }; | 246 | }; |
232 | 247 | ||
233 | /** | 248 | /** |
234 | * c'tor BackEnd | 249 | * c'tor BackEnd |
235 | * enum Access a small hint on how to handle the backend | 250 | * enum Access a small hint on how to handle the backend |
236 | */ | 251 | */ |
237 | template <class T> | 252 | template <class T> |
238 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 253 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
239 | : OTemplateBase<T>(), m_backEnd( end ) | 254 | : OTemplateBase<T>(), m_backEnd( end ) |
240 | { | 255 | { |
241 | if (end ) | 256 | if (end ) |
242 | end->setFrontend( this ); | 257 | end->setFrontend( this ); |
243 | } | 258 | } |
244 | template <class T> | 259 | template <class T> |
245 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 260 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
246 | delete m_backEnd; | 261 | delete m_backEnd; |
247 | } | 262 | } |
248 | 263 | ||
249 | /** | 264 | /** |
250 | * load from the backend | 265 | * load from the backend |
251 | */ | 266 | */ |
252 | template <class T> | 267 | template <class T> |
253 | bool OPimAccessTemplate<T>::load() { | 268 | bool OPimAccessTemplate<T>::load() { |
254 | invalidateCache(); | 269 | invalidateCache(); |
255 | return m_backEnd->load(); | 270 | return m_backEnd->load(); |
256 | } | 271 | } |
257 | 272 | ||
258 | /** Reload database. | 273 | /** Reload database. |
259 | * You should execute this function if the external database | 274 | * You should execute this function if the external database |
260 | * was changed. | 275 | * was changed. |
261 | * This function will load the external database and afterwards | 276 | * This function will load the external database and afterwards |
262 | * rejoin the local changes. Therefore the local database will be set consistent. | 277 | * rejoin the local changes. Therefore the local database will be set consistent. |
263 | */ | 278 | */ |
264 | template <class T> | 279 | template <class T> |
265 | bool OPimAccessTemplate<T>::reload() { | 280 | bool OPimAccessTemplate<T>::reload() { |
266 | invalidateCache(); | 281 | invalidateCache(); |
267 | return m_backEnd->reload(); | 282 | return m_backEnd->reload(); |
268 | } | 283 | } |
269 | 284 | ||
270 | /** | 285 | /** |
271 | * Save contacts database. | 286 | * Save contacts database. |
272 | * Save is more a "commit". After calling this function, all changes are public available. | 287 | * Save is more a "commit". After calling this function, all changes are public available. |
273 | * @return true if successful | 288 | * @return true if successful |
274 | */ | 289 | */ |
275 | template <class T> | 290 | template <class T> |
276 | bool OPimAccessTemplate<T>::save() { | 291 | bool OPimAccessTemplate<T>::save() { |
277 | return m_backEnd->save(); | 292 | return m_backEnd->save(); |
278 | } | 293 | } |
279 | 294 | ||
280 | 295 | ||
281 | /** | 296 | /** |
282 | * return a List of records | 297 | * return a List of records |
283 | * you can iterate over them | 298 | * you can iterate over them |
284 | */ | 299 | */ |
285 | template <class T> | 300 | template <class T> |
286 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 301 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
287 | QArray<int> ints = m_backEnd->allRecords(); | 302 | QArray<int> ints = m_backEnd->allRecords(); |
288 | List lis(ints, this ); | 303 | List lis(ints, this ); |
289 | return lis; | 304 | return lis; |
290 | } | 305 | } |
291 | 306 | ||
292 | /** | 307 | /** |
293 | * return a List of records | 308 | * return a List of records |
294 | * that match the regex | 309 | * that match the regex |
295 | */ | 310 | */ |
296 | template <class T> | 311 | template <class T> |
297 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | 312 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { |
298 | QArray<int> ints = m_backEnd->matchRegexp( r ); | 313 | QArray<int> ints = m_backEnd->matchRegexp( r ); |
299 | List lis(ints, this ); | 314 | List lis(ints, this ); |
300 | return lis; | 315 | return lis; |
301 | } | 316 | } |
302 | 317 | ||
303 | /** | 318 | /** |
304 | * find the OPimRecord uid | 319 | * find the OPimRecord uid |
305 | */ | 320 | */ |
306 | template <class T> | 321 | template <class T> |
307 | QArray<int> OPimAccessTemplate<T>::records()const { | 322 | QArray<int> OPimAccessTemplate<T>::records()const { |
308 | return m_backEnd->allRecords(); | 323 | return m_backEnd->allRecords(); |
309 | } | 324 | } |
310 | 325 | ||
326 | template <class T> | ||
327 | const uint OPimAccessTemplate<T>::querySettings(){ | ||
328 | return m_backEnd->querySettings(); | ||
329 | } | ||
330 | |||
331 | template <class T> | ||
332 | bool OPimAccessTemplate<T>::hasQuerySettings ( int querySettings ) const { | ||
333 | return m_backEnd->hasQuerySettings( querySettings ); | ||
334 | } | ||
335 | |||
311 | 336 | ||
312 | template <class T> | 337 | template <class T> |
313 | typename OPimAccessTemplate<T>::List | 338 | typename OPimAccessTemplate<T>::List |
314 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 339 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
315 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 340 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
316 | 341 | ||
317 | List list(ints, this ); | 342 | List list(ints, this ); |
318 | return list; | 343 | return list; |
319 | } | 344 | } |
320 | 345 | ||
321 | template <class T> | 346 | template <class T> |
322 | typename OPimAccessTemplate<T>::List | 347 | typename OPimAccessTemplate<T>::List |
323 | OPimAccessTemplate<T>::queryByExample( const OPimRecord* t, int settings, const QDateTime& d ) { | 348 | OPimAccessTemplate<T>::queryByExample( const OPimRecord* t, int settings, const QDateTime& d ) { |
324 | T tempInstance; | 349 | T tempInstance; |
325 | 350 | ||
326 | if ( t->rtti() == tempInstance.rtti() ) { | 351 | if ( t->rtti() == tempInstance.rtti() ) { |
327 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 352 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
328 | List list( ints, this ); | 353 | List list( ints, this ); |
329 | return list; | 354 | return list; |
330 | } else { | 355 | } else { |
331 | owarn << "Query not possible: Objecttype mismatch" << oendl; | 356 | owarn << "Query not possible: Objecttype mismatch" << oendl; |
332 | } | 357 | } |
333 | 358 | ||
334 | return List(); | 359 | return List(); |
335 | } | 360 | } |
336 | 361 | ||
337 | template <class T> | 362 | template <class T> |
338 | typename OPimAccessTemplate<T>::List | 363 | typename OPimAccessTemplate<T>::List |
339 | OPimAccessTemplate<T>::queryByExample( const OPimAccessTemplate::List& uidlist, const T& t, int settings, const QDateTime& d ) { | 364 | OPimAccessTemplate<T>::queryByExample( const OPimAccessTemplate::List& uidlist, const T& t, int settings, const QDateTime& d ) { |
340 | QArray<int> ints = m_backEnd->queryByExample( uidlist.uids(), t, settings, d ); | 365 | QArray<int> ints = m_backEnd->queryByExample( uidlist.uids(), t, settings, d ); |
341 | 366 | ||
342 | List list( ints, this ); | 367 | List list( ints, this ); |
343 | return list; | 368 | return list; |
344 | } | 369 | } |
345 | 370 | ||
346 | 371 | ||
347 | template <class T> | 372 | template <class T> |
348 | T OPimAccessTemplate<T>::find( UID uid ) const{ | 373 | T OPimAccessTemplate<T>::find( UID uid ) const{ |
349 | // First search in cache.. | 374 | // First search in cache.. |
350 | if ( m_cache.contains( uid ) ) | 375 | if ( m_cache.contains( uid ) ) |
351 | return m_cache.find( uid ); | 376 | return m_cache.find( uid ); |
352 | 377 | ||
353 | T t = m_backEnd->find( uid ); | 378 | T t = m_backEnd->find( uid ); |
354 | cache( t ); | 379 | cache( t ); |
355 | 380 | ||
356 | return t; | 381 | return t; |
357 | } | 382 | } |
358 | 383 | ||
359 | 384 | ||
360 | /** | 385 | /** |
361 | * read ahead cache find method ;) | 386 | * read ahead cache find method ;) |
362 | */ | 387 | */ |
363 | template <class T> | 388 | template <class T> |
364 | T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar, | 389 | T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar, |
365 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 390 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
366 | /* | 391 | /* |
367 | * better do T.isEmpty() | 392 | * better do T.isEmpty() |
368 | * after a find this way we would | 393 | * after a find this way we would |
369 | * avoid two finds in QCache... | 394 | * avoid two finds in QCache... |
370 | */ | 395 | */ |
371 | if (m_cache.contains( uid ) ) | 396 | if (m_cache.contains( uid ) ) |
372 | return m_cache.find( uid ); | 397 | return m_cache.find( uid ); |
373 | 398 | ||
374 | 399 | ||
375 | T t = m_backEnd->find( uid, ar, current, dir ); | 400 | T t = m_backEnd->find( uid, ar, current, dir ); |
376 | cache( t ); | 401 | cache( t ); |
377 | return t; | 402 | return t; |
378 | } | 403 | } |
379 | 404 | ||
380 | /** | 405 | /** |
381 | * clears the backend and invalidates the backend | 406 | * clears the backend and invalidates the backend |
382 | */ | 407 | */ |
383 | template <class T> | 408 | template <class T> |
384 | void OPimAccessTemplate<T>::clear() { | 409 | void OPimAccessTemplate<T>::clear() { |
385 | invalidateCache(); | 410 | invalidateCache(); |
386 | m_backEnd->clear(); | 411 | m_backEnd->clear(); |
387 | } | 412 | } |
388 | 413 | ||
389 | 414 | ||
390 | /** | 415 | /** |
391 | * add T to the backend | 416 | * add T to the backend |
392 | * @param t The item to add. | 417 | * @param t The item to add. |
393 | * @return <i>true</i> if added successfully. | 418 | * @return <i>true</i> if added successfully. |
394 | */ | 419 | */ |
395 | template <class T> | 420 | template <class T> |
396 | bool OPimAccessTemplate<T>::add( const T& t ) { | 421 | bool OPimAccessTemplate<T>::add( const T& t ) { |
397 | cache( t ); | 422 | cache( t ); |
398 | return m_backEnd->add( t ); | 423 | return m_backEnd->add( t ); |
399 | } | 424 | } |
400 | 425 | ||
401 | template <class T> | 426 | template <class T> |
402 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { | 427 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { |
403 | /* same type */ | 428 | /* same type */ |
404 | T tempInstance; | 429 | T tempInstance; |
405 | if ( rec.rtti() == tempInstance.rtti() ) { | 430 | if ( rec.rtti() == tempInstance.rtti() ) { |
406 | const T& t = static_cast<const T&>(rec); | 431 | const T& t = static_cast<const T&>(rec); |