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.cpp34
1 files changed, 19 insertions, 15 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,27 +1,21 @@
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
9class ConvertXMLToSQL: public converter_base {
10public:
11 ConvertXMLToSQL()
12 {
13 convertContact();
14 } 13 }
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..
25 OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter", 19 OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
26 QString::null ); 20 QString::null );
27 21
@@ -31,33 +25,43 @@ void ConvertXMLToSQL::convertContact(){
31 OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml", 25 OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml",
32 QString::null , xmlBackend, true ); 26 QString::null , xmlBackend, true );
33 27
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
53int main( int argc, char** argv ) { 57int 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 ( );
61 65
62 return a.exec(); 66 return a.exec();
63 67