-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 1 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 6 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.h | 5 | ||||
-rw-r--r-- | libopie2/opiepim/core/odatebookaccess.cpp | 5 | ||||
-rw-r--r-- | libopie2/opiepim/core/odatebookaccess.h | 6 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 28 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimtemplatebase.h | 16 | ||||
-rw-r--r-- | libopie2/opiepim/core/otodoaccess.cpp | 7 | ||||
-rw-r--r-- | libopie2/opiepim/core/otodoaccess.h | 6 |
9 files changed, 65 insertions, 15 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index 401a3c1..14207be 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -421,24 +421,25 @@ QArray<int> OPimContactAccessBackend_SQL::allRecords() const | |||
421 | { | 421 | { |
422 | 422 | ||
423 | // FIXME: Think about cute handling of changed tables.. | 423 | // FIXME: Think about cute handling of changed tables.. |
424 | // Thus, we don't have to call update here... | 424 | // Thus, we don't have to call update here... |
425 | if ( m_changed ) | 425 | if ( m_changed ) |
426 | ((OPimContactAccessBackend_SQL*)this)->update(); | 426 | ((OPimContactAccessBackend_SQL*)this)->update(); |
427 | 427 | ||
428 | return m_uids; | 428 | return m_uids; |
429 | } | 429 | } |
430 | 430 | ||
431 | bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) | 431 | bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) |
432 | { | 432 | { |
433 | qDebug("add in contact SQL-Backend"); | ||
433 | InsertQuery ins( newcontact ); | 434 | InsertQuery ins( newcontact ); |
434 | OSQLResult res = m_driver->query( &ins ); | 435 | OSQLResult res = m_driver->query( &ins ); |
435 | 436 | ||
436 | if ( res.state() == OSQLResult::Failure ) | 437 | if ( res.state() == OSQLResult::Failure ) |
437 | return false; | 438 | return false; |
438 | 439 | ||
439 | int c = m_uids.count(); | 440 | int c = m_uids.count(); |
440 | m_uids.resize( c+1 ); | 441 | m_uids.resize( c+1 ); |
441 | m_uids[c] = newcontact.uid(); | 442 | m_uids[c] = newcontact.uid(); |
442 | 443 | ||
443 | return true; | 444 | return true; |
444 | } | 445 | } |
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 4f9b504..67f267f 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -43,24 +43,25 @@ | |||
43 | #include <qlist.h> | 43 | #include <qlist.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | 45 | ||
46 | //#include <qpe/qcopenvelope_qws.h> | 46 | //#include <qpe/qcopenvelope_qws.h> |
47 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
48 | 48 | ||
49 | #include <errno.h> | 49 | #include <errno.h> |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #include <opie2/ocontactaccessbackend_xml.h> | 54 | #include <opie2/ocontactaccessbackend_xml.h> |
55 | #include <opie2/opimresolver.h> | ||
55 | 56 | ||
56 | namespace Opie { | 57 | namespace Opie { |
57 | 58 | ||
58 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | 59 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , |
59 | OPimContactAccessBackend* end, bool autosync ): | 60 | OPimContactAccessBackend* end, bool autosync ): |
60 | OPimAccessTemplate<OPimContact>( end ) | 61 | OPimAccessTemplate<OPimContact>( end ) |
61 | { | 62 | { |
62 | /* take care of the backend. If there is no one defined, we | 63 | /* take care of the backend. If there is no one defined, we |
63 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 64 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
64 | */ | 65 | */ |
65 | if( end == 0 ) { | 66 | if( end == 0 ) { |
66 | qWarning ("Using BackendFactory !"); | 67 | qWarning ("Using BackendFactory !"); |
@@ -140,13 +141,18 @@ void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) | |||
140 | qWarning ("OPimContactAccess: Received addressbokUpdated()"); | 141 | qWarning ("OPimContactAccess: Received addressbokUpdated()"); |
141 | emit signalChanged ( this ); | 142 | emit signalChanged ( this ); |
142 | } else if ( msg == "flush()" ) { | 143 | } else if ( msg == "flush()" ) { |
143 | qWarning ("OPimContactAccess: Received flush()"); | 144 | qWarning ("OPimContactAccess: Received flush()"); |
144 | save (); | 145 | save (); |
145 | } else if ( msg == "reload()" ) { | 146 | } else if ( msg == "reload()" ) { |
146 | qWarning ("OPimContactAccess: Received reload()"); | 147 | qWarning ("OPimContactAccess: Received reload()"); |
147 | reload (); | 148 | reload (); |
148 | emit signalChanged ( this ); | 149 | emit signalChanged ( this ); |
149 | } | 150 | } |
150 | } | 151 | } |
151 | 152 | ||
153 | int OPimContactAccess::rtti() const | ||
154 | { | ||
155 | return OPimResolver::AddressBook; | ||
156 | } | ||
157 | |||
152 | } | 158 | } |
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index cf5333a..4429b6f 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -118,24 +118,29 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
118 | /** | 118 | /** |
119 | * if the resource was changed externally. | 119 | * if the resource was changed externally. |
120 | * You should use the signal instead of polling possible changes ! | 120 | * You should use the signal instead of polling possible changes ! |
121 | */ | 121 | */ |
122 | bool wasChangedExternally()const; | 122 | bool wasChangedExternally()const; |
123 | 123 | ||
124 | 124 | ||
125 | /** Save contacts database. | 125 | /** Save contacts database. |
126 | * Save is more a "commit". After calling this function, all changes are public available. | 126 | * Save is more a "commit". After calling this function, all changes are public available. |
127 | * @return true if successful | 127 | * @return true if successful |
128 | */ | 128 | */ |
129 | bool save(); | 129 | bool save(); |
130 | |||
131 | /** | ||
132 | * Return identification of used records | ||
133 | */ | ||
134 | int rtti() const; | ||
130 | 135 | ||
131 | signals: | 136 | signals: |
132 | /* Signal is emitted if the database was changed. Therefore | 137 | /* Signal is emitted if the database was changed. Therefore |
133 | * we may need to reload to stay consistent. | 138 | * we may need to reload to stay consistent. |
134 | * @param which Pointer to the database who created this event. This pointer | 139 | * @param which Pointer to the database who created this event. This pointer |
135 | * is useful if an application has to handle multiple databases at the same time. | 140 | * is useful if an application has to handle multiple databases at the same time. |
136 | * @see reload() | 141 | * @see reload() |
137 | */ | 142 | */ |
138 | void signalChanged ( const OPimContactAccess *which ); | 143 | void signalChanged ( const OPimContactAccess *which ); |
139 | 144 | ||
140 | 145 | ||
141 | private: | 146 | private: |
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp index ac310c1..29298ea 100644 --- a/libopie2/opiepim/core/odatebookaccess.cpp +++ b/libopie2/opiepim/core/odatebookaccess.cpp | |||
@@ -19,24 +19,25 @@ | |||
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <opie2/obackendfactory.h> | 29 | #include <opie2/obackendfactory.h> |
30 | #include <opie2/odatebookaccess.h> | 30 | #include <opie2/odatebookaccess.h> |
31 | #include <opie2/opimresolver.h> | ||
31 | 32 | ||
32 | namespace Opie { | 33 | namespace Opie { |
33 | /** | 34 | /** |
34 | * Simple constructor | 35 | * Simple constructor |
35 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation | 36 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation |
36 | * will be used! | 37 | * will be used! |
37 | * @param back The backend to be used or 0 for the default backend | 38 | * @param back The backend to be used or 0 for the default backend |
38 | * @param ac What kind of access is intended | 39 | * @param ac What kind of access is intended |
39 | */ | 40 | */ |
40 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) | 41 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) |
41 | : OPimAccessTemplate<OPimEvent>( back ) | 42 | : OPimAccessTemplate<OPimEvent>( back ) |
42 | { | 43 | { |
@@ -99,14 +100,18 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& st | |||
99 | * @param from Include all events from... | 100 | * @param from Include all events from... |
100 | * @param to Include all events to... | 101 | * @param to Include all events to... |
101 | */ | 102 | */ |
102 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { | 103 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { |
103 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); | 104 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); |
104 | } | 105 | } |
105 | /** | 106 | /** |
106 | * @return all non repeating events at a given datetime | 107 | * @return all non repeating events at a given datetime |
107 | */ | 108 | */ |
108 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { | 109 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { |
109 | return m_backEnd->effectiveNonRepeatingEvents( start ); | 110 | return m_backEnd->effectiveNonRepeatingEvents( start ); |
110 | } | 111 | } |
112 | int ODateBookAccess::rtti() const | ||
113 | { | ||
114 | return OPimResolver::DateBook; | ||
115 | } | ||
111 | 116 | ||
112 | } | 117 | } |
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h index 6c9290f..c6c3598 100644 --- a/libopie2/opiepim/core/odatebookaccess.h +++ b/libopie2/opiepim/core/odatebookaccess.h | |||
@@ -55,21 +55,27 @@ public: | |||
55 | /* return repeating events */ | 55 | /* return repeating events */ |
56 | List rawRepeats()const; | 56 | List rawRepeats()const; |
57 | 57 | ||
58 | /* return non repeating events */ | 58 | /* return non repeating events */ |
59 | List nonRepeats()const; | 59 | List nonRepeats()const; |
60 | 60 | ||
61 | /* return non repeating events (from,to) */ | 61 | /* return non repeating events (from,to) */ |
62 | OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; | 62 | OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; |
63 | OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; | 63 | OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; |
64 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; | 64 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; |
65 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; | 65 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; |
66 | 66 | ||
67 | /** | ||
68 | * Return identification of used records | ||
69 | */ | ||
70 | int rtti() const; | ||
71 | |||
72 | |||
67 | private: | 73 | private: |
68 | ODateBookAccessBackend* m_backEnd; | 74 | ODateBookAccessBackend* m_backEnd; |
69 | class Private; | 75 | class Private; |
70 | Private* d; | 76 | Private* d; |
71 | }; | 77 | }; |
72 | 78 | ||
73 | } | 79 | } |
74 | 80 | ||
75 | #endif | 81 | #endif |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index f1bcc44..d4c5fbb 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,15 +1,16 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 6 | .=l. |
6 | .>+-= | 7 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 14 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
@@ -128,24 +129,31 @@ public: | |||
128 | /** | 129 | /** |
129 | * clears the backend and invalidates the backend | 130 | * clears the backend and invalidates the backend |
130 | */ | 131 | */ |
131 | void clear() ; | 132 | void clear() ; |
132 | 133 | ||
133 | /** | 134 | /** |
134 | * add T to the backend | 135 | * add T to the backend |
135 | * @param t The item to add. | 136 | * @param t The item to add. |
136 | * @return <i>true</i> if added successfully. | 137 | * @return <i>true</i> if added successfully. |
137 | */ | 138 | */ |
138 | virtual bool add( const T& t ) ; | 139 | virtual bool add( const T& t ) ; |
139 | bool add( const OPimRecord& ); | 140 | bool add( const OPimRecord& ); |
141 | // Needed for real generic access (eilers) | ||
142 | // Info: Take this if you are working with OPimRecord, which is a generic base class, and | ||
143 | // you need to add it into any database, you cannot generate a reference to | ||
144 | // it and casting may be not approriate, too. | ||
145 | // But take care that the accessing database is compatible to the real type of OPimRecord !! | ||
146 | bool add( const OPimRecord* ); | ||
147 | |||
140 | 148 | ||
141 | /* only the uid matters */ | 149 | /* only the uid matters */ |
142 | /** | 150 | /** |
143 | * remove T from the backend | 151 | * remove T from the backend |
144 | * @param t The item to remove | 152 | * @param t The item to remove |
145 | * @return <i>true</i> if successful. | 153 | * @return <i>true</i> if successful. |
146 | */ | 154 | */ |
147 | virtual bool remove( const T& t ); | 155 | virtual bool remove( const T& t ); |
148 | 156 | ||
149 | /** | 157 | /** |
150 | * remove the OPimRecord with uid | 158 | * remove the OPimRecord with uid |
151 | * @param uid The ID of the item to remove | 159 | * @param uid The ID of the item to remove |
@@ -262,33 +270,47 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | |||
262 | return t; | 270 | return t; |
263 | } | 271 | } |
264 | template <class T> | 272 | template <class T> |
265 | void OPimAccessTemplate<T>::clear() { | 273 | void OPimAccessTemplate<T>::clear() { |
266 | invalidateCache(); | 274 | invalidateCache(); |
267 | m_backEnd->clear(); | 275 | m_backEnd->clear(); |
268 | } | 276 | } |
269 | template <class T> | 277 | template <class T> |
270 | bool OPimAccessTemplate<T>::add( const T& t ) { | 278 | bool OPimAccessTemplate<T>::add( const T& t ) { |
271 | cache( t ); | 279 | cache( t ); |
272 | return m_backEnd->add( t ); | 280 | return m_backEnd->add( t ); |
273 | } | 281 | } |
282 | |||
274 | template <class T> | 283 | template <class T> |
275 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { | 284 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { |
276 | /* same type */ | 285 | /* same type */ |
277 | if ( rec.rtti() == T::rtti() ) { | 286 | T tempInstance; |
278 | const T &t = static_cast<const T&>(rec); | 287 | if ( rec.rtti() == tempInstance.rtti() ) { |
288 | const T& t = static_cast<const T&>(rec); | ||
279 | return add(t); | 289 | return add(t); |
280 | } | 290 | } |
281 | return false; | 291 | return false; |
282 | } | 292 | } |
293 | |||
294 | template <class T> | ||
295 | bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { | ||
296 | /* same type, but pointer */ | ||
297 | T tempInstance; | ||
298 | if ( rec -> rtti() == tempInstance.rtti() ) { | ||
299 | const T* t = static_cast<const T*>(rec); | ||
300 | return add( *t ); | ||
301 | } | ||
302 | return false; | ||
303 | } | ||
304 | |||
283 | template <class T> | 305 | template <class T> |
284 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 306 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
285 | return remove( t.uid() ); | 307 | return remove( t.uid() ); |
286 | } | 308 | } |
287 | template <class T> | 309 | template <class T> |
288 | bool OPimAccessTemplate<T>::remove( int uid ) { | 310 | bool OPimAccessTemplate<T>::remove( int uid ) { |
289 | m_cache.remove( uid ); | 311 | m_cache.remove( uid ); |
290 | return m_backEnd->remove( uid ); | 312 | return m_backEnd->remove( uid ); |
291 | } | 313 | } |
292 | template <class T> | 314 | template <class T> |
293 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | 315 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { |
294 | return remove( rec.uid() ); | 316 | return remove( rec.uid() ); |
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h index 58cbfeb..b48dfed 100644 --- a/libopie2/opiepim/core/opimtemplatebase.h +++ b/libopie2/opiepim/core/opimtemplatebase.h | |||
@@ -1,15 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
@@ -40,28 +40,29 @@ namespace Opie { | |||
40 | * Templates do not have a base class, This is why | 40 | * Templates do not have a base class, This is why |
41 | * we've this class | 41 | * we've this class |
42 | * this is here to give us the possibility | 42 | * this is here to give us the possibility |
43 | * to have a common base class | 43 | * to have a common base class |
44 | * You may not want to use that interface internaly | 44 | * You may not want to use that interface internaly |
45 | * POOR mans interface | 45 | * POOR mans interface |
46 | */ | 46 | */ |
47 | class OPimBasePrivate; | 47 | class OPimBasePrivate; |
48 | struct OPimBase { | 48 | struct OPimBase { |
49 | /** | 49 | /** |
50 | * return the rtti | 50 | * return the rtti |
51 | */ | 51 | */ |
52 | virtual int rtti()= 0; | 52 | virtual int rtti() const = 0; |
53 | virtual OPimRecord* record()const = 0; | 53 | virtual OPimRecord* record()const = 0; |
54 | virtual OPimRecord* record(int uid)const = 0; | 54 | virtual OPimRecord* record(int uid)const = 0; |
55 | virtual bool add( const OPimRecord& ) = 0; | 55 | virtual bool add( const OPimRecord& ) = 0; |
56 | virtual bool add( const OPimRecord* ) = 0; | ||
56 | virtual bool remove( int uid ) = 0; | 57 | virtual bool remove( int uid ) = 0; |
57 | virtual bool remove( const OPimRecord& ) = 0; | 58 | virtual bool remove( const OPimRecord& ) = 0; |
58 | virtual void clear() = 0; | 59 | virtual void clear() = 0; |
59 | virtual bool load() = 0; | 60 | virtual bool load() = 0; |
60 | virtual bool save() = 0; | 61 | virtual bool save() = 0; |
61 | virtual QArray<int> records()const = 0; | 62 | virtual QArray<int> records()const = 0; |
62 | /* | 63 | /* |
63 | * ADD editing here? | 64 | * ADD editing here? |
64 | * -zecke | 65 | * -zecke |
65 | */ | 66 | */ |
66 | private: | 67 | private: |
67 | OPimBasePrivate* d; | 68 | OPimBasePrivate* d; |
@@ -81,42 +82,33 @@ public: | |||
81 | virtual ~OTemplateBase() { | 82 | virtual ~OTemplateBase() { |
82 | } | 83 | } |
83 | virtual T find( int uid )const = 0; | 84 | virtual T find( int uid )const = 0; |
84 | 85 | ||
85 | /** | 86 | /** |
86 | * read ahead find | 87 | * read ahead find |
87 | */ | 88 | */ |
88 | virtual T find( int uid, const QArray<int>& items, | 89 | virtual T find( int uid, const QArray<int>& items, |
89 | uint current, CacheDirection dir = Forward )const = 0; | 90 | uint current, CacheDirection dir = Forward )const = 0; |
90 | virtual void cache( const T& )const = 0; | 91 | virtual void cache( const T& )const = 0; |
91 | virtual void setSaneCacheSize( int ) = 0; | 92 | virtual void setSaneCacheSize( int ) = 0; |
92 | 93 | ||
93 | /* reimplement of OPimBase */ | ||
94 | int rtti(); | ||
95 | OPimRecord* record()const; | 94 | OPimRecord* record()const; |
96 | OPimRecord* record(int uid )const; | 95 | OPimRecord* record(int uid )const; |
97 | static T* rec(); | 96 | static T* rec(); |
98 | 97 | ||
99 | private: | 98 | private: |
100 | OTemplateBasePrivate *d; | 99 | OTemplateBasePrivate *d; |
101 | }; | 100 | }; |
102 | 101 | ||
103 | /* | 102 | |
104 | * implementation | ||
105 | */ | ||
106 | template <class T> | ||
107 | int | ||
108 | OTemplateBase<T>::rtti() { | ||
109 | return T::rtti(); | ||
110 | } | ||
111 | template <class T> | 103 | template <class T> |
112 | OPimRecord* OTemplateBase<T>::record()const { | 104 | OPimRecord* OTemplateBase<T>::record()const { |
113 | T* t = new T; | 105 | T* t = new T; |
114 | return t; | 106 | return t; |
115 | } | 107 | } |
116 | template <class T> | 108 | template <class T> |
117 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 109 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
118 | T t2 = find(uid ); | 110 | T t2 = find(uid ); |
119 | T* t1 = new T(t2); | 111 | T* t1 = new T(t2); |
120 | 112 | ||
121 | return t1; | 113 | return t1; |
122 | }; | 114 | }; |
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp index 83750d5..6fa0089 100644 --- a/libopie2/opiepim/core/otodoaccess.cpp +++ b/libopie2/opiepim/core/otodoaccess.cpp | |||
@@ -24,24 +24,25 @@ | |||
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | 30 | ||
31 | #include <qpe/alarmserver.h> | 31 | #include <qpe/alarmserver.h> |
32 | 32 | ||
33 | // #include "otodoaccesssql.h" | 33 | // #include "otodoaccesssql.h" |
34 | #include <opie2/otodoaccess.h> | 34 | #include <opie2/otodoaccess.h> |
35 | #include <opie2/obackendfactory.h> | 35 | #include <opie2/obackendfactory.h> |
36 | #include <opie2/opimresolver.h> | ||
36 | 37 | ||
37 | namespace Opie { | 38 | namespace Opie { |
38 | OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) | 39 | OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) |
39 | : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) | 40 | : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) |
40 | { | 41 | { |
41 | // if (end == 0l ) | 42 | // if (end == 0l ) |
42 | // m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); | 43 | // m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); |
43 | 44 | ||
44 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! | 45 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! |
45 | if (end == 0l ) | 46 | if (end == 0l ) |
46 | m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::Default ("todo", QString::null); | 47 | m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::Default ("todo", QString::null); |
47 | 48 | ||
@@ -81,13 +82,19 @@ OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter | |||
81 | return list; | 82 | return list; |
82 | } | 83 | } |
83 | void OPimTodoAccess::removeAllCompleted() { | 84 | void OPimTodoAccess::removeAllCompleted() { |
84 | m_todoBackEnd->removeAllCompleted(); | 85 | m_todoBackEnd->removeAllCompleted(); |
85 | } | 86 | } |
86 | QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ | 87 | QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ |
87 | return m_todoBackEnd->supports(); | 88 | return m_todoBackEnd->supports(); |
88 | } | 89 | } |
89 | bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ | 90 | bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ |
90 | return backendSupport(ar).testBit( attr ); | 91 | return backendSupport(ar).testBit( attr ); |
91 | } | 92 | } |
92 | 93 | ||
94 | |||
95 | int OPimTodoAccess::rtti() const | ||
96 | { | ||
97 | return OPimResolver::TodoList; | ||
98 | } | ||
99 | |||
93 | } | 100 | } |
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h index 51f3793..3f5af30 100644 --- a/libopie2/opiepim/core/otodoaccess.h +++ b/libopie2/opiepim/core/otodoaccess.h | |||
@@ -107,24 +107,30 @@ public: | |||
107 | * This is related to the enum in OPimTodo | 107 | * This is related to the enum in OPimTodo |
108 | * | 108 | * |
109 | * @param backend Will be used in the future when we support multiple backend | 109 | * @param backend Will be used in the future when we support multiple backend |
110 | */ | 110 | */ |
111 | QBitArray backendSupport( const QString& backend = QString::null )const; | 111 | QBitArray backendSupport( const QString& backend = QString::null )const; |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * see above but for a specefic attribute. This method was added for convience | 114 | * see above but for a specefic attribute. This method was added for convience |
115 | * @param attr The attribute to be queried for | 115 | * @param attr The attribute to be queried for |
116 | * @param backend Will be used in the future when we support multiple backends | 116 | * @param backend Will be used in the future when we support multiple backends |
117 | */ | 117 | */ |
118 | bool backendSupports( int attr, const QString& backend = QString::null )const; | 118 | bool backendSupports( int attr, const QString& backend = QString::null )const; |
119 | |||
120 | |||
121 | /** | ||
122 | * Return identification of used records | ||
123 | */ | ||
124 | int rtti() const; | ||
119 | signals: | 125 | signals: |
120 | /** | 126 | /** |
121 | * if the OPimTodoAccess was changed | 127 | * if the OPimTodoAccess was changed |
122 | */ | 128 | */ |
123 | void changed( const OPimTodoAccess* ); | 129 | void changed( const OPimTodoAccess* ); |
124 | void changed( const OPimTodoAccess*, int uid ); | 130 | void changed( const OPimTodoAccess*, int uid ); |
125 | void added( const OPimTodoAccess*, int uid ); | 131 | void added( const OPimTodoAccess*, int uid ); |
126 | void removed( const OPimTodoAccess*, int uid ); | 132 | void removed( const OPimTodoAccess*, int uid ); |
127 | private: | 133 | private: |
128 | int m_cat; | 134 | int m_cat; |
129 | OPimTodoAccessBackend* m_todoBackEnd; | 135 | OPimTodoAccessBackend* m_todoBackEnd; |
130 | class OPimTodoAccessPrivate; | 136 | class OPimTodoAccessPrivate; |