-rw-r--r-- | libopie/pim/test/converter.cpp | 64 | ||||
-rw-r--r-- | libopie/pim/test/converter.pro | 12 | ||||
-rw-r--r-- | libopie/pim/test/converter_base.ui | 43 |
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 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
2 | |||
3 | #include <opie/ocontactaccess.h> | ||
4 | #include <opie/ocontactaccessbackend_xml.h> | ||
5 | #include <opie/ocontactaccessbackend_sql.h> | ||
6 | |||
7 | #include "converter_base.h" | ||
8 | |||
9 | class ConvertXMLToSQL: public converter_base { | ||
10 | public: | ||
11 | ConvertXMLToSQL() | ||
12 | { | ||
13 | convertContact(); | ||
14 | } | ||
15 | private: | ||
16 | void convertContact(); | ||
17 | |||
18 | }; | ||
19 | |||
20 | |||
21 | void ConvertXMLToSQL::convertContact(){ | ||
22 | qWarning("Converting Contacts from XML to SQL.."); | ||
23 | |||
24 | // Creating backends to the requested databases.. | ||
25 | OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter", | ||
26 | QString::null ); | ||
27 | |||
28 | OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null, | ||
29 | QString::null ); | ||
30 | // Put the created backends into frontends to access them | ||
31 | OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml", | ||
32 | QString::null , xmlBackend, true ); | ||
33 | |||
34 | OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", | ||
35 | QString::null , sqlBackend, true ); | ||
36 | |||
37 | // Clean the sql-database.. | ||
38 | sqlAccess->clear(); | ||
39 | |||
40 | // Now trasmit every contact from the xml database to the sql-database | ||
41 | OContactAccess::List contactList = xmlAccess->allRecords(); | ||
42 | if ( sqlAccess && xmlAccess ){ | ||
43 | OContactAccess::List::Iterator it; | ||
44 | for ( it = contactList.begin(); it != contactList.end(); ++it ) | ||
45 | sqlAccess->add( *it ); | ||
46 | } | ||
47 | |||
48 | // Delete the frontends. Backends will be deleted automatically, too ! | ||
49 | delete sqlAccess; | ||
50 | delete xmlAccess; | ||
51 | } | ||
52 | |||
53 | int main( int argc, char** argv ) { | ||
54 | |||
55 | QPEApplication a( argc, argv ); | ||
56 | |||
57 | ConvertXMLToSQL dlg; | ||
58 | |||
59 | a.showMainWidget( &dlg ); | ||
60 | // dlg. showMaximized ( ); | ||
61 | |||
62 | return a.exec(); | ||
63 | |||
64 | } | ||
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 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on debug | ||
3 | # CONFIG = qt warn_on release | ||
4 | #HEADERS = | ||
5 | SOURCES = converter.cpp | ||
6 | INTERFACES = converter_base.ui | ||
7 | INCLUDEPATH+= $(OPIEDIR)/include | ||
8 | DEPENDPATH+= $(OPIEDIR)/include | ||
9 | LIBS += -lqpe -lopie | ||
10 | TARGET = converter | ||
11 | |||
12 | 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 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>converter_base</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>converter_base</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>579</width> | ||
15 | <height>211</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Form2</string> | ||
21 | </property> | ||
22 | <widget> | ||
23 | <class>QLabel</class> | ||
24 | <property stdset="1"> | ||
25 | <name>name</name> | ||
26 | <cstring>TextLabel1</cstring> | ||
27 | </property> | ||
28 | <property stdset="1"> | ||
29 | <name>geometry</name> | ||
30 | <rect> | ||
31 | <x>340</x> | ||
32 | <y>40</y> | ||
33 | <width>210</width> | ||
34 | <height>20</height> | ||
35 | </rect> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>text</name> | ||
39 | <string>Converter from XML->SQL</string> | ||
40 | </property> | ||
41 | </widget> | ||
42 | </widget> | ||
43 | </UI> | ||