summaryrefslogtreecommitdiff
path: root/libopie2
authoreilers <eilers>2002-11-13 14:14:51 (UTC)
committer eilers <eilers>2002-11-13 14:14:51 (UTC)
commit2255284b2e80bdc2881ab9106e9afa614a08c140 (patch) (side-by-side diff)
tree89e53028d842061371e6414ee037f96fa0fbef5e /libopie2
parenteaecbed44924ece119c5b41db2828b4554f263d2 (diff)
downloadopie-2255284b2e80bdc2881ab9106e9afa614a08c140.zip
opie-2255284b2e80bdc2881ab9106e9afa614a08c140.tar.gz
opie-2255284b2e80bdc2881ab9106e9afa614a08c140.tar.bz2
Added sorted for Contacts..
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp10
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h4
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h32
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp8
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h11
6 files changed, 69 insertions, 0 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index c898f61..821f5bf 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -20,4 +20,7 @@
* History:
* $Log$
+ * Revision 1.4 2002/11/13 14:14:51 eilers
+ * Added sorted for Contacts..
+ *
* Revision 1.3 2002/11/01 15:10:42 eilers
* Added regExp-search in database for all fields in a contact.
@@ -77,4 +80,5 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
virtual bool hasQuerySettings (uint querySettings) const = 0;
+ virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
};
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index faa72b4..09ae37b 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -18,4 +18,7 @@
* History:
* $Log$
+ * Revision 1.4 2002/11/13 14:14:51 eilers
+ * Added sorted for Contacts..
+ *
* Revision 1.3 2002/11/11 16:41:09 kergoth
* no default arguments in implementation
@@ -179,4 +182,11 @@ bool OContactAccessBackend_VCard::wasChangedExternally()
}
+// Not implemented
+QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int )
+{
+ QArray<int> ar(0);
+ return ar;
+}
+
// *** Private stuff ***
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index 177ec24..4437756 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -18,4 +18,7 @@
* History:
* $Log$
+ * Revision 1.3 2002/11/13 14:14:51 eilers
+ * Added sorted for Contacts..
+ *
* Revision 1.2 2002/11/10 15:41:53 eilers
* Bugfixes..
@@ -54,4 +57,5 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
const uint querySettings();
bool hasQuerySettings (uint querySettings) const;
+ QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
bool wasChangedExternally();
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index f7e8207..8b95102 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -18,4 +18,7 @@
* History:
* $Log$
+ * Revision 1.6 2002/11/13 14:14:51 eilers
+ * Added sorted for Contacts..
+ *
* Revision 1.5 2002/11/01 15:10:42 eilers
* Added regExp-search in database for all fields in a contact.
@@ -48,4 +51,5 @@
#include <qregexp.h>
#include <qarray.h>
+#include <qmap.h>
#include <qpe/global.h>
@@ -302,4 +306,32 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
}
+ // Currently only asc implemented..
+ QArray<int> sorted( bool asc, int , int , int )
+ {
+ QMap<QString, int> nameToUid;
+ QStringList names;
+ QArray<int> m_currentQuery( m_contactList.count() );
+
+ // First fill map and StringList with all Names ( better LastNames ? )
+ // Afterwards sort namelist and use map to fill array to return..
+ QValueListConstIterator<OContact> it;
+ for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){
+ names.append( (*it).lastName() );
+ nameToUid.insert( (*it).lastName(), (*it).uid() );
+ }
+ names.sort();
+
+ int i = 0;
+ if ( asc ){
+ for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
+ m_currentQuery[i++] = nameToUid[ (*it) ];
+ }else{
+ for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
+ m_currentQuery[i++] = nameToUid[ (*it) ];
+ }
+
+ return m_currentQuery;
+
+ }
bool add ( const OContact &newcontact )
{
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index f868b53..9c9338e 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -22,4 +22,7 @@
* History:
* $Log$
+ * Revision 1.7 2002/11/13 14:14:51 eilers
+ * Added sorted for Contacts..
+ *
* Revision 1.6 2002/11/01 15:10:42 eilers
* Added regExp-search in database for all fields in a contact.
@@ -138,4 +141,9 @@ bool OContactAccess::hasQuerySettings ( int querySettings ) const
return ( m_backEnd->hasQuerySettings ( querySettings ) );
}
+ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
+{
+ QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
+ return ( ORecordList<OContact>(matchingContacts, this) );
+}
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index b4921d5..961968f 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -18,4 +18,7 @@
* History:
* $Log$
+ * Revision 1.5 2002/11/13 14:14:51 eilers
+ * Added sorted for Contacts..
+ *
* Revision 1.4 2002/11/01 15:10:42 eilers
* Added regExp-search in database for all fields in a contact.
@@ -92,4 +95,12 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
ORecordList<OContact> matchRegexp( const QRegExp &r )const;
+ /** Return all Contacts in a sorted manner.
+ * @param ascending true: Sorted in acending order.
+ * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
+ * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
+ * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
+ */
+ List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
+
/** Return all possible settings.
* @return All settings provided by the current backend