summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ChangeLog4
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp29
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.h2
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp27
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h15
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h6
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.cpp32
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h15
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp34
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h2
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp5
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h1
13 files changed, 134 insertions, 42 deletions
diff --git a/libopie2/opiepim/ChangeLog b/libopie2/opiepim/ChangeLog
index 564e92a..2007744 100644
--- a/libopie2/opiepim/ChangeLog
+++ b/libopie2/opiepim/ChangeLog
@@ -1,15 +1,17 @@
12004-12-28 Stefan Eilers <stefan@eilers-online.net> 12004-12-28 Stefan Eilers <stefan@eilers-online.net>
2 * Make improved query by example accessable via frontend 2 * Make improved query by example accessable via frontend
3 * Some API improvement 3 * Some API documentation improvement
4 * Cleanup of backend api..
5 * Fixing bug #1501
42004-11-23 Stefan Eilers <stefan@eilers-online.net> 62004-11-23 Stefan Eilers <stefan@eilers-online.net>
5 * Implement fast and full featured version of sorted() for addressbook 7 * Implement fast and full featured version of sorted() for addressbook
6 * Implement generic queryByExample for all Addressboook backends. It allows incremental search. 8 * Implement generic queryByExample for all Addressboook backends. It allows incremental search.
7 * Update of API Documentation 9 * Update of API Documentation
82004-11-18 Holger Freyther <freyther@handhelds.org> 102004-11-18 Holger Freyther <freyther@handhelds.org>
9 * Every Access can give a set of Occurrences for a period or a datetime 11 * Every Access can give a set of Occurrences for a period or a datetime
10 * QueryByExample, Find, Sort can be generically accessed by OPimBase 12 * QueryByExample, Find, Sort can be generically accessed by OPimBase
11 pointer interface 13 pointer interface
12 * OPimBackendOccurrence gets split up to OPimOccurrences by 14 * OPimBackendOccurrence gets split up to OPimOccurrences by
13 OPimTemplateBase 15 OPimTemplateBase
14 * Add safeCast to various OPimRecords 16 * Add safeCast to various OPimRecords
15 * Kill memleak in OPimTodo 17 * Kill memleak in OPimTodo
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index ee6dbc2..27d70ab 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -71,31 +71,31 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
71 * this case. It is not our problem to handle this conflict ... 71 * this case. It is not our problem to handle this conflict ...
72 * @return <i>true</i> if the database was changed and if save without reload will 72 * @return <i>true</i> if the database was changed and if save without reload will
73 * be dangerous. <i>false</i> if the database was not changed or it is save to write 73 * be dangerous. <i>false</i> if the database was not changed or it is save to write
74 * in this situation. 74 * in this situation.
75 */ 75 */
76 virtual bool wasChangedExternally() = 0; 76 virtual bool wasChangedExternally() = 0;
77 77
78 /** 78 /**
79 * Return all possible settings. 79 * Return all possible settings.
80 * @return All settings provided by the current backend 80 * @return All settings provided by the current backend
81 * (i.e.: query_WildCards & query_IgnoreCase) 81 * (i.e.: query_WildCards & query_IgnoreCase)
82 */ 82 */
83 virtual const uint querySettings() const; 83 const uint querySettings() const;
84 84
85 /** 85 /**
86 * Check whether settings are correct. 86 * Check whether settings are correct.
87 * @return <i>true</i> if the given settings are correct and possible. 87 * @return <i>true</i> if the given settings are correct and possible.
88 */ 88 */
89 virtual bool hasQuerySettings (uint querySettings) const; 89 bool hasQuerySettings (uint querySettings) const;
90 90
91 /** 91 /**
92 * Advanced search mechanism. 92 * Advanced search mechanism.
93 */ 93 */
94 UIDArray queryByExample( const UIDArray& uidlist, const OPimContact&, int settings, const QDateTime &d = QDateTime() ) const; 94 UIDArray queryByExample( const UIDArray& uidlist, const OPimContact&, int settings, const QDateTime &d = QDateTime() ) const;
95 /** 95 /**
96 * Slow and inefficent default implementation 96 * Slow and inefficent default implementation
97 */ 97 */
98//@{ 98//@{
99 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const; 99 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
100 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const; 100 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const;
101//@} 101//@}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index 9375f43..2368865 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -270,51 +270,53 @@ namespace {
270 + ",'" 270 + ",'"
271 + it.data() 271 + it.data()
272 + "');"; 272 + "');";
273 } 273 }
274 // qu += "commit;"; 274 // qu += "commit;";
275 odebug << "add " << qu << "" << oendl; 275 odebug << "add " << qu << "" << oendl;
276 return qu; 276 return qu;
277 } 277 }
278 278
279 279
280 RemoveQuery::RemoveQuery(int uid ) 280 RemoveQuery::RemoveQuery(int uid )
281 : OSQLQuery(), m_uid( uid ) {} 281 : OSQLQuery(), m_uid( uid ) {}
282
282 RemoveQuery::~RemoveQuery() {} 283 RemoveQuery::~RemoveQuery() {}
284
283 QString RemoveQuery::query()const { 285 QString RemoveQuery::query()const {
284 QString qu = "DELETE from addressbook where uid = " 286 QString qu = "DELETE from addressbook where uid = "
285 + QString::number(m_uid) + ";"; 287 + QString::number(m_uid) + ";";
286 qu += "DELETE from custom_data where uid = " 288 qu += "DELETE from custom_data where uid = "
287 + QString::number(m_uid) + ";"; 289 + QString::number(m_uid) + ";";
288 return qu; 290 return qu;
289 } 291 }
290 292
291 293
292
293
294 FindQuery::FindQuery(int uid) 294 FindQuery::FindQuery(int uid)
295 : OSQLQuery(), m_uid( uid ) { 295 : OSQLQuery(), m_uid( uid ) {
296 } 296 }
297 FindQuery::FindQuery(const UIDArray& ints) 297 FindQuery::FindQuery(const UIDArray& ints)
298 : OSQLQuery(), m_uids( ints ){ 298 : OSQLQuery(), m_uids( ints ){
299 } 299 }
300 FindQuery::~FindQuery() { 300 FindQuery::~FindQuery() {
301 } 301 }
302 QString FindQuery::query()const{ 302 QString FindQuery::query()const{
303 if ( m_uids.count() == 0 ) 303 if ( m_uids.count() == 0 )
304 return single(); 304 return single();
305 else 305 else
306 return multi(); 306 return multi();
307 } 307 }
308 308
309
310
309 QString FindQuery::multi()const { 311 QString FindQuery::multi()const {
310 QString qu = "select * from addressbook where"; 312 QString qu = "select * from addressbook where";
311 for (uint i = 0; i < m_uids.count(); i++ ) { 313 for (uint i = 0; i < m_uids.count(); i++ ) {
312 qu += " uid = " + QString::number( m_uids[i] ) + " OR"; 314 qu += " uid = " + QString::number( m_uids[i] ) + " OR";
313 } 315 }
314 qu.remove( qu.length()-2, 2 ); // Hmmmm.. 316 qu.remove( qu.length()-2, 2 ); // Hmmmm..
315 317
316 odebug << "find query: " << qu << "" << oendl; 318 odebug << "find query: " << qu << "" << oendl;
317 return qu; 319 return qu;
318 } 320 }
319 321
320 QString FindQuery::single()const{ 322 QString FindQuery::single()const{
@@ -519,28 +521,41 @@ OPimContact OPimContactAccessBackend_SQL::find( int uid, const UIDArray& queryUi
519 } 521 }
520 522
521 //Shrink to real size.. 523 //Shrink to real size..
522 searchList.resize( size ); 524 searchList.resize( size );
523 525
524 OPimContact retContact( requestContactsAndCache( uid, searchList ) ); 526 OPimContact retContact( requestContactsAndCache( uid, searchList ) );
525 527
526 odebug << "OPimContactAccessBackend_SQL::find( ..multi.. ) needed: " << t.elapsed() << " ms" << oendl; 528 odebug << "OPimContactAccessBackend_SQL::find( ..multi.. ) needed: " << t.elapsed() << " ms" << oendl;
527 return retContact; 529 return retContact;
528} 530}
529 531
530 532
531UIDArray OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, 533UIDArray OPimContactAccessBackend_SQL::queryByExample ( const UIDArray& uidlist, const OPimContact &query, int settings,
532 const QDateTime& qd ) const 534 const QDateTime& qd ) const
533{ 535{
534 QString qu = "SELECT uid FROM addressbook WHERE"; 536 QString qu = "SELECT uid FROM addressbook WHERE";
537
538 // Just add uid's selection if we really try to search in a subset of all uids! Otherwise this would
539 // just take time and memory!
540 if ( uidlist.count() != m_uids.count() ) {
541 qu += " (";
542
543 for ( uint i = 0; i < uidlist.count(); i++ ) {
544 qu += " uid = " + QString::number( uidlist[i] ) + " OR";
545 }
546 qu.remove( qu.length()-2, 2 ); // Hmmmm..
547 qu += " ) AND ";
548 }
549
535 QString searchQuery =""; 550 QString searchQuery ="";
536 551
537 QDate startDate; 552 QDate startDate;
538 553
539 if ( qd.isValid() ) 554 if ( qd.isValid() )
540 startDate = qd.date(); 555 startDate = qd.date();
541 else 556 else
542 startDate = QDate::currentDate(); 557 startDate = QDate::currentDate();
543 558
544 559
545 QMap<int, QString> queryFields = query.toMap(); 560 QMap<int, QString> queryFields = query.toMap();
546 QStringList fieldList = OPimContactFields::untrfields( false ); 561 QStringList fieldList = OPimContactFields::untrfields( false );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
index 299c175..1cf1185 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
@@ -66,25 +66,25 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
66 66
67 bool load (); 67 bool load ();
68 68
69 void clear (); 69 void clear ();
70 70
71 bool wasChangedExternally(); 71 bool wasChangedExternally();
72 72
73 UIDArray allRecords() const; 73 UIDArray allRecords() const;
74 74
75 OPimContact find( int uid ) const; 75 OPimContact find( int uid ) const;
76 OPimContact find( int uid, const UIDArray& items, uint cur, Frontend::CacheDirection ) const; 76 OPimContact find( int uid, const UIDArray& items, uint cur, Frontend::CacheDirection ) const;
77 77
78 UIDArray queryByExample ( const OPimContact &query, int settings, 78 UIDArray queryByExample ( const UIDArray& uidlist, const OPimContact &query, int settings,
79 const QDateTime& d ) const; 79 const QDateTime& d ) const;
80 80
81 UIDArray matchRegexp( const QRegExp &r ) const; 81 UIDArray matchRegexp( const QRegExp &r ) const;
82 82
83 const uint querySettings() const; 83 const uint querySettings() const;
84 84
85 bool hasQuerySettings (uint querySettings) const; 85 bool hasQuerySettings (uint querySettings) const;
86 86
87 UIDArray sorted( const UIDArray& ar, bool asc, int sortOrder, 87 UIDArray sorted( const UIDArray& ar, bool asc, int sortOrder,
88 int filter, const QArray<int>& categories)const; 88 int filter, const QArray<int>& categories)const;
89 89
90 bool add ( const OPimContact &newcontact ); 90 bool add ( const OPimContact &newcontact );
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
index 73c7059..e44912a 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -91,48 +91,65 @@ ODateBookAccessBackend::ODateBookAccessBackend()
91ODateBookAccessBackend::~ODateBookAccessBackend() { 91ODateBookAccessBackend::~ODateBookAccessBackend() {
92 92
93} 93}
94OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDate& from, 94OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDate& from,
95 const QDate& to )const { 95 const QDate& to )const {
96 OPimBackendOccurrence::List tmpList; 96 OPimBackendOccurrence::List tmpList;
97 97
98 events( tmpList, directNonRepeats(), from, to ); 98 events( tmpList, directNonRepeats(), from, to );
99 repeat( tmpList, directRawRepeats(),from,to ); 99 repeat( tmpList, directRawRepeats(),from,to );
100 100
101 return tmpList; 101 return tmpList;
102} 102}
103OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const { 103
104OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const
105{
104 OPimBackendOccurrence::List day = occurrences( dt.date(), dt.date() ); 106 OPimBackendOccurrence::List day = occurrences( dt.date(), dt.date() );
105 107
106 return filterOccurrences( day, dt ); 108 return filterOccurrences( day, dt );
107} 109}
108 110
109OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, 111OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from,
110 const QDate& to )const { 112 const QDate& to )const
113{
111 OPimBackendOccurrence::List tmpList; 114 OPimBackendOccurrence::List tmpList;
112 OPimEvent::ValueList list = directNonRepeats(); 115 OPimEvent::ValueList list = directNonRepeats();
113 116
114 events( tmpList, list, from, to ); 117 events( tmpList, list, from, to );
115 118
116 return tmpList; 119 return tmpList;
117} 120}
118 121
119OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const { 122OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const
123{
120 OPimBackendOccurrence::List day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); 124 OPimBackendOccurrence::List day = effectiveNonRepeatingEvents( dt.date(), dt.date() );
121 return filterOccurrences( day,dt ); 125 return filterOccurrences( day,dt );
122} 126}
123 127
128const uint ODateBookAccessBackend::querySettings() const
129{
130 return 0;
131}
132
133bool ODateBookAccessBackend::hasQuerySettings (uint querySettings) const
134{
135 return false;
136}
137
138
124 139
125UIDArray ODateBookAccessBackend::queryByExample( const OPimEvent&, int settings, 140UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings,
126 const QDateTime& d )const { 141 const QDateTime& d )const
142{
143 qDebug( "Accessing ODateBookAccessBackend::queryByExample() which is not implemented!" );
127 return UIDArray(); 144 return UIDArray();
128} 145}
129 146
130UIDArray ODateBookAccessBackend::sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const { 147UIDArray ODateBookAccessBackend::sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const {
131 return UIDArray(); 148 return UIDArray();
132} 149}
133 150
134OPimBackendOccurrence::List ODateBookAccessBackend::filterOccurrences( const OPimBackendOccurrence::List dayList, 151OPimBackendOccurrence::List ODateBookAccessBackend::filterOccurrences( const OPimBackendOccurrence::List dayList,
135 const QDateTime& dt ) { 152 const QDateTime& dt ) {
136 OPimBackendOccurrence::List tmpList; 153 OPimBackendOccurrence::List tmpList;
137 OPimBackendOccurrence::List::ConstIterator it; 154 OPimBackendOccurrence::List::ConstIterator it;
138 155
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index 8927ca1..91f63aa 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -85,25 +85,38 @@ public:
85 /** 85 /**
86 * this is an overloaded member function 86 * this is an overloaded member function
87 * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) 87 * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to )
88 */ 88 */
89 virtual OPimBackendOccurrence::List effectiveNonRepeatingEvents( const QDateTime& start )const; 89 virtual OPimBackendOccurrence::List effectiveNonRepeatingEvents( const QDateTime& start )const;
90 90
91 /** 91 /**
92 * Common and probably inefficent implementation 92 * Common and probably inefficent implementation
93 * for queryByExample, sorted 93 * for queryByExample, sorted
94 * and occurrences 94 * and occurrences
95 */ 95 */
96//@{ 96//@{
97 UIDArray queryByExample( const OPimEvent&, int settings, const QDateTime& d = QDateTime() )const; 97 /**
98 * Return all possible settings.
99 * @return All settings provided by the current backend
100 * (i.e.: query_WildCards & query_IgnoreCase)
101 */
102 const uint querySettings() const;
103
104 /**
105 * Check whether settings are correct.
106 * @return <i>true</i> if the given settings are correct and possible.
107 */
108 bool hasQuerySettings (uint querySettings) const;
109
110 UIDArray queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings, const QDateTime& d = QDateTime() )const;
98 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const; 111 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
99 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& end )const; 112 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& end )const;
100 OPimBackendOccurrence::List occurrences( const QDateTime& )const; 113 OPimBackendOccurrence::List occurrences( const QDateTime& )const;
101//@} 114//@}
102 115
103protected: 116protected:
104 static OPimBackendOccurrence::List filterOccurrences(const OPimBackendOccurrence::List, 117 static OPimBackendOccurrence::List filterOccurrences(const OPimBackendOccurrence::List,
105 const QDateTime& time ); 118 const QDateTime& time );
106private: 119private:
107 class Private; 120 class Private;
108 Private *d; 121 Private *d;
109 122
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 7321758..6666fd6 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -66,40 +66,40 @@ public:
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 { return 0; } /* FIXME: Make Abstrakt !! = 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 { return false; } /* FIXME: Make Abstrakt !! = 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 { return UIDArray(); } /* FIXME: Make Abstrakt !! = 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,
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp
index 5f86be9..f979976 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.cpp
+++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp
@@ -33,27 +33,53 @@
33 33
34#include <qintdict.h> 34#include <qintdict.h>
35 35
36namespace Opie { 36namespace Opie {
37OPimTodoAccessBackend::OPimTodoAccessBackend() 37OPimTodoAccessBackend::OPimTodoAccessBackend()
38 : OPimAccessBackend<OPimTodo>() 38 : OPimAccessBackend<OPimTodo>()
39{ 39{
40} 40}
41OPimTodoAccessBackend::~OPimTodoAccessBackend() { 41OPimTodoAccessBackend::~OPimTodoAccessBackend() {
42 42
43} 43}
44 44
45UIDArray OPimTodoAccessBackend::queryByExample( const OPimTodo&, int settings, 45const uint OPimTodoAccessBackend::querySettings() const
46 const QDateTime& d)const { 46{
47 return UIDArray(); 47 return 0;
48}
49
50bool OPimTodoAccessBackend::hasQuerySettings (uint querySettings) const
51{
52 return false;
53}
54
55
56UIDArray OPimTodoAccessBackend::queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings,
57 const QDateTime& endperiod )const
58{
59 qDebug( "Accessing OPimTodoAccessBackend::queryByExample() which is not implemented!" );
60 return UIDArray();
61
62// odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl;
63
64// UIDArray m_currentQuery( uid_array.count() );
65// uint arraycounter = 0;
66
67// for( uint it = 0; it < uid_array.count(); ++it ){
68 // /* Search all fields and compare them with query object. Store them into list
69 // * if all fields matches.
70 // */
71// }
72
73
48} 74}
49 75
50UIDArray OPimTodoAccessBackend::sorted( const UIDArray& events, bool asc, 76UIDArray OPimTodoAccessBackend::sorted( const UIDArray& events, bool asc,
51 int sortOrder, int sortFilter, 77 int sortOrder, int sortFilter,
52 const QArray<int>& categories )const { 78 const QArray<int>& categories )const {
53 odebug << "Using Unaccelerated TodoList sorted Implementation" << oendl; 79 odebug << "Using Unaccelerated TodoList sorted Implementation" << oendl;
54 Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder ); 80 Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder );
55 int item = 0; 81 int item = 0;
56 82
57 bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false; 83 bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false;
58 bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false; 84 bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false;
59 bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false; 85 bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false;
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 66297bb..870ee57 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/otodoaccessbackend.h
@@ -42,25 +42,38 @@ public:
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 UIDArray queryByExample( const OPimTodo&, int settings, const QDateTime& d = QDateTime() )const; 54 /**
55 * Return all possible settings.
56 * @return All settings provided by the current backend
57 * (i.e.: query_WildCards & query_IgnoreCase)
58 */
59 const uint querySettings() const;
60
61 /**
62 * Check whether settings are correct.
63 * @return <i>true</i> if the given settings are correct and possible.
64 */
65 bool hasQuerySettings (uint querySettings) const;
66
67 UIDArray queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings, const QDateTime& endperiod = QDateTime() )const;
55 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;
56 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const; 69 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const;
57 //@} 70 //@}
58 71
59private: 72private:
60 class Private; 73 class Private;
61 Private *d; 74 Private *d;
62 75
63}; 76};
64} 77}
65 78
66 79
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 2bcab29..70e40e4 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -292,47 +292,57 @@ namespace {
292 + ",'" 292 + ",'"
293 + it.data() 293 + it.data()
294 + "');"; 294 + "');";
295 } 295 }
296 296
297 297
298 odebug << "add " << qu << "" << oendl; 298 odebug << "add " << qu << "" << oendl;
299 return qu; 299 return qu;
300 } 300 }
301 301
302 RemoveQuery::RemoveQuery(int uid ) 302 RemoveQuery::RemoveQuery(int uid )
303 : OSQLQuery(), m_uid( uid ) {} 303 : OSQLQuery(), m_uid( uid ) {}
304
304 RemoveQuery::~RemoveQuery() {} 305 RemoveQuery::~RemoveQuery() {}
306
305 QString RemoveQuery::query()const { 307 QString RemoveQuery::query()const {
306 QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;"; 308 QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;";
307 qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); 309 qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
308 return qu; 310 return qu;
309 } 311 }
310 312
311 313
312 ClearQuery::ClearQuery() 314 ClearQuery::ClearQuery()
313 : OSQLQuery() {} 315 : OSQLQuery() {}
314 ClearQuery::~ClearQuery() {} 316 ClearQuery::~ClearQuery() {}
315 QString ClearQuery::query()const { 317 QString ClearQuery::query()const
316 QString qu = "drop table todolist"; 318 {
317 return qu; 319 QString qu = "drop table todolist";
320 return qu;
318 } 321 }
322
319 FindQuery::FindQuery(int uid) 323 FindQuery::FindQuery(int uid)
320 : OSQLQuery(), m_uid(uid ) { 324 : OSQLQuery(), m_uid(uid )
325 {
321 } 326 }
327
322 FindQuery::FindQuery(const QArray<int>& ints) 328 FindQuery::FindQuery(const QArray<int>& ints)
323 : OSQLQuery(), m_uids(ints){ 329 : OSQLQuery(), m_uids(ints)
330 {
324 } 331 }
325 FindQuery::~FindQuery() { 332
333 FindQuery::~FindQuery()
334 {
326 } 335 }
336
327 QString FindQuery::query()const{ 337 QString FindQuery::query()const{
328 if (m_uids.count() == 0 ) 338 if (m_uids.count() == 0 )
329 return single(); 339 return single();
330 else 340 else
331 return multi(); 341 return multi();
332 } 342 }
333 QString FindQuery::single()const{ 343 QString FindQuery::single()const{
334 QString qu = "select * from todolist where uid = " + QString::number(m_uid); 344 QString qu = "select * from todolist where uid = " + QString::number(m_uid);
335 return qu; 345 return qu;
336 } 346 }
337 QString FindQuery::multi()const { 347 QString FindQuery::multi()const {
338 QString qu = "select * from todolist where "; 348 QString qu = "select * from todolist where ";
@@ -439,28 +449,28 @@ bool OPimTodoAccessBackendSQL::reload(){
439 return load(); 449 return load();
440} 450}
441 451
442bool OPimTodoAccessBackendSQL::save(){ 452bool OPimTodoAccessBackendSQL::save(){
443 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 453 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
444} 454}
445QArray<int> OPimTodoAccessBackendSQL::allRecords()const { 455QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
446 if (m_dirty ) 456 if (m_dirty )
447 update(); 457 update();
448 458
449 return m_uids; 459 return m_uids;
450} 460}
451QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){ 461// QArray<int> OPimTodoAccessBackendSQL::queryByExample( const UIDArray& uidlist, const OPimTodo& , int, const QDateTime& ){
452 QArray<int> ints(0); 462// QArray<int> ints(0);
453 return ints; 463// return ints;
454} 464// }
455OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ 465OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
456 FindQuery query( uid ); 466 FindQuery query( uid );
457 return parseResultAndCache( uid, m_driver->query(&query) ); 467 return parseResultAndCache( uid, m_driver->query(&query) );
458} 468}
459 469
460// Remember: uid is already in the list of uids, called ints ! 470// Remember: uid is already in the list of uids, called ints !
461OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, 471OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
462 uint cur, Frontend::CacheDirection dir ) const{ 472 uint cur, Frontend::CacheDirection dir ) const{
463 uint CACHE = readAhead(); 473 uint CACHE = readAhead();
464 odebug << "searching for " << uid << "" << oendl; 474 odebug << "searching for " << uid << "" << oendl;
465 QArray<int> search( CACHE ); 475 QArray<int> search( CACHE );
466 uint size =0; 476 uint size =0;
@@ -610,25 +620,25 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
610 if ( !asc ) 620 if ( !asc )
611 query += " DESC"; 621 query += " DESC";
612 622
613 623
614 odebug << query << oendl; 624 odebug << query << oendl;
615 OSQLRawQuery raw(query ); 625 OSQLRawQuery raw(query );
616 return uids( m_driver->query(&raw) ); 626 return uids( m_driver->query(&raw) );
617} 627}
618#endif 628#endif
619 629
620 630
621bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ 631bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
622 if ( str == "0-0-0" ) 632 if ( str == "0000-00-00" )
623 return false; 633 return false;
624 else{ 634 else{
625 int day, year, month; 635 int day, year, month;
626 QStringList list = QStringList::split("-", str ); 636 QStringList list = QStringList::split("-", str );
627 year = list[0].toInt(); 637 year = list[0].toInt();
628 month = list[1].toInt(); 638 month = list[1].toInt();
629 day = list[2].toInt(); 639 day = list[2].toInt();
630 da.setYMD( year, month, day ); 640 da.setYMD( year, month, day );
631 return true; 641 return true;
632 } 642 }
633} 643}
634 644
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 0ba8f3a..ac3476a 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -44,25 +44,25 @@ class OSQLResultItem;
44namespace Opie { 44namespace Opie {
45 45
46class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend { 46class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend {
47public: 47public:
48 OPimTodoAccessBackendSQL( const QString& file ); 48 OPimTodoAccessBackendSQL( const QString& file );
49 ~OPimTodoAccessBackendSQL(); 49 ~OPimTodoAccessBackendSQL();
50 50
51 bool load(); 51 bool load();
52 bool reload(); 52 bool reload();
53 bool save(); 53 bool save();
54 QArray<UID> allRecords()const; 54 QArray<UID> allRecords()const;
55 55
56 QArray<UID> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() ); 56/* QArray<UID> queryByExample( const UIDArray& uidlist, const OPimTodo& t, int settings, const QDateTime& d = QDateTime() ); */
57 OPimTodo find(UID uid)const; 57 OPimTodo find(UID uid)const;
58 OPimTodo find(UID uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 58 OPimTodo find(UID uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
59 void clear(); 59 void clear();
60 bool add( const OPimTodo& t ); 60 bool add( const OPimTodo& t );
61 bool remove( UID uid ); 61 bool remove( UID uid );
62 bool replace( const OPimTodo& t ); 62 bool replace( const OPimTodo& t );
63 63
64 QArray<UID> overDue()const; 64 QArray<UID> overDue()const;
65 QArray<UID> effectiveToDos( const QDate& start, 65 QArray<UID> effectiveToDos( const QDate& start,
66 const QDate& end, bool includeNoDates )const; 66 const QDate& end, bool includeNoDates )const;
67 QArray<UID> matchRegexp( const QRegExp &r ) const; 67 QArray<UID> matchRegexp( const QRegExp &r ) const;
68 void removeAllCompleted(); 68 void removeAllCompleted();
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 273f91a..ab50604 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -317,28 +317,25 @@ bool OPimTodoAccessXML::save() {
317} 317}
318QArray<int> OPimTodoAccessXML::allRecords()const { 318QArray<int> OPimTodoAccessXML::allRecords()const {
319 QArray<int> ids( m_events.count() ); 319 QArray<int> ids( m_events.count() );
320 QMap<int, OPimTodo>::ConstIterator it; 320 QMap<int, OPimTodo>::ConstIterator it;
321 int i = 0; 321 int i = 0;
322 322
323 for ( it = m_events.begin(); it != m_events.end(); ++it ) 323 for ( it = m_events.begin(); it != m_events.end(); ++it )
324 ids[i++] = it.key(); 324 ids[i++] = it.key();
325 325
326 326
327 return ids; 327 return ids;
328} 328}
329QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) { 329
330 QArray<int> ids(0);
331 return ids;
332}
333OPimTodo OPimTodoAccessXML::find( int uid )const { 330OPimTodo OPimTodoAccessXML::find( int uid )const {
334 OPimTodo todo; 331 OPimTodo todo;
335 todo.setUid( 0 ); // isEmpty() 332 todo.setUid( 0 ); // isEmpty()
336 QMap<int, OPimTodo>::ConstIterator it = m_events.find( uid ); 333 QMap<int, OPimTodo>::ConstIterator it = m_events.find( uid );
337 if ( it != m_events.end() ) 334 if ( it != m_events.end() )
338 todo = it.data(); 335 todo = it.data();
339 336
340 return todo; 337 return todo;
341} 338}
342void OPimTodoAccessXML::clear() { 339void OPimTodoAccessXML::clear() {
343 if (m_opened ) 340 if (m_opened )
344 m_changed = true; 341 m_changed = true;
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index 134a21a..8a71bb7 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -43,25 +43,24 @@ public:
43 * fileName if Empty we will use the default path 43 * fileName if Empty we will use the default path
44 */ 44 */
45 OPimTodoAccessXML( const QString& appName, 45 OPimTodoAccessXML( const QString& appName,
46 const QString& fileName = QString::null ); 46 const QString& fileName = QString::null );
47 ~OPimTodoAccessXML(); 47 ~OPimTodoAccessXML();
48 48
49 bool load(); 49 bool load();
50 bool reload(); 50 bool reload();
51 bool save(); 51 bool save();
52 52
53 QArray<int> allRecords()const; 53 QArray<int> allRecords()const;
54 QArray<int> matchRegexp(const QRegExp &r) const; 54 QArray<int> matchRegexp(const QRegExp &r) const;
55 QArray<int> queryByExample( const OPimTodo&, int querysettings, const QDateTime& d = QDateTime() );
56 OPimTodo find( int uid )const; 55 OPimTodo find( int uid )const;
57 void clear(); 56 void clear();
58 bool add( const OPimTodo& ); 57 bool add( const OPimTodo& );
59 bool remove( int uid ); 58 bool remove( int uid );
60 void removeAllCompleted(); 59 void removeAllCompleted();
61 bool replace( const OPimTodo& ); 60 bool replace( const OPimTodo& );
62 61
63 /* our functions */ 62 /* our functions */
64 QArray<int> effectiveToDos( const QDate& start, 63 QArray<int> effectiveToDos( const QDate& start,
65 const QDate& end, 64 const QDate& end,
66 bool includeNoDates )const; 65 bool includeNoDates )const;
67 QArray<int> overDue()const; 66 QArray<int> overDue()const;