summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend
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
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') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.cpp5
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h3
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp58
3 files changed, 60 insertions, 6 deletions
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 <freyther@handhelds.org>
+ Copyright (C) Holger Freyther <freyther@handhelds.org>
+ Copyright (C) Stefan Eilers <stefan@eilers-online.net>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=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<int>& categories)const {
+ int filter, const QArray<int>& 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 <main-author@whereever.org>
+ Copyright (C) Holger Freyther <freyther@handhelds.org>
+ Copyright (C) Stefan Eilers <stefan@eilers-online.net>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=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 <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,