From 37f290f048eeade1036cd1dc2239d2a98412c54b Mon Sep 17 00:00:00 2001 From: eilers Date: Sun, 16 Jan 2005 19:54:28 +0000 Subject: Added new generic sorted for the databook backends. Needed an sortedvector to do this job, which is now added to private classes.. --- (limited to 'libopie2/opiepim/backend') diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.cpp b/libopie2/opiepim/backend/ocontactaccessbackend.cpp index b4fdd46..c09427c 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend.cpp @@ -1,6 +1,7 @@ /* This file is part of the Opie Project - Copyright (C) 2004 Holger Freyther + Copyright (C) Holger Freyther + Copyright (C) Stefan Eilers =. Copyright (C) The Opie Team .=l. .>+-= @@ -237,7 +238,7 @@ bool OPimContactAccessBackend::hasQuerySettings (uint querySettings) const UIDArray OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, - int filter, const QArray& categories)const { + int filter, const QArray& categories )const { odebug << "Using Unaccelerated OPimContactAccessBackend sorted Implementation" << oendl; Internal::OPimContactSortVector vector(ar.count(), asc, sortOrder ); diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index 27d70ab..d5c463b 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h @@ -1,6 +1,7 @@ /* This file is part of the Opie Project - Copyright (C) The Main Author + Copyright (C) Holger Freyther + Copyright (C) Stefan Eilers =. Copyright (C) The Opie Team .=l. .>+-= diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp index e44912a..6da0170 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp @@ -28,9 +28,11 @@ */ #include +#include #include - +#include #include +#include using namespace Opie; @@ -144,8 +146,58 @@ UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const return UIDArray(); } -UIDArray ODateBookAccessBackend::sorted( const UIDArray&, bool asc, int, int, const QArray& )const { - return UIDArray(); +UIDArray ODateBookAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, int filter, const QArray& categories )const { + odebug << "Using Unaccelerated ODateBookAccessBackend sorted Implementation" << oendl; + + Internal::OPimEventSortVector vector( ar.count(), asc, sortOrder ); + int item = 0; + + for ( uint i = 0; i < ar.count(); ++i ){ + OPimEvent event = find( ar[i], ar, i, Frontend::Forward ); + if ( event.isEmpty() ) + continue; + + bool catPassed = true; + if ( filter & ODateBookAccess::FilterCategory ){ + catPassed = false; + // Filter Categories + for ( uint cat_idx = 0; cat_idx < categories.count(); ++cat_idx ){ + int cat = categories[cat_idx]; + if ( cat == -1 || cat == 0 ){ + // Unfiled. Check next category if list is not empty. + // Else: take it as we will not filter unfiled events.. + if ( !event.categories().isEmpty() ) + continue; + else + catPassed = true; + } else { + if ( !event.categories().contains( cat ) ) + continue; + else{ + catPassed = true; + break; + } + } + } + } + + // Continue to next event if the category filter removed this item + if ( !catPassed ) + continue; + + vector.insert( item++, event ); + } + + // Now sort the vector and return the list of UID's + vector.resize( item ); + vector.sort(); + + UIDArray array( vector.count() ); + for ( uint i= 0; i < vector.count(); i++ ) + array[i] = vector.uidAt( i ); + + return array; + } OPimBackendOccurrence::List ODateBookAccessBackend::filterOccurrences( const OPimBackendOccurrence::List dayList, -- cgit v0.9.0.2