summaryrefslogtreecommitdiff
path: root/libopie/pim/test
authoreilers <eilers>2003-12-22 10:19:25 (UTC)
committer eilers <eilers>2003-12-22 10:19:25 (UTC)
commitae70312b1613e26b4ef89a2c9821d9531b82e987 (patch) (side-by-side diff)
tree7eb70bc45ee29e94da27a18b0136eb4a14e59fa6 /libopie/pim/test
parent9e7aafdb7c76d29fee742d53131a73dd60aded2b (diff)
downloadopie-ae70312b1613e26b4ef89a2c9821d9531b82e987.zip
opie-ae70312b1613e26b4ef89a2c9821d9531b82e987.tar.gz
opie-ae70312b1613e26b4ef89a2c9821d9531b82e987.tar.bz2
Finishing implementation of sql-backend for datebook. But I have to
port the PIM datebook application to use it, before I could debug the whole stuff. Thus, PIM-Database backend is finished, but highly experimental. And some parts are still generic. For instance, the "queryByExample()" methods are not (or not fully) implemented. Todo: custom-entries not stored. The big show stopper: matchRegExp() (needed by OpieSearch) needs regular expression search in the database, which is not supported by sqlite ! Therefore we need either an extended sqlite or a workaround which would be very slow and memory consuming..
Diffstat (limited to 'libopie/pim/test') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/test/converter.cpp45
-rwxr-xr-xlibopie/pim/test/converter.h18
-rw-r--r--libopie/pim/test/converter.pro2
3 files changed, 61 insertions, 4 deletions
diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp
index 650d119..bfdb605 100644
--- a/libopie/pim/test/converter.cpp
+++ b/libopie/pim/test/converter.cpp
@@ -9,6 +9,12 @@
#include <opie/ocontactaccessbackend_xml.h>
#include <opie/ocontactaccessbackend_sql.h>
+#include <opie/odatebookaccess.h>
+#include <opie/odatebookaccessbackend_xml.h>
+#include <opie/odatebookaccessbackend_sql.h>
+
+// #define _ADDRESSBOOK_ACCESS
+
Converter::Converter(){
}
@@ -16,6 +22,8 @@ void Converter::start_conversion(){
qWarning("Converting Contacts from XML to SQL..");
// Creating backends to the requested databases..
+
+#ifdef _ADDRESSBOOK_ACCESS
OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
QString::null );
@@ -26,14 +34,30 @@ void Converter::start_conversion(){
QString::null , xmlBackend, true );
OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql",
- QString::null , sqlBackend, true );
+ QString::null );
+#else
+ ODateBookAccessBackend* xmlBackend = new ODateBookAccessBackend_XML( "Converter",
+ QString::null );
+
+ ODateBookAccessBackend* sqlBackend = new ODateBookAccessBackend_SQL( QString::null,
+ QString::null );
+ // Put the created backends into frontends to access them
+ ODateBookAccess* xmlAccess = new ODateBookAccess ( xmlBackend );
+
+ ODateBookAccess* sqlAccess = new ODateBookAccess ( sqlBackend );
+
+ xmlAccess->load();
+
+#endif
+
QTime t;
t.start();
- // Clean the sql-database..
+// Clean the sql-database..
sqlAccess->clear();
+#ifdef _ADDRESSBOOK_ACCESS
// Now trasmit every contact from the xml database to the sql-database
OContactAccess::List contactList = xmlAccess->allRecords();
m_progressBar->setTotalSteps( contactList.count() );
@@ -45,7 +69,22 @@ void Converter::start_conversion(){
m_progressBar->setProgress( ++count );
}
}
-
+#else
+ // Now transmit every contact from the xml database to the sql-database
+ ODateBookAccess::List dateList = xmlAccess->allRecords();
+ m_progressBar->setTotalSteps( dateList.count() );
+ qWarning( "Number of elements to copy: %d", dateList.count() );
+
+ int count = 0;
+ if ( sqlAccess && xmlAccess ){
+ ODateBookAccess::List::Iterator it;
+ for ( it = dateList.begin(); it != dateList.end(); ++it ){
+ sqlAccess->add( *it );
+ m_progressBar->setProgress( ++count );
+ }
+ }
+
+#endif
// Delete the frontends. Backends will be deleted automatically, too !
delete sqlAccess;
diff --git a/libopie/pim/test/converter.h b/libopie/pim/test/converter.h
new file mode 100755
index 0000000..1cc2a7c
--- a/dev/null
+++ b/libopie/pim/test/converter.h
@@ -0,0 +1,18 @@
+#ifndef _CONVERTER_H_
+#define _CONVERTER_H_
+
+
+#include "converter_base.h"
+
+
+class Converter: public converter_base {
+public:
+ Converter();
+
+ void start_conversion();
+private:
+
+};
+
+
+#endif
diff --git a/libopie/pim/test/converter.pro b/libopie/pim/test/converter.pro
index aa74bff..bd9c7a3 100644
--- a/libopie/pim/test/converter.pro
+++ b/libopie/pim/test/converter.pro
@@ -1,4 +1,4 @@
-TEMPLATE = app
+# TEMPLATE = app
CONFIG = qt warn_on debug
# CONFIG = qt warn_on release
#HEADERS =