summaryrefslogtreecommitdiff
path: root/libopie/pim/test/converter.cpp
Unidiff
Diffstat (limited to 'libopie/pim/test/converter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/test/converter.cpp41
1 files changed, 40 insertions, 1 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
@@ -11,2 +11,8 @@
11 11
12#include <opie/odatebookaccess.h>
13#include <opie/odatebookaccessbackend_xml.h>
14#include <opie/odatebookaccessbackend_sql.h>
15
16// #define _ADDRESSBOOK_ACCESS
17
12Converter::Converter(){ 18Converter::Converter(){
@@ -18,2 +24,4 @@ void Converter::start_conversion(){
18 // Creating backends to the requested databases.. 24 // Creating backends to the requested databases..
25
26#ifdef _ADDRESSBOOK_ACCESS
19 OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter", 27 OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
@@ -28,3 +36,18 @@ void Converter::start_conversion(){
28 OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", 36 OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql",
29 QString::null , sqlBackend, true ); 37 QString::null );
38
39#else
40 ODateBookAccessBackend* xmlBackend = new ODateBookAccessBackend_XML( "Converter",
41 QString::null );
42
43 ODateBookAccessBackend* sqlBackend = new ODateBookAccessBackend_SQL( QString::null,
44 QString::null );
45 // Put the created backends into frontends to access them
46 ODateBookAccess* xmlAccess = new ODateBookAccess ( xmlBackend );
47
48 ODateBookAccess* sqlAccess = new ODateBookAccess ( sqlBackend );
49
50 xmlAccess->load();
51
52#endif
30 53
@@ -36,2 +59,3 @@ void Converter::start_conversion(){
36 59
60#ifdef _ADDRESSBOOK_ACCESS
37 // Now trasmit every contact from the xml database to the sql-database 61 // Now trasmit every contact from the xml database to the sql-database
@@ -47,3 +71,18 @@ void Converter::start_conversion(){
47 } 71 }
72#else
73 // Now transmit every contact from the xml database to the sql-database
74 ODateBookAccess::List dateList = xmlAccess->allRecords();
75 m_progressBar->setTotalSteps( dateList.count() );
76 qWarning( "Number of elements to copy: %d", dateList.count() );
77
78 int count = 0;
79 if ( sqlAccess && xmlAccess ){
80 ODateBookAccess::List::Iterator it;
81 for ( it = dateList.begin(); it != dateList.end(); ++it ){
82 sqlAccess->add( *it );
83 m_progressBar->setProgress( ++count );
84 }
85 }
48 86
87 #endif
49 // Delete the frontends. Backends will be deleted automatically, too ! 88 // Delete the frontends. Backends will be deleted automatically, too !