summaryrefslogtreecommitdiff
path: root/libopie/pim/test
authoreilers <eilers>2003-09-22 14:31:15 (UTC)
committer eilers <eilers>2003-09-22 14:31:15 (UTC)
commit34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56 (patch) (side-by-side diff)
treecee19bfcf7c8d6a24cd4aaf578bd64b38b2d0ee4 /libopie/pim/test
parentfd500184450e37c239e573adf1c12a6ff62b65f6 (diff)
downloadopie-34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56.zip
opie-34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56.tar.gz
opie-34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56.tar.bz2
Added first experimental incarnation of sql-backend for addressbook.
Some modifications to be able to compile the todo sql-backend. A lot of changes fill follow...
Diffstat (limited to 'libopie/pim/test') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/test/converter.cpp64
-rw-r--r--libopie/pim/test/converter.pro12
-rw-r--r--libopie/pim/test/converter_base.ui43
3 files changed, 119 insertions, 0 deletions
diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp
new file mode 100644
index 0000000..0a488f2
--- a/dev/null
+++ b/libopie/pim/test/converter.cpp
@@ -0,0 +1,64 @@
+#include <qpe/qpeapplication.h>
+
+#include <opie/ocontactaccess.h>
+#include <opie/ocontactaccessbackend_xml.h>
+#include <opie/ocontactaccessbackend_sql.h>
+
+#include "converter_base.h"
+
+class ConvertXMLToSQL: public converter_base {
+public:
+ ConvertXMLToSQL()
+ {
+ convertContact();
+ }
+private:
+ void convertContact();
+
+};
+
+
+void ConvertXMLToSQL::convertContact(){
+ qWarning("Converting Contacts from XML to SQL..");
+
+ // Creating backends to the requested databases..
+ OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
+ QString::null );
+
+ OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null,
+ QString::null );
+ // Put the created backends into frontends to access them
+ OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml",
+ QString::null , xmlBackend, true );
+
+ OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql",
+ QString::null , sqlBackend, true );
+
+ // Clean the sql-database..
+ sqlAccess->clear();
+
+ // Now trasmit every contact from the xml database to the sql-database
+ OContactAccess::List contactList = xmlAccess->allRecords();
+ if ( sqlAccess && xmlAccess ){
+ OContactAccess::List::Iterator it;
+ for ( it = contactList.begin(); it != contactList.end(); ++it )
+ sqlAccess->add( *it );
+ }
+
+ // Delete the frontends. Backends will be deleted automatically, too !
+ delete sqlAccess;
+ delete xmlAccess;
+}
+
+int main( int argc, char** argv ) {
+
+ QPEApplication a( argc, argv );
+
+ ConvertXMLToSQL dlg;
+
+ a.showMainWidget( &dlg );
+ // dlg. showMaximized ( );
+
+ return a.exec();
+
+}
diff --git a/libopie/pim/test/converter.pro b/libopie/pim/test/converter.pro
new file mode 100644
index 0000000..aa74bff
--- a/dev/null
+++ b/libopie/pim/test/converter.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+CONFIG = qt warn_on debug
+# CONFIG = qt warn_on release
+#HEADERS =
+SOURCES = converter.cpp
+INTERFACES = converter_base.ui
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopie
+TARGET = converter
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/libopie/pim/test/converter_base.ui b/libopie/pim/test/converter_base.ui
new file mode 100644
index 0000000..f680550
--- a/dev/null
+++ b/libopie/pim/test/converter_base.ui
@@ -0,0 +1,43 @@
+<!DOCTYPE UI><UI>
+<class>converter_base</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>converter_base</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>579</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Form2</string>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>340</x>
+ <y>40</y>
+ <width>210</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Converter from XML-&gt;SQL</string>
+ </property>
+ </widget>
+</widget>
+</UI>