summaryrefslogtreecommitdiff
path: root/libopie/pim/test/converter.cpp
Unidiff
Diffstat (limited to 'libopie/pim/test/converter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/test/converter.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp
index 0a488f2..650d119 100644
--- a/libopie/pim/test/converter.cpp
+++ b/libopie/pim/test/converter.cpp
@@ -1,24 +1,18 @@
1#include "converter.h"
2
3#include <qdatetime.h>
4#include <qprogressbar.h>
5
1#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
2 7
3#include <opie/ocontactaccess.h> 8#include <opie/ocontactaccess.h>
4#include <opie/ocontactaccessbackend_xml.h> 9#include <opie/ocontactaccessbackend_xml.h>
5#include <opie/ocontactaccessbackend_sql.h> 10#include <opie/ocontactaccessbackend_sql.h>
6 11
7#include "converter_base.h" 12Converter::Converter(){
8 13}
9class ConvertXMLToSQL: public converter_base {
10public:
11 ConvertXMLToSQL()
12 {
13 convertContact();
14 }
15private:
16 void convertContact();
17
18};
19
20 14
21void ConvertXMLToSQL::convertContact(){ 15void Converter::start_conversion(){
22 qWarning("Converting Contacts from XML to SQL.."); 16 qWarning("Converting Contacts from XML to SQL..");
23 17
24 // Creating backends to the requested databases.. 18 // Creating backends to the requested databases..
@@ -34,19 +28,29 @@ void ConvertXMLToSQL::convertContact(){
34 OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", 28 OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql",
35 QString::null , sqlBackend, true ); 29 QString::null , sqlBackend, true );
36 30
31 QTime t;
32 t.start();
33
37 // Clean the sql-database.. 34 // Clean the sql-database..
38 sqlAccess->clear(); 35 sqlAccess->clear();
39 36
40 // Now trasmit every contact from the xml database to the sql-database 37 // Now trasmit every contact from the xml database to the sql-database
41 OContactAccess::List contactList = xmlAccess->allRecords(); 38 OContactAccess::List contactList = xmlAccess->allRecords();
39 m_progressBar->setTotalSteps( contactList.count() );
40 int count = 0;
42 if ( sqlAccess && xmlAccess ){ 41 if ( sqlAccess && xmlAccess ){
43 OContactAccess::List::Iterator it; 42 OContactAccess::List::Iterator it;
44 for ( it = contactList.begin(); it != contactList.end(); ++it ) 43 for ( it = contactList.begin(); it != contactList.end(); ++it ){
45 sqlAccess->add( *it ); 44 sqlAccess->add( *it );
45 m_progressBar->setProgress( ++count );
46 }
46 } 47 }
47 48
48 // Delete the frontends. Backends will be deleted automatically, too ! 49 // Delete the frontends. Backends will be deleted automatically, too !
49 delete sqlAccess; 50 delete sqlAccess;
51
52 qWarning("Conversion is finished and needed %d ms !", t.elapsed());
53
50 delete xmlAccess; 54 delete xmlAccess;
51} 55}
52 56
@@ -54,7 +58,7 @@ int main( int argc, char** argv ) {
54 58
55 QPEApplication a( argc, argv ); 59 QPEApplication a( argc, argv );
56 60
57 ConvertXMLToSQL dlg; 61 Converter dlg;
58 62
59 a.showMainWidget( &dlg ); 63 a.showMainWidget( &dlg );
60 // dlg. showMaximized ( ); 64 // dlg. showMaximized ( );