summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -1,5 +1,7 @@
2004-12-28 Stefan Eilers <stefan@eilers-online.net>
* Make improved query by example accessable via frontend
- * Some API improvement
+ * Some API documentation improvement
+ * Cleanup of backend api..
+ * Fixing bug #1501
2004-11-23 Stefan Eilers <stefan@eilers-online.net>
* Implement fast and full featured version of sorted() for addressbook
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
@@ -81,5 +81,5 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
* (i.e.: query_WildCards & query_IgnoreCase)
*/
- virtual const uint querySettings() const;
+ const uint querySettings() const;
/**
@@ -87,5 +87,5 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
* @return <i>true</i> if the given settings are correct and possible.
*/
- virtual bool hasQuerySettings (uint querySettings) const;
+ bool hasQuerySettings (uint querySettings) const;
/**
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
@@ -280,5 +280,7 @@ namespace {
RemoveQuery::RemoveQuery(int uid )
: OSQLQuery(), m_uid( uid ) {}
+
RemoveQuery::~RemoveQuery() {}
+
QString RemoveQuery::query()const {
QString qu = "DELETE from addressbook where uid = "
@@ -290,6 +292,4 @@ namespace {
-
-
FindQuery::FindQuery(int uid)
: OSQLQuery(), m_uid( uid ) {
@@ -301,10 +301,12 @@ namespace {
}
QString FindQuery::query()const{
- if ( m_uids.count() == 0 )
- return single();
- else
- return multi();
+ if ( m_uids.count() == 0 )
+ return single();
+ else
+ return multi();
}
+
+
QString FindQuery::multi()const {
QString qu = "select * from addressbook where";
@@ -529,8 +531,21 @@ OPimContact OPimContactAccessBackend_SQL::find( int uid, const UIDArray& queryUi
-UIDArray OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings,
+UIDArray OPimContactAccessBackend_SQL::queryByExample ( const UIDArray& uidlist, const OPimContact &query, int settings,
const QDateTime& qd ) const
{
QString qu = "SELECT uid FROM addressbook WHERE";
+
+ // Just add uid's selection if we really try to search in a subset of all uids! Otherwise this would
+ // just take time and memory!
+ if ( uidlist.count() != m_uids.count() ) {
+ qu += " (";
+
+ for ( uint i = 0; i < uidlist.count(); i++ ) {
+ qu += " uid = " + QString::number( uidlist[i] ) + " OR";
+ }
+ qu.remove( qu.length()-2, 2 ); // Hmmmm..
+ qu += " ) AND ";
+ }
+
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
@@ -76,5 +76,5 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
OPimContact find( int uid, const UIDArray& items, uint cur, Frontend::CacheDirection ) const;
- UIDArray queryByExample ( const OPimContact &query, int settings,
+ UIDArray queryByExample ( const UIDArray& uidlist, const OPimContact &query, int settings,
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
@@ -101,5 +101,7 @@ OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDate& fr
return tmpList;
}
-OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const {
+
+OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const
+{
OPimBackendOccurrence::List day = occurrences( dt.date(), dt.date() );
@@ -108,5 +110,6 @@ OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime
OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from,
- const QDate& to )const {
+ const QDate& to )const
+{
OPimBackendOccurrence::List tmpList;
OPimEvent::ValueList list = directNonRepeats();
@@ -117,12 +120,26 @@ OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents(
}
-OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const {
+OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const
+{
OPimBackendOccurrence::List day = effectiveNonRepeatingEvents( dt.date(), dt.date() );
return filterOccurrences( day,dt );
}
+const uint ODateBookAccessBackend::querySettings() const
+{
+ return 0;
+}
+
+bool ODateBookAccessBackend::hasQuerySettings (uint querySettings) const
+{
+ return false;
+}
+
+
-UIDArray ODateBookAccessBackend::queryByExample( const OPimEvent&, int settings,
- const QDateTime& d )const {
+UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings,
+ const QDateTime& d )const
+{
+ qDebug( "Accessing ODateBookAccessBackend::queryByExample() which is not implemented!" );
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
@@ -95,5 +95,18 @@ public:
*/
//@{
- UIDArray queryByExample( const OPimEvent&, int settings, const QDateTime& d = QDateTime() )const;
+ /**
+ * Return all possible settings.
+ * @return All settings provided by the current backend
+ * (i.e.: query_WildCards & query_IgnoreCase)
+ */
+ const uint querySettings() const;
+
+ /**
+ * Check whether settings are correct.
+ * @return <i>true</i> if the given settings are correct and possible.
+ */
+ bool hasQuerySettings (uint querySettings) const;
+
+ UIDArray queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings, const QDateTime& d = QDateTime() )const;
UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
OPimBackendOccurrence::List occurrences( const QDate&, const QDate& end )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
@@ -76,5 +76,5 @@ public:
* See implementation in the specific backends for contacts, todo and dates.
*/
- virtual const uint querySettings() const { return 0; } /* FIXME: Make Abstrakt !! = 0; */
+ virtual const uint querySettings() const = 0;
/**
@@ -83,5 +83,5 @@ public:
* @return <i>true</i> if the given settings are correct and possible.
*/
- virtual bool hasQuerySettings (uint querySettings) const { return false; } /* FIXME: Make Abstrakt !! = 0; */
+ virtual bool hasQuerySettings (uint querySettings) const = 0;
//@}
@@ -91,5 +91,5 @@ public:
virtual UIDArray matchRegexp(const QRegExp &r) const;
virtual UIDArray queryByExample( const UIDArray&, const T& t,
- int settings, const QDateTime& d = QDateTime() )const { return UIDArray(); } /* FIXME: Make Abstrakt !! = 0; */
+ int settings, const QDateTime& d = QDateTime() )const = 0;
virtual UIDArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() )const;
virtual UIDArray queryByExample( const OPimRecord* rec, 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
@@ -43,7 +43,33 @@ OPimTodoAccessBackend::~OPimTodoAccessBackend() {
}
-UIDArray OPimTodoAccessBackend::queryByExample( const OPimTodo&, int settings,
- const QDateTime& d)const {
- return UIDArray();
+const uint OPimTodoAccessBackend::querySettings() const
+{
+ return 0;
+}
+
+bool OPimTodoAccessBackend::hasQuerySettings (uint querySettings) const
+{
+ return false;
+}
+
+
+UIDArray OPimTodoAccessBackend::queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings,
+ const QDateTime& endperiod )const
+{
+ qDebug( "Accessing OPimTodoAccessBackend::queryByExample() which is not implemented!" );
+ return UIDArray();
+
+// odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl;
+
+// UIDArray m_currentQuery( uid_array.count() );
+// uint arraycounter = 0;
+
+// for( uint it = 0; it < uid_array.count(); ++it ){
+// /* Search all fields and compare them with query object. Store them into list
+// * if all fields matches.
+// */
+// }
+
+
}
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
@@ -52,5 +52,18 @@ public:
*/
//@{
- UIDArray queryByExample( const OPimTodo&, int settings, const QDateTime& d = QDateTime() )const;
+ /**
+ * Return all possible settings.
+ * @return All settings provided by the current backend
+ * (i.e.: query_WildCards & query_IgnoreCase)
+ */
+ const uint querySettings() const;
+
+ /**
+ * Check whether settings are correct.
+ * @return <i>true</i> if the given settings are correct and possible.
+ */
+ bool hasQuerySettings (uint querySettings) const;
+
+ UIDArray queryByExample( const UIDArray& uidlist, const OPimTodo& query, int settings, const QDateTime& endperiod = QDateTime() )const;
UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )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
@@ -302,8 +302,10 @@ namespace {
RemoveQuery::RemoveQuery(int uid )
: OSQLQuery(), m_uid( uid ) {}
+
RemoveQuery::~RemoveQuery() {}
+
QString RemoveQuery::query()const {
QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;";
- qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
+ qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
return qu;
}
@@ -313,16 +315,24 @@ namespace {
: OSQLQuery() {}
ClearQuery::~ClearQuery() {}
- QString ClearQuery::query()const {
- QString qu = "drop table todolist";
- return qu;
+ QString ClearQuery::query()const
+ {
+ QString qu = "drop table todolist";
+ return qu;
}
+
FindQuery::FindQuery(int uid)
- : OSQLQuery(), m_uid(uid ) {
+ : OSQLQuery(), m_uid(uid )
+ {
}
+
FindQuery::FindQuery(const QArray<int>& ints)
- : OSQLQuery(), m_uids(ints){
+ : OSQLQuery(), m_uids(ints)
+ {
}
- FindQuery::~FindQuery() {
+
+ FindQuery::~FindQuery()
+ {
}
+
QString FindQuery::query()const{
if (m_uids.count() == 0 )
@@ -449,8 +459,8 @@ QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
return m_uids;
}
-QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){
- QArray<int> ints(0);
- return ints;
-}
+// QArray<int> OPimTodoAccessBackendSQL::queryByExample( const UIDArray& uidlist, const OPimTodo& , int, const QDateTime& ){
+// QArray<int> ints(0);
+// return ints;
+// }
OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
FindQuery query( uid );
@@ -620,5 +630,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
- if ( str == "0-0-0" )
+ if ( str == "0000-00-00" )
return false;
else{
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
@@ -54,5 +54,5 @@ public:
QArray<UID> allRecords()const;
- QArray<UID> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() );
+/* QArray<UID> queryByExample( const UIDArray& uidlist, const OPimTodo& t, int settings, const QDateTime& d = QDateTime() ); */
OPimTodo find(UID uid)const;
OPimTodo find(UID uid, const QArray<int>&, uint cur, Frontend::CacheDirection )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
@@ -327,8 +327,5 @@ QArray<int> OPimTodoAccessXML::allRecords()const {
return ids;
}
-QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) {
- QArray<int> ids(0);
- return ids;
-}
+
OPimTodo OPimTodoAccessXML::find( int uid )const {
OPimTodo todo;
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
@@ -53,5 +53,4 @@ public:
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
- QArray<int> queryByExample( const OPimTodo&, int querysettings, const QDateTime& d = QDateTime() );
OPimTodo find( int uid )const;
void clear();