summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/backends.pro5
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h42
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.cpp121
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h80
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp26
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h3
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp29
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h5
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp228
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h47
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp15
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.h5
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp12
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h4
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h361
-rw-r--r--libopie2/opiepim/backend/opimbackendoccurrence.cpp241
-rw-r--r--libopie2/opiepim/backend/opimbackendoccurrence.h108
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.cpp114
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h40
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp135
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h37
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp40
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h10
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp316
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h13
25 files changed, 1218 insertions, 819 deletions
diff --git a/libopie2/opiepim/backend/backends.pro b/libopie2/opiepim/backend/backends.pro
index 42d807c..739f74e 100644
--- a/libopie2/opiepim/backend/backends.pro
+++ b/libopie2/opiepim/backend/backends.pro
@@ -1,8 +1,10 @@
1SOURCES += \ 1SOURCES += \
2 backend/ocontactaccessbackend.cpp \
2 backend/ocontactaccessbackend_vcard.cpp \ 3 backend/ocontactaccessbackend_vcard.cpp \
3 backend/ocontactaccessbackend_xml.cpp \ 4 backend/ocontactaccessbackend_xml.cpp \
4 backend/odatebookaccessbackend.cpp \ 5 backend/odatebookaccessbackend.cpp \
5 backend/odatebookaccessbackend_xml.cpp \ 6 backend/odatebookaccessbackend_xml.cpp \
7 backend/opimbackendoccurrence.cpp \
6 backend/otodoaccessbackend.cpp \ 8 backend/otodoaccessbackend.cpp \
7 backend/otodoaccessvcal.cpp \ 9 backend/otodoaccessvcal.cpp \
8 backend/otodoaccessxml.cpp 10 backend/otodoaccessxml.cpp
@@ -14,7 +16,8 @@ HEADERS += \
14 backend/ocontactaccessbackend_xml.h \ 16 backend/ocontactaccessbackend_xml.h \
15 backend/odatebookaccessbackend.h \ 17 backend/odatebookaccessbackend.h \
16 backend/odatebookaccessbackend_xml.h \ 18 backend/odatebookaccessbackend_xml.h \
17 backend/opimaccessbackend.h \ 19 backend/opimaccessbackend.h \
20 backend/opimbackendoccurrence.h \
18 backend/otodoaccessbackend.h \ 21 backend/otodoaccessbackend.h \
19 backend/otodoaccessvcal.h \ 22 backend/otodoaccessvcal.h \
20 backend/otodoaccessxml.h 23 backend/otodoaccessxml.h
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index 9f3a823..25e247b 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -62,9 +62,9 @@ using namespace Opie;
62using namespace Opie::Pim; 62using namespace Opie::Pim;
63 63
64namespace Opie { 64namespace Opie {
65 65
66class OBackendPrivate; 66class OBackendPrivate;
67 67
68/** 68/**
69 * This class is our factory. It will give us the default implementations 69 * This class is our factory. It will give us the default implementations
70 * of at least Todolist, Contacts and Datebook. In the future this class will 70 * of at least Todolist, Contacts and Datebook. In the future this class will
@@ -84,8 +84,8 @@ class OBackendPrivate;
84 class OBackendFactory 84 class OBackendFactory
85 { 85 {
86 public: 86 public:
87 OBackendFactory() {}; 87 OBackendFactory() {};
88 88
89 /** 89 /**
90 * Returns a selected backend implementation 90 * Returns a selected backend implementation
91 * @param type the type of the backend 91 * @param type the type of the backend
@@ -96,16 +96,18 @@ class OBackendPrivate;
96 */ 96 */
97 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, 97 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database,
98 const QString& appName, const QString& filename = QString::null ){ 98 const QString& appName, const QString& filename = QString::null ){
99 owarn << "Selected backend for " << type << " is: " << database << oendl; 99 owarn << "Selected backend for " << type << " is: " <<
100 // If we should use the dafult database style, we have to request it 100database << oendl;
101
102 // If we should use the dafult database style, we have to request it
101 OPimGlobal::DatabaseStyle use_database = database; 103 OPimGlobal::DatabaseStyle use_database = database;
102 if ( use_database == OPimGlobal::DEFAULT ){ 104 if ( use_database == OPimGlobal::DEFAULT ){
103 use_database = defaultDB( type ); 105 use_database = defaultDB( type );
104 } 106 }
105 107
106 switch ( type ){ 108 switch ( type ){
107 case OPimGlobal::TODOLIST: 109 case OPimGlobal::TODOLIST:
108 110
109 switch ( use_database ){ 111 switch ( use_database ){
110 default: // Use SQL if something weird is given. 112 default: // Use SQL if something weird is given.
111 // Fall through !! 113 // Fall through !!
@@ -166,9 +168,9 @@ class OBackendPrivate;
166 default: 168 default:
167 return (T*) NULL; 169 return (T*) NULL;
168 } 170 }
169 171
170 } 172 }
171 173
172 /** 174 /**
173 * Returns the style of the default database which is used to contact PIM data. 175 * Returns the style of the default database which is used to contact PIM data.
174 * @param type the type of the backend 176 * @param type the type of the backend
@@ -189,27 +191,27 @@ class OBackendPrivate;
189 default: 191 default:
190 group_name = "unknown"; 192 group_name = "unknown";
191 } 193 }
192 194
193 Config config( "pimaccess" ); 195 Config config( "pimaccess" );
194 config.setGroup ( group_name ); 196 config.setGroup ( group_name );
195 QString db_String = config.readEntry( "usebackend", "xml" ); 197 QString db_String = config.readEntry( "usebackend", "xml" );
196 198
197 QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); 199 QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle );
198 dictDbTypes.setAutoDelete( TRUE ); 200 dictDbTypes.setAutoDelete( TRUE );
199 201
200 dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); 202 dictDbTypes.insert( "xml", new int (OPimGlobal::XML) );
201 dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); 203 dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) );
202 dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); 204 dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) );
203 205
204 int* db_find = dictDbTypes[ db_String ]; 206 int* db_find = dictDbTypes[ db_String ];
205 207
206 if ( !db_find ) 208 if ( !db_find )
207 return OPimGlobal::UNKNOWN; 209 return OPimGlobal::UNKNOWN;
208 210
209 return (OPimGlobal::DatabaseStyle) *db_find; 211 return (OPimGlobal::DatabaseStyle) *db_find;
210 } 212 }
211 213
212 214
213 /** 215 /**
214 * Returns the default backend implementation for backendName. Which one is used, is defined 216 * Returns the default backend implementation for backendName. Which one is used, is defined
215 * by the configfile "pimaccess.conf". 217 * by the configfile "pimaccess.conf".
@@ -222,9 +224,9 @@ class OBackendPrivate;
222 } 224 }
223 private: 225 private:
224 OBackendPrivate* d; 226 OBackendPrivate* d;
225 227
226 }; 228 };
227 229
228} 230}
229 231
230#endif 232#endif
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}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index 8436adc..efb04c7 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -57,56 +57,50 @@ namespace Opie {
57 */ 57 */
58class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> { 58class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
59 public: 59 public:
60 /** 60 OPimContactAccessBackend();
61 * @todo make non line in regard to BC guide of KDE
62 */
63 OPimContactAccessBackend() {}
64 /**
65 * @todo make non inline in regard to the BC guide of KDE
66 */
67 virtual ~OPimContactAccessBackend() {}
68 61
69 62
70 /** 63 /**
71 * Return if database was changed externally. 64 * Return if database was changed externally.
72 * This may just make sense on file based databases like a XML-File. 65 * This may just make sense on file based databases like a XML-File.
73 * It is used to prevent to overwrite the current database content 66 * It is used to prevent to overwrite the current database content
74 * if the file was already changed by something else ! 67 * if the file was already changed by something else !
75 * If this happens, we have to reload before save our data. 68 * If this happens, we have to reload before save our data.
76 * If we use real databases, this should be handled by the database 69 * If we use real databases, this should be handled by the database
77 * management system themselve, therefore this function should always return false in 70 * management system themselve, therefore this function should always return false in
78 * this case. It is not our problem to handle this conflict ... 71 * this case. It is not our problem to handle this conflict ...
79 * @return <i>true</i> if the database was changed and if save without reload will 72 * @return <i>true</i> if the database was changed and if save without reload will
80 * be dangerous. <i>false</i> if the database was not changed or it is save to write 73 * be dangerous. <i>false</i> if the database was not changed or it is save to write
81 * in this situation. 74 * in this situation.
82 */ 75 */
83 virtual bool wasChangedExternally() = 0; 76 virtual bool wasChangedExternally() = 0;
84 77
85 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; 78 /**
79 * Return all possible settings.
80 * @return All settings provided by the current backend
81 * (i.e.: query_WildCards & query_IgnoreCase)
82 */
83 virtual const uint querySettings() = 0;
86 84
87 /** 85 /**
88 * Return all possible settings. 86 * Check whether settings are correct.
89 * @return All settings provided by the current backend 87 * @return <i>true</i> if the given settings are correct and possible.
90 * (i.e.: query_WildCards & query_IgnoreCase) 88 */
91 */ 89 virtual bool hasQuerySettings (uint querySettings) const = 0;
92 virtual const uint querySettings() = 0; 90
91 /**
92 * Slow and inefficent default implementation
93 */
94//@{
95 UIDArray queryByExample( const OPimContact&, int settings, const QDateTime& d = QDateTime() )const;
96 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
97 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const;
98//@}
93 99
94 /**
95 * Check whether settings are correct.
96 * @return <i>true</i> if the given settings are correct and possible.
97 */
98 virtual bool hasQuerySettings (uint querySettings) const = 0;
99 100
100 /**
101 * FIXME!!!
102 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category
103 */
104 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
105
106
107private: 101private:
108 class Private; 102 class Private;
109 Private *d; 103 Private *d;
110}; 104};
111 105
112} 106}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index af77a05..43e530a 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -167,20 +167,6 @@ QArray<int> OPimContactAccessBackend_VCard::allRecords() const
167 return ar; 167 return ar;
168} 168}
169 169
170// Not implemented
171QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& )
172{
173 QArray<int> ar(0);
174 return ar;
175}
176
177// Not implemented
178QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
179{
180 QArray<int> ar(0);
181 return ar;
182}
183
184const uint OPimContactAccessBackend_VCard::querySettings() 170const uint OPimContactAccessBackend_VCard::querySettings()
185{ 171{
186 return 0; // No search possible 172 return 0; // No search possible
@@ -196,16 +182,7 @@ bool OPimContactAccessBackend_VCard::wasChangedExternally()
196 return false; // Don't expect concurrent access 182 return false; // Don't expect concurrent access
197} 183}
198 184
199// Not implemented
200QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int )
201{
202 QArray<int> ar(0);
203 return ar;
204}
205
206// *** Private stuff *** 185// *** Private stuff ***
207
208
209OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) 186OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
210{ 187{
211 OPimContact c; 188 OPimContact c;
@@ -320,7 +297,6 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
320 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 297 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
321 type |= VOICE; 298 type |= VOICE;
322 299
323 owarn << "value %s %d" << value.data() << type << oendl;
324 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 300 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
325 c.setHomePhone( value ); 301 c.setHomePhone( value );
326 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 302 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
@@ -525,7 +501,6 @@ VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
525 501
526 // Exporting Birthday regarding RFC 2425 (5.8.4) 502 // Exporting Birthday regarding RFC 2425 (5.8.4)
527 if ( c.birthday().isValid() ){ 503 if ( c.birthday().isValid() ){
528 owarn << "Exporting birthday as: " << convDateToVCardDate( c.birthday() ) << "" << oendl;
529 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 504 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
530 } 505 }
531 506
@@ -544,7 +519,6 @@ VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
544 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 519 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
545 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 520 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
546 if ( c.anniversary().isValid() ){ 521 if ( c.anniversary().isValid() ){
547 owarn << "Exporting anniversary as: " << convDateToVCardDate( c.anniversary() ) << "" << oendl;
548 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 522 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
549 } 523 }
550 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 524 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index 2a786af..1faf747 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -59,12 +59,9 @@ class OPimContactAccessBackend_VCard : public OPimContactAccessBackend {
59 59
60 OPimContact find ( int uid ) const; 60 OPimContact find ( int uid ) const;
61 QArray<int> allRecords() const; 61 QArray<int> allRecords() const;
62 QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() );
63 QArray<int> matchRegexp( const QRegExp &r ) const;
64 62
65 const uint querySettings(); 63 const uint querySettings();
66 bool hasQuerySettings (uint querySettings) const; 64 bool hasQuerySettings (uint querySettings) const;
67 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
68 bool wasChangedExternally(); 65 bool wasChangedExternally();
69 66
70private: 67private:
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 18113c2..5df7253 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -108,7 +108,6 @@ bool OPimContactAccessBackend_XML::save()
108 // Write all contacts 108 // Write all contacts
109 QListIterator<OPimContact> it( m_contactList ); 109 QListIterator<OPimContact> it( m_contactList );
110 for ( ; it.current(); ++it ) { 110 for ( ; it.current(); ++it ) {
111 // owarn << " Uid " << (*it)->uid() << " at Offset: " << idx_offset << "" << oendl;
112 out += "<Contact "; 111 out += "<Contact ";
113 (*it)->save( out ); 112 (*it)->save( out );
114 out += "/>\n"; 113 out += "/>\n";
@@ -137,8 +136,6 @@ bool OPimContactAccessBackend_XML::save()
137 // move the file over, I'm just going to use the system call 136 // move the file over, I'm just going to use the system call
138 // because, I don't feel like using QDir. 137 // because, I don't feel like using QDir.
139 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { 138 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
140 owarn << "problem renaming file " << strNewFile << " to " << m_journalName
141 << ", errno: " << errno << oendl;
142 // remove the tmp file... 139 // remove the tmp file...
143 QFile::remove( strNewFile ); 140 QFile::remove( strNewFile );
144 } 141 }
@@ -213,9 +210,8 @@ OPimContact OPimContactAccessBackend_XML::find ( int uid ) const
213} 210}
214 211
215QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings, 212QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings,
216 const QDateTime& d ) 213 const QDateTime& d )const
217{ 214{
218
219 QArray<int> m_currentQuery( m_contactList.count() ); 215 QArray<int> m_currentQuery( m_contactList.count() );
220 QListIterator<OPimContact> it( m_contactList ); 216 QListIterator<OPimContact> it( m_contactList );
221 uint arraycounter = 0; 217 uint arraycounter = 0;
@@ -278,13 +274,10 @@ QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &qu
278 // Check whether the birthday/anniversary date is between 274 // Check whether the birthday/anniversary date is between
279 // the current/given date and the maximum date 275 // the current/given date and the maximum date
280 // ( maximum time range ) ! 276 // ( maximum time range ) !
281 owarn << "Checking if " << checkDate->toString() << " is between " << current.toString()
282 << " and " << queryDate->toString() << " ! " << oendl;
283 if ( current.daysTo( *queryDate ) >= 0 ){ 277 if ( current.daysTo( *queryDate ) >= 0 ){
284 if ( !( ( *checkDate >= current ) && 278 if ( !( ( *checkDate >= current ) &&
285 ( *checkDate <= *queryDate ) ) ){ 279 ( *checkDate <= *queryDate ) ) ){
286 allcorrect = false; 280 allcorrect = false;
287 owarn << " Nope!.." << oendl;
288 } 281 }
289 } 282 }
290 } 283 }
@@ -430,6 +423,7 @@ bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
430 } 423 }
431} 424}
432 425
426#if 0
433// Currently only asc implemented.. 427// Currently only asc implemented..
434QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int ) 428QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
435{ 429{
@@ -458,10 +452,11 @@ QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
458 return m_currentQuery; 452 return m_currentQuery;
459 453
460} 454}
455#endif
456
461 457
462bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact ) 458bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact )
463{ 459{
464 //owarn << "odefaultbackend: ACTION::ADD" << oendl;
465 updateJournal (newcontact, ACTION_ADD); 460 updateJournal (newcontact, ACTION_ADD);
466 addContact_p( newcontact ); 461 addContact_p( newcontact );
467 462
@@ -485,8 +480,6 @@ bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact )
485 m_uidToContact.remove( QString().setNum( contact.uid() ) ); 480 m_uidToContact.remove( QString().setNum( contact.uid() ) );
486 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); 481 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
487 482
488 owarn << "Nur zur Sicherheit: " << contact.uid() << " == " << newCont->uid() << " ?" << oendl;
489
490 return true; 483 return true;
491 } else 484 } else
492 return false; 485 return false;
@@ -591,22 +584,17 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
591 dict.insert( "action", new int(JOURNALACTION) ); 584 dict.insert( "action", new int(JOURNALACTION) );
592 dict.insert( "actionrow", new int(JOURNALROW) ); 585 dict.insert( "actionrow", new int(JOURNALROW) );
593 586
594 //owarn << "OPimContactDefaultBackEnd::loading " << filename << "" << oendl;
595
596 XMLElement *root = XMLElement::load( filename ); 587 XMLElement *root = XMLElement::load( filename );
597 if(root != 0l ){ // start parsing 588 if(root != 0l ){ // start parsing
598 /* Parse all XML-Elements and put the data into the 589 /* Parse all XML-Elements and put the data into the
599 * Contact-Class 590 * Contact-Class
600 */ 591 */
601 XMLElement *element = root->firstChild(); 592 XMLElement *element = root->firstChild();
602 //owarn << "OPimContactAccess::load tagName(): " << root->tagName() << "" << oendl;
603 element = element ? element->firstChild() : 0; 593 element = element ? element->firstChild() : 0;
604 594
605 /* Search Tag "Contacts" which is the parent of all Contacts */ 595 /* Search Tag "Contacts" which is the parent of all Contacts */
606 while( element && !isJournal ){ 596 while( element && !isJournal ){
607 if( element->tagName() != QString::fromLatin1("Contacts") ){ 597 if( element->tagName() != QString::fromLatin1("Contacts") ){
608 //owarn << "OPimContactDefBack::Searching for Tag \"Contacts\"! Found: "
609 // << element->tagName() << oendl;
610 element = element->nextChild(); 598 element = element->nextChild();
611 } else { 599 } else {
612 element = element->firstChild(); 600 element = element->firstChild();
@@ -616,16 +604,12 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
616 /* Parse all Contacts and ignore unknown tags */ 604 /* Parse all Contacts and ignore unknown tags */
617 while( element ){ 605 while( element ){
618 if( element->tagName() != QString::fromLatin1("Contact") ){ 606 if( element->tagName() != QString::fromLatin1("Contact") ){
619 //owarn << "OPimContactDefBack::Searching for Tag \"Contact\"! Found: "
620 // << element->tagName() << oendl;
621 element = element->nextChild(); 607 element = element->nextChild();
622 continue; 608 continue;
623 } 609 }
624 /* Found alement with tagname "contact", now parse and store all 610 /* Found alement with tagname "contact", now parse and store all
625 * attributes contained 611 * attributes contained
626 */ 612 */
627 //owarn << "OPimContactDefBack::load element tagName() : "
628 // << element->tagName() << oendl;
629 QString dummy; 613 QString dummy;
630 foundAction = false; 614 foundAction = false;
631 615
@@ -634,12 +618,9 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
634 contactMap.clear(); 618 contactMap.clear();
635 customMap.clear(); 619 customMap.clear();
636 for( it = aMap.begin(); it != aMap.end(); ++it ){ 620 for( it = aMap.begin(); it != aMap.end(); ++it ){
637 // owarn << "Read Attribute: " << it.key() << "=" << it.data() << oendl;
638
639 int *find = dict[ it.key() ]; 621 int *find = dict[ it.key() ];
640 /* Unknown attributes will be stored as "Custom" elements */ 622 /* Unknown attributes will be stored as "Custom" elements */
641 if ( !find ) { 623 if ( !find ) {
642 // owarn << "Attribute " << it.key() << " not known." << oendl;
643 //contact.setCustomField(it.key(), it.data()); 624 //contact.setCustomField(it.key(), it.data());
644 customMap.insert( it.key(), it.data() ); 625 customMap.insert( it.key(), it.data() );
645 continue; 626 continue;
@@ -704,10 +685,8 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
704 element = element->nextChild(); 685 element = element->nextChild();
705 } 686 }
706 }else { 687 }else {
707 owarn << "ODefBack::could not load" << oendl;
708 } 688 }
709 delete root; 689 delete root;
710 owarn << "returning from loading" << oendl;
711 return true; 690 return true;
712} 691}
713 692
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index eaea352..3e4f1e1 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -62,16 +62,13 @@ class OPimContactAccessBackend_XML : public OPimContactAccessBackend {
62 62
63 OPimContact find ( int uid ) const; 63 OPimContact find ( int uid ) const;
64 64
65 QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() ); 65 QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d )const;
66
67 QArray<int> matchRegexp( const QRegExp &r ) const; 66 QArray<int> matchRegexp( const QRegExp &r ) const;
68 67
69 const uint querySettings(); 68 const uint querySettings();
70 69
71 bool hasQuerySettings (uint querySettings) const; 70 bool hasQuerySettings (uint querySettings) const;
72 71
73 // Currently only asc implemented..
74 QArray<int> sorted( bool asc, int , int , int );
75 bool add ( const OPimContact &newcontact ); 72 bool add ( const OPimContact &newcontact );
76 73
77 bool replace ( const OPimContact &contact ); 74 bool replace ( const OPimContact &contact );
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
index f3b7b5f..73c7059 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -36,118 +36,50 @@ using namespace Opie;
36 36
37namespace { 37namespace {
38/* a small helper to get all NonRepeating events for a range of time */ 38/* a small helper to get all NonRepeating events for a range of time */
39 void events( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& events, 39void events( OPimBackendOccurrence::List& tmpList,
40 const QDate& from, const QDate& to ) { 40 const OPimEvent::ValueList& events,
41 QDateTime dtStart, dtEnd; 41 const QDate& from, const QDate& to ) {
42 42 QDateTime dtStart, dtEnd;
43 for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { 43
44 dtStart = (*it).startDateTime(); 44 for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
45 dtEnd = (*it).endDateTime(); 45 dtStart = (*it).startDateTime();
46 46 dtEnd = (*it).endDateTime();
47 /* 47
48 * If in range 48 /*
49 */ 49 * If in range
50 if (dtStart.date() >= from && dtEnd.date() <= to ) { 50 */
51 OEffectiveEvent eff; 51 if (dtStart.date() >= from && dtEnd.date() <= to ) {
52 eff.setEvent( (*it) ); 52 OPimBackendOccurrence eff( dtStart, dtEnd, (*it).uid() );;
53 eff.setDate( dtStart.date() ); 53 tmpList.append( eff );
54 eff.setStartTime( dtStart.time() );
55
56 /* if not on the same day */
57 if ( dtStart.date() != dtEnd.date() )
58 eff.setEndTime( QTime(23, 59, 0 ) );
59 else
60 eff.setEndTime( dtEnd.time() );
61
62 tmpList.append( eff );
63 }
64
65 /* we must also check for end date information... */
66 if ( dtEnd.date() != dtStart.date() && dtEnd.date() >= from ) {
67 QDateTime dt = dtStart.addDays( 1 );
68 dt.setTime( QTime(0, 0, 0 ) );
69 QDateTime dtStop;
70 if ( dtEnd > to )
71 dtStop = to;
72 else
73 dtStop = dtEnd;
74
75 while ( dt <= dtStop ) {
76 OEffectiveEvent eff;
77 eff.setEvent( (*it) );
78 eff.setDate( dt.date() );
79
80 if ( dt >= from ) {
81 eff.setStartTime( QTime(0, 0, 0 ) );
82 if ( dt.date() == dtEnd.date() )
83 eff.setEndTime( dtEnd.time() );
84 else
85 eff.setEndTime( QTime(23, 59, 0 ) );
86 tmpList.append( eff );
87 }
88 dt = dt.addDays( 1 );
89 }
90 }
91 } 54 }
92 } 55 }
56}
93 57
94 void repeat( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& list, 58void repeat( OPimBackendOccurrence::List& tmpList, const OPimEvent::ValueList& list,
95 const QDate& from, const QDate& to ) { 59 const QDate& from, const QDate& to ) {
96 QDate repeat; 60 QDate repeat;
97 for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { 61 for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
98 int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); 62 int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() );
99 QDate itDate = from.addDays(-dur ); 63 QDate itDate = from.addDays(-dur );
100 OPimRecurrence rec = (*it).recurrence(); 64 OPimRecurrence rec = (*it).recurrence();
101 if ( !rec.hasEndDate() || rec.endDate() > to ) { 65 if ( !rec.hasEndDate() || rec.endDate() > to ) {
102 rec.setEndDate( to ); 66 rec.setEndDate( to );
103 rec.setHasEndDate( true ); 67 rec.setHasEndDate( true );
104 } 68 }
105 while (rec.nextOcurrence(itDate, repeat ) ) { 69
106 if (repeat > to ) break; 70 QDateTime start, end;
107 OEffectiveEvent eff; 71 while (rec.nextOcurrence(itDate, repeat ) ) {
108 eff.setDate( repeat ); 72 if (repeat > to ) break;
109 if ( (*it).isAllDay() ) { 73
110 eff.setStartTime( QTime(0, 0, 0 ) ); 74 OPimEvent event = *it;
111 eff.setEndTime( QTime(23, 59, 59 ) ); 75 start = QDateTime( repeat, event.startDateTime().time() );
112 }else { 76 end = QDateTime( repeat.addDays(dur), event.endDateTime().time() );
113 /* we only occur by days, not hours/minutes/seconds. Hence 77 OPimBackendOccurrence eff(start, end, event.uid() );
114 * the actual end and start times will be the same for 78 tmpList.append( eff );
115 * every repeated event. For multi day events this is
116 * fixed up later if on wronge day span
117 */
118 eff.setStartTime( (*it).startDateTime().time() );
119 eff.setEndTime( (*it).endDateTime().time() );
120 }
121 if ( dur != 0 ) {
122 // multi-day repeating events
123 QDate sub_it = QMAX( repeat, from );
124 QDate startDate = repeat;
125 QDate endDate = startDate.addDays( dur );
126
127 while ( sub_it <= endDate && sub_it <= to ) {
128 OEffectiveEvent tmpEff = eff;
129 tmpEff.setEvent( (*it) );
130 if ( sub_it != startDate )
131 tmpEff.setStartTime( QTime(0, 0, 0 ) );
132 if ( sub_it != endDate )
133 tmpEff.setEndTime( QTime( 23, 59, 59 ) );
134
135 tmpEff.setDate( sub_it );
136 tmpEff.setEffectiveDates( startDate, endDate );
137 tmpList.append( tmpEff );
138
139 sub_it = sub_it.addDays( 1 );
140 }
141 itDate = endDate;
142 }else {
143 eff.setEvent( (*it) );
144 tmpList.append( eff );
145 itDate = repeat.addDays( 1 );
146 }
147 }
148 } 79 }
149 } 80 }
150} 81}
82}
151 83
152namespace Opie { 84namespace Opie {
153 85
@@ -159,58 +91,74 @@ ODateBookAccessBackend::ODateBookAccessBackend()
159ODateBookAccessBackend::~ODateBookAccessBackend() { 91ODateBookAccessBackend::~ODateBookAccessBackend() {
160 92
161} 93}
162OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, 94OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDate& from,
163 const QDate& to ) { 95 const QDate& to )const {
164 OEffectiveEvent::ValueList tmpList; 96 OPimBackendOccurrence::List tmpList;
165 OPimEvent::ValueList list = directNonRepeats();
166 97
167 events( tmpList, list, from, to ); 98 events( tmpList, directNonRepeats(), from, to );
168 repeat( tmpList, directRawRepeats(),from,to ); 99 repeat( tmpList, directRawRepeats(),from,to );
169 100
170 list = directRawRepeats(); // Useless, isn't it ? (eilers)
171
172 qHeapSort( tmpList );
173 return tmpList; 101 return tmpList;
174} 102}
175OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) { 103OPimBackendOccurrence::List ODateBookAccessBackend::occurrences( const QDateTime& dt )const {
176 OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() ); 104 OPimBackendOccurrence::List day = occurrences( dt.date(), dt.date() );
177 OEffectiveEvent::ValueList::Iterator it;
178
179 OEffectiveEvent::ValueList tmpList;
180 QDateTime dtTmp;
181 for ( it = day.begin(); it != day.end(); ++it ) {
182 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
183 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
184 tmpList.append( (*it) );
185 }
186 105
187 return tmpList; 106 return filterOccurrences( day, dt );
188} 107}
189 108
190OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, 109OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from,
191 const QDate& to ) { 110 const QDate& to )const {
192 OEffectiveEvent::ValueList tmpList; 111 OPimBackendOccurrence::List tmpList;
193 OPimEvent::ValueList list = directNonRepeats(); 112 OPimEvent::ValueList list = directNonRepeats();
194 113
195 events( tmpList, list, from, to ); 114 events( tmpList, list, from, to );
196 115
197 qHeapSort( tmpList );
198 return tmpList; 116 return tmpList;
199} 117}
200 118
201OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) { 119OPimBackendOccurrence::List ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt )const {
202 OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); 120 OPimBackendOccurrence::List day = effectiveNonRepeatingEvents( dt.date(), dt.date() );
203 OEffectiveEvent::ValueList::Iterator it; 121 return filterOccurrences( day,dt );
122}
123
124
125UIDArray ODateBookAccessBackend::queryByExample( const OPimEvent&, int settings,
126 const QDateTime& d )const {
127 return UIDArray();
128}
129
130UIDArray ODateBookAccessBackend::sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const {
131 return UIDArray();
132}
204 133
205 OEffectiveEvent::ValueList tmpList; 134OPimBackendOccurrence::List ODateBookAccessBackend::filterOccurrences( const OPimBackendOccurrence::List dayList,
206 QDateTime dtTmp; 135 const QDateTime& dt ) {
207 for ( it = day.begin(); it != day.end(); ++it ) { 136 OPimBackendOccurrence::List tmpList;
208 dtTmp = QDateTime( (*it).date(), (*it).startTime() ); 137 OPimBackendOccurrence::List::ConstIterator it;
209 if ( QABS(dt.secsTo(dtTmp) ) < 60 ) 138
210 tmpList.append( (*it) ); 139 for ( it = dayList.begin(); it != dayList.end(); ++it ) {
140 OPimBackendOccurrence occ = *it;
141
142 /*
143 * Let us find occurrences that are 'now'!
144 * If the dt.date() is on the same day as start or end of the Occurrence
145 * check how near start/end are.
146 * If it is in the middle of a multiday occurrence list it.
147 *
148 * We might want to 'lose' the sixty second offset and list
149 * all Events which are active at that time.
150 */
151 if ( dt.date() == occ.startDateTime().date() ) {
152 if ( QABS( dt.time().secsTo( occ.startDateTime().time() ) ) < 60 )
153 tmpList.append( occ );
154 }else if ( dt.date() == occ.endDateTime().date() ) {
155 if ( QABS( dt.time().secsTo( occ.endDateTime().time() ) ) < 60 )
156 tmpList.append( occ );
157 }else if ( dt.date() >= occ.startDateTime().date() &&
158 dt.date() >= occ.endDateTime().date() )
159 tmpList.append( occ );
211 } 160 }
212 161
213 return tmpList; 162 return tmpList;
214} 163}
215
216} 164}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index a9cce6a..8927ca1 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -42,8 +42,6 @@ namespace Opie {
42 */ 42 */
43class ODateBookAccessBackend : public OPimAccessBackend<OPimEvent> { 43class ODateBookAccessBackend : public OPimAccessBackend<OPimEvent> {
44public: 44public:
45 typedef int UID;
46
47 /** 45 /**
48 * c'tor without parameter 46 * c'tor without parameter
49 */ 47 */
@@ -52,36 +50,29 @@ public:
52 50
53 /** 51 /**
54 * This method should return a list of UIDs containing 52 * This method should return a list of UIDs containing
55 * all events. No filter should be applied
56 * @return list of events
57 */
58 virtual QArray<UID> rawEvents()const = 0;
59
60 /**
61 * This method should return a list of UIDs containing
62 * all repeating events. No filter should be applied 53 * all repeating events. No filter should be applied
63 * @return list of repeating events 54 * @return list of repeating events
64 */ 55 */
65 virtual QArray<UID> rawRepeats()const = 0; 56 virtual UIDArray rawRepeats()const = 0;
66 57
67 /** 58 /**
68 * This mthod should return a list of UIDs containing all non 59 * This mthod should return a list of UIDs containing all non
69 * repeating events. No filter should be applied 60 * repeating events. No filter should be applied
70 * @return list of nonrepeating events 61 * @return list of nonrepeating events
71 */ 62 */
72 virtual QArray<UID> nonRepeats() const = 0; 63 virtual UIDArray nonRepeats() const = 0;
73 64
74 /** 65 /**
75 * If you do not want to implement the effectiveEvents methods below 66 * If you do not want to implement the effectiveEvents methods below
76 * you need to supply it with directNonRepeats. 67 * you need to supply it with directNonRepeats.
77 * This method can return empty lists if effectiveEvents is implememted 68 * This method can return empty lists if effectiveEvents is implememted
78 */ 69 */
79 virtual OPimEvent::ValueList directNonRepeats() = 0; 70 virtual OPimEvent::ValueList directNonRepeats()const = 0;
80 71
81 /** 72 /**
82 * Same as above but return raw repeats! 73 * Same as above but return raw repeats!
83 */ 74 */
84 virtual OPimEvent::ValueList directRawRepeats() = 0; 75 virtual OPimEvent::ValueList directRawRepeats()const = 0;
85 76
86 /* is implemented by default but you can reimplement it*/ 77 /* is implemented by default but you can reimplement it*/
87 /** 78 /**
@@ -89,27 +80,29 @@ public:
89 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method 80 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
90 * yourself 81 * yourself
91 */ 82 */
92 virtual OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ); 83 virtual OPimBackendOccurrence::List effectiveNonRepeatingEvents( const QDate& from, const QDate& to )const;
93 84
94 /** 85 /**
95 * this is an overloaded member function 86 * this is an overloaded member function
96 * @see effectiveEvents( const QDate& from, const QDate& to ) 87 * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to )
97 */
98 virtual OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start );
99
100 /**
101 * Effective Events are special event occuring during a time frame. This method does calcualte
102 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
103 * yourself
104 */ 88 */
105 virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ); 89 virtual OPimBackendOccurrence::List effectiveNonRepeatingEvents( const QDateTime& start )const;
106 90
107 /** 91 /**
108 * this is an overloaded member function 92 * Common and probably inefficent implementation
109 * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) 93 * for queryByExample, sorted
94 * and occurrences
110 */ 95 */
111 virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ); 96//@{
112 97 UIDArray queryByExample( const OPimEvent&, int settings, const QDateTime& d = QDateTime() )const;
98 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
99 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& end )const;
100 OPimBackendOccurrence::List occurrences( const QDateTime& )const;
101//@}
102
103protected:
104 static OPimBackendOccurrence::List filterOccurrences(const OPimBackendOccurrence::List,
105 const QDateTime& time );
113private: 106private:
114 class Private; 107 class Private;
115 Private *d; 108 Private *d;
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 105c106..41b714e 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -167,8 +167,6 @@ bool ODateBookAccessBackend_SQL::load()
167 167
168 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; 168 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
169 169
170 owarn << "command: " << qu << "" << oendl;
171
172 OSQLRawQuery raw( qu ); 170 OSQLRawQuery raw( qu );
173 OSQLResult res = m_driver->query( &raw ); 171 OSQLResult res = m_driver->query( &raw );
174 if ( res.state() != OSQLResult::Success ) 172 if ( res.state() != OSQLResult::Success )
@@ -288,7 +286,6 @@ bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
288 + it.data() //.latin1() 286 + it.data() //.latin1()
289 + "');"; 287 + "');";
290 } 288 }
291 owarn << "add " << qu << "" << oendl;
292 289
293 OSQLRawQuery raw( qu ); 290 OSQLRawQuery raw( qu );
294 OSQLResult res = m_driver->query( &raw ); 291 OSQLResult res = m_driver->query( &raw );
@@ -328,10 +325,6 @@ bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
328 return add( ev ); 325 return add( ev );
329} 326}
330 327
331QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
332{
333 return allRecords();
334}
335 328
336QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const 329QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
337{ 330{
@@ -359,7 +352,7 @@ QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
359 return extractUids( res ); 352 return extractUids( res );
360} 353}
361 354
362OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() 355OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()const
363{ 356{
364 QArray<int> nonRepUids = nonRepeats(); 357 QArray<int> nonRepUids = nonRepeats();
365 OPimEvent::ValueList list; 358 OPimEvent::ValueList list;
@@ -371,7 +364,7 @@ OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
371 return list; 364 return list;
372 365
373} 366}
374OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() 367OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()const
375{ 368{
376 QArray<int> rawRepUids = rawRepeats(); 369 QArray<int> rawRepUids = rawRepeats();
377 OPimEvent::ValueList list; 370 OPimEvent::ValueList list;
@@ -410,20 +403,17 @@ QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
410 403
411QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const 404QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
412{ 405{
413 owarn << "extractUids" << oendl;
414 QTime t; 406 QTime t;
415 t.start(); 407 t.start();
416 OSQLResultItem::ValueList list = res.results(); 408 OSQLResultItem::ValueList list = res.results();
417 OSQLResultItem::ValueList::Iterator it; 409 OSQLResultItem::ValueList::Iterator it;
418 QArray<int> ints(list.count() ); 410 QArray<int> ints(list.count() );
419 owarn << " count = " << list.count() << "" << oendl;
420 411
421 int i = 0; 412 int i = 0;
422 for (it = list.begin(); it != list.end(); ++it ) { 413 for (it = list.begin(); it != list.end(); ++it ) {
423 ints[i] = (*it).data("uid").toInt(); 414 ints[i] = (*it).data("uid").toInt();
424 i++; 415 i++;
425 } 416 }
426 owarn << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
427 417
428 return ints; 418 return ints;
429 419
@@ -440,7 +430,6 @@ QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) cons
440 OSQLResult res_custom = m_driver->query( &query ); 430 OSQLResult res_custom = m_driver->query( &query );
441 431
442 if ( res_custom.state() == OSQLResult::Failure ) { 432 if ( res_custom.state() == OSQLResult::Failure ) {
443 owarn << "OSQLResult::Failure in find query !!" << oendl;
444 QMap<QString, QString> empty; 433 QMap<QString, QString> empty;
445 return empty; 434 return empty;
446 } 435 }
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
index b624159..a649d25 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
@@ -66,12 +66,11 @@ public:
66 bool remove( int uid ); 66 bool remove( int uid );
67 bool replace( const OPimEvent& ev ); 67 bool replace( const OPimEvent& ev );
68 68
69 QArray<UID> rawEvents()const;
70 QArray<UID> rawRepeats()const; 69 QArray<UID> rawRepeats()const;
71 QArray<UID> nonRepeats()const; 70 QArray<UID> nonRepeats()const;
72 71
73 OPimEvent::ValueList directNonRepeats(); 72 OPimEvent::ValueList directNonRepeats()const;
74 OPimEvent::ValueList directRawRepeats(); 73 OPimEvent::ValueList directRawRepeats()const;
75 74
76private: 75private:
77 bool loadFile(); 76 bool loadFile();
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 0f99d50..55e47e2 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -122,7 +122,6 @@ namespace {
122 122
123 // FIXME: Use OPimEvent::toMap() here !! (eilers) 123 // FIXME: Use OPimEvent::toMap() here !! (eilers)
124 static void save( const OPimEvent& ev, QString& buf ) { 124 static void save( const OPimEvent& ev, QString& buf ) {
125 owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl;
126 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; 125 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\"";
127 if (!ev.location().isEmpty() ) 126 if (!ev.location().isEmpty() )
128 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; 127 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\"";
@@ -326,9 +325,7 @@ bool ODateBookAccessBackend_XML::replace( const OPimEvent& ev ) {
326 replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) 325 replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers)
327 return add( ev ); 326 return add( ev );
328} 327}
329QArray<int> ODateBookAccessBackend_XML::rawEvents()const { 328
330 return allRecords();
331}
332QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { 329QArray<int> ODateBookAccessBackend_XML::rawRepeats()const {
333 QArray<int> ints( m_rep.count() ); 330 QArray<int> ints( m_rep.count() );
334 uint i = 0; 331 uint i = 0;
@@ -353,7 +350,7 @@ QArray<int> ODateBookAccessBackend_XML::nonRepeats()const {
353 350
354 return ints; 351 return ints;
355} 352}
356OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { 353OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats()const {
357 OPimEvent::ValueList list; 354 OPimEvent::ValueList list;
358 QMap<int, OPimEvent>::ConstIterator it; 355 QMap<int, OPimEvent>::ConstIterator it;
359 for (it = m_raw.begin(); it != m_raw.end(); ++it ) 356 for (it = m_raw.begin(); it != m_raw.end(); ++it )
@@ -361,7 +358,7 @@ OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() {
361 358
362 return list; 359 return list;
363} 360}
364OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { 361OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats()const {
365 OPimEvent::ValueList list; 362 OPimEvent::ValueList list;
366 QMap<int, OPimEvent>::ConstIterator it; 363 QMap<int, OPimEvent>::ConstIterator it;
367 for (it = m_rep.begin(); it != m_rep.end(); ++it ) 364 for (it = m_rep.begin(); it != m_rep.end(); ++it )
@@ -539,7 +536,6 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
539 ev.notifiers().add( al ); 536 ev.notifiers().add( al );
540 } 537 }
541 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 538 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
542 owarn << "already contains assign uid" << oendl;
543 ev.setUid( 1 ); 539 ev.setUid( 1 );
544 } 540 }
545 541
@@ -550,7 +546,6 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
550 546
551} 547}
552void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) { 548void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) {
553// owarn << " setting " << value << "" << oendl;
554 switch( id ) { 549 switch( id ) {
555 case FDescription: 550 case FDescription:
556 e.setDescription( value ); 551 e.setDescription( value );
@@ -634,7 +629,6 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString&
634 QStringList list = QStringList::split(' ', value ); 629 QStringList list = QStringList::split(' ', value );
635 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 630 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
636 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 631 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
637 owarn << "adding exception " << date.toString() << "" << oendl;
638 recur()->exceptions().append( date ); 632 recur()->exceptions().append( date );
639 } 633 }
640 } 634 }
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index af5b114..cb19f76 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -63,8 +63,8 @@ public:
63 QArray<UID> rawRepeats()const; 63 QArray<UID> rawRepeats()const;
64 QArray<UID> nonRepeats()const; 64 QArray<UID> nonRepeats()const;
65 65
66 OPimEvent::ValueList directNonRepeats(); 66 OPimEvent::ValueList directNonRepeats()const;
67 OPimEvent::ValueList directRawRepeats(); 67 OPimEvent::ValueList directRawRepeats()const;
68 68
69private: 69private:
70 bool m_changed :1 ; 70 bool m_changed :1 ;
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 26af762..0d112c9 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -34,92 +34,66 @@
34 34
35#include <opie2/opimtemplatebase.h> 35#include <opie2/opimtemplatebase.h>
36#include <opie2/opimrecord.h> 36#include <opie2/opimrecord.h>
37 37#include <opie2/opimbackendoccurrence.h>
38 38
39namespace Opie { 39namespace Opie {
40class OPimAccessBackendPrivate; 40class OPimAccessBackendPrivate;
41
41/** 42/**
42 * OPimAccessBackend is the base class 43 * OPimAccessBackend is the Backend Interface to be used
43 * for all private backends 44 * by OTemplateBase based Frontends.
44 * it operates on OPimRecord as the base class 45 * For efficency reasons and to support delayed loading
45 * and it's responsible for fast manipulating 46 * most of the Frontend functions can be implemented
46 * the resource the implementation takes care 47 * by this backend.
47 * of 48 * This allows to utilise the best method on each backend.
49 * For example we can use SQL queries instead of self made
50 * query which is first more efficent and also uses less memory.
48 */ 51 */
49template <class T = OPimRecord> 52template <class T = OPimRecord>
50class OPimAccessBackend { 53class OPimAccessBackend {
51public: 54public:
52 typedef OTemplateBase<T> Frontend; 55 typedef OTemplateBase<T> Frontend;
53 56
54 /** The access hint from the frontend */ 57 //@{
55 OPimAccessBackend(int access = 0); 58 OPimAccessBackend(int access = 0);
56 virtual ~OPimAccessBackend(); 59 virtual ~OPimAccessBackend();
60 //@}
57 61
58 /** 62 //@{
59 * load the resource
60 */
61 virtual bool load() = 0; 63 virtual bool load() = 0;
62
63 /**
64 * reload the resource
65 */
66 virtual bool reload() = 0; 64 virtual bool reload() = 0;
67
68 /**
69 * save the resource and
70 * all it's changes
71 */
72 virtual bool save() = 0; 65 virtual bool save() = 0;
66 virtual void clear() = 0;
67 //@}
73 68
74 /**
75 * return an array of
76 * all available uids
77 */
78 virtual QArray<int> allRecords()const = 0;
79 69
80 /** 70 //@{
81 * return a List of records 71 virtual UIDArray allRecords()const = 0;
82 * that match the regex 72 virtual UIDArray matchRegexp(const QRegExp &r) const;
83 */ 73 virtual UIDArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() )const = 0;
84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 74 virtual UIDArray queryByExample( const OPimRecord* rec, int, const QDateTime& d = QDateTime() )const;
75 virtual UIDArray sorted( const UIDArray&, bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const;
76 virtual UIDArray sorted( bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const;
77 virtual OPimBackendOccurrence::List occurrences( const QDate& start, const QDate& end)const;
78 virtual OPimBackendOccurrence::List occurrences( const QDateTime& dt )const;
79 //@}
85 80
86 /**
87 * queryByExample for T with the given Settings
88 *
89 */
90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
91 81
92 /** 82 //@{
93 * find the OPimRecord with uid @param uid 83 virtual T find(UID uid )const = 0;
94 * returns T and T.isEmpty() if nothing was found 84 virtual T find(UID uid, const QArray<UID>& items,
95 */ 85 uint current, typename Frontend::CacheDirection )const ;
96 virtual T find( int uid )const = 0; 86 //@}
97 87
98 virtual T find( int uid, const QArray<int>& items,
99 uint current, typename Frontend::CacheDirection ) const;
100 /**
101 * clear the back end
102 */
103 virtual void clear() = 0;
104 88
105 /** 89 //@{
106 * add T
107 */
108 virtual bool add( const T& t ) = 0; 90 virtual bool add( const T& t ) = 0;
91 virtual bool remove( UID uid ) = 0;
92 virtual bool replace( const T& t ) = 0;
93 //@}
109 94
110 /**
111 * remove
112 */
113 virtual bool remove( int uid ) = 0;
114 95
115 /**
116 * replace a record with T.uid()
117 */
118 virtual bool replace( const T& t ) = 0;
119 96
120 /*
121 * setTheFrontEnd!!!
122 */
123 void setFrontend( Frontend* front ); 97 void setFrontend( Frontend* front );
124 98
125 /** 99 /**
@@ -127,16 +101,12 @@ public:
127 */ 101 */
128 void setReadAhead( uint count ); 102 void setReadAhead( uint count );
129protected: 103protected:
104 //@{
130 int access()const; 105 int access()const;
131
132 void cache( const T& t )const; 106 void cache( const T& t )const;
133
134 /**
135 * use a prime number here!
136 */
137 void setSaneCacheSize( int ); 107 void setSaneCacheSize( int );
138
139 uint readAhead()const; 108 uint readAhead()const;
109 //@}
140 110
141private: 111private:
142 OPimAccessBackendPrivate *d; 112 OPimAccessBackendPrivate *d;
@@ -156,6 +126,64 @@ template <class T>
156OPimAccessBackend<T>::~OPimAccessBackend() { 126OPimAccessBackend<T>::~OPimAccessBackend() {
157 127
158} 128}
129
130/*
131 * Slow but default matchRegexp Implementation
132 * Create a Big Enough QArray and then iterate
133 * over all Records and matchRegexp them.
134 * At the end we will resize the array to the actual
135 * number of items
136 */
137template <class T>
138UIDArray OPimAccessBackend<T>::matchRegexp( const QRegExp& reg )const {
139 UIDArray all_rec = allRecords();
140 UIDArray result( all_rec.count() );
141 uint used_records = 0, all_rec_count = all_rec.count();
142
143 for ( uint i = 0; i < all_rec_count; ++i )
144 if (find( all_rec[i], all_rec, i, Frontend::Forward ).match( reg ) )
145 result[used_records++] = all_rec[i];
146
147 /* shrink to fit */
148 result.resize( used_records );
149 return result;
150}
151
152template <class T>
153UIDArray OPimAccessBackend<T>::queryByExample( const OPimRecord* rec, int settings,
154 const QDateTime& datetime )const {
155 T* tmp_rec = T::safeCast( rec );
156 UIDArray ar;
157 if ( tmp_rec )
158 ar = queryByExample( *tmp_rec, settings, datetime );
159
160 return ar;
161}
162
163template <class T>
164UIDArray OPimAccessBackend<T>::sorted( const UIDArray& ids, bool,
165 int, int, const QArray<int>& ) const {
166 return ids;
167}
168
169template <class T>
170UIDArray OPimAccessBackend<T>::sorted( bool asc, int order, int filter,
171 const QArray<int>& cats )const {
172 return sorted( allRecords(), asc, order, filter, cats );
173}
174
175template<class T>
176OPimBackendOccurrence::List OPimAccessBackend<T>::occurrences( const QDate&,
177 const QDate& )const {
178 return OPimBackendOccurrence::List();
179}
180
181template<class T>
182OPimBackendOccurrence::List OPimAccessBackend<T>::occurrences( const QDateTime& dt )const {
183 QDate date = dt.date();
184 return occurrences( date, date );
185}
186
159template <class T> 187template <class T>
160void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 188void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
161 m_front = fr; 189 m_front = fr;
@@ -166,7 +194,6 @@ void OPimAccessBackend<T>::cache( const T& t )const {
166 m_front->cache( t ); 194 m_front->cache( t );
167} 195}
168 196
169
170template <class T> 197template <class T>
171void OPimAccessBackend<T>::setSaneCacheSize( int size) { 198void OPimAccessBackend<T>::setSaneCacheSize( int size) {
172 if ( m_front ) 199 if ( m_front )
@@ -193,4 +220,204 @@ int OPimAccessBackend<T>::access()const {
193 220
194} 221}
195 222
223/**
224 * \fn template <class T> OPimAccessBackend<T>::OPimAccessBackend(int hint )
225 * @param hint The access hint from the frontend
226 */
227
228/**
229 * \fn template <class T> bool OPimAccessBackend<T>::load()
230 * Opens the DataBase and does necessary
231 * initialisation of internal structures.
232 *
233 * @return true If the DataBase could be opened and
234 * Information was successfully loaded
235 */
236
237/**
238 * \fn template <class T> bool OPimAccessBackend<T>::reload()
239 * Reinitialise the DataBase and merges the external changes
240 * with your local changes.
241 *
242 * @return True if the DataBase was reloaded.
243 *
244 */
245
246/**
247 * \fn template <class T> bool OPimAccessBackend<T>::save()
248 *
249 * Save the changes to storage. In case of memory or
250 * disk shortage, return false.
251 *
252 *
253 * @return True if the DataBase could be saved to storage.
254 */
255
256/**
257 * \fn template <class T> bool OPimAccessBackend<T>::clear()
258 * Until a \sa save() changes shouldn't be comitted
259 *
260 *
261 * @return True if the DataBase could be cleared
262 * @todo Introduce a 'Commit'
263 */
264
265/**
266 * \fn template <class T> QArray<UID> OPimAccessBackend<T>::allRecords()const
267 * Return an array of all available uids in the loaded
268 * DataBase.
269 * @see load
270 */
271
272/**
273 * \fn template <class T> QArray<UID> OPimAccessBackend<T>::matchRegexp(const QRegExp& r)const
274 * Return a List of records that match the regex \par r.
275 *
276 * @param r The QRegExp to match.
277 */
278
279/**
280 * \fn template <class T> QArray<UID> OPimAccessBackend<T>::queryByExample(const T& t, int settings, const QDateTime& d = QDateTime() )
281 *
282 * Implement QueryByExample. An Example record is filled and with the
283 * settings and QDateTime it is determined how the query should be executed.
284 * Return a list of UIDs that match the Example
285 *
286 * @param t The Example record
287 * @param settings Gives
288 *
289 */
290
291/**
292 * \fn template<class T> QArray<UID> OPimAccessBackend<T>::sorted(const QArray<UID>& ids, bool asc, int sortOrder, int sortFilter, int cat)
293 * \brief Sort the List of records according to the preference
294 *
295 * Implement sorting in your backend. The default implementation is
296 * to return the list as it was passed.
297 * The default Backend Implementation should do unaccelerated filtering
298 *
299 *
300 * @param ids The Records to sort
301 * @param asc Sort ascending or descending
302 * @param sortOrder
303 * @param sortFilter Sort filter
304 * @param cat The Category to include
305 */
306
307/**
308 * \fn template <class T> T OPimAccessBackend<T>::find(UID uid)const
309 * \brief Find the Record with the UID
310 *
311 * Find the UID in the database and return the record.
312 * @param uid The uid to be searched for
313 * @return The record or an empty record (T.isEmpty())
314 *
315 */
316
317/**
318 * \fn template <class T> T OPimAccessBackend<T>::find( UID uid, const QArray<UID>& items, uint current, typename Frontend::CacheDirection d)const
319 * \brief find a Record and do a read ahead or read behind
320 *
321 * @param uid The UID to search for
322 * @param items The list of items from where your search
323 * @param current The index of \param uid
324 * @param d The direction to search for
325 *
326 * @see find
327 */
328
329
330/**
331 * \fn template<class T> bool OPimAccessBackend<T>::add(const T& t)
332 *
333 * \brief Add the record to the internal database
334 *
335 * If an record with the same t.uid() is already present internally
336 * the behaviour is undefined but the state of the database
337 * needs to be stable.
338 * For modifying a record use \sa replace.
339 *
340 *
341 * @return true if the record could be added or false if not
342 * @todo Eilers your opinion on readd/replace
343 */
344
345/**
346 * \fn template<class T> bool OPimAccessBackend<T>::remove(UID uid)
347 * \brief Remove a record by its UID
348 *
349 * Remove the records with UID from the internal Database.
350 *
351 * @return True if the record could be removed.
352 *
353 */
354
355/**
356 * \fn template<class T> bool OPimAccessBackend<T>::replace(const T& t)
357 * \brief Take this Record and replace the old version.
358 *
359 * Take \param t as the new record for t.uid(). It is not described
360 * what happens if the record is not present in the database.
361 * Normally the record is determined by the UID.
362 *
363 * @param t The record to use internally.
364 */
365
366/**
367 * \fn template<class T> void OPimAccessBackend<T>::setFrontend( Frontend* fron)
368 * \@aram fron The Frontend that uses this backend
369 *
370 * This function is called by the frontend and is used
371 */
372
373/**
374 * \fn template<class T> void OPimAccessBackend<T>::setReadAhead(uint count)
375 * \brief Set the number of items to Read-Ahead/Read-Behind
376 *
377 * @param count The number of records to read ahead
378 */
379
380/**
381 * \fn template<class T> void OPimAccessBackend<T>::cache( const T& t)const
382 * \brief Add the Record to the PIM Cache
383 *
384 * This will add the Record to the PIM cache, which is owned
385 * by the FrontEnd. If no FrontEnd is available the item will
386 * not be cached.
387 *
388 *
389 * @param t The Item to be added to the Cache
390 */
391
392/**
393 * \fn template<class T> void OPimAccessBackend<T>::setSaneCacheSize(int items)
394 * \brief Give a hint on the number of too cached items
395 *
396 * Give the Frontend a hint on the number of items to be cached. Use
397 * a prime number for best performance.
398 *
399 * @param items The number of items to be cached
400 */
401
402/**
403 * \fn template<class T> uint OPimAccessBackend<T>::readAhead()const
404 * \brief Return the number of Items to be ReadAhead
405 *
406 * @return The number of Items to read ahead/read behind
407 */
408
409/**
410 * \fn template<class T> QArray<OPimBackendOccurence> OPimAccessBackend<T>::occurrences(const QDateTime& start,const QDateTime& end)
411 * \brief Get a List of Occurrences for a period of time
412 *
413 * Return an Array of OPimBackendOccurence for a period of time. If start == end date
414 * return only occurrences for the start date. If end is smaller the start date
415 * the result is not defined. You could switch dates or return an empty list.
416 *
417 * @return Return an array of OPimBackendOccurence for the period specified by the parameters
418 * @param start The start of the period.
419 * @param end The end of the period.
420 *
421 */
422
196#endif 423#endif
diff --git a/libopie2/opiepim/backend/opimbackendoccurrence.cpp b/libopie2/opiepim/backend/opimbackendoccurrence.cpp
new file mode 100644
index 0000000..8af930d
--- a/dev/null
+++ b/libopie2/opiepim/backend/opimbackendoccurrence.cpp
@@ -0,0 +1,241 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) 2004 Holger Hans Peter Freyther <zecke@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 "opimbackendoccurrence.h"
31
32namespace Opie {
33
34OPimBackendOccurrence::OPimBackendOccurrence() {}
35/**
36 * \brief The occurence is only on the specefic Day
37 *
38 * If an occurrence is only a day without any time associated
39 * use this Constructor.
40 * \sa timeAssociated() will return false.
41 *
42 * @param date The Date this Occurence takes place
43 * @param uid The \sa UID of the associated OPimRecord
44 * @param sum The optional summary
45 *
46 */
47OPimBackendOccurrence::OPimBackendOccurrence( const QDate& date,
48 const UID& uid,
49 const QString& sum )
50 : m_start( date ), m_end( date ), m_uid( uid ),
51 m_haveTime(false ), m_summary( sum )
52{}
53
54/**
55 * \brief An Occurrence with a start day and end day without time
56 *
57 * Overloaded Constructor. Use this if you've a start date and
58 * end date but no time. If you need to overwrite the summary
59 * use setSummary.
60 * \sa timeAssociated() will return false.
61 *
62 * @param date The Start Date
63 * @param end Tne End Date
64 * @param uid The UID of the associated record
65 *
66 * @see setSummary
67 */
68OPimBackendOccurrence::OPimBackendOccurrence( const QDate& date,
69 const QDate& end,
70 const UID& uid)
71 : m_start( date ), m_end( end ), m_uid( uid ), m_haveTime( false )
72{}
73
74
75/**
76 * \brief Use Start and End Date with Time
77 *
78 * Overloaded Constructor to use Dates with Time time associated
79 * to it. \sa timeAssociated() will return true.
80 *
81 * @param date The Start Date and Time of the occurrence
82 * @param end The End Date and Time of the occurrence
83 * @param uid The UID of the \sa OPimRecord.
84 */
85OPimBackendOccurrence::OPimBackendOccurrence( const QDateTime& date,
86 const QDateTime& end,
87 const UID& uid )
88 : m_start( date ), m_end( end ), m_uid( uid ), m_haveTime( true )
89{}
90
91/**
92 * \brief Return the Start Date and Time
93 *
94 * @return This method will return the start
95 * Date and Time. Time is only valid if
96 * \sa timeAssociated() is true.
97 *
98 */
99QDateTime OPimBackendOccurrence::startDateTime()const {
100 return m_start;
101}
102
103/**
104 * \brief Return the Start Date and Time
105 *
106 * @return This will return the end Date and Time. The
107 * limitation for Time is the same as in startDateTime
108 *
109 * @see startDateTime()
110 */
111QDateTime OPimBackendOccurrence::endDateTime()const {
112 return m_end;
113}
114
115/**
116 * \brief Return the UID of the Associated OPimRecord
117 *
118 * @return the associated OPimRecord
119 */
120UID OPimBackendOccurrence::uid()const {
121 return m_uid;
122}
123
124/**
125 * \brief Return if there is a time associated or not
126 *
127 * If a time is present with start and end date this method
128 * will return true. There is no direct way to manipulate
129 * that attribute. But \sa setStartDate and \sa setStartDateTime
130 * will change it.
131 *
132 * @return Return true if a time is available with the date
133 *
134 */
135bool OPimBackendOccurrence::isAllDay()const {
136 return m_haveTime;
137}
138
139/**
140 * @return The special summary that will overwrite OPimRecord::summary
141 */
142QString OPimBackendOccurrence::summary()const {
143 return m_summary;
144}
145
146QString OPimBackendOccurrence::location()const {
147 return m_location;
148}
149
150QString OPimBackendOccurrence::note()const {
151 return m_note;
152}
153
154/**
155 * \brief Set the Start Date
156 *
157 * This method will set the start date and internally will mark
158 * this occurrence to have no time associated to both start
159 * and end date.
160 * A call to timeAssociated will return false after using this
161 * method.
162 *
163 * @param start The Start Date
164 *
165 */
166void OPimBackendOccurrence::setStartDate( const QDate& start) {
167 m_start = start;
168 m_haveTime = false;
169}
170
171/**
172 * \brief Set the Start Date and Time
173 *
174 * Set the Start Date and Time. After this call
175 * \sa timeAssociated will return true.
176 *
177 * @param dt The Start Date and Time to be set
178 */
179void OPimBackendOccurrence::setStartDateTime( const QDateTime& dt ) {
180 m_start = dt;
181 m_haveTime = true;
182}
183
184/**
185 * \brief This will set the End Date.
186 *
187 * This method will set the End Date. The timeAssociated attribute
188 * will not be changed.
189 *
190 * @param end The End Date to be set
191 */
192void OPimBackendOccurrence::setEndDate( const QDate& end ) {
193 m_end = end;
194}
195
196/**
197 * \brief Set the End Date and Time of the occurrence
198 *
199 * This will set the End Date and Time but will not change
200 * the timeAssociated attribute.
201 *
202 * @param dt The End Date and Time to be set.
203 */
204void OPimBackendOccurrence::setEndDateTime( const QDateTime& dt ) {
205 m_end = dt;
206}
207
208/**
209 * \brief This method will set the UID of the Record
210 *
211 * Set the UID of the OPimRecord to be associated with
212 * this OPimRecurrence.
213 *
214 * @param uid The UID of the associated OPimRecord to be set
215 */
216void OPimBackendOccurrence::setUid( const UID& uid ) {
217 m_uid = uid;
218}
219
220
221/**
222 * \brief Set a special summary instead of \sa OPimRecord::summary()
223 *
224 * If \sa OPimRecord::summary() doesn't describe the occurrence
225 * reason you can set a custom summary for the Occurrence.
226 *
227 * @param str The to be set Summary
228 */
229void OPimBackendOccurrence::setSummary( const QString& str ) {
230 m_summary = str;
231}
232
233void OPimBackendOccurrence::setLocation( const QString& str ) {
234 m_location = str;
235}
236
237void OPimBackendOccurrence::setNote( const QString& str ) {
238 m_note = str;
239}
240
241}
diff --git a/libopie2/opiepim/backend/opimbackendoccurrence.h b/libopie2/opiepim/backend/opimbackendoccurrence.h
new file mode 100644
index 0000000..08c3cdf
--- a/dev/null
+++ b/libopie2/opiepim/backend/opimbackendoccurrence.h
@@ -0,0 +1,108 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) 2004 Holger Hans Peter Freyther <zecke@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#ifndef OPIE_PIM_BACKEND_OCCURRENCE_H
31#define OPIE_PIM_BACKEND_OCCURRENCE_H
32
33#include <opie2/opimglobal.h>
34
35#include <qarray.h>
36#include <qdatetime.h>
37#include <qvaluelist.h>
38
39namespace Opie {
40
41/**
42 * \brief Internal representation of an Occurence
43 *
44 * This class is used by the Backends to express
45 * Occurences for the Period Based Query to
46 * the by the Backend represanted Database.
47 * In the Frontend this single representation is splitted
48 * into per day \sa OPimOccurrence 's.
49 * OPimBackendOccurrence can be understand as a hint to
50 * the Frontend and must contain the \sa UID, the Start Date
51 * and End Date of the Occurence. If you have no time associated
52 * to the datetime use the QDate constructors.
53 * If OPimRecord::summary() does not describe the Occurrence
54 * right you can call setSummary() and then the supplied
55 * summary will be used.
56 * All Dates and Times are in the local time.
57 *
58 * @version 1.0
59 * @author Holger Hans Peter Freyther zecke@handhelds.org
60 */
61class OPimBackendOccurrence {
62public:
63 typedef QValueList<OPimBackendOccurrence> List;
64
65 //@{
66 OPimBackendOccurrence();
67 OPimBackendOccurrence( const QDate& date,
68 const UID& , const QString& = QString::null );
69 OPimBackendOccurrence( const QDate& date, const QDate& end,
70 const UID& );
71 OPimBackendOccurrence( const QDateTime& start,
72 const QDateTime& end,
73 const UID& uid );
74 //@}
75
76 //@{
77 QDateTime startDateTime()const;
78 QDateTime endDateTime()const;
79 UID uid()const;
80 bool isAllDay()const;
81 QString summary()const;
82 QString location()const;
83 QString note()const;
84 //@}
85
86 //@{
87 void setStartDate( const QDate& );
88 void setStartDateTime( const QDateTime& dt );
89 void setEndDate( const QDate& );
90 void setEndDateTime( const QDateTime& dt );
91 void setUid( const UID& );
92 void setSummary( const QString& );
93 void setLocation( const QString& );
94 void setNote( const QString& );
95 //@}
96
97private:
98 QDateTime m_start, m_end;
99 UID m_uid;
100 bool m_haveTime : 1;
101 QString m_summary, m_note, m_location;
102
103 struct Private;
104 Private *d;
105};
106}
107
108#endif
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp
index 790a764..5f86be9 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.cpp
+++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp
@@ -28,6 +28,10 @@
28*/ 28*/
29 29
30#include <opie2/otodoaccessbackend.h> 30#include <opie2/otodoaccessbackend.h>
31#include <opie2/private/opimtodosortvector.h>
32#include <opie2/otodoaccess.h>
33
34#include <qintdict.h>
31 35
32namespace Opie { 36namespace Opie {
33OPimTodoAccessBackend::OPimTodoAccessBackend() 37OPimTodoAccessBackend::OPimTodoAccessBackend()
@@ -38,4 +42,114 @@ OPimTodoAccessBackend::~OPimTodoAccessBackend() {
38 42
39} 43}
40 44
45UIDArray OPimTodoAccessBackend::queryByExample( const OPimTodo&, int settings,
46 const QDateTime& d)const {
47 return UIDArray();
48}
49
50UIDArray OPimTodoAccessBackend::sorted( const UIDArray& events, bool asc,
51 int sortOrder, int sortFilter,
52 const QArray<int>& categories )const {
53 odebug << "Using Unaccelerated TodoList sorted Implementation" << oendl;
54 Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder );
55 int item = 0;
56
57 bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false;
58 bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false;
59 bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false;
60 bool catPassed = false;
61 int cat;
62
63 for ( uint i = 0; i < events.count(); ++i ) {
64 OPimTodo todo = find( events[i], events, i, Frontend::Forward );
65 if ( todo.isEmpty() )
66 continue;
67
68 /* show category */
69 /* -1 == unfiled */
70 catPassed = false;
71 for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) {
72 cat = categories[cat_nu];
73 if ( bCat && cat == -1 ) {
74 if(!todo.categories().isEmpty() )
75 continue;
76 } else if ( bCat && cat != 0)
77 if (!todo.categories().contains( cat ) )
78 continue;
79 catPassed = true;
80 break;
81 }
82
83 /*
84 * If none of the Categories matched
85 * continue
86 */
87 if ( !catPassed )
88 continue;
89 if ( !todo.isOverdue() && bOnly )
90 continue;
91 if (todo.isCompleted() && comp )
92 continue;
93
94 vector.insert(item++, todo );
95 }
96
97 vector.resize( item );
98 /* sort it now */
99 vector.sort();
100 /* now get the uids */
101 UIDArray array( vector.count() );
102 for (uint i= 0; i < vector.count(); i++ )
103 array[i] = vector.uidAt( i );
104
105 return array;
106}
107
108OPimBackendOccurrence::List OPimTodoAccessBackend::occurrences( const QDate& start,
109 const QDate& end )const {
110 OPimBackendOccurrence::List lst;
111 UIDArray effective = effectiveToDos( start, end, false );
112 UIDArray overdue = overDue();
113 uint count = effective.count();
114 int uid;
115 QIntDict<int> hash;
116 hash.setAutoDelete( true );
117 OPimTodo todo;
118
119 for ( uint i = 0; i < count; ++i ) {
120 uid = effective[i];
121 todo = find( uid, effective, i, Frontend::Forward );
122 /*
123 * If isOverdue but in the 'normal' range we will fill
124 * the hash so we won't have duplicates in OPimBackendOccurrence
125 */
126 if ( todo.isOverdue() )
127 hash.insert( uid, new int(6) );
128 OPimBackendOccurrence oc = todo.hasStartDate() ?
129 OPimBackendOccurrence( todo.startDate(),
130 todo.dueDate(), uid ) :
131 OPimBackendOccurrence( todo.dueDate(), uid, QString::null );
132 oc.setSummary( todo.summary() );
133 lst.append( oc );
134 }
135
136 /*
137 * Create the OverDue items but skip
138 * the already handled Records
139 */
140 if ( !overdue.isEmpty() ) {
141 QDate today = QDate::currentDate();
142 QDate dueDate = (start >= today && today <= end ) ? today : start;
143 count = overdue.count();
144 for ( uint i = 0; i < count; ++i ) {
145 uid = overdue[i];
146 if (!hash.find( uid ) )
147 continue;
148 todo = find( uid, overdue, i, Frontend::Forward );
149 lst.append( OPimBackendOccurrence(dueDate, uid, todo.summary() ) );
150 }
151 }
152
153 return lst;
154}
41} 155}
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 9dfda45..66297bb 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/otodoaccessbackend.h
@@ -39,21 +39,41 @@ class OPimTodoAccessBackend : public OPimAccessBackend<OPimTodo> {
39public: 39public:
40 OPimTodoAccessBackend(); 40 OPimTodoAccessBackend();
41 ~OPimTodoAccessBackend(); 41 ~OPimTodoAccessBackend();
42 virtual QArray<int> effectiveToDos( const QDate& start, 42 virtual UIDArray effectiveToDos( const QDate& start,
43 const QDate& end, 43 const QDate& end,
44 bool includeNoDates ) = 0; 44 bool includeNoDates )const = 0;
45 virtual QArray<int> overDue() = 0; 45 virtual UIDArray overDue()const = 0;
46 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 46 virtual void removeAllCompleted() = 0;
47 int cat ) = 0; 47
48 virtual void removeAllCompleted() = 0; 48 /**
49 virtual QBitArray supports()const = 0; 49 * Common and probably inefficent implementation
50 50 * for queryByExample, matchRegexp, sorted
51 * and occurrences
52 */
53 //@{
54 UIDArray queryByExample( const OPimTodo&, int settings, const QDateTime& d = QDateTime() )const;
55 UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const;
56 OPimBackendOccurrence::List occurrences( const QDate&, const QDate& )const;
57 //@}
58
51private: 59private:
52 class Private; 60 class Private;
53 Private *d; 61 Private *d;
54 62
55}; 63};
56
57} 64}
58 65
66
67/**
68 * \fn Opie::OPimBackendOccurrence::List Opie::OPimTodoAccessBackend::occurrences(const QDate& start,const QDate& end)const
69 * \brief Return occurrences for a period of time
70 *
71 * This method will return the 'effective' Todos and also
72 * 'Overdue' Todos. Overdues will be shown on the 'current'
73 * day if it is in the range or on \par start. If the overdue
74 * is inside the 'Effective Todos' we will skip the
75 * special overdue handling.
76 *
77 *
78 */
59#endif 79#endif
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 4e3e47b..2bcab29 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -455,7 +455,6 @@ QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, con
455OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ 455OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
456 FindQuery query( uid ); 456 FindQuery query( uid );
457 return parseResultAndCache( uid, m_driver->query(&query) ); 457 return parseResultAndCache( uid, m_driver->query(&query) );
458
459} 458}
460 459
461// Remember: uid is already in the list of uids, called ints ! 460// Remember: uid is already in the list of uids, called ints !
@@ -465,20 +464,18 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
465 odebug << "searching for " << uid << "" << oendl; 464 odebug << "searching for " << uid << "" << oendl;
466 QArray<int> search( CACHE ); 465 QArray<int> search( CACHE );
467 uint size =0; 466 uint size =0;
468 OPimTodo to;
469 467
470 // we try to cache CACHE items 468 // we try to cache CACHE items
471 switch( dir ) { 469 switch( dir ) {
472 /* forward */ 470 /* forward */
473 case Frontend::Forward: 471 case Frontend::Forward:
474 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { 472 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
475 odebug << "size " << size << " " << ints[i] << "" << oendl;
476 search[size] = ints[i]; 473 search[size] = ints[i];
477 size++; 474 size++;
478 } 475 }
479 break; 476 break;
480 /* reverse */ 477 /* reverse */
481 case Frontend::Reverse: 478 case Frontend::Reverse:
482 for (uint i = cur; i != 0 && size < CACHE; i-- ) { 479 for (uint i = cur; i != 0 && size < CACHE; i-- ) {
483 search[size] = ints[i]; 480 search[size] = ints[i];
484 size++; 481 size++;
@@ -490,7 +487,7 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
490 FindQuery query( search ); 487 FindQuery query( search );
491 OSQLResult res = m_driver->query( &query ); 488 OSQLResult res = m_driver->query( &query );
492 if ( res.state() != OSQLResult::Success ) 489 if ( res.state() != OSQLResult::Success )
493 return to; 490 return OPimTodo();
494 491
495 return parseResultAndCache( uid, res ); 492 return parseResultAndCache( uid, res );
496} 493}
@@ -507,6 +504,7 @@ bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) {
507 504
508 if ( res.state() == OSQLResult::Failure ) 505 if ( res.state() == OSQLResult::Failure )
509 return false; 506 return false;
507
510 int c = m_uids.count(); 508 int c = m_uids.count();
511 m_uids.resize( c+1 ); 509 m_uids.resize( c+1 );
512 m_uids[c] = t.uid(); 510 m_uids[c] = t.uid();
@@ -534,16 +532,18 @@ bool OPimTodoAccessBackendSQL::replace( const OPimTodo& t) {
534 m_dirty = false; // we changed some stuff but the UID stayed the same 532 m_dirty = false; // we changed some stuff but the UID stayed the same
535 return b; 533 return b;
536} 534}
537QArray<int> OPimTodoAccessBackendSQL::overDue() { 535QArray<int> OPimTodoAccessBackendSQL::overDue()const {
538 OverDueQuery qu; 536 OverDueQuery qu;
539 return uids( m_driver->query(&qu ) ); 537 return uids( m_driver->query(&qu ) );
540} 538}
541QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s, 539QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
542 const QDate& t, 540 const QDate& t,
543 bool u) { 541 bool u)const {
544 EffQuery ef(s, t, u ); 542 EffQuery ef(s, t, u );
545 return uids (m_driver->query(&ef) ); 543 return uids (m_driver->query(&ef) );
546} 544}
545
546#if 0
547/* 547/*
548 * 548 *
549 */ 549 */
@@ -560,13 +560,13 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
560 * 560 *
561 */ 561 */
562 /* Category */ 562 /* Category */
563 if ( sortFilter & 1 ) { 563 if ( sortFilter & OPimTodoAccess::FilterCategory ) {
564 QString str; 564 QString str;
565 if (cat != 0 ) str = QString::number( cat ); 565 if (cat != 0 ) str = QString::number( cat );
566 query += " categories like '%" +str+"%' AND"; 566 query += " categories like '%" +str+"%' AND";
567 } 567 }
568 /* Show only overdue */ 568 /* Show only overdue */
569 if ( sortFilter & 2 ) { 569 if ( sortFilter & OPimTodoAccess::OnlyOverDue ) {
570 QDate date = QDate::currentDate(); 570 QDate date = QDate::currentDate();
571 QString due; 571 QString due;
572 QString base; 572 QString base;
@@ -577,7 +577,7 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
577 query += " " + base + " AND"; 577 query += " " + base + " AND";
578 } 578 }
579 /* not show completed */ 579 /* not show completed */
580 if ( sortFilter & 4 ) { 580 if ( sortFilter & OPimTodoAccess::DoNotShowCompleted ) {
581 query += " completed = 0 AND"; 581 query += " completed = 0 AND";
582 }else{ 582 }else{
583 query += " ( completed = 1 OR completed = 0) AND"; 583 query += " ( completed = 1 OR completed = 0) AND";
@@ -593,29 +593,31 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
593 query += "ORDER BY "; 593 query += "ORDER BY ";
594 switch( sortOrder ) { 594 switch( sortOrder ) {
595 /* completed */ 595 /* completed */
596 case 0: 596 case OPimTodoAccess::Completed:
597 query += "completed"; 597 query += "completed";
598 break; 598 break;
599 case 1: 599 case OPimTodoAccess::Priority:
600 query += "priority"; 600 query += "priority";
601 break; 601 break;
602 case 2: 602 case OPimTodoAccess::SortSummary:
603 query += "summary"; 603 query += "summary";
604 break; 604 break;
605 case 3: 605 case OPimTodoAccess::Deadline:
606 query += "DueDate"; 606 query += "DueDate";
607 break; 607 break;
608 } 608 }
609 609
610 if ( !asc ) { 610 if ( !asc )
611 odebug << "not ascending!" << oendl;
612 query += " DESC"; 611 query += " DESC";
613 } 612
614 613
615 odebug << query << oendl; 614 odebug << query << oendl;
616 OSQLRawQuery raw(query ); 615 OSQLRawQuery raw(query );
617 return uids( m_driver->query(&raw) ); 616 return uids( m_driver->query(&raw) );
618} 617}
618#endif
619
620
619bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ 621bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
620 if ( str == "0-0-0" ) 622 if ( str == "0-0-0" )
621 return false; 623 return false;
@@ -629,6 +631,8 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
629 return true; 631 return true;
630 } 632 }
631} 633}
634
635
632OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{ 636OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
633 if ( res.state() == OSQLResult::Failure ) { 637 if ( res.state() == OSQLResult::Failure ) {
634 OPimTodo to; 638 OPimTodo to;
@@ -639,22 +643,17 @@ OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResul
639 643
640 OSQLResultItem::ValueList list = res.results(); 644 OSQLResultItem::ValueList list = res.results();
641 OSQLResultItem::ValueList::Iterator it = list.begin(); 645 OSQLResultItem::ValueList::Iterator it = list.begin();
642 odebug << "todo1" << oendl; 646 OPimTodo to, tmp;
643 OPimTodo to = todo( (*it) );
644 cache( to );
645 ++it;
646 647
647 for ( ; it != list.end(); ++it ) { 648 for ( ; it != list.end(); ++it ) {
648 odebug << "caching" << oendl; 649 OPimTodo newTodo = parse( (*it) );
649 OPimTodo newTodo = todo( (*it) );
650 cache( newTodo ); 650 cache( newTodo );
651 if ( newTodo.uid() == uid ) 651 if ( newTodo.uid() == uid )
652 retTodo = newTodo; 652 retTodo = newTodo;
653 } 653 }
654 return retTodo; 654 return retTodo;
655} 655}
656OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { 656OPimTodo OPimTodoAccessBackendSQL::parse( OSQLResultItem& item )const {
657 odebug << "todo(ResultItem)" << oendl;
658 657
659 // Request information from addressbook table and create the OPimTodo-object. 658 // Request information from addressbook table and create the OPimTodo-object.
660 659
@@ -662,8 +661,6 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
662 hasDueDate = date( dueDate, item.data("DueDate") ); 661 hasDueDate = date( dueDate, item.data("DueDate") );
663 QStringList cats = QStringList::split(";", item.data("categories") ); 662 QStringList cats = QStringList::split(";", item.data("categories") );
664 663
665 odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
666
667 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), 664 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
668 cats, item.data("summary"), item.data("description"), 665 cats, item.data("summary"), item.data("description"),
669 item.data("progress").toUShort(), hasDueDate, dueDate, 666 item.data("progress").toUShort(), hasDueDate, dueDate,
@@ -717,36 +714,8 @@ OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
717 FindQuery find( uid ); 714 FindQuery find( uid );
718 return parseResultAndCache( uid, m_driver->query(&find) ); 715 return parseResultAndCache( uid, m_driver->query(&find) );
719} 716}
720/*
721 * update the dict
722 */
723void OPimTodoAccessBackendSQL::fillDict() {
724 717
725#if 0
726 /* initialize dict */
727 /*
728 * UPDATE dict if you change anything!!!
729 * FIXME: Isn't this dict obsolete ? (eilers)
730 */
731 m_dict.setAutoDelete( TRUE );
732 m_dict.insert("Categories" , new int(OPimTodo::Category) );
733 m_dict.insert("Uid" , new int(OPimTodo::Uid) );
734 m_dict.insert("HasDate" , new int(OPimTodo::HasDate) );
735 m_dict.insert("Completed" , new int(OPimTodo::Completed) );
736 m_dict.insert("Description" , new int(OPimTodo::Description) );
737 m_dict.insert("Summary" , new int(OPimTodo::Summary) );
738 m_dict.insert("Priority" , new int(OPimTodo::Priority) );
739 m_dict.insert("DateDay" , new int(OPimTodo::DateDay) );
740 m_dict.insert("DateMonth" , new int(OPimTodo::DateMonth) );
741 m_dict.insert("DateYear" , new int(OPimTodo::DateYear) );
742 m_dict.insert("Progress" , new int(OPimTodo::Progress) );
743 m_dict.insert("Completed", new int(OPimTodo::Completed) ); // Why twice ? (eilers)
744 m_dict.insert("CrossReference", new int(OPimTodo::CrossReference) );
745// m_dict.insert("HasAlarmDateTime",new int(OPimTodo::HasAlarmDateTime) ); // old stuff (eilers)
746// m_dict.insert("AlarmDateTime", new int(OPimTodo::AlarmDateTime) ); // old stuff (eilers)
747 718
748#endif
749}
750/* 719/*
751 * need to be const so let's fool the 720 * need to be const so let's fool the
752 * compiler :( 721 * compiler :(
@@ -765,7 +734,6 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
765 OSQLResultItem::ValueList list = res.results(); 734 OSQLResultItem::ValueList list = res.results();
766 OSQLResultItem::ValueList::Iterator it; 735 OSQLResultItem::ValueList::Iterator it;
767 QArray<int> ints(list.count() ); 736 QArray<int> ints(list.count() );
768 odebug << " count = " << list.count() << "" << oendl;
769 737
770 int i = 0; 738 int i = 0;
771 for (it = list.begin(); it != list.end(); ++it ) { 739 for (it = list.begin(); it != list.end(); ++it ) {
@@ -777,47 +745,18 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
777 745
778QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const 746QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
779{ 747{
780
781#if 0
782 QArray<int> empty;
783 return empty;
784
785#else
786 QString qu = "SELECT uid FROM todolist WHERE ("; 748 QString qu = "SELECT uid FROM todolist WHERE (";
787 749
788 // Do it make sense to search other fields, too ? 750 // Does it make sense to search other fields, too ?
789 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; 751 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
790 qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; 752 qu += " rlike(\""+ r.pattern() + "\",\"summary\")";
791 753
792 qu += ")"; 754 qu += ")";
793 755
794 odebug << "query: " << qu << "" << oendl;
795
796 OSQLRawQuery raw( qu ); 756 OSQLRawQuery raw( qu );
797 OSQLResult res = m_driver->query( &raw ); 757 OSQLResult res = m_driver->query( &raw );
798 758
799 return uids( res ); 759 return uids( res );
800
801
802#endif
803
804}
805QBitArray OPimTodoAccessBackendSQL::supports()const {
806
807 return sup();
808}
809
810QBitArray OPimTodoAccessBackendSQL::sup() const{
811
812 QBitArray ar( OPimTodo::CompletedDate + 1 );
813 ar.fill( true );
814 ar[OPimTodo::CrossReference] = false;
815 ar[OPimTodo::State ] = false;
816 ar[OPimTodo::Reminders] = false;
817 ar[OPimTodo::Notifiers] = false;
818 ar[OPimTodo::Maintainer] = false;
819
820 return ar;
821} 760}
822 761
823void OPimTodoAccessBackendSQL::removeAllCompleted(){ 762void OPimTodoAccessBackendSQL::removeAllCompleted(){
@@ -831,15 +770,13 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
831 770
832 QArray<int> completed_uids = uids( res ); 771 QArray<int> completed_uids = uids( res );
833 772
834 odebug << "Number of completed: " << completed_uids.size() << "" << oendl;
835
836 if ( completed_uids.size() == 0 ) 773 if ( completed_uids.size() == 0 )
837 return; 774 return;
838 775
839 qu = "DELETE FROM todolist WHERE ("; 776 qu = "DELETE FROM todolist WHERE (";
840 QString query; 777 QString query;
841 778
842 for ( int i = 0; i < completed_uids.size(); i++ ){ 779 for ( uint i = 0; i < completed_uids.size(); i++ ){
843 if ( !query.isEmpty() ) 780 if ( !query.isEmpty() )
844 query += " OR "; 781 query += " OR ";
845 query += QString( "uid = %1" ).arg( completed_uids[i] ); 782 query += QString( "uid = %1" ).arg( completed_uids[i] );
@@ -850,20 +787,19 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
850 qu += "DELETE FORM custom_data WHERE ("; 787 qu += "DELETE FORM custom_data WHERE (";
851 query = ""; 788 query = "";
852 789
853 for ( int i = 0; i < completed_uids.size(); i++ ){ 790 for ( uint i = 0; i < completed_uids.size(); i++ ){
854 if ( !query.isEmpty() ) 791 if ( !query.isEmpty() )
855 query += " OR "; 792 query += " OR ";
856 query += QString( "uid = %1" ).arg( completed_uids[i] ); 793 query += QString( "uid = %1" ).arg( completed_uids[i] );
857 } 794 }
858 qu += query + " );"; 795 qu += query + " );";
859 796
860 odebug << "query: " << qu << "" << oendl;
861
862 OSQLRawQuery raw2( qu ); 797 OSQLRawQuery raw2( qu );
863 res = m_driver->query( &raw2 ); 798 res = m_driver->query( &raw2 );
864 if ( res.state() == OSQLResult::Failure ) { 799
800 if ( res.state() == OSQLResult::Failure )
865 owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl; 801 owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
866 } 802
867} 803}
868 804
869 805
@@ -876,15 +812,14 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
876 812
877 if ( res_custom.state() == OSQLResult::Failure ) { 813 if ( res_custom.state() == OSQLResult::Failure ) {
878 owarn << "OSQLResult::Failure in find query !!" << oendl; 814 owarn << "OSQLResult::Failure in find query !!" << oendl;
879 QMap<QString, QString> empty; 815 return QMap<QString, QString>();
880 return empty;
881 } 816 }
882 817
883 OSQLResultItem::ValueList list = res_custom.results(); 818 OSQLResultItem::ValueList list = res_custom.results();
884 OSQLResultItem::ValueList::Iterator it = list.begin(); 819 OSQLResultItem::ValueList::Iterator it = list.begin();
885 for ( ; it != list.end(); ++it ) { 820 for ( ; it != list.end(); ++it )
886 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 821 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
887 } 822
888 823
889 return customMap; 824 return customMap;
890} 825}
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 415f791..0ba8f3a 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -51,40 +51,35 @@ public:
51 bool load(); 51 bool load();
52 bool reload(); 52 bool reload();
53 bool save(); 53 bool save();
54 QArray<int> allRecords()const; 54 QArray<UID> allRecords()const;
55 55
56 QArray<int> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() ); 56 QArray<UID> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() );
57 OPimTodo find(int uid)const; 57 OPimTodo find(UID uid)const;
58 OPimTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 58 OPimTodo find(UID uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
59 void clear(); 59 void clear();
60 bool add( const OPimTodo& t ); 60 bool add( const OPimTodo& t );
61 bool remove( int uid ); 61 bool remove( UID uid );
62 bool replace( const OPimTodo& t ); 62 bool replace( const OPimTodo& t );
63 63
64 QArray<int> overDue(); 64 QArray<UID> overDue()const;
65 QArray<int> effectiveToDos( const QDate& start, 65 QArray<UID> effectiveToDos( const QDate& start,
66 const QDate& end, bool includeNoDates ); 66 const QDate& end, bool includeNoDates )const;
67 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); 67 QArray<UID> matchRegexp( const QRegExp &r ) const;
68
69 QBitArray supports()const;
70 QArray<int> matchRegexp( const QRegExp &r ) const;
71 void removeAllCompleted(); 68 void removeAllCompleted();
72 69
73 70
74private: 71private:
75 void update()const; 72 void update()const;
76 void fillDict();
77 inline bool date( QDate& date, const QString& )const; 73 inline bool date( QDate& date, const QString& )const;
78 inline OPimTodo parseResultAndCache( int uid, const Opie::DB::OSQLResult& )const; 74 inline OPimTodo parseResultAndCache( UID uid, const Opie::DB::OSQLResult& )const;
79 inline OPimTodo todo( Opie::DB::OSQLResultItem& )const; 75 inline OPimTodo parse( Opie::DB::OSQLResultItem& )const;
80 inline QArray<int> uids( const Opie::DB::OSQLResult& )const; 76 inline QArray<UID> uids( const Opie::DB::OSQLResult& )const;
81 OPimTodo todo( int uid )const; 77 OPimTodo todo( UID uid )const;
82 QBitArray sup() const; 78 QMap<QString, QString> requestCustom( UID uid ) const;
83 QMap<QString, QString> requestCustom( int uid ) const;
84 79
85 // QAsciiDict<int> m_dict; 80 // QAsciiDict<int> m_dict;
86 Opie::DB::OSQLDriver* m_driver; 81 Opie::DB::OSQLDriver* m_driver;
87 QArray<int> m_uids; 82 QArray<UID> m_uids;
88 bool m_dirty : 1; 83 bool m_dirty : 1;
89}; 84};
90 85
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 7d58a40..aa8a7eb 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -92,7 +92,6 @@ namespace {
92 // categories 92 // categories
93 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 93 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
94 name = vObjectStringZValue( ob ); 94 name = vObjectStringZValue( ob );
95 owarn << "Categories:" << name.data() << "" << oendl;
96 } 95 }
97 96
98 event.setUid( 1 ); 97 event.setUid( 1 );
@@ -233,10 +232,7 @@ bool OPimTodoAccessVCal::replace( const OPimTodo& to ) {
233OPimTodo OPimTodoAccessVCal::find(int uid )const { 232OPimTodo OPimTodoAccessVCal::find(int uid )const {
234 return m_map[uid]; 233 return m_map[uid];
235} 234}
236QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) { 235
237 QArray<int> ar(0);
238 return ar;
239}
240QArray<int> OPimTodoAccessVCal::allRecords()const { 236QArray<int> OPimTodoAccessVCal::allRecords()const {
241 QArray<int> ar( m_map.count() ); 237 QArray<int> ar( m_map.count() );
242 QMap<int, OPimTodo>::ConstIterator it; 238 QMap<int, OPimTodo>::ConstIterator it;
@@ -247,42 +243,16 @@ QArray<int> OPimTodoAccessVCal::allRecords()const {
247 } 243 }
248 return ar; 244 return ar;
249} 245}
250QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { 246
251 QArray<int> ar(0);
252 return ar;
253}
254QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) {
255 QArray<int> ar(0);
256 return ar;
257}
258QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& , 247QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& ,
259 const QDate& , 248 const QDate& ,
260 bool ) { 249 bool )const {
261 QArray<int> ar(0);
262 return ar;
263}
264QArray<int> OPimTodoAccessVCal::overDue() {
265 QArray<int> ar(0); 250 QArray<int> ar(0);
266 return ar; 251 return ar;
267} 252}
268QBitArray OPimTodoAccessVCal::supports()const {
269 static QBitArray ar = sup();
270
271 return ar;
272}
273QBitArray OPimTodoAccessVCal::sup() {
274 QBitArray ar ( OPimTodo::CompletedDate +1 );
275 ar.fill( true );
276
277 ar[OPimTodo::CrossReference] = false;
278 ar[OPimTodo::State ] = false;
279 ar[OPimTodo::Reminders] = false;
280 ar[OPimTodo::Notifiers] = false;
281 ar[OPimTodo::Maintainer] = false;
282 ar[OPimTodo::Progress] = false;
283 ar[OPimTodo::Alarms ] = false;
284 ar[OPimTodo::Recurrence] = false;
285 253
254QArray<int> OPimTodoAccessVCal::overDue()const {
255 QArray<int> ar(0);
286 return ar; 256 return ar;
287} 257}
288 258
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index 1e106d3..05dd76b 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -43,14 +43,10 @@ public:
43 bool save(); 43 bool save();
44 44
45 QArray<int> allRecords()const; 45 QArray<int> allRecords()const;
46 QArray<int> matchRegexp(const QRegExp &r) const;
47 QArray<int> queryByExample( const OPimTodo& t, int sort, const QDateTime& d = QDateTime() );
48 QArray<int> effectiveToDos( const QDate& start, 46 QArray<int> effectiveToDos( const QDate& start,
49 const QDate& end, 47 const QDate& end,
50 bool includeNoDates ); 48 bool includeNoDates )const;
51 QArray<int> overDue(); 49 QArray<int> overDue()const;
52 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
53 int cat );
54 OPimTodo find(int uid)const; 50 OPimTodo find(int uid)const;
55 void clear(); 51 void clear();
56 bool add( const OPimTodo& ); 52 bool add( const OPimTodo& );
@@ -58,10 +54,8 @@ public:
58 bool replace( const OPimTodo& ); 54 bool replace( const OPimTodo& );
59 55
60 void removeAllCompleted(); 56 void removeAllCompleted();
61 virtual QBitArray supports()const;
62 57
63private: 58private:
64 static QBitArray sup();
65 bool m_dirty : 1; 59 bool m_dirty : 1;
66 QString m_file; 60 QString m_file;
67 QMap<int, OPimTodo> m_map; 61 QMap<int, OPimTodo> m_map;
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 3e06d88..273f91a 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -34,8 +34,11 @@
34#include <opie2/opimnotifymanager.h> 34#include <opie2/opimnotifymanager.h>
35#include <opie2/opimrecurrence.h> 35#include <opie2/opimrecurrence.h>
36#include <opie2/otodoaccessxml.h> 36#include <opie2/otodoaccessxml.h>
37#include <opie2/otodoaccess.h>
37#include <opie2/odebug.h> 38#include <opie2/odebug.h>
38 39
40#include <opie2/private/opimtodosortvector.h>
41
39#include <qpe/global.h> 42#include <qpe/global.h>
40#include <qpe/stringutil.h> 43#include <qpe/stringutil.h>
41#include <qpe/timeconversion.h> 44#include <qpe/timeconversion.h>
@@ -142,7 +145,6 @@ bool OPimTodoAccessXML::load() {
142 dict.insert("State", new int(OPimTodo::State) ); 145 dict.insert("State", new int(OPimTodo::State) );
143 dict.insert("Alarms", new int(OPimTodo::Alarms) ); 146 dict.insert("Alarms", new int(OPimTodo::Alarms) );
144 dict.insert("Reminders", new int(OPimTodo::Reminders) ); 147 dict.insert("Reminders", new int(OPimTodo::Reminders) );
145 dict.insert("Notifiers", new int(OPimTodo::Notifiers) );
146 dict.insert("Maintainer", new int(OPimTodo::Maintainer) ); 148 dict.insert("Maintainer", new int(OPimTodo::Maintainer) );
147 dict.insert("rtype", new int(FRType) ); 149 dict.insert("rtype", new int(FRType) );
148 dict.insert("rweekdays", new int(FRWeekdays) ); 150 dict.insert("rweekdays", new int(FRWeekdays) );
@@ -182,7 +184,6 @@ bool OPimTodoAccessXML::load() {
182 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { 184 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
183 i = point -dt; 185 i = point -dt;
184 i+= strLen; 186 i+= strLen;
185 owarn << "Found a start at " << i << " " << (point-dt) << "" << oendl;
186 187
187 OPimTodo ev; 188 OPimTodo ev;
188 m_year = m_month = m_day = 0; 189 m_year = m_month = m_day = 0;
@@ -238,7 +239,6 @@ bool OPimTodoAccessXML::load() {
238 /* 239 /*
239 * now add it 240 * now add it
240 */ 241 */
241 owarn << "End at " << i << "" << oendl;
242 if (m_events.contains( ev.uid() ) || ev.uid() == 0) { 242 if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
243 ev.setUid( 1 ); 243 ev.setUid( 1 );
244 m_changed = true; 244 m_changed = true;
@@ -261,7 +261,6 @@ bool OPimTodoAccessXML::load() {
261 261
262 munmap(map_addr, attribut.st_size ); 262 munmap(map_addr, attribut.st_size );
263 263
264 owarn << "counts " << m_events.count() << " records loaded!" << oendl;
265 return true; 264 return true;
266} 265}
267bool OPimTodoAccessXML::reload() { 266bool OPimTodoAccessXML::reload() {
@@ -269,9 +268,7 @@ bool OPimTodoAccessXML::reload() {
269 return load(); 268 return load();
270} 269}
271bool OPimTodoAccessXML::save() { 270bool OPimTodoAccessXML::save() {
272// owarn << "saving" << oendl;
273 if (!m_opened || !m_changed ) { 271 if (!m_opened || !m_changed ) {
274// owarn << "not saving" << oendl;
275 return true; 272 return true;
276 } 273 }
277 QString strNewFile = m_file + ".new"; 274 QString strNewFile = m_file + ".new";
@@ -312,7 +309,6 @@ bool OPimTodoAccessXML::save() {
312 f.close(); 309 f.close();
313 310
314 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 311 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
315// owarn << "error renaming" << oendl;
316 QFile::remove( strNewFile ); 312 QFile::remove( strNewFile );
317 } 313 }
318 314
@@ -324,10 +320,10 @@ QArray<int> OPimTodoAccessXML::allRecords()const {
324 QMap<int, OPimTodo>::ConstIterator it; 320 QMap<int, OPimTodo>::ConstIterator it;
325 int i = 0; 321 int i = 0;
326 322
327 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 323 for ( it = m_events.begin(); it != m_events.end(); ++it )
328 ids[i] = it.key(); 324 ids[i++] = it.key();
329 i++; 325
330 } 326
331 return ids; 327 return ids;
332} 328}
333QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) { 329QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) {
@@ -350,7 +346,6 @@ void OPimTodoAccessXML::clear() {
350 m_events.clear(); 346 m_events.clear();
351} 347}
352bool OPimTodoAccessXML::add( const OPimTodo& todo ) { 348bool OPimTodoAccessXML::add( const OPimTodo& todo ) {
353// owarn << "add" << oendl;
354 m_changed = true; 349 m_changed = true;
355 m_events.insert( todo.uid(), todo ); 350 m_events.insert( todo.uid(), todo );
356 351
@@ -370,31 +365,27 @@ bool OPimTodoAccessXML::replace( const OPimTodo& todo) {
370} 365}
371QArray<int> OPimTodoAccessXML::effectiveToDos( const QDate& start, 366QArray<int> OPimTodoAccessXML::effectiveToDos( const QDate& start,
372 const QDate& end, 367 const QDate& end,
373 bool includeNoDates ) { 368 bool includeNoDates )const {
374 QArray<int> ids( m_events.count() ); 369 QArray<int> ids( m_events.count() );
375 QMap<int, OPimTodo>::Iterator it; 370 QMap<int, OPimTodo>::ConstIterator it;
376 371
377 int i = 0; 372 int i = 0;
378 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 373 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
379 if ( !it.data().hasDueDate() ) { 374 if ( !it.data().hasDueDate() && includeNoDates) {
380 if ( includeNoDates ) { 375 ids[i++] = it.key();
381 ids[i] = it.key();
382 i++;
383 }
384 }else if ( it.data().dueDate() >= start && 376 }else if ( it.data().dueDate() >= start &&
385 it.data().dueDate() <= end ) { 377 it.data().dueDate() <= end ) {
386 ids[i] = it.key(); 378 ids[i++] = it.key();
387 i++;
388 } 379 }
389 } 380 }
390 ids.resize( i ); 381 ids.resize( i );
391 return ids; 382 return ids;
392} 383}
393QArray<int> OPimTodoAccessXML::overDue() { 384QArray<int> OPimTodoAccessXML::overDue()const {
394 QArray<int> ids( m_events.count() ); 385 QArray<int> ids( m_events.count() );
395 int i = 0; 386 int i = 0;
396 387
397 QMap<int, OPimTodo>::Iterator it; 388 QMap<int, OPimTodo>::ConstIterator it;
398 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 389 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
399 if ( it.data().isOverdue() ) { 390 if ( it.data().isOverdue() ) {
400 ids[i] = it.key(); 391 ids[i] = it.key();
@@ -409,13 +400,11 @@ QArray<int> OPimTodoAccessXML::overDue() {
409/* private */ 400/* private */
410void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, 401void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
411 const QCString& attr, const QString& val) { 402 const QCString& attr, const QString& val) {
412// owarn << "parse to do from XMLElement" << oendl;
413 403
414 int *find=0; 404 int *find=0;
415 405
416 find = (*dict)[ attr.data() ]; 406 find = (*dict)[ attr.data() ];
417 if (!find ) { 407 if (!find ) {
418// owarn << "Unknown option" + it.key() << oendl;
419 ev.setCustomField( attr, val ); 408 ev.setCustomField( attr, val );
420 return; 409 return;
421 } 410 }
@@ -468,8 +457,6 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
468 QStringList als = QStringList::split(";", val ); 457 QStringList als = QStringList::split(";", val );
469 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { 458 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
470 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty 459 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
471 owarn << "alarm: " << alarm.join("___") << "" << oendl;
472 owarn << "alarm[0]: " << alarm[0] << " " << OPimDateConversion::dateTimeFromString( alarm[0] ).toString() << "" << oendl;
473 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); 460 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
474 manager.add( al ); 461 manager.add( al );
475 } 462 }
@@ -542,11 +529,9 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
542namespace { 529namespace {
543QString customToXml(const QMap<QString, QString>& customMap ) 530QString customToXml(const QMap<QString, QString>& customMap )
544{ 531{
545 //owarn << QString("writing custom %1").arg(customMap.count()) << oendl;
546 QString buf(" "); 532 QString buf(" ");
547 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); 533 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
548 cit != customMap.end(); ++cit) { 534 cit != customMap.end(); ++cit) {
549// owarn << ".ITEM." << oendl;
550 buf += cit.key(); 535 buf += cit.key();
551 buf += "=\""; 536 buf += "=\"";
552 buf += Qtopia::escapeString(cit.data()); 537 buf += Qtopia::escapeString(cit.data());
@@ -575,7 +560,6 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
575 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 560 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
576 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 561 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
577 } 562 }
578// owarn << "Uid " << ev.uid() << "" << oendl;
579 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 563 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
580 564
581// append the extra options 565// append the extra options
@@ -622,7 +606,6 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
622 } 606 }
623 } 607 }
624 // now write the list 608 // now write the list
625 owarn << "als: " << als.join("____________") << "" << oendl;
626 str += "Alarms=\""+als.join(";") +"\" "; 609 str += "Alarms=\""+als.join(";") +"\" ";
627 } 610 }
628 611
@@ -648,229 +631,66 @@ QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const {
648 return Qtopia::Record::idsToString( ints ); 631 return Qtopia::Record::idsToString( ints );
649} 632}
650 633
651/* internal class for sorting
652 *
653 * Inspired by todoxmlio.cpp from TT
654 */
655 634
656struct OPimTodoXMLContainer { 635QArray<int> OPimTodoAccessXML::sorted( const UIDArray& events, bool asc,
657 OPimTodo todo; 636 int sortOrder,int sortFilter,
658}; 637 const QArray<int>& categories )const {
638 Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder );
639 int item = 0;
659 640
660namespace { 641 bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false;
661 inline QString string( const OPimTodo& todo) { 642 bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false;
662 return todo.summary().isEmpty() ? 643 bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false;
663 todo.description().left(20 ) : 644 bool catPassed = false;
664 todo.summary(); 645 int cat;
665 }
666 inline int completed( const OPimTodo& todo1, const OPimTodo& todo2) {
667 int ret = 0;
668 if ( todo1.isCompleted() ) ret++;
669 if ( todo2.isCompleted() ) ret--;
670 return ret;
671 }
672 inline int priority( const OPimTodo& t1, const OPimTodo& t2) {
673 return ( t1.priority() - t2.priority() );
674 }
675 inline int description( const OPimTodo& t1, const OPimTodo& t2) {
676 return QString::compare( string(t1), string(t2) );
677 }
678 inline int deadline( const OPimTodo& t1, const OPimTodo& t2) {
679 int ret = 0;
680 if ( t1.hasDueDate() &&
681 t2.hasDueDate() )
682 ret = t2.dueDate().daysTo( t1.dueDate() );
683 else if ( t1.hasDueDate() )
684 ret = -1;
685 else if ( t2.hasDueDate() )
686 ret = 1;
687 else
688 ret = 0;
689 646
690 return ret; 647 for ( uint i = 0; i < events.count(); ++i ) {
691 } 648 /* Guard against creating a new item... */
649 if ( !m_events.contains( events[i] ) )
650 continue;
692 651
693}; 652 OPimTodo todo = m_events[events[i]];
694 653
695/* 654 /* show category */
696 * Returns: 655 /* -1 == unfiled */
697 * 0 if item1 == item2 656 catPassed = false;
698 * 657 for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) {
699 * non-zero if item1 != item2 658 cat = categories[cat_nu];
700 * 659 if ( bCat && cat == -1 ) {
701 * This function returns int rather than bool so that reimplementations 660 if(!todo.categories().isEmpty() )
702 * can return one of three values and use it to sort by: 661 continue;
703 * 662 } else if ( bCat && cat != 0)
704 * 0 if item1 == item2 663 if (!todo.categories().contains( cat ) )
705 * 664 continue;
706 * > 0 (positive integer) if item1 > item2 665 catPassed = true;
707 *
708 * < 0 (negative integer) if item1 < item2
709 *
710 */
711class OPimTodoXMLVector : public QVector<OPimTodoXMLContainer> {
712public:
713 OPimTodoXMLVector(int size, bool asc, int sort)
714 : QVector<OPimTodoXMLContainer>( size )
715 {
716 setAutoDelete( true );
717 m_asc = asc;
718 m_sort = sort;
719 }
720 /* return the summary/description */
721 QString string( const OPimTodo& todo) {
722 return todo.summary().isEmpty() ?
723 todo.description().left(20 ) :
724 todo.summary();
725 }
726 /**
727 * we take the sortorder( switch on it )
728 *
729 */
730 int compareItems( Item d1, Item d2 ) {
731 bool seComp, sePrio, seDesc, seDeadline;
732 seComp = sePrio = seDeadline = seDesc = false;
733 int ret =0;
734 OPimTodoXMLContainer* con1 = (OPimTodoXMLContainer*)d1;
735 OPimTodoXMLContainer* con2 = (OPimTodoXMLContainer*)d2;
736
737 /* same item */
738 if ( con1->todo.uid() == con2->todo.uid() )
739 return 0;
740
741 switch ( m_sort ) {
742 /* completed */
743 case 0: {
744 ret = completed( con1->todo, con2->todo );
745 seComp = TRUE;
746 break;
747 }
748 /* priority */
749 case 1: {
750 ret = priority( con1->todo, con2->todo );
751 sePrio = TRUE;
752 break;
753 }
754 /* description */
755 case 2: {
756 ret = description( con1->todo, con2->todo );
757 seDesc = TRUE;
758 break;
759 }
760 /* deadline */
761 case 3: {
762 ret = deadline( con1->todo, con2->todo );
763 seDeadline = TRUE;
764 break; 666 break;
765 } 667 }
766 default:
767 ret = 0;
768 break;
769 };
770 /*
771 * FIXME do better sorting if the first sort criteria
772 * ret equals 0 start with complete and so on...
773 */
774
775 /* twist it we're not ascending*/
776 if (!m_asc)
777 ret = ret * -1;
778 668
779 if ( ret )
780 return ret;
781
782 // default did not gave difference let's try it other way around
783 /* 669 /*
784 * General try if already checked if not test 670 * If none of the Categories matched
785 * and return 671 * continue
786 * 1.Completed
787 * 2.Priority
788 * 3.Description
789 * 4.DueDate
790 */ 672 */
791 if (!seComp ) { 673 if ( !catPassed )
792 if ( (ret = completed( con1->todo, con2->todo ) ) ) {
793 if (!m_asc ) ret *= -1;
794 return ret;
795 }
796 }
797 if (!sePrio ) {
798 if ( (ret = priority( con1->todo, con2->todo ) ) ) {
799 if (!m_asc ) ret *= -1;
800 return ret;
801 }
802 }
803 if (!seDesc ) {
804 if ( (ret = description(con1->todo, con2->todo ) ) ) {
805 if (!m_asc) ret *= -1;
806 return ret;
807 }
808 }
809 if (!seDeadline) {
810 if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
811 if (!m_asc) ret *= -1;
812 return ret;
813 }
814 }
815
816 return 0;
817 }
818 private:
819 bool m_asc;
820 int m_sort;
821
822};
823
824QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder,
825 int sortFilter, int cat ) {
826 OPimTodoXMLVector vector(m_events.count(), asc,sortOrder );
827 QMap<int, OPimTodo>::Iterator it;
828 int item = 0;
829
830 bool bCat = sortFilter & 1 ? true : false;
831 bool bOnly = sortFilter & 2 ? true : false;
832 bool comp = sortFilter & 4 ? true : false;
833 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
834
835 /* show category */
836 /* -1 == unfiled */
837 if ( bCat && cat == -1 ) {
838 if(!(*it).categories().isEmpty() )
839 continue;
840 }else if ( bCat && cat != 0)
841 if (!(*it).categories().contains( cat ) ) {
842 continue;
843 }
844 /* isOverdue but we should not show overdue - why?*/
845/* if ( (*it).isOverdue() && !bOnly ) {
846 owarn << "item is overdue but !bOnly" << oendl;
847 continue; 674 continue;
848 } 675 if ( !todo.isOverdue() && bOnly )
849*/
850 if ( !(*it).isOverdue() && bOnly ) {
851 continue; 676 continue;
852 } 677 if (todo.isCompleted() && comp )
853
854 if ((*it).isCompleted() && comp ) {
855 continue; 678 continue;
856 }
857 679
858 680 vector.insert(item++, todo );
859 OPimTodoXMLContainer* con = new OPimTodoXMLContainer();
860 con->todo = (*it);
861 vector.insert(item, con );
862 item++;
863 } 681 }
682
864 vector.resize( item ); 683 vector.resize( item );
865 /* sort it now */ 684 /* sort it now */
866 vector.sort(); 685 vector.sort();
867 /* now get the uids */ 686 /* now get the uids */
868 QArray<int> array( vector.count() ); 687 UIDArray array( vector.count() );
869 for (uint i= 0; i < vector.count(); i++ ) { 688 for (uint i= 0; i < vector.count(); i++ )
870 array[i] = ( vector.at(i) )->todo.uid(); 689 array[i] = vector.uidAt( i );
871 } 690
872 return array; 691 return array;
873}; 692}
693
874void OPimTodoAccessXML::removeAllCompleted() { 694void OPimTodoAccessXML::removeAllCompleted() {
875 QMap<int, OPimTodo> events = m_events; 695 QMap<int, OPimTodo> events = m_events;
876 for ( QMap<int, OPimTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 696 for ( QMap<int, OPimTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
@@ -879,36 +699,22 @@ void OPimTodoAccessXML::removeAllCompleted() {
879 } 699 }
880 m_events = events; 700 m_events = events;
881} 701}
882QBitArray OPimTodoAccessXML::supports()const { 702
883 static QBitArray ar = sup();
884 return ar;
885}
886QBitArray OPimTodoAccessXML::sup() {
887 QBitArray ar( OPimTodo::CompletedDate +1 );
888 ar.fill( true );
889 ar[OPimTodo::CrossReference] = false;
890 ar[OPimTodo::State ] = false;
891 ar[OPimTodo::Reminders] = false;
892 ar[OPimTodo::Notifiers] = false;
893 ar[OPimTodo::Maintainer] = false;
894
895 return ar;
896}
897QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const 703QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const
898{ 704{
899 QArray<int> m_currentQuery( m_events.count() ); 705 QArray<int> currentQuery( m_events.count() );
900 uint arraycounter = 0; 706 uint arraycounter = 0;
901 707
902 QMap<int, OPimTodo>::ConstIterator it; 708 QMap<int, OPimTodo>::ConstIterator it;
903 for (it = m_events.begin(); it != m_events.end(); ++it ) { 709 for (it = m_events.begin(); it != m_events.end(); ++it ) {
904 if ( it.data().match( r ) ) 710 if ( it.data().match( r ) )
905 m_currentQuery[arraycounter++] = it.data().uid(); 711 currentQuery[arraycounter++] = it.data().uid();
906 712
907 } 713 }
908 // Shrink to fit.. 714 // Shrink to fit..
909 m_currentQuery.resize(arraycounter); 715 currentQuery.resize(arraycounter);
910 716
911 return m_currentQuery; 717 return currentQuery;
912} 718}
913 719
914} 720}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index 3a51543..134a21a 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -63,13 +63,13 @@ public:
63 /* our functions */ 63 /* our functions */
64 QArray<int> effectiveToDos( const QDate& start, 64 QArray<int> effectiveToDos( const QDate& start,
65 const QDate& end, 65 const QDate& end,
66 bool includeNoDates ); 66 bool includeNoDates )const;
67 QArray<int> overDue(); 67 QArray<int> overDue()const;
68 QArray<int> sorted( bool asc, int sortOrder, 68
69 int sortFilter, int cat ); 69//@{
70 QBitArray supports()const; 70 UIDArray sorted( const UIDArray&, bool, int, int, const QArray<int>& )const;
71//@}
71private: 72private:
72 static QBitArray sup();
73 void todo( QAsciiDict<int>*, OPimTodo&,const QCString&,const QString& ); 73 void todo( QAsciiDict<int>*, OPimTodo&,const QCString&,const QString& );
74 QString toString( const OPimTodo& )const; 74 QString toString( const OPimTodo& )const;
75 QString toString( const QArray<int>& ints ) const; 75 QString toString( const QArray<int>& ints ) const;
@@ -81,7 +81,6 @@ private:
81 class OPimTodoAccessXMLPrivate; 81 class OPimTodoAccessXMLPrivate;
82 OPimTodoAccessXMLPrivate* d; 82 OPimTodoAccessXMLPrivate* d;
83 int m_year, m_month, m_day; 83 int m_year, m_month, m_day;
84
85}; 84};
86 85
87}; 86};