author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/pim/test/converter.cpp | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
Diffstat (limited to 'libopie/pim/test/converter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/test/converter.cpp | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp deleted file mode 100644 index bfdb605..0000000 --- a/libopie/pim/test/converter.cpp +++ b/dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | #include "converter.h" | ||
2 | |||
3 | #include <qdatetime.h> | ||
4 | #include <qprogressbar.h> | ||
5 | |||
6 | #include <qpe/qpeapplication.h> | ||
7 | |||
8 | #include <opie/ocontactaccess.h> | ||
9 | #include <opie/ocontactaccessbackend_xml.h> | ||
10 | #include <opie/ocontactaccessbackend_sql.h> | ||
11 | |||
12 | #include <opie/odatebookaccess.h> | ||
13 | #include <opie/odatebookaccessbackend_xml.h> | ||
14 | #include <opie/odatebookaccessbackend_sql.h> | ||
15 | |||
16 | // #define _ADDRESSBOOK_ACCESS | ||
17 | |||
18 | Converter::Converter(){ | ||
19 | } | ||
20 | |||
21 | void Converter::start_conversion(){ | ||
22 | qWarning("Converting Contacts from XML to SQL.."); | ||
23 | |||
24 | // Creating backends to the requested databases.. | ||
25 | |||
26 | #ifdef _ADDRESSBOOK_ACCESS | ||
27 | OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter", | ||
28 | QString::null ); | ||
29 | |||
30 | OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null, | ||
31 | QString::null ); | ||
32 | // Put the created backends into frontends to access them | ||
33 | OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml", | ||
34 | QString::null , xmlBackend, true ); | ||
35 | |||
36 | OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", | ||
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 | ||
53 | |||
54 | QTime t; | ||
55 | t.start(); | ||
56 | |||
57 | // Clean the sql-database.. | ||
58 | sqlAccess->clear(); | ||
59 | |||
60 | #ifdef _ADDRESSBOOK_ACCESS | ||
61 | // Now trasmit every contact from the xml database to the sql-database | ||
62 | OContactAccess::List contactList = xmlAccess->allRecords(); | ||
63 | m_progressBar->setTotalSteps( contactList.count() ); | ||
64 | int count = 0; | ||
65 | if ( sqlAccess && xmlAccess ){ | ||
66 | OContactAccess::List::Iterator it; | ||
67 | for ( it = contactList.begin(); it != contactList.end(); ++it ){ | ||
68 | sqlAccess->add( *it ); | ||
69 | m_progressBar->setProgress( ++count ); | ||
70 | } | ||
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 | } | ||
86 | |||
87 | #endif | ||
88 | // Delete the frontends. Backends will be deleted automatically, too ! | ||
89 | delete sqlAccess; | ||
90 | |||
91 | qWarning("Conversion is finished and needed %d ms !", t.elapsed()); | ||
92 | |||
93 | delete xmlAccess; | ||
94 | } | ||
95 | |||
96 | int main( int argc, char** argv ) { | ||
97 | |||
98 | QPEApplication a( argc, argv ); | ||
99 | |||
100 | Converter dlg; | ||
101 | |||
102 | a.showMainWidget( &dlg ); | ||
103 | // dlg. showMaximized ( ); | ||
104 | |||
105 | return a.exec(); | ||
106 | |||
107 | } | ||