author | ar <ar> | 2004-05-21 21:03:21 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-21 21:03:21 (UTC) |
commit | e7810bdfec718c3364e31c2d32357ec0fd2fda77 (patch) (unidiff) | |
tree | 2e5e4028580ca4fce98dc56567731b4cdce4b74b /noncore/tools/pimconverter/converter.cpp | |
parent | 37294c41a902eab36427372bdda31b4462fd73ca (diff) | |
download | opie-e7810bdfec718c3364e31c2d32357ec0fd2fda77.zip opie-e7810bdfec718c3364e31c2d32357ec0fd2fda77.tar.gz opie-e7810bdfec718c3364e31c2d32357ec0fd2fda77.tar.bz2 |
- convert qDebug to odebug
Diffstat (limited to 'noncore/tools/pimconverter/converter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/pimconverter/converter.cpp | 334 |
1 files changed, 169 insertions, 165 deletions
diff --git a/noncore/tools/pimconverter/converter.cpp b/noncore/tools/pimconverter/converter.cpp index 2bd47a4..7d34b24 100644 --- a/noncore/tools/pimconverter/converter.cpp +++ b/noncore/tools/pimconverter/converter.cpp | |||
@@ -1,203 +1,207 @@ | |||
1 | #include "converter.h" | 1 | #include "converter.h" |
2 | 2 | ||
3 | #include <qdatetime.h> | 3 | /* OPIE */ |
4 | #include <qprogressbar.h> | ||
5 | #include <qcombobox.h> | ||
6 | #include <qcheckbox.h> | ||
7 | |||
8 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
9 | 5 | ||
6 | #include <opie2/odebug.h> | ||
10 | #include <opie2/opimglobal.h> | 7 | #include <opie2/opimglobal.h> |
11 | // Include SQL related header files | 8 | // Include SQL related header files |
12 | #define __USE_SQL | 9 | #define __USE_SQL |
13 | #include <opie2/opimaccessfactory.h> | 10 | #include <opie2/opimaccessfactory.h> |
14 | 11 | ||
12 | /* QT */ | ||
13 | #include <qdatetime.h> | ||
14 | #include <qprogressbar.h> | ||
15 | #include <qcombobox.h> | ||
16 | #include <qcheckbox.h> | ||
17 | |||
18 | |||
15 | using namespace Opie; | 19 | using namespace Opie; |
16 | using namespace Pim; | 20 | using namespace Pim; |
17 | 21 | ||
18 | Converter::Converter(): | 22 | Converter::Converter(): |
19 | m_selectedDatabase( ADDRESSBOOK ), | 23 | m_selectedDatabase( ADDRESSBOOK ), |
20 | m_selectedSourceFormat( XML ), | 24 | m_selectedSourceFormat( XML ), |
21 | m_selectedDestFormat( SQL ) | 25 | m_selectedDestFormat( SQL ) |
22 | { | 26 | { |
23 | m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); | 27 | m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); |
24 | m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); | 28 | m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); |
25 | m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); | 29 | m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); |
26 | m_eraseDB -> setChecked( true ); // Default erase on copy | 30 | m_eraseDB -> setChecked( true ); // Default erase on copy |
27 | } | 31 | } |
28 | 32 | ||
29 | void Converter::selectedDatabase( int num ) | 33 | void Converter::selectedDatabase( int num ) |
30 | { | 34 | { |
31 | m_selectedDatabase = num; | 35 | m_selectedDatabase = num; |
32 | } | 36 | } |
33 | 37 | ||
34 | void Converter::selectedDestFormat( int num ) | 38 | void Converter::selectedDestFormat( int num ) |
35 | { | 39 | { |
36 | m_selectedDestFormat = num; | 40 | m_selectedDestFormat = num; |
37 | } | 41 | } |
38 | 42 | ||
39 | void Converter::selectedSourceFormat( int num ) | 43 | void Converter::selectedSourceFormat( int num ) |
40 | { | 44 | { |
41 | m_selectedSourceFormat = num; | 45 | m_selectedSourceFormat = num; |
42 | } | 46 | } |
43 | 47 | ||
44 | void Converter::start_conversion(){ | 48 | void Converter::start_conversion(){ |
45 | 49 | ||
46 | // Creating backends to the requested databases.. | 50 | // Creating backends to the requested databases.. |
47 | OPimBase* sourceDB; | 51 | OPimBase* sourceDB; |
48 | OPimBase* destDB; | 52 | OPimBase* destDB; |
49 | 53 | ||
50 | switch( m_selectedSourceFormat ){ | 54 | switch( m_selectedSourceFormat ){ |
51 | case XML: | 55 | case XML: |
52 | qDebug("XMLSourceDB = %d", m_selectedDatabase); | 56 | odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; |
53 | switch( m_selectedDatabase ){ | 57 | switch( m_selectedDatabase ){ |
54 | case ADDRESSBOOK:{ | 58 | case ADDRESSBOOK:{ |
55 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); | 59 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
56 | } | 60 | } |
57 | break; | 61 | break; |
58 | case TODOLIST:{ | 62 | case TODOLIST:{ |
59 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); | 63 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
60 | }break; | 64 | }break; |
61 | case DATEBOOK:{ | 65 | case DATEBOOK:{ |
62 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); | 66 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
63 | } | 67 | } |
64 | break; | 68 | break; |
65 | default: | 69 | default: |
66 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 70 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
67 | return; | 71 | return; |
68 | } | 72 | } |
69 | break; | 73 | break; |
70 | case SQL: | 74 | case SQL: |
71 | qDebug("SQLSourceDB = %d", m_selectedDatabase); | 75 | odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; |
72 | switch( m_selectedDatabase ){ | 76 | switch( m_selectedDatabase ){ |
73 | case ADDRESSBOOK:{ | 77 | case ADDRESSBOOK:{ |
74 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); | 78 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
75 | } | 79 | } |
76 | break; | 80 | break; |
77 | case TODOLIST:{ | 81 | case TODOLIST:{ |
78 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); | 82 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
79 | }break; | 83 | }break; |
80 | case DATEBOOK:{ | 84 | case DATEBOOK:{ |
81 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); | 85 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
82 | } | 86 | } |
83 | break; | 87 | break; |
84 | default: | 88 | default: |
85 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 89 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
86 | return; | 90 | return; |
87 | } | 91 | } |
88 | break; | 92 | break; |
89 | default: | 93 | default: |
90 | qWarning( "Unknown source format selected (%d) !!", m_selectedSourceFormat ); | 94 | owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; |
91 | return; | 95 | return; |
92 | } | 96 | } |
93 | 97 | ||
94 | switch ( m_selectedDestFormat ){ | 98 | switch ( m_selectedDestFormat ){ |
95 | case XML: | 99 | case XML: |
96 | qDebug("XMLDestDB = %d", m_selectedDatabase); | 100 | odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; |
97 | switch( m_selectedDatabase ){ | 101 | switch( m_selectedDatabase ){ |
98 | case ADDRESSBOOK:{ | 102 | case ADDRESSBOOK:{ |
99 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); | 103 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
100 | } | 104 | } |
101 | break; | 105 | break; |
102 | case TODOLIST:{ | 106 | case TODOLIST:{ |
103 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); | 107 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
104 | }break; | 108 | }break; |
105 | case DATEBOOK:{ | 109 | case DATEBOOK:{ |
106 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); | 110 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
107 | } | 111 | } |
108 | break; | 112 | break; |
109 | default: | 113 | default: |
110 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 114 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
111 | return; | 115 | return; |
112 | } | 116 | } |
113 | break; | 117 | break; |
114 | case SQL: | 118 | case SQL: |
115 | qDebug("SQLDestDB = %d", m_selectedDatabase); | 119 | odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; |
116 | switch( m_selectedDatabase ){ | 120 | switch( m_selectedDatabase ){ |
117 | case ADDRESSBOOK:{ | 121 | case ADDRESSBOOK:{ |
118 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); | 122 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
119 | } | 123 | } |
120 | break; | 124 | break; |
121 | case TODOLIST:{ | 125 | case TODOLIST:{ |
122 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); | 126 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
123 | }break; | 127 | }break; |
124 | case DATEBOOK:{ | 128 | case DATEBOOK:{ |
125 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); | 129 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
126 | } | 130 | } |
127 | break; | 131 | break; |
128 | default: | 132 | default: |
129 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 133 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
130 | return; | 134 | return; |
131 | } | 135 | } |
132 | break; | 136 | break; |
133 | default: | 137 | default: |
134 | qWarning( "Unknown destination format selected (%d)!!", m_selectedDestFormat ); | 138 | owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; |
135 | return; | 139 | return; |
136 | } | 140 | } |
137 | 141 | ||
138 | if ( !sourceDB || !destDB ) | 142 | if ( !sourceDB || !destDB ) |
139 | return; | 143 | return; |
140 | 144 | ||
141 | sourceDB -> load(); | 145 | sourceDB -> load(); |
142 | destDB -> load(); | 146 | destDB -> load(); |
143 | 147 | ||
144 | QTime t; | 148 | QTime t; |
145 | t.start(); | 149 | t.start(); |
146 | 150 | ||
147 | // Clean the dest-database if requested (isChecked) | 151 | // Clean the dest-database if requested (isChecked) |
148 | if ( m_eraseDB -> isChecked() ){ | 152 | if ( m_eraseDB -> isChecked() ){ |
149 | qDebug( "Clearing destination database!" ); | 153 | odebug << "Clearing destination database!" << oendl; |
150 | destDB -> clear(); | 154 | destDB -> clear(); |
151 | } | 155 | } |
152 | 156 | ||
153 | // Now transmit every pim-item from the source database to the destination -database | 157 | // Now transmit every pim-item from the source database to the destination -database |
154 | QArray<int> uidList = sourceDB->records(); | 158 | QArray<int> uidList = sourceDB->records(); |
155 | qDebug( "Try to move data for addressbook.. (%d items) ", uidList.count() ); | 159 | odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; |
156 | m_progressBar->setTotalSteps( uidList.count() ); | 160 | m_progressBar->setTotalSteps( uidList.count() ); |
157 | int count = 0; | 161 | int count = 0; |
158 | for ( uint i = 0; i < uidList.count(); ++i ){ | 162 | for ( uint i = 0; i < uidList.count(); ++i ){ |
159 | qDebug( "Adding uid: %d", uidList[i] ); | 163 | odebug << "Adding uid: " << uidList[i] << "" << oendl; |
160 | OPimRecord* rec = sourceDB -> record( uidList[i] ); | 164 | OPimRecord* rec = sourceDB -> record( uidList[i] ); |
161 | destDB -> add( rec ); | 165 | destDB -> add( rec ); |
162 | m_progressBar->setProgress( ++count ); | 166 | m_progressBar->setProgress( ++count ); |
163 | } | 167 | } |
164 | 168 | ||
165 | // Now commit data.. | 169 | // Now commit data.. |
166 | destDB -> save(); | 170 | destDB -> save(); |
167 | 171 | ||
168 | // Delete the frontends. Backends will be deleted automatically, too ! | 172 | // Delete the frontends. Backends will be deleted automatically, too ! |
169 | // We have to cast them back to delete them properly ! | 173 | // We have to cast them back to delete them properly ! |
170 | switch( m_selectedDatabase ){ | 174 | switch( m_selectedDatabase ){ |
171 | case ADDRESSBOOK: | 175 | case ADDRESSBOOK: |
172 | delete static_cast<OPimContactAccess*> (sourceDB); | 176 | delete static_cast<OPimContactAccess*> (sourceDB); |
173 | delete static_cast<OPimContactAccess*> (destDB); | 177 | delete static_cast<OPimContactAccess*> (destDB); |
174 | break; | 178 | break; |
175 | case TODOLIST: | 179 | case TODOLIST: |
176 | delete static_cast<OPimTodoAccess*> (sourceDB); | 180 | delete static_cast<OPimTodoAccess*> (sourceDB); |
177 | delete static_cast<OPimTodoAccess*> (destDB); | 181 | delete static_cast<OPimTodoAccess*> (destDB); |
178 | break; | 182 | break; |
179 | case DATEBOOK: | 183 | case DATEBOOK: |
180 | delete static_cast<ODateBookAccess*> (sourceDB); | 184 | delete static_cast<ODateBookAccess*> (sourceDB); |
181 | delete static_cast<ODateBookAccess*> (destDB); | 185 | delete static_cast<ODateBookAccess*> (destDB); |
182 | break; | 186 | break; |
183 | default: | 187 | default: |
184 | qWarning( "Unknown database selected (%d)", m_selectedDatabase ); | 188 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
185 | return; | 189 | return; |
186 | } | 190 | } |
187 | 191 | ||
188 | 192 | ||
189 | qWarning("Conversion is finished and needed %d ms !", t.elapsed()); | 193 | owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; |
190 | } | 194 | } |
191 | 195 | ||
192 | int main( int argc, char** argv ) { | 196 | int main( int argc, char** argv ) { |
193 | 197 | ||
194 | QPEApplication a( argc, argv ); | 198 | QPEApplication a( argc, argv ); |
195 | 199 | ||
196 | Converter dlg; | 200 | Converter dlg; |
197 | 201 | ||
198 | a.showMainWidget( &dlg ); | 202 | a.showMainWidget( &dlg ); |
199 | // dlg. showMaximized ( ); | 203 | // dlg. showMaximized ( ); |
200 | 204 | ||
201 | return a.exec(); | 205 | return a.exec(); |
202 | 206 | ||
203 | } | 207 | } |