author | eilers <eilers> | 2002-11-01 15:10:42 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-11-01 15:10:42 (UTC) |
commit | 28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f (patch) (side-by-side diff) | |
tree | d5ead4aa63aed345ce406c7857ba1ec7813272db | |
parent | a098735b8749ead08c658792cc31f95e73045107 (diff) | |
download | opie-28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f.zip opie-28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f.tar.gz opie-28b70b2b7f8fa03ba0991fb73dccf7b46e5c3d1f.tar.bz2 |
Added regExp-search in database for all fields in a contact.
-rw-r--r-- | libopie/pim/ocontact.h | 4 | ||||
-rw-r--r-- | libopie/pim/ocontactaccess.cpp | 8 | ||||
-rw-r--r-- | libopie/pim/ocontactaccess.h | 8 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend.h | 7 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend_xml.h | 20 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.h | 7 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 20 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.h | 8 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 4 |
10 files changed, 86 insertions, 8 deletions
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 382ab94..038a59f 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h @@ -106,13 +106,9 @@ public: // other void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } bool match( const QString ®exp ) const; - -// DON'T ATTEMPT TO USE THIS -#ifdef QTOPIA_INTERNAL_CONTACT_MRE bool match( const QRegExp ®exp ) const; -#endif // // custom // void setCustomField( const QString &key, const QString &v ) // { replace(Custom- + key, v ); } diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp index 2ca0283..f868b53 100644 --- a/libopie/pim/ocontactaccess.cpp +++ b/libopie/pim/ocontactaccess.cpp @@ -20,8 +20,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.6 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * Revision 1.5 2002/10/16 10:52:40 eilers * Added some docu to the interface and now using the cache infrastucture by zecke.. :) * * Revision 1.4 2002/10/14 16:21:54 eilers @@ -119,8 +122,13 @@ bool OContactAccess::save () return true; } +ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{ + QArray<int> matchingContacts = m_backEnd -> matchRegexp( r ); + return ( ORecordList<OContact>(matchingContacts, this) ); +} + const uint OContactAccess::querySettings() { return ( m_backEnd->querySettings() ); } diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h index da9c942..b4921d5 100644 --- a/libopie/pim/ocontactaccess.h +++ b/libopie/pim/ocontactaccess.h @@ -16,8 +16,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.4 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * Revision 1.3 2002/10/16 10:52:40 eilers * Added some docu to the interface and now using the cache infrastucture by zecke.. :) * * Revision 1.2 2002/10/14 16:21:54 eilers @@ -47,8 +50,9 @@ /** Class to access the contacts database. * This is just a frontend for the real database handling which is * done by the backend. + * @see OPimAccessTemplate */ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> { Q_OBJECT @@ -80,10 +84,14 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> WildCards = 0x0001, IgnoreCase = 0x0002, RegExp = 0x0004, ExactMatch = 0x0008, + MatchOne = 0x0010 // Only one Entry must match }; + + ORecordList<OContact> matchRegexp( const QRegExp &r )const; + /** Return all possible settings. * @return All settings provided by the current backend * (i.e.: query_WildCards & query_IgnoreCase) */ diff --git a/libopie/pim/ocontactaccessbackend.h b/libopie/pim/ocontactaccessbackend.h index a651477..c898f61 100644 --- a/libopie/pim/ocontactaccessbackend.h +++ b/libopie/pim/ocontactaccessbackend.h @@ -18,8 +18,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.3 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * 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 @@ -37,8 +40,10 @@ #include "ocontact.h" #include "opimaccessbackend.h" +#include "qregexp.h" + class OContactAccessBackend: public OPimAccessBackend<OContact> { public: OContactAccessBackend() {} virtual ~OContactAccessBackend() {} @@ -57,8 +62,10 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> { * in this situation. */ virtual bool wasChangedExternally() = 0; + virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; + /** Return all possible settings. * @return All settings provided by the current backend * (i.e.: query_WildCards & query_IgnoreCase) */ diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h index 12a75ba..f7e8207 100644 --- a/libopie/pim/ocontactaccessbackend_xml.h +++ b/libopie/pim/ocontactaccessbackend_xml.h @@ -16,8 +16,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.5 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * Revision 1.4 2002/10/16 10:52:40 eilers * Added some docu to the interface and now using the cache infrastucture by zecke.. :) * * Revision 1.3 2002/10/14 16:21:54 eilers @@ -253,8 +256,25 @@ class OContactAccessBackend_XML : public OContactAccessBackend { m_currentQuery.resize(arraycounter); return m_currentQuery; } + + QArray<int> matchRegexp( const QRegExp &r ) const{ + QArray<int> m_currentQuery( m_contactList.count() ); + QValueListConstIterator<OContact> it; + uint arraycounter = 0; + + for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ + if ( (*it).match( r ) ){ + m_currentQuery[arraycounter++] = (*it).uid(); + } + + } + // Shrink to fit.. + m_currentQuery.resize(arraycounter); + + return m_currentQuery; + } const uint querySettings() { return ( OContactAccess::WildCards diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index a651477..c898f61 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h @@ -18,8 +18,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.3 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * 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 @@ -37,8 +40,10 @@ #include "ocontact.h" #include "opimaccessbackend.h" +#include "qregexp.h" + class OContactAccessBackend: public OPimAccessBackend<OContact> { public: OContactAccessBackend() {} virtual ~OContactAccessBackend() {} @@ -57,8 +62,10 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> { * in this situation. */ virtual bool wasChangedExternally() = 0; + virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; + /** Return all possible settings. * @return All settings provided by the current backend * (i.e.: query_WildCards & query_IgnoreCase) */ diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index 12a75ba..f7e8207 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h @@ -16,8 +16,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.5 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * Revision 1.4 2002/10/16 10:52:40 eilers * Added some docu to the interface and now using the cache infrastucture by zecke.. :) * * Revision 1.3 2002/10/14 16:21:54 eilers @@ -253,8 +256,25 @@ class OContactAccessBackend_XML : public OContactAccessBackend { m_currentQuery.resize(arraycounter); return m_currentQuery; } + + QArray<int> matchRegexp( const QRegExp &r ) const{ + QArray<int> m_currentQuery( m_contactList.count() ); + QValueListConstIterator<OContact> it; + uint arraycounter = 0; + + for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ + if ( (*it).match( r ) ){ + m_currentQuery[arraycounter++] = (*it).uid(); + } + + } + // Shrink to fit.. + m_currentQuery.resize(arraycounter); + + return m_currentQuery; + } const uint querySettings() { return ( OContactAccess::WildCards diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 2ca0283..f868b53 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp @@ -20,8 +20,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.6 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * Revision 1.5 2002/10/16 10:52:40 eilers * Added some docu to the interface and now using the cache infrastucture by zecke.. :) * * Revision 1.4 2002/10/14 16:21:54 eilers @@ -119,8 +122,13 @@ bool OContactAccess::save () return true; } +ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{ + QArray<int> matchingContacts = m_backEnd -> matchRegexp( r ); + return ( ORecordList<OContact>(matchingContacts, this) ); +} + const uint OContactAccess::querySettings() { return ( m_backEnd->querySettings() ); } diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index da9c942..b4921d5 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h @@ -16,8 +16,11 @@ * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.4 2002/11/01 15:10:42 eilers + * Added regExp-search in database for all fields in a contact. + * * Revision 1.3 2002/10/16 10:52:40 eilers * Added some docu to the interface and now using the cache infrastucture by zecke.. :) * * Revision 1.2 2002/10/14 16:21:54 eilers @@ -47,8 +50,9 @@ /** Class to access the contacts database. * This is just a frontend for the real database handling which is * done by the backend. + * @see OPimAccessTemplate */ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> { Q_OBJECT @@ -80,10 +84,14 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> WildCards = 0x0001, IgnoreCase = 0x0002, RegExp = 0x0004, ExactMatch = 0x0008, + MatchOne = 0x0010 // Only one Entry must match }; + + ORecordList<OContact> matchRegexp( const QRegExp &r )const; + /** Return all possible settings. * @return All settings provided by the current backend * (i.e.: query_WildCards & query_IgnoreCase) */ diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 382ab94..038a59f 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h @@ -106,13 +106,9 @@ public: // other void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } bool match( const QString ®exp ) const; - -// DON'T ATTEMPT TO USE THIS -#ifdef QTOPIA_INTERNAL_CONTACT_MRE bool match( const QRegExp ®exp ) const; -#endif // // custom // void setCustomField( const QString &key, const QString &v ) // { replace(Custom- + key, v ); } |