summaryrefslogtreecommitdiff
path: root/libopie/pim
Side-by-side diff
Diffstat (limited to 'libopie/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccess.cpp8
-rw-r--r--libopie/pim/ocontactaccess.h11
-rw-r--r--libopie/pim/ocontactaccessbackend.h4
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp10
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.h4
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.h32
6 files changed, 69 insertions, 0 deletions
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index f868b53..9c9338e 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/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/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index b4921d5..961968f 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/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
diff --git a/libopie/pim/ocontactaccessbackend.h b/libopie/pim/ocontactaccessbackend.h
index c898f61..821f5bf 100644
--- a/libopie/pim/ocontactaccessbackend.h
+++ b/libopie/pim/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/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index faa72b4..09ae37b 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/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/libopie/pim/ocontactaccessbackend_vcard.h b/libopie/pim/ocontactaccessbackend_vcard.h
index 177ec24..4437756 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.h
+++ b/libopie/pim/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/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h
index f7e8207..8b95102 100644
--- a/libopie/pim/ocontactaccessbackend_xml.h
+++ b/libopie/pim/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 )
{