summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend
Side-by-side diff
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,19 +1,20 @@
/*
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.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
@@ -224,33 +225,33 @@ bool OPimContactAccessBackend::hasQuerySettings (uint querySettings) const
){
case OPimContactAccess::RegExp:
return ( true );
case OPimContactAccess::WildCards:
return ( true );
case OPimContactAccess::ExactMatch:
return ( true );
case 0: // one of the upper removed bits were set..
return ( true );
default:
return ( false );
}
}
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 );
int item = 0;
uint cat_count = categories.count();
uint eve_count = ar.count();
bool bCat = filter & OPimContactAccess::FilterCategory ? true : false;
bool catPassed = false;
int cat;
for ( uint i = 0; i < eve_count; ++i ) {
OPimContact contact = find( ar[i], ar, i, Frontend::Forward );
if ( contact.isEmpty() )
continue;
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,19 +1,20 @@
/*
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.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
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
@@ -15,35 +15,37 @@
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#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;
namespace {
/* a small helper to get all NonRepeating events for a range of time */
void events( OPimBackendOccurrence::List& tmpList,
const OPimEvent::ValueList& events,
const QDate& from, const QDate& to ) {
QDateTime dtStart, dtEnd;
for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
dtStart = (*it).startDateTime();
dtEnd = (*it).endDateTime();
/*
* If in range
@@ -131,34 +133,84 @@ const uint ODateBookAccessBackend::querySettings() const
}
bool ODateBookAccessBackend::hasQuerySettings (uint querySettings) const
{
return false;
}
UIDArray ODateBookAccessBackend::queryByExample( const UIDArray& uidlist, const OPimEvent&, int settings,
const QDateTime& d )const
{
qDebug( "Accessing ODateBookAccessBackend::queryByExample() which is not implemented!" );
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,
const QDateTime& dt ) {
OPimBackendOccurrence::List tmpList;
OPimBackendOccurrence::List::ConstIterator it;
for ( it = dayList.begin(); it != dayList.end(); ++it ) {
OPimBackendOccurrence occ = *it;
/*
* Let us find occurrences that are 'now'!
* If the dt.date() is on the same day as start or end of the Occurrence
* check how near start/end are.
* If it is in the middle of a multiday occurrence list it.
*