summaryrefslogtreecommitdiff
authoreilers <eilers>2004-12-28 14:19:26 (UTC)
committer eilers <eilers>2004-12-28 14:19:26 (UTC)
commit47c87c92a46f56bc9190025e7a653fa48718431e (patch) (unidiff)
tree2c8d87f8a8132d6b59d56cdb35762a479515b1d1
parent521e3eed02205bca9baca9000ac7ff095a15abde (diff)
downloadopie-47c87c92a46f56bc9190025e7a653fa48718431e.zip
opie-47c87c92a46f56bc9190025e7a653fa48718431e.tar.gz
opie-47c87c92a46f56bc9190025e7a653fa48718431e.tar.bz2
Fixing bug #1501 and preparing for implementation of generic QueryByExample and
sorted for datebook and todo..
Diffstat (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
@@ -2,3 +2,5 @@
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>
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
@@ -82,3 +82,3 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
82 */ 82 */
83 virtual const uint querySettings() const; 83 const uint querySettings() const;
84 84
@@ -88,3 +88,3 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
88 */ 88 */
89 virtual bool hasQuerySettings (uint querySettings) const; 89 bool hasQuerySettings (uint querySettings) const;
90 90
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
@@ -281,3 +281,5 @@ namespace {
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 {
@@ -291,4 +293,2 @@ namespace {
291 293
292
293
294 FindQuery::FindQuery(int uid) 294 FindQuery::FindQuery(int uid)
@@ -302,8 +302,10 @@ namespace {
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 {
@@ -530,3 +532,3 @@ OPimContact OPimContactAccessBackend_SQL::find( int uid, const UIDArray& queryUi
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
@@ -534,2 +536,15 @@ UIDArray OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query
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 ="";
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
@@ -77,3 +77,3 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
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;
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
@@ -102,3 +102,5 @@ OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDate& fr
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() );
@@ -109,3 +111,4 @@ OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime
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;
@@ -118,3 +121,4 @@ OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents(
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() );
@@ -123,5 +127,18 @@ OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents(
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();
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
@@ -96,3 +96,16 @@ public:
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;
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
@@ -77,3 +77,3 @@ public:
77 */ 77 */
78 virtual const uint querySettings() const { return 0; } /* FIXME: Make Abstrakt !! = 0; */ 78 virtual const uint querySettings() const = 0;
79 79
@@ -84,3 +84,3 @@ public:
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 //@}
@@ -92,3 +92,3 @@ public:
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;
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
@@ -44,5 +44,31 @@ OPimTodoAccessBackend::~OPimTodoAccessBackend() {
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}
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
@@ -53,3 +53,16 @@ public:
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;
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
@@ -303,6 +303,8 @@ namespace {
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;
@@ -314,14 +316,22 @@ namespace {
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{
@@ -450,6 +460,6 @@ QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
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{
@@ -621,3 +631,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
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;
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
@@ -55,3 +55,3 @@ public:
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;
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
@@ -328,6 +328,3 @@ QArray<int> OPimTodoAccessXML::allRecords()const {
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 {
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
@@ -54,3 +54,2 @@ public:
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;