summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.cpp b/libopie2/opiepim/backend/ocontactaccessbackend.cpp
new file mode 100644
index 0000000..6ef60eb
--- a/dev/null
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.cpp
@@ -0,0 +1,121 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) 2004 Holger Freyther <freyther@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#include "ocontactaccessbackend.h"
31#include <opie2/private/opimcontactsortvector.h>
32#include <opie2/ocontactaccess.h>
33
34#include <opie2/odebug.h>
35
36namespace Opie {
37OPimContactAccessBackend::OPimContactAccessBackend() {}
38
39UIDArray
40OPimContactAccessBackend::queryByExample( const OPimContact&, int,
41 const QDateTime& )const {
42 return UIDArray();
43}
44
45UIDArray
46OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder,
47 int filter, const QArray<int>& categories)const {
48 odebug << "Using Unaccelerated OPimContactAccessBackend sorted Implementation" << oendl;
49
50 Internal::OPimContactSortVector vector(ar.count(), asc, sortOrder );
51
52 int item = 0;
53 uint cat_count = categories.count();
54 uint eve_count = ar.count();
55 bool bCat = filter & OPimContactAccess::FilterCategory ? true : false;
56 bool catPassed = false;
57 int cat;
58
59 for ( uint i = 0; i < eve_count; ++i ) {
60 OPimContact contact = find( ar[i], ar, i, Frontend::Forward );
61 if ( contact.isEmpty() )
62 continue;
63
64 /* show category */
65 /* -1 == unfiled */
66 catPassed = false;
67 for ( uint cat_nu = 0; cat_nu < cat_count; ++cat_nu ) {
68 cat = categories[cat_nu];
69 if ( bCat && cat == -1 ) {
70 if(!contact.categories().isEmpty() )
71 continue;
72 } else if ( bCat && cat != 0)
73 if (!contact.categories().contains( cat ) )
74 continue;
75 catPassed = true;
76 break;
77 }
78
79 /*
80 * If none of the Categories matched
81 * continue
82 */
83 if ( !catPassed )
84 continue;
85
86 vector.insert(item++, contact );
87 }
88
89 vector.resize( item );
90 /* sort it now */
91 vector.sort();
92 /* now get the uids */
93 UIDArray array( vector.count() );
94 for (uint i= 0; i < vector.count(); i++ )
95 array[i] = vector.uidAt( i );
96
97 return array;
98}
99
100OPimBackendOccurrence::List OPimContactAccessBackend::occurrences( const QDate& start,
101 const QDate& end)const {
102 OPimBackendOccurrence::List lst;
103
104 UIDArray records = allRecords();
105 const uint count = records.count();
106 int uid;
107
108 for ( uint i = 0; i < count; ++i ) {
109 uid = records[i];
110 OPimContact contact = find(uid, records, i, Frontend::Forward );
111
112 QDate date = contact.anniversary();
113 date = QDate( start.year(), date.month(),date.day() );
114
115// if ( date.isValid() && date.) {
116// }
117 }
118
119 return lst;
120}
121}