-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.cpp | 5 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.h | 3 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend.cpp | 58 |
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 | |||
@@ -2,3 +2,4 @@ | |||
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2004 Holger Freyther <freyther@handhelds.org> | 3 | Copyright (C) Holger Freyther <freyther@handhelds.org> |
4 | Copyright (C) Stefan Eilers <stefan@eilers-online.net> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
@@ -239,3 +240,3 @@ bool OPimContactAccessBackend::hasQuerySettings (uint querySettings) const | |||
239 | UIDArray OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, | 240 | UIDArray OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, |
240 | int filter, const QArray<int>& categories)const { | 241 | int filter, const QArray<int>& categories )const { |
241 | odebug << "Using Unaccelerated OPimContactAccessBackend sorted Implementation" << oendl; | 242 | odebug << "Using Unaccelerated OPimContactAccessBackend sorted Implementation" << oendl; |
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 | |||
@@ -2,3 +2,4 @@ | |||
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Holger Freyther <freyther@handhelds.org> |
4 | Copyright (C) Stefan Eilers <stefan@eilers-online.net> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
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 | |||
@@ -30,5 +30,7 @@ | |||
30 | 30 | ||
31 | #include <opie2/odebug.h> | ||
31 | #include <opie2/opimrecurrence.h> | 32 | #include <opie2/opimrecurrence.h> |
32 | 33 | #include <opie2/odatebookaccess.h> | |
33 | #include <opie2/odatebookaccessbackend.h> | 34 | #include <opie2/odatebookaccessbackend.h> |
35 | #include <opie2/private/opimeventsortvector.h> | ||
34 | 36 | ||
@@ -146,4 +148,54 @@ UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const | |||
146 | 148 | ||
147 | UIDArray ODateBookAccessBackend::sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const { | 149 | UIDArray ODateBookAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, int filter, const QArray<int>& categories )const { |
148 | return UIDArray(); | 150 | odebug << "Using Unaccelerated ODateBookAccessBackend sorted Implementation" << oendl; |
151 | |||
152 | Internal::OPimEventSortVector vector( ar.count(), asc, sortOrder ); | ||
153 | int item = 0; | ||
154 | |||
155 | for ( uint i = 0; i < ar.count(); ++i ){ | ||
156 | OPimEvent event = find( ar[i], ar, i, Frontend::Forward ); | ||
157 | if ( event.isEmpty() ) | ||
158 | continue; | ||
159 | |||
160 | bool catPassed = true; | ||
161 | if ( filter & ODateBookAccess::FilterCategory ){ | ||
162 | catPassed = false; | ||
163 | // Filter Categories | ||
164 | for ( uint cat_idx = 0; cat_idx < categories.count(); ++cat_idx ){ | ||
165 | int cat = categories[cat_idx]; | ||
166 | if ( cat == -1 || cat == 0 ){ | ||
167 | // Unfiled. Check next category if list is not empty. | ||
168 | // Else: take it as we will not filter unfiled events.. | ||
169 | if ( !event.categories().isEmpty() ) | ||
170 | continue; | ||
171 | else | ||
172 | catPassed = true; | ||
173 | } else { | ||
174 | if ( !event.categories().contains( cat ) ) | ||
175 | continue; | ||
176 | else{ | ||
177 | catPassed = true; | ||
178 | break; | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | |||
184 | // Continue to next event if the category filter removed this item | ||
185 | if ( !catPassed ) | ||
186 | continue; | ||
187 | |||
188 | vector.insert( item++, event ); | ||
189 | } | ||
190 | |||
191 | // Now sort the vector and return the list of UID's | ||
192 | vector.resize( item ); | ||
193 | vector.sort(); | ||
194 | |||
195 | UIDArray array( vector.count() ); | ||
196 | for ( uint i= 0; i < vector.count(); i++ ) | ||
197 | array[i] = vector.uidAt( i ); | ||
198 | |||
199 | return array; | ||
200 | |||
149 | } | 201 | } |