summaryrefslogtreecommitdiff
authoreilers <eilers>2004-04-28 09:22:02 (UTC)
committer eilers <eilers>2004-04-28 09:22:02 (UTC)
commit134b7accd6bdc8fbc160a42f7c52c585e73f4add (patch) (side-by-side diff)
tree5e221e990d0c94e38d816e147762f205733b0e72
parent8ce67859c54234dabd88e17a0bc72369ea8301a3 (diff)
downloadopie-134b7accd6bdc8fbc160a42f7c52c585e73f4add.zip
opie-134b7accd6bdc8fbc160a42f7c52c585e73f4add.tar.gz
opie-134b7accd6bdc8fbc160a42f7c52c585e73f4add.tar.bz2
Some modifications to alow use of generic OPimRecords without need to
cast them manually to the right type
Diffstat (more/less context) (show 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.h26
-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, 64 insertions, 14 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
@@ -432,2 +432,3 @@ bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact )
{
+ qDebug("add in contact SQL-Backend");
InsertQuery ins( newcontact );
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
@@ -54,2 +54,3 @@
#include <opie2/ocontactaccessbackend_xml.h>
+#include <opie2/opimresolver.h>
@@ -151,2 +152,7 @@ void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
+int OPimContactAccess::rtti() const
+{
+ return OPimResolver::AddressBook;
+}
+
}
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
@@ -130,2 +130,7 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
+ /**
+ * Return identification of used records
+ */
+ int rtti() const;
+
signals:
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
@@ -30,2 +30,3 @@
#include <opie2/odatebookaccess.h>
+#include <opie2/opimresolver.h>
@@ -110,2 +111,6 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const Q
}
+int ODateBookAccess::rtti() const
+{
+ return OPimResolver::DateBook;
+}
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
@@ -66,2 +66,8 @@ public:
+ /**
+ * Return identification of used records
+ */
+ int rtti() const;
+
+
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
@@ -2,3 +2,4 @@
This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
+ Copyright (C) Holger Freyther <zecke@handhelds.org>
+ Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -139,2 +140,9 @@ public:
bool add( const OPimRecord& );
+ // Needed for real generic access (eilers)
+ // Info: Take this if you are working with OPimRecord, which is a generic base class, and
+ // you need to add it into any database, you cannot generate a reference to
+ // it and casting may be not approriate, too.
+ // But take care that the accessing database is compatible to the real type of OPimRecord !!
+ bool add( const OPimRecord* );
+
@@ -273,2 +281,3 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
}
+
template <class T>
@@ -276,3 +285,4 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
/* same type */
- if ( rec.rtti() == T::rtti() ) {
+ T tempInstance;
+ if ( rec.rtti() == tempInstance.rtti() ) {
const T &t = static_cast<const T&>(rec);
@@ -282,2 +292,14 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
}
+
+template <class T>
+bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
+ /* same type, but pointer */
+ T tempInstance;
+ if ( rec -> rtti() == tempInstance.rtti() ) {
+ const T* t = static_cast<const T*>(rec);
+ return add( *t );
+ }
+ return false;
+}
+
template <class T>
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
@@ -2,3 +2,3 @@
This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
+ Copyright (C) Holger Freyther <zecke@handhelds.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -51,3 +51,3 @@ struct OPimBase {
*/
- virtual int rtti()= 0;
+ virtual int rtti() const = 0;
virtual OPimRecord* record()const = 0;
@@ -55,2 +55,3 @@ struct OPimBase {
virtual bool add( const OPimRecord& ) = 0;
+ virtual bool add( const OPimRecord* ) = 0;
virtual bool remove( int uid ) = 0;
@@ -92,4 +93,2 @@ public:
- /* reimplement of OPimBase */
- int rtti();
OPimRecord* record()const;
@@ -102,10 +101,3 @@ private:
-/*
- * implementation
- */
-template <class T>
-int
-OTemplateBase<T>::rtti() {
- return T::rtti();
-}
+
template <class 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
@@ -35,2 +35,3 @@
#include <opie2/obackendfactory.h>
+#include <opie2/opimresolver.h>
@@ -92,2 +93,8 @@ bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{
+
+int OPimTodoAccess::rtti() const
+{
+ return OPimResolver::TodoList;
+}
+
}
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
@@ -118,2 +118,8 @@ public:
bool backendSupports( int attr, const QString& backend = QString::null )const;
+
+
+ /**
+ * Return identification of used records
+ */
+ int rtti() const;
signals: