summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend.cpp
authoreilers <eilers>2005-01-16 19:54:28 (UTC)
committer eilers <eilers>2005-01-16 19:54:28 (UTC)
commit37f290f048eeade1036cd1dc2239d2a98412c54b (patch) (side-by-side diff)
tree04dea39ccf2725f4992d5b8bdbf12807e9a67ae2 /libopie2/opiepim/backend/odatebookaccessbackend.cpp
parent07a4cf7e277aee7097c4da286a2559b717054362 (diff)
downloadopie-37f290f048eeade1036cd1dc2239d2a98412c54b.zip
opie-37f290f048eeade1036cd1dc2239d2a98412c54b.tar.gz
opie-37f290f048eeade1036cd1dc2239d2a98412c54b.tar.bz2
Added new generic sorted for the databook backends. Needed an sortedvector
to do this job, which is now added to private classes..
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp58
1 files changed, 55 insertions, 3 deletions
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 <qtl.h>
+#include <opie2/odebug.h>
#include <opie2/opimrecurrence.h>
-
+#include <opie2/odatebookaccess.h>
#include <opie2/odatebookaccessbackend.h>
+#include <opie2/private/opimeventsortvector.h>
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<int>& )const {
- return UIDArray();
+UIDArray ODateBookAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, int filter, const QArray<int>& 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,