summaryrefslogtreecommitdiff
path: root/libopie
authoreilers <eilers>2002-10-14 16:21:54 (UTC)
committer eilers <eilers>2002-10-14 16:21:54 (UTC)
commitf48ddfb53e49550f9fe8e9502f2a44aeb8b359cc (patch) (side-by-side diff)
tree7972f3fc9a1d61e22fe57ff0fa96fd9a0badb55d /libopie
parentda3868438e739310862bf65b0d0c8ffa864392e8 (diff)
downloadopie-f48ddfb53e49550f9fe8e9502f2a44aeb8b359cc.zip
opie-f48ddfb53e49550f9fe8e9502f2a44aeb8b359cc.tar.gz
opie-f48ddfb53e49550f9fe8e9502f2a44aeb8b359cc.tar.bz2
Some minor interface updates
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/DESIGN6
-rw-r--r--libopie/pim/ocontactaccess.cpp4
-rw-r--r--libopie/pim/ocontactaccess.h49
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.h35
-rw-r--r--libopie/pim/opimaccesstemplate.h12
-rw-r--r--libopie/pim/otodoaccessxml.cpp2
-rw-r--r--libopie/pim/otodoaccessxml.h2
7 files changed, 37 insertions, 73 deletions
diff --git a/libopie/pim/DESIGN b/libopie/pim/DESIGN
index 4def7b9..bd92b1b 100644
--- a/libopie/pim/DESIGN
+++ b/libopie/pim/DESIGN
@@ -47,16 +47,10 @@ You just have to sub class it and voila you're done
Hope you enjoy using OPIE PIM
regards Holger 'zecke' Freyther
-Comment by Stefan Eilers:
-
-The opimaccesstemplate defines "SortOrder":
-I think sortorder is the wrong name for the meaning of it and
-it should be defined by the childs of opimaccesstemplate (every
-implementation may use different values for this..)
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index b5f358b..e8c0a45 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -18,12 +18,15 @@
*
* =====================================================================
* Version: $Id$
* =====================================================================
* History:
* $Log$
+ * Revision 1.4 2002/10/14 16:21:54 eilers
+ * Some minor interface updates
+ *
* Revision 1.3 2002/10/07 17:34:24 eilers
* added OBackendFactory for advanced backend access
*
* Revision 1.2 2002/10/02 16:18:11 eilers
* debugged and seems to work almost perfectly ..
*
@@ -63,13 +66,12 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
m_changed ( false )
{
/* take care of the backend. If there is no one defined, we
* will use the XML-Backend as default (until we have a cute SQL-Backend..).
*/
if( end == 0 ) {
- // __asm__("int3");
qWarning ("Using BackendFactory !");
end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
}
// Set backend locally and in template
m_backEnd = end;
OPimAccessTemplate<OContact>::setBackEnd (end);
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index 54f7f07..adc66cf 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -14,12 +14,15 @@
* ToDo: Define enum for query settings
* =====================================================================
* Version: $Id$
* =====================================================================
* History:
* $Log$
+ * Revision 1.2 2002/10/14 16:21:54 eilers
+ * Some minor interface updates
+ *
* Revision 1.1 2002/09/27 17:11:44 eilers
* Added API for accessing the Contact-Database ! It is compiling, but
* please do not expect that anything is working !
* I will debug that stuff in the next time ..
* Please read README_COMPILE for compiling !
*
@@ -44,73 +47,41 @@
* done by the backend.
*/
class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
{
Q_OBJECT
-
- /* class Iterator{
- friend OContactAccess;
- public:
- Iterator();
- Iterator ( const Iterator& copy );
-
- bool operator== ( const Iterator& it );
- bool operator!= ( const Iterator& it );
- Iterator& operator= ( const Iterator& it );
- Iterator& operator++ (); // prefix
- Iterator operator++ ( int ); // postfix
- Iterator& operator-- (); // prefix
- Iterator operator-- ( int ); // postfix
- Contact operator*() const;
- Contact operator->() const;
-
- Iterator begin();
- Iterator end();
-
- uint count() const;
-
- private:
- QValueList<int> m_uids;
- int m_cur_position;
- bool m_end_reached;
- OContactAccess *m_db;
-
- };
-
- */
-
public:
/** Create Database with contacts (addressbook).
* @param appname Name of application which wants access to the database
* (i.e. "todolist")
* @param filename The name of the database file. If not set, the default one
* is used.
* @param backend Pointer to an alternative Backend. If not set, we will use
* the default backend.
* @param handlesync If <b>true</b> the database stores the current state
* automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
* which are used before and after synchronisation. If the application wants
* to react itself, it should be disabled by setting it to <b>false</b>
- * @see OContactBackend
+ * @see OContactAccessBackend
*/
OContactAccess (const QString appname, const QString filename = 0l,
OContactAccessBackend* backend = 0l, bool handlesync = true);
~OContactAccess ();
/** Constants for query.
* Use this constants to set the query parameters.
* Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
* @see queryByExample()
- * - why not enum - zecke?
- * -> Had some implementation problems .. Will use enum soon ! .. (se)
*/
- static const int query_WildCards = 0x0001;
- static const int query_IgnoreCase = 0x0002;
- static const int query_RegExp = 0x0004;
- static const int query_ExactMatch = 0x0008;
+ enum QuerySettings {
+ WildCards = 0x0001,
+ IgnoreCase = 0x0002,
+ RegExp = 0x0004,
+ ExactMatch = 0x0008,
+ };
/** Return all possible settings.
* @return All settings provided by the current backend
* (i.e.: query_WildCards & query_IgnoreCase)
*/
const uint querySettings();
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h
index 97ef40f..50ea329 100644
--- a/libopie/pim/ocontactaccessbackend_xml.h
+++ b/libopie/pim/ocontactaccessbackend_xml.h
@@ -14,12 +14,15 @@
*
* =====================================================================
* Version: $Id$
* =====================================================================
* History:
* $Log$
+ * Revision 1.3 2002/10/14 16:21:54 eilers
+ * Some minor interface updates
+ *
* Revision 1.2 2002/10/07 17:34:24 eilers
* added OBackendFactory for advanced backend access
*
* Revision 1.1 2002/09/27 17:11:44 eilers
* Added API for accessing the Contact-Database ! It is compiling, but
* please do not expect that anything is working !
@@ -196,31 +199,31 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
* if all fields matches.
*/
bool allcorrect = true;
for ( int i = 0; i < Qtopia::rid; i++ ) {
/* Just compare fields which are not empty in the query object */
if ( !query.field(i).isEmpty() ){
- switch ( settings & ~OContactAccess::query_IgnoreCase ){
- case OContactAccess::query_RegExp:{
+ switch ( settings & ~OContactAccess::IgnoreCase ){
+ case OContactAccess::RegExp:{
QRegExp expr ( query.field(i),
- !(settings & OContactAccess::query_IgnoreCase),
+ !(settings & OContactAccess::IgnoreCase),
false );
if ( expr.find ( (*it).field(i), 0 ) == -1 )
allcorrect = false;
}
break;
- case OContactAccess::query_WildCards:{
+ case OContactAccess::WildCards:{
QRegExp expr ( query.field(i),
- !(settings & OContactAccess::query_IgnoreCase),
+ !(settings & OContactAccess::IgnoreCase),
true );
if ( expr.find ( (*it).field(i), 0 ) == -1 )
allcorrect = false;
}
break;
- case OContactAccess::query_ExactMatch:{
- if (settings & OContactAccess::query_IgnoreCase){
+ case OContactAccess::ExactMatch:{
+ if (settings & OContactAccess::IgnoreCase){
if ( query.field(i).upper() !=
(*it).field(i).upper() )
allcorrect = false;
}else{
if ( query.field(i) != (*it).field(i) )
allcorrect = false;
@@ -240,30 +243,30 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
return m_currentQuery;
}
const uint querySettings()
{
- return ( OContactAccess::query_WildCards
- & OContactAccess::query_IgnoreCase
- & OContactAccess::query_RegExp
- & OContactAccess::query_ExactMatch );
+ return ( OContactAccess::WildCards
+ & OContactAccess::IgnoreCase
+ & OContactAccess::RegExp
+ & OContactAccess::ExactMatch );
}
bool hasQuerySettings (uint querySettings) const
{
- /* OContactAccess::query_IgnoreCase may be added with one
+ /* OContactAccess::IgnoreCase may be added with one
* of the other settings, but never used alone.
* The other settings are just valid alone...
*/
- switch ( querySettings & ~OContactAccess::query_IgnoreCase ){
- case OContactAccess::query_RegExp:
+ switch ( querySettings & ~OContactAccess::IgnoreCase ){
+ case OContactAccess::RegExp:
return ( true );
- case OContactAccess::query_WildCards:
+ case OContactAccess::WildCards:
return ( true );
- case OContactAccess::query_ExactMatch:
+ case OContactAccess::ExactMatch:
return ( true );
default:
return ( false );
}
}
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index a0d8f63..3e1f393 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -24,19 +24,12 @@ class OPimAccessTemplate : public OTemplateBase<T> {
public:
typedef ORecordList<T> List;
typedef OPimAccessBackend<T> BackEnd;
typedef OPimCache<T> Cache;
/**
- * our sort order
- * should be safe explaining
- */
- enum SortOrder { WildCards = 0, IgnoreCase = 1,
- RegExp = 2, ExactMatch = 4 };
-
- /**
* c'tor BackEnd
*/
OPimAccessTemplate( BackEnd* end);
virtual ~OPimAccessTemplate();
/**
@@ -63,15 +56,16 @@ public:
* return a List of records
* you can iterate over them
*/
virtual List allRecords()const;
/**
- * queryByExample
+ * queryByExample)
+ * @see otodoaccess, ocontactaccess
*/
- virtual List queryByExample( const T& t, int sortOrder );
+ virtual List queryByExample( const T& t, int querySettings );
/**
* find the OPimRecord uid
*/
virtual T find( int uid )const;
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index f3b0783..3b4cab2 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -184,13 +184,13 @@ QArray<int> OTodoAccessXML::allRecords()const {
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
ids[i] = it.key();
i++;
}
return ids;
}
-QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) {
+QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int ) {
QArray<int> ids(0);
return ids;
}
OTodo OTodoAccessXML::find( int uid )const {
OTodo todo;
todo.setUid( 0 ); // isEmpty()
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index 1e7e371..dc41c32 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -21,13 +21,13 @@ public:
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
- QArray<int> queryByExample( const OTodo&, int sort );
+ QArray<int> queryByExample( const OTodo&, int querysettings );
OTodo find( int uid )const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
bool replace( const OTodo& );