author | eilers <eilers> | 2003-09-29 07:41:45 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-09-29 07:41:45 (UTC) |
commit | b2e22408970ef548e23e9bbdcd87302f35fc6d4d (patch) (unidiff) | |
tree | 9dd613f64fb333c3591a4aa2b080d1e9e984cddd /libopie/pim/test/converter.cpp | |
parent | 33a64fac931c3332bce9fb97e9996dc0e4c9d236 (diff) | |
download | opie-b2e22408970ef548e23e9bbdcd87302f35fc6d4d.zip opie-b2e22408970ef548e23e9bbdcd87302f35fc6d4d.tar.gz opie-b2e22408970ef548e23e9bbdcd87302f35fc6d4d.tar.bz2 |
Starting to develop a universal PIM-database converter
Diffstat (limited to 'libopie/pim/test/converter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/test/converter.cpp | 36 |
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" | 12 | Converter::Converter(){ |
8 | 13 | } | |
9 | class ConvertXMLToSQL: public converter_base { | ||
10 | public: | ||
11 | ConvertXMLToSQL() | ||
12 | { | ||
13 | convertContact(); | ||
14 | } | ||
15 | private: | ||
16 | void convertContact(); | ||
17 | |||
18 | }; | ||
19 | |||
20 | 14 | ||
21 | void ConvertXMLToSQL::convertContact(){ | 15 | void 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 ( ); |