From 2255284b2e80bdc2881ab9106e9afa614a08c140 Mon Sep 17 00:00:00 2001 From: eilers Date: Wed, 13 Nov 2002 14:14:51 +0000 Subject: Added sorted for Contacts.. --- 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 @@ -21,6 +21,9 @@ * ===================================================================== * 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. * @@ -137,6 +140,11 @@ bool OContactAccess::hasQuerySettings ( int querySettings ) const { return ( m_backEnd->hasQuerySettings ( querySettings ) ); } +ORecordList OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const +{ + QArray matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); + return ( ORecordList(matchingContacts, this) ); +} bool OContactAccess::wasChangedExternally()const 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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. * @@ -91,6 +94,14 @@ class OContactAccess: public QObject, public OPimAccessTemplate ORecordList 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 * (i.e.: query_WildCards & query_IgnoreCase) 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 @@ -19,6 +19,9 @@ * ===================================================================== * 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. * @@ -76,6 +79,7 @@ class OContactAccessBackend: public OPimAccessBackend { */ virtual bool hasQuerySettings (uint querySettings) const = 0; + virtual QArray sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; }; #endif 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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 * @@ -178,6 +181,13 @@ bool OContactAccessBackend_VCard::wasChangedExternally() return false; // Don't expect concurrent access } +// Not implemented +QArray OContactAccessBackend_VCard::sorted( bool , int, int, int ) +{ + QArray 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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.. * @@ -53,6 +56,7 @@ class OContactAccessBackend_VCard : public OContactAccessBackend { const uint querySettings(); bool hasQuerySettings (uint querySettings) const; + QArray sorted( bool ascending, int sortOrder, int sortFilter, int cat ); bool wasChangedExternally(); private: 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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. * @@ -47,6 +50,7 @@ #include #include #include +#include #include @@ -301,6 +305,34 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } } + // Currently only asc implemented.. + QArray sorted( bool asc, int , int , int ) + { + QMap nameToUid; + QStringList names; + QArray 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 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 ) { //qWarning("odefaultbackend: ACTION::ADD"); 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 @@ -19,6 +19,9 @@ * ===================================================================== * 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. * @@ -76,6 +79,7 @@ class OContactAccessBackend: public OPimAccessBackend { */ virtual bool hasQuerySettings (uint querySettings) const = 0; + virtual QArray sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; }; #endif 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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 * @@ -178,6 +181,13 @@ bool OContactAccessBackend_VCard::wasChangedExternally() return false; // Don't expect concurrent access } +// Not implemented +QArray OContactAccessBackend_VCard::sorted( bool , int, int, int ) +{ + QArray 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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.. * @@ -53,6 +56,7 @@ class OContactAccessBackend_VCard : public OContactAccessBackend { const uint querySettings(); bool hasQuerySettings (uint querySettings) const; + QArray sorted( bool ascending, int sortOrder, int sortFilter, int cat ); bool wasChangedExternally(); private: 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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. * @@ -47,6 +50,7 @@ #include #include #include +#include #include @@ -301,6 +305,34 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } } + // Currently only asc implemented.. + QArray sorted( bool asc, int , int , int ) + { + QMap nameToUid; + QStringList names; + QArray 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 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 ) { //qWarning("odefaultbackend: ACTION::ADD"); 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 @@ -21,6 +21,9 @@ * ===================================================================== * 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. * @@ -137,6 +140,11 @@ bool OContactAccess::hasQuerySettings ( int querySettings ) const { return ( m_backEnd->hasQuerySettings ( querySettings ) ); } +ORecordList OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const +{ + QArray matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); + return ( ORecordList(matchingContacts, this) ); +} bool OContactAccess::wasChangedExternally()const 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 @@ -17,6 +17,9 @@ * ===================================================================== * 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. * @@ -91,6 +94,14 @@ class OContactAccess: public QObject, public OPimAccessTemplate ORecordList 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 * (i.e.: query_WildCards & query_IgnoreCase) -- cgit v0.9.0.2