summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp1
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp6
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h5
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp5
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h6
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h28
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h16
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp7
-rw-r--r--libopie2/opiepim/core/otodoaccess.h6
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
@@ -430,6 +430,7 @@ QArray<int> OPimContactAccessBackend_SQL::allRecords() const
430 430
431bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) 431bool 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
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
@@ -52,6 +52,7 @@
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
56namespace Opie { 57namespace Opie {
57 58
@@ -149,4 +150,9 @@ void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
149 } 150 }
150} 151}
151 152
153int 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
@@ -127,6 +127,11 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
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
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
@@ -28,6 +28,7 @@
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
32namespace Opie { 33namespace Opie {
33/** 34/**
@@ -108,5 +109,9 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const Q
108OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { 109OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const {
109 return m_backEnd->effectiveNonRepeatingEvents( start ); 110 return m_backEnd->effectiveNonRepeatingEvents( start );
110} 111}
112int 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
@@ -64,6 +64,12 @@ public:
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
67private: 73private:
68 ODateBookAccessBackend* m_backEnd; 74 ODateBookAccessBackend* m_backEnd;
69 class Private; 75 class Private;
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,6 +1,7 @@
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 .>+-=
@@ -137,6 +138,13 @@ public:
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 /**
@@ -271,15 +279,29 @@ 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
274template <class T> 283template <class T>
275bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 284bool 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
294template <class T>
295bool 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
283template <class T> 305template <class T>
284bool OPimAccessTemplate<T>::remove( const T& t ) { 306bool OPimAccessTemplate<T>::remove( const T& t ) {
285 return remove( t.uid() ); 307 return remove( t.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,6 +1,6 @@
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 .>+-=
@@ -49,10 +49,11 @@ 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;
@@ -90,8 +91,6 @@ public:
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();
@@ -100,14 +99,7 @@ private:
100 OTemplateBasePrivate *d; 99 OTemplateBasePrivate *d;
101}; 100};
102 101
103/* 102
104 * implementation
105 */
106template <class T>
107int
108OTemplateBase<T>::rtti() {
109 return T::rtti();
110}
111template <class T> 103template <class T>
112OPimRecord* OTemplateBase<T>::record()const { 104OPimRecord* OTemplateBase<T>::record()const {
113 T* t = new T; 105 T* t = new T;
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
@@ -33,6 +33,7 @@
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
37namespace Opie { 38namespace Opie {
38OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) 39OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
@@ -90,4 +91,10 @@ 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
95int 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
@@ -116,6 +116,12 @@ public:
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;
119signals: 125signals:
120 /** 126 /**
121 * if the OPimTodoAccess was changed 127 * if the OPimTodoAccess was changed