author | eilers <eilers> | 2004-10-23 12:05:13 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-10-23 12:05:13 (UTC) |
commit | aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb (patch) (unidiff) | |
tree | 37b683afa01b06245f81ff13cf8362e9f6ab9378 | |
parent | f2a2eca1870e1fd88c82a6ccb039610949daa72c (diff) | |
download | opie-aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb.zip opie-aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb.tar.gz opie-aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb.tar.bz2 |
Pimconverter got a button to convert databases from sqlite 2->3.
If correct implementation is confirmed, I will commit the rest..
-rw-r--r-- | noncore/tools/pimconverter/converter.cpp | 87 | ||||
-rwxr-xr-x | noncore/tools/pimconverter/converter.h | 2 | ||||
-rw-r--r-- | noncore/tools/pimconverter/converter_base.ui | 62 |
3 files changed, 141 insertions, 10 deletions
diff --git a/noncore/tools/pimconverter/converter.cpp b/noncore/tools/pimconverter/converter.cpp index e9de3c3..2cd6969 100644 --- a/noncore/tools/pimconverter/converter.cpp +++ b/noncore/tools/pimconverter/converter.cpp | |||
@@ -1,226 +1,313 @@ | |||
1 | #include "converter.h" | 1 | #include "converter.h" |
2 | 2 | ||
3 | #include <stdlib.h> // For "system()" command | ||
4 | |||
3 | /* OPIE */ | 5 | /* OPIE */ |
4 | #include <opie2/oapplicationfactory.h> | 6 | #include <opie2/oapplicationfactory.h> |
5 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
6 | #include <opie2/opimglobal.h> | 8 | #include <opie2/opimglobal.h> |
7 | // Include SQL related header files | 9 | // Include SQL related header files |
8 | #define __USE_SQL | 10 | #define __USE_SQL |
9 | #include <opie2/opimaccessfactory.h> | 11 | #include <opie2/opimaccessfactory.h> |
10 | 12 | ||
11 | /* QT */ | 13 | /* QT */ |
12 | #include <qdatetime.h> | 14 | #include <qdatetime.h> |
13 | #include <qprogressbar.h> | 15 | #include <qprogressbar.h> |
14 | #include <qcombobox.h> | 16 | #include <qcombobox.h> |
15 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
16 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
17 | 19 | ||
18 | 20 | ||
19 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<Converter> ) | 21 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<Converter> ) |
20 | 22 | ||
21 | using namespace Opie; | 23 | using namespace Opie; |
22 | using namespace Pim; | 24 | using namespace Pim; |
23 | 25 | ||
24 | Converter::Converter(QWidget *p, const char* n, WFlags fl): | 26 | Converter::Converter(QWidget *p, const char* n, WFlags fl): |
25 | converter_base( p, n, fl ), | 27 | converter_base( p, n, fl ), |
26 | m_selectedDatabase( ADDRESSBOOK ), | 28 | m_selectedDatabase( ADDRESSBOOK ), |
27 | m_selectedSourceFormat( XML ), | 29 | m_selectedSourceFormat( XML ), |
28 | m_selectedDestFormat( SQL ), | 30 | m_selectedDestFormat( SQL ), |
29 | m_criticalState( false ) | 31 | m_criticalState( false ) |
30 | { | 32 | { |
31 | m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); | 33 | m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); |
32 | m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); | 34 | m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); |
33 | m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); | 35 | m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); |
34 | m_eraseDB -> setChecked( true ); // Default erase on copy | 36 | m_eraseDB -> setChecked( true ); // Default erase on copy |
35 | } | 37 | } |
36 | 38 | ||
37 | void Converter::selectedDatabase( int num ) | 39 | void Converter::selectedDatabase( int num ) |
38 | { | 40 | { |
39 | m_selectedDatabase = num; | 41 | m_selectedDatabase = num; |
40 | } | 42 | } |
41 | 43 | ||
42 | void Converter::selectedDestFormat( int num ) | 44 | void Converter::selectedDestFormat( int num ) |
43 | { | 45 | { |
44 | m_selectedDestFormat = num; | 46 | m_selectedDestFormat = num; |
45 | } | 47 | } |
46 | 48 | ||
47 | void Converter::selectedSourceFormat( int num ) | 49 | void Converter::selectedSourceFormat( int num ) |
48 | { | 50 | { |
49 | m_selectedSourceFormat = num; | 51 | m_selectedSourceFormat = num; |
50 | } | 52 | } |
51 | 53 | ||
52 | void Converter::start_conversion(){ | 54 | void Converter::start_conversion(){ |
53 | 55 | ||
54 | // Creating backends to the requested databases.. | 56 | // Creating backends to the requested databases.. |
55 | OPimBase* sourceDB; | 57 | OPimBase* sourceDB; |
56 | OPimBase* destDB; | 58 | OPimBase* destDB; |
57 | 59 | ||
58 | odebug << "SourceFormat: " << m_selectedSourceFormat << oendl; | 60 | odebug << "SourceFormat: " << m_selectedSourceFormat << oendl; |
59 | odebug << "DestFormat: " << m_selectedDestFormat << oendl; | 61 | odebug << "DestFormat: " << m_selectedDestFormat << oendl; |
60 | if ( m_selectedSourceFormat == m_selectedDestFormat ){ | 62 | if ( m_selectedSourceFormat == m_selectedDestFormat ){ |
61 | 63 | ||
62 | QMessageBox::warning( this, "PimConverter", | 64 | QMessageBox::warning( this, "PimConverter", |
63 | tr( "It is not a good idea to use\n" ) | 65 | tr( "It is not a good idea to use\n" ) |
64 | +tr( "the same source and destformat !" ), | 66 | +tr( "the same source and destformat !" ), |
65 | tr( "Ok" ) ); | 67 | tr( "Ok" ) ); |
66 | return; | 68 | return; |
67 | } | 69 | } |
68 | 70 | ||
69 | switch( m_selectedSourceFormat ){ | 71 | switch( m_selectedSourceFormat ){ |
70 | case XML: | 72 | case XML: |
71 | odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; | 73 | odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; |
72 | switch( m_selectedDatabase ){ | 74 | switch( m_selectedDatabase ){ |
73 | case ADDRESSBOOK:{ | 75 | case ADDRESSBOOK:{ |
74 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); | 76 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
75 | } | 77 | } |
76 | break; | 78 | break; |
77 | case TODOLIST:{ | 79 | case TODOLIST:{ |
78 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); | 80 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
79 | }break; | 81 | }break; |
80 | case DATEBOOK:{ | 82 | case DATEBOOK:{ |
81 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); | 83 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
82 | } | 84 | } |
83 | break; | 85 | break; |
84 | default: | 86 | default: |
85 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 87 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
86 | return; | 88 | return; |
87 | } | 89 | } |
88 | break; | 90 | break; |
89 | case SQL: | 91 | case SQL: |
90 | odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; | 92 | odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; |
91 | switch( m_selectedDatabase ){ | 93 | switch( m_selectedDatabase ){ |
92 | case ADDRESSBOOK:{ | 94 | case ADDRESSBOOK:{ |
93 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); | 95 | sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
94 | } | 96 | } |
95 | break; | 97 | break; |
96 | case TODOLIST:{ | 98 | case TODOLIST:{ |
97 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); | 99 | sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
98 | }break; | 100 | }break; |
99 | case DATEBOOK:{ | 101 | case DATEBOOK:{ |
100 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); | 102 | sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
101 | } | 103 | } |
102 | break; | 104 | break; |
103 | default: | 105 | default: |
104 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 106 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
105 | return; | 107 | return; |
106 | } | 108 | } |
107 | break; | 109 | break; |
108 | default: | 110 | default: |
109 | owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; | 111 | owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; |
110 | return; | 112 | return; |
111 | } | 113 | } |
112 | 114 | ||
113 | switch ( m_selectedDestFormat ){ | 115 | switch ( m_selectedDestFormat ){ |
114 | case XML: | 116 | case XML: |
115 | odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; | 117 | odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; |
116 | switch( m_selectedDatabase ){ | 118 | switch( m_selectedDatabase ){ |
117 | case ADDRESSBOOK:{ | 119 | case ADDRESSBOOK:{ |
118 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); | 120 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); |
119 | } | 121 | } |
120 | break; | 122 | break; |
121 | case TODOLIST:{ | 123 | case TODOLIST:{ |
122 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); | 124 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); |
123 | }break; | 125 | }break; |
124 | case DATEBOOK:{ | 126 | case DATEBOOK:{ |
125 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); | 127 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); |
126 | } | 128 | } |
127 | break; | 129 | break; |
128 | default: | 130 | default: |
129 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 131 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
130 | return; | 132 | return; |
131 | } | 133 | } |
132 | break; | 134 | break; |
133 | case SQL: | 135 | case SQL: |
134 | odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; | 136 | odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; |
135 | switch( m_selectedDatabase ){ | 137 | switch( m_selectedDatabase ){ |
136 | case ADDRESSBOOK:{ | 138 | case ADDRESSBOOK:{ |
137 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); | 139 | destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); |
138 | } | 140 | } |
139 | break; | 141 | break; |
140 | case TODOLIST:{ | 142 | case TODOLIST:{ |
141 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); | 143 | destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); |
142 | }break; | 144 | }break; |
143 | case DATEBOOK:{ | 145 | case DATEBOOK:{ |
144 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); | 146 | destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); |
145 | } | 147 | } |
146 | break; | 148 | break; |
147 | default: | 149 | default: |
148 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 150 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
149 | return; | 151 | return; |
150 | } | 152 | } |
151 | break; | 153 | break; |
152 | default: | 154 | default: |
153 | owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; | 155 | owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; |
154 | return; | 156 | return; |
155 | } | 157 | } |
156 | 158 | ||
157 | if ( !sourceDB || !destDB ) | 159 | if ( !sourceDB || !destDB ) |
158 | return; | 160 | return; |
159 | 161 | ||
160 | m_criticalState = true; | 162 | m_criticalState = true; |
161 | 163 | ||
162 | sourceDB -> load(); | 164 | sourceDB -> load(); |
163 | destDB -> load(); | 165 | destDB -> load(); |
164 | 166 | ||
165 | QTime t; | 167 | QTime t; |
166 | t.start(); | 168 | t.start(); |
167 | 169 | ||
168 | // Clean the dest-database if requested (isChecked) | 170 | // Clean the dest-database if requested (isChecked) |
169 | if ( m_eraseDB -> isChecked() ){ | 171 | if ( m_eraseDB -> isChecked() ){ |
170 | odebug << "Clearing destination database!" << oendl; | 172 | odebug << "Clearing destination database!" << oendl; |
171 | destDB -> clear(); | 173 | destDB -> clear(); |
172 | } | 174 | } |
173 | 175 | ||
174 | // Now transmit every pim-item from the source database to the destination -database | 176 | // Now transmit every pim-item from the source database to the destination -database |
175 | QArray<int> uidList = sourceDB->records(); | 177 | QArray<int> uidList = sourceDB->records(); |
176 | odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; | 178 | odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; |
177 | m_progressBar->setTotalSteps( uidList.count() ); | 179 | m_progressBar->setTotalSteps( uidList.count() ); |
178 | int count = 0; | 180 | int count = 0; |
179 | for ( uint i = 0; i < uidList.count(); ++i ){ | 181 | for ( uint i = 0; i < uidList.count(); ++i ){ |
180 | odebug << "Adding uid: " << uidList[i] << "" << oendl; | 182 | odebug << "Adding uid: " << uidList[i] << "" << oendl; |
181 | OPimRecord* rec = sourceDB -> record( uidList[i] ); | 183 | OPimRecord* rec = sourceDB -> record( uidList[i] ); |
182 | destDB -> add( rec ); | 184 | destDB -> add( rec ); |
183 | m_progressBar->setProgress( ++count ); | 185 | m_progressBar->setProgress( ++count ); |
184 | } | 186 | } |
185 | 187 | ||
186 | // Now commit data.. | 188 | // Now commit data.. |
187 | destDB -> save(); | 189 | destDB -> save(); |
188 | 190 | ||
189 | m_criticalState = false; | 191 | m_criticalState = false; |
190 | 192 | ||
191 | // Delete the frontends. Backends will be deleted automatically, too ! | 193 | // Delete the frontends. Backends will be deleted automatically, too ! |
192 | // We have to cast them back to delete them properly ! | 194 | // We have to cast them back to delete them properly ! |
193 | switch( m_selectedDatabase ){ | 195 | switch( m_selectedDatabase ){ |
194 | case ADDRESSBOOK: | 196 | case ADDRESSBOOK: |
195 | delete static_cast<OPimContactAccess*> (sourceDB); | 197 | delete static_cast<OPimContactAccess*> (sourceDB); |
196 | delete static_cast<OPimContactAccess*> (destDB); | 198 | delete static_cast<OPimContactAccess*> (destDB); |
197 | break; | 199 | break; |
198 | case TODOLIST: | 200 | case TODOLIST: |
199 | delete static_cast<OPimTodoAccess*> (sourceDB); | 201 | delete static_cast<OPimTodoAccess*> (sourceDB); |
200 | delete static_cast<OPimTodoAccess*> (destDB); | 202 | delete static_cast<OPimTodoAccess*> (destDB); |
201 | break; | 203 | break; |
202 | case DATEBOOK: | 204 | case DATEBOOK: |
203 | delete static_cast<ODateBookAccess*> (sourceDB); | 205 | delete static_cast<ODateBookAccess*> (sourceDB); |
204 | delete static_cast<ODateBookAccess*> (destDB); | 206 | delete static_cast<ODateBookAccess*> (destDB); |
205 | break; | 207 | break; |
206 | default: | 208 | default: |
207 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; | 209 | owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; |
208 | return; | 210 | return; |
209 | } | 211 | } |
210 | 212 | ||
211 | 213 | ||
212 | owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; | 214 | owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; |
213 | } | 215 | } |
214 | 216 | ||
215 | void Converter::closeEvent( QCloseEvent *e ) | 217 | void Converter::closeEvent( QCloseEvent *e ) |
216 | { | 218 | { |
217 | 219 | ||
218 | /* Due to the fact that we don't have multitasking here, this | 220 | /* Due to the fact that we don't have multitasking here, this |
219 | * critical handling don't make sense, but the future.. | 221 | * critical handling don't make sense, but the future.. |
220 | */ | 222 | */ |
221 | if ( m_criticalState ){ | 223 | if ( m_criticalState ){ |
222 | e->ignore(); | 224 | e->ignore(); |
223 | return; | 225 | return; |
224 | } | 226 | } |
225 | e->accept(); | 227 | e->accept(); |
226 | } | 228 | } |
229 | |||
230 | |||
231 | |||
232 | void Converter::start_upgrade() | ||
233 | { | ||
234 | odebug << "Start upgrading" << oendl; | ||
235 | switch( QMessageBox::warning( this, "Pim-Converter", | ||
236 | "Are you really sure that you\n" | ||
237 | "want to convert your database from\n" | ||
238 | "sqlite V2 to sqlite V3?", | ||
239 | QMessageBox::Ok | QMessageBox::Default, | ||
240 | QMessageBox::Abort | QMessageBox::Escape )) { | ||
241 | |||
242 | case QMessageBox::Abort: // Abort clicked or Escape pressed | ||
243 | // abort | ||
244 | return; | ||
245 | break; | ||
246 | } | ||
247 | odebug << "Checking whether sqlite is installed" << oendl; | ||
248 | if ( system( "which sqlite" ) != 0 ){ | ||
249 | QMessageBox::critical( this, "Pim-Converter", | ||
250 | QString("An internal error occurred:\n") + | ||
251 | "sqlite was not accessible!\n"+ | ||
252 | "Please correct the PATH or install \n" + | ||
253 | "this packages!" ); | ||
254 | return; | ||
255 | } | ||
256 | if ( system( "which sqlite3" ) != 0 ){ | ||
257 | QMessageBox::critical( this, "Pim-Converter", | ||
258 | QString("An internal error occurred:\n") + | ||
259 | "sqlite3 was not accessible!\n"+ | ||
260 | "Please correct the PATH or install \n" + | ||
261 | "this packages!" ); | ||
262 | return; | ||
263 | } | ||
264 | if ( QFile::exists( "~/Applications/addressbook/addressbook.db" ) | ||
265 | && !QFile::exists( "~/Applications/addressbook/addressbook.db_v2" ) ){ | ||
266 | odebug << "Executing conversion commands" << oendl; | ||
267 | QString addr_convert_string = "cd ~/Applications/addressbook/;cp addressbook.db addressbook.db_v2;sqlite addressbook.db_v2 .dump | sqlite3 addressbook.db"; | ||
268 | odebug << "1. Addressbook Command:" << addr_convert_string << oendl; | ||
269 | if ( system( addr_convert_string ) != 0 ){ | ||
270 | QMessageBox::critical( this, "Pim-Converter", | ||
271 | QString("An internal error occurred:\n") + | ||
272 | "Converting the addressbook command was impossible!\n"+ | ||
273 | "Executed the following command:\n" + | ||
274 | addr_convert_string ); | ||
275 | return; | ||
276 | } | ||
277 | } | ||
278 | if ( QFile::exists( "~/Applications/datebook/datebook.db" ) | ||
279 | && !QFile::exists( "~/Applications/datebook/datebook.db_v2" ) ){ | ||
280 | QString dateb_convert_string = "cd ~/Applications/datebook/;cp datebook.db datebook.db_v2;sqlite datebook.db_v2 .dump | sqlite3 datebook.db"; | ||
281 | odebug << "2. Datebook Command" << dateb_convert_string << oendl; | ||
282 | if ( system( dateb_convert_string ) != 0 ){ | ||
283 | QMessageBox::critical( this, "Pim-Converter", | ||
284 | QString("An internal error occurred:\n") + | ||
285 | "Converting the datebook command was impossible!\n"+ | ||
286 | "Executed the following command:\n" + | ||
287 | dateb_convert_string ); | ||
288 | return; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | if ( QFile::exists( "~/Applications/todolist/todolist.db" ) | ||
293 | && !QFile::exists( "~/Applications/todolist/todolist.db_v2" ) ){ | ||
294 | QString todo_convert_string = "cd ~/Applications/todolist/;cp todolist.db todolist.db_v2;sqlite todolist.db_v2 .dump | sqlite3 todolist.db"; | ||
295 | odebug << "3. Todolist Command:" << todo_convert_string << oendl; | ||
296 | if ( system( todo_convert_string ) != 0 ){ | ||
297 | QMessageBox::critical( this, "Pim-Converter", | ||
298 | QString("An internal error occurred:\n") + | ||
299 | "Converting the todolist command was impossible!\n"+ | ||
300 | "Executed the following command:\n" + | ||
301 | todo_convert_string ); | ||
302 | return; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | QMessageBox::information( this, "Pim-Converter", | ||
307 | "Conversion is finished!", | ||
308 | "&OK", NULL, NULL, | ||
309 | 0, // Enter == button 0 | ||
310 | 0 ); | ||
311 | |||
312 | |||
313 | } | ||
diff --git a/noncore/tools/pimconverter/converter.h b/noncore/tools/pimconverter/converter.h index 344562a..9d75d79 100755 --- a/noncore/tools/pimconverter/converter.h +++ b/noncore/tools/pimconverter/converter.h | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef _CONVERTER_H_ | 1 | #ifndef _CONVERTER_H_ |
2 | #define _CONVERTER_H_ | 2 | #define _CONVERTER_H_ |
3 | 3 | ||
4 | 4 | ||
5 | #include "converter_base.h" | 5 | #include "converter_base.h" |
6 | 6 | ||
7 | 7 | ||
8 | class Converter: public converter_base { | 8 | class Converter: public converter_base { |
9 | public: | 9 | public: |
10 | Converter(QWidget *parent, const char* name, WFlags fl); | 10 | Converter(QWidget *parent, const char* name, WFlags fl); |
11 | static QString appName() { return QString::fromLatin1("opimconverter");} | 11 | static QString appName() { return QString::fromLatin1("opimconverter");} |
12 | 12 | ||
13 | // Slots defined in the ui-description file | 13 | // Slots defined in the ui-description file |
14 | void start_conversion(); | 14 | void start_conversion(); |
15 | void start_upgrade(); | ||
15 | void selectedDatabase( int num ); | 16 | void selectedDatabase( int num ); |
16 | void selectedDestFormat( int num ); | 17 | void selectedDestFormat( int num ); |
17 | void selectedSourceFormat( int num ); | 18 | void selectedSourceFormat( int num ); |
18 | 19 | ||
19 | void closeEvent( QCloseEvent *e ); | 20 | void closeEvent( QCloseEvent *e ); |
20 | 21 | ||
21 | private: | 22 | private: |
22 | // Caution: | 23 | // Caution: |
23 | // The order and value of the following enums must be regarding | 24 | // The order and value of the following enums must be regarding |
24 | // the predefinition in the UI-File !! | 25 | // the predefinition in the UI-File !! |
26 | // If you don't understand what I am talking about: Keep your fingers away!! | ||
25 | enum DataBases{ | 27 | enum DataBases{ |
26 | ADDRESSBOOK = 0, | 28 | ADDRESSBOOK = 0, |
27 | TODOLIST = 1, | 29 | TODOLIST = 1, |
28 | DATEBOOK = 2, | 30 | DATEBOOK = 2, |
29 | }; | 31 | }; |
30 | 32 | ||
31 | enum DbFormats{ | 33 | enum DbFormats{ |
32 | XML = 0, | 34 | XML = 0, |
33 | SQL = 1, | 35 | SQL = 1, |
34 | }; | 36 | }; |
35 | 37 | ||
36 | int m_selectedDatabase; | 38 | int m_selectedDatabase; |
37 | int m_selectedSourceFormat; | 39 | int m_selectedSourceFormat; |
38 | int m_selectedDestFormat; | 40 | int m_selectedDestFormat; |
39 | bool m_criticalState; | 41 | bool m_criticalState; |
40 | 42 | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | 45 | ||
44 | #endif | 46 | #endif |
diff --git a/noncore/tools/pimconverter/converter_base.ui b/noncore/tools/pimconverter/converter_base.ui index a5b22c9..b519f2e 100644 --- a/noncore/tools/pimconverter/converter_base.ui +++ b/noncore/tools/pimconverter/converter_base.ui | |||
@@ -1,291 +1,333 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>converter_base</class> | 2 | <class>converter_base</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>converter_base</cstring> | 7 | <cstring>converter_base</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>269</width> | 14 | <width>308</width> |
15 | <height>324</height> | 15 | <height>323</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>PIM-Database Converter</string> | 20 | <string>PIM-Database Converter</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <grid> | 25 | <grid> |
26 | <property stdset="1"> | 26 | <property stdset="1"> |
27 | <name>margin</name> | 27 | <name>margin</name> |
28 | <number>4</number> | 28 | <number>4</number> |
29 | </property> | 29 | </property> |
30 | <property stdset="1"> | 30 | <property stdset="1"> |
31 | <name>spacing</name> | 31 | <name>spacing</name> |
32 | <number>6</number> | 32 | <number>6</number> |
33 | </property> | 33 | </property> |
34 | <widget row="0" column="0" > | 34 | <widget row="0" column="0" > |
35 | <class>QGroupBox</class> | 35 | <class>QGroupBox</class> |
36 | <property stdset="1"> | 36 | <property stdset="1"> |
37 | <name>name</name> | 37 | <name>name</name> |
38 | <cstring>GroupBox6</cstring> | 38 | <cstring>GroupBox6</cstring> |
39 | </property> | 39 | </property> |
40 | <property stdset="1"> | 40 | <property stdset="1"> |
41 | <name>title</name> | 41 | <name>title</name> |
42 | <string>Converter</string> | 42 | <string>Converter</string> |
43 | </property> | 43 | </property> |
44 | <property> | 44 | <property> |
45 | <name>layoutMargin</name> | 45 | <name>layoutMargin</name> |
46 | </property> | 46 | </property> |
47 | <property> | 47 | <property> |
48 | <name>layoutSpacing</name> | 48 | <name>layoutSpacing</name> |
49 | </property> | 49 | </property> |
50 | <vbox> | 50 | <vbox> |
51 | <property stdset="1"> | 51 | <property stdset="1"> |
52 | <name>margin</name> | 52 | <name>margin</name> |
53 | <number>4</number> | 53 | <number>4</number> |
54 | </property> | 54 | </property> |
55 | <property stdset="1"> | 55 | <property stdset="1"> |
56 | <name>spacing</name> | 56 | <name>spacing</name> |
57 | <number>2</number> | 57 | <number>2</number> |
58 | </property> | 58 | </property> |
59 | <widget> | 59 | <widget> |
60 | <class>QPushButton</class> | ||
61 | <property stdset="1"> | ||
62 | <name>name</name> | ||
63 | <cstring>PushButton2</cstring> | ||
64 | </property> | ||
65 | <property stdset="1"> | ||
66 | <name>text</name> | ||
67 | <string>Upgrade to SQLite3</string> | ||
68 | </property> | ||
69 | </widget> | ||
70 | <widget> | ||
60 | <class>QGroupBox</class> | 71 | <class>QGroupBox</class> |
61 | <property stdset="1"> | 72 | <property stdset="1"> |
62 | <name>name</name> | 73 | <name>name</name> |
63 | <cstring>GroupBox1</cstring> | 74 | <cstring>GroupBox1</cstring> |
64 | </property> | 75 | </property> |
65 | <property stdset="1"> | 76 | <property stdset="1"> |
66 | <name>title</name> | 77 | <name>title</name> |
67 | <string>Select Database:</string> | 78 | <string>Select Database:</string> |
68 | </property> | 79 | </property> |
80 | <property> | ||
81 | <name>layoutMargin</name> | ||
82 | </property> | ||
83 | <property> | ||
84 | <name>layoutSpacing</name> | ||
85 | </property> | ||
69 | <grid> | 86 | <grid> |
70 | <property stdset="1"> | 87 | <property stdset="1"> |
71 | <name>margin</name> | 88 | <name>margin</name> |
72 | <number>11</number> | 89 | <number>4</number> |
73 | </property> | 90 | </property> |
74 | <property stdset="1"> | 91 | <property stdset="1"> |
75 | <name>spacing</name> | 92 | <name>spacing</name> |
76 | <number>6</number> | 93 | <number>2</number> |
77 | </property> | 94 | </property> |
78 | <widget row="0" column="1" > | 95 | <widget row="0" column="1" > |
79 | <class>QComboBox</class> | 96 | <class>QComboBox</class> |
80 | <item> | 97 | <item> |
81 | <property> | 98 | <property> |
82 | <name>text</name> | 99 | <name>text</name> |
83 | <string>Addressbook</string> | 100 | <string>Addressbook</string> |
84 | </property> | 101 | </property> |
85 | </item> | 102 | </item> |
86 | <item> | 103 | <item> |
87 | <property> | 104 | <property> |
88 | <name>text</name> | 105 | <name>text</name> |
89 | <string>TodoList</string> | 106 | <string>TodoList</string> |
90 | </property> | 107 | </property> |
91 | </item> | 108 | </item> |
92 | <item> | 109 | <item> |
93 | <property> | 110 | <property> |
94 | <name>text</name> | 111 | <name>text</name> |
95 | <string>Datebook</string> | 112 | <string>Datebook</string> |
96 | </property> | 113 | </property> |
97 | </item> | 114 | </item> |
98 | <property stdset="1"> | 115 | <property stdset="1"> |
99 | <name>name</name> | 116 | <name>name</name> |
100 | <cstring>m_dataBaseSelector</cstring> | 117 | <cstring>m_dataBaseSelector</cstring> |
101 | </property> | 118 | </property> |
102 | </widget> | 119 | </widget> |
103 | </grid> | 120 | </grid> |
104 | </widget> | 121 | </widget> |
105 | <widget> | 122 | <widget> |
106 | <class>QGroupBox</class> | 123 | <class>QGroupBox</class> |
107 | <property stdset="1"> | 124 | <property stdset="1"> |
108 | <name>name</name> | 125 | <name>name</name> |
109 | <cstring>GroupBox2</cstring> | 126 | <cstring>GroupBox2</cstring> |
110 | </property> | 127 | </property> |
111 | <property stdset="1"> | 128 | <property stdset="1"> |
112 | <name>title</name> | 129 | <name>title</name> |
113 | <string>Source/Destination:</string> | 130 | <string>Source/Destination:</string> |
114 | </property> | 131 | </property> |
132 | <property> | ||
133 | <name>layoutMargin</name> | ||
134 | </property> | ||
135 | <property> | ||
136 | <name>layoutSpacing</name> | ||
137 | </property> | ||
115 | <grid> | 138 | <grid> |
116 | <property stdset="1"> | 139 | <property stdset="1"> |
117 | <name>margin</name> | 140 | <name>margin</name> |
118 | <number>11</number> | 141 | <number>4</number> |
119 | </property> | 142 | </property> |
120 | <property stdset="1"> | 143 | <property stdset="1"> |
121 | <name>spacing</name> | 144 | <name>spacing</name> |
122 | <number>6</number> | 145 | <number>2</number> |
123 | </property> | 146 | </property> |
124 | <widget row="1" column="0" > | 147 | <widget row="1" column="0" > |
125 | <class>QLabel</class> | 148 | <class>QLabel</class> |
126 | <property stdset="1"> | 149 | <property stdset="1"> |
127 | <name>name</name> | 150 | <name>name</name> |
128 | <cstring>TextLabel3_2</cstring> | 151 | <cstring>TextLabel3_2</cstring> |
129 | </property> | 152 | </property> |
130 | <property stdset="1"> | 153 | <property stdset="1"> |
131 | <name>text</name> | 154 | <name>text</name> |
132 | <string>to</string> | 155 | <string>to</string> |
133 | </property> | 156 | </property> |
134 | </widget> | 157 | </widget> |
135 | <widget row="1" column="1" > | 158 | <widget row="1" column="1" > |
136 | <class>QComboBox</class> | 159 | <class>QComboBox</class> |
137 | <item> | 160 | <item> |
138 | <property> | 161 | <property> |
139 | <name>text</name> | 162 | <name>text</name> |
140 | <string>XML</string> | 163 | <string>XML</string> |
141 | </property> | 164 | </property> |
142 | </item> | 165 | </item> |
143 | <item> | 166 | <item> |
144 | <property> | 167 | <property> |
145 | <name>text</name> | 168 | <name>text</name> |
146 | <string>SQL (SQLite)</string> | 169 | <string>SQL (SQLite)</string> |
147 | </property> | 170 | </property> |
148 | </item> | 171 | </item> |
149 | <property stdset="1"> | 172 | <property stdset="1"> |
150 | <name>name</name> | 173 | <name>name</name> |
151 | <cstring>m_destFormatSelector</cstring> | 174 | <cstring>m_destFormatSelector</cstring> |
152 | </property> | 175 | </property> |
153 | </widget> | 176 | </widget> |
154 | <widget row="0" column="0" > | 177 | <widget row="0" column="0" > |
155 | <class>QLabel</class> | 178 | <class>QLabel</class> |
156 | <property stdset="1"> | 179 | <property stdset="1"> |
157 | <name>name</name> | 180 | <name>name</name> |
158 | <cstring>TextLabel2_2</cstring> | 181 | <cstring>TextLabel2_2</cstring> |
159 | </property> | 182 | </property> |
160 | <property stdset="1"> | 183 | <property stdset="1"> |
161 | <name>text</name> | 184 | <name>text</name> |
162 | <string>Convert from</string> | 185 | <string>Convert from</string> |
163 | </property> | 186 | </property> |
164 | </widget> | 187 | </widget> |
165 | <widget row="0" column="1" > | 188 | <widget row="0" column="1" > |
166 | <class>QComboBox</class> | 189 | <class>QComboBox</class> |
167 | <item> | 190 | <item> |
168 | <property> | 191 | <property> |
169 | <name>text</name> | 192 | <name>text</name> |
170 | <string>XML</string> | 193 | <string>XML</string> |
171 | </property> | 194 | </property> |
172 | </item> | 195 | </item> |
173 | <item> | 196 | <item> |
174 | <property> | 197 | <property> |
175 | <name>text</name> | 198 | <name>text</name> |
176 | <string>SQL (SQLite)</string> | 199 | <string>SQL (SQLite)</string> |
177 | </property> | 200 | </property> |
178 | </item> | 201 | </item> |
179 | <property stdset="1"> | 202 | <property stdset="1"> |
180 | <name>name</name> | 203 | <name>name</name> |
181 | <cstring>m_sourceFormatSelector</cstring> | 204 | <cstring>m_sourceFormatSelector</cstring> |
182 | </property> | 205 | </property> |
183 | </widget> | 206 | </widget> |
184 | </grid> | 207 | </grid> |
185 | </widget> | 208 | </widget> |
186 | <widget> | 209 | <widget> |
187 | <class>QGroupBox</class> | 210 | <class>QGroupBox</class> |
188 | <property stdset="1"> | 211 | <property stdset="1"> |
189 | <name>name</name> | 212 | <name>name</name> |
190 | <cstring>GroupBox5</cstring> | 213 | <cstring>GroupBox5</cstring> |
191 | </property> | 214 | </property> |
192 | <property stdset="1"> | 215 | <property stdset="1"> |
193 | <name>title</name> | 216 | <name>title</name> |
194 | <string>Config:</string> | 217 | <string>Config:</string> |
195 | </property> | 218 | </property> |
219 | <property> | ||
220 | <name>layoutMargin</name> | ||
221 | </property> | ||
222 | <property> | ||
223 | <name>layoutSpacing</name> | ||
224 | </property> | ||
196 | <grid> | 225 | <grid> |
197 | <property stdset="1"> | 226 | <property stdset="1"> |
198 | <name>margin</name> | 227 | <name>margin</name> |
199 | <number>11</number> | 228 | <number>4</number> |
200 | </property> | 229 | </property> |
201 | <property stdset="1"> | 230 | <property stdset="1"> |
202 | <name>spacing</name> | 231 | <name>spacing</name> |
203 | <number>6</number> | 232 | <number>4</number> |
204 | </property> | 233 | </property> |
205 | <widget row="0" column="0" > | 234 | <widget row="0" column="0" > |
206 | <class>QCheckBox</class> | 235 | <class>QCheckBox</class> |
207 | <property stdset="1"> | 236 | <property stdset="1"> |
208 | <name>name</name> | 237 | <name>name</name> |
209 | <cstring>m_eraseDB</cstring> | 238 | <cstring>m_eraseDB</cstring> |
210 | </property> | 239 | </property> |
211 | <property stdset="1"> | 240 | <property stdset="1"> |
212 | <name>text</name> | 241 | <name>text</name> |
213 | <string>Erase before copy</string> | 242 | <string>Erase before copy</string> |
214 | </property> | 243 | </property> |
215 | </widget> | 244 | </widget> |
216 | </grid> | 245 | </grid> |
217 | </widget> | 246 | </widget> |
218 | <widget> | 247 | <widget> |
219 | <class>QGroupBox</class> | 248 | <class>QGroupBox</class> |
220 | <property stdset="1"> | 249 | <property stdset="1"> |
221 | <name>name</name> | 250 | <name>name</name> |
222 | <cstring>GroupBox4</cstring> | 251 | <cstring>GroupBox4</cstring> |
223 | </property> | 252 | </property> |
224 | <property stdset="1"> | 253 | <property stdset="1"> |
225 | <name>title</name> | 254 | <name>title</name> |
226 | <string>Progress:</string> | 255 | <string>Progress:</string> |
227 | </property> | 256 | </property> |
257 | <property> | ||
258 | <name>layoutMargin</name> | ||
259 | </property> | ||
260 | <property> | ||
261 | <name>layoutSpacing</name> | ||
262 | </property> | ||
228 | <vbox> | 263 | <vbox> |
229 | <property stdset="1"> | 264 | <property stdset="1"> |
230 | <name>margin</name> | 265 | <name>margin</name> |
231 | <number>11</number> | 266 | <number>4</number> |
232 | </property> | 267 | </property> |
233 | <property stdset="1"> | 268 | <property stdset="1"> |
234 | <name>spacing</name> | 269 | <name>spacing</name> |
235 | <number>6</number> | 270 | <number>2</number> |
236 | </property> | 271 | </property> |
237 | <widget> | 272 | <widget> |
238 | <class>QProgressBar</class> | 273 | <class>QProgressBar</class> |
239 | <property stdset="1"> | 274 | <property stdset="1"> |
240 | <name>name</name> | 275 | <name>name</name> |
241 | <cstring>m_progressBar</cstring> | 276 | <cstring>m_progressBar</cstring> |
242 | </property> | 277 | </property> |
243 | </widget> | 278 | </widget> |
244 | <widget> | 279 | <widget> |
245 | <class>QPushButton</class> | 280 | <class>QPushButton</class> |
246 | <property stdset="1"> | 281 | <property stdset="1"> |
247 | <name>name</name> | 282 | <name>name</name> |
248 | <cstring>PushButton1</cstring> | 283 | <cstring>PushButton1</cstring> |
249 | </property> | 284 | </property> |
250 | <property stdset="1"> | 285 | <property stdset="1"> |
251 | <name>text</name> | 286 | <name>text</name> |
252 | <string>Go!</string> | 287 | <string>Go!</string> |
253 | </property> | 288 | </property> |
254 | </widget> | 289 | </widget> |
255 | </vbox> | 290 | </vbox> |
256 | </widget> | 291 | </widget> |
257 | </vbox> | 292 | </vbox> |
258 | </widget> | 293 | </widget> |
259 | </grid> | 294 | </grid> |
260 | </widget> | 295 | </widget> |
261 | <connections> | 296 | <connections> |
262 | <connection> | 297 | <connection> |
263 | <sender>PushButton1</sender> | 298 | <sender>PushButton1</sender> |
264 | <signal>clicked()</signal> | 299 | <signal>clicked()</signal> |
265 | <receiver>converter_base</receiver> | 300 | <receiver>converter_base</receiver> |
266 | <slot>start_conversion()</slot> | 301 | <slot>start_conversion()</slot> |
267 | </connection> | 302 | </connection> |
268 | <connection> | 303 | <connection> |
269 | <sender>m_sourceFormatSelector</sender> | 304 | <sender>m_sourceFormatSelector</sender> |
270 | <signal>activated(int)</signal> | 305 | <signal>activated(int)</signal> |
271 | <receiver>converter_base</receiver> | 306 | <receiver>converter_base</receiver> |
272 | <slot>selectedSourceFormat(int)</slot> | 307 | <slot>selectedSourceFormat(int)</slot> |
273 | </connection> | 308 | </connection> |
274 | <connection> | 309 | <connection> |
275 | <sender>m_dataBaseSelector</sender> | 310 | <sender>m_dataBaseSelector</sender> |
276 | <signal>activated(int)</signal> | 311 | <signal>activated(int)</signal> |
277 | <receiver>converter_base</receiver> | 312 | <receiver>converter_base</receiver> |
278 | <slot>selectedDatabase(int)</slot> | 313 | <slot>selectedDatabase(int)</slot> |
279 | </connection> | 314 | </connection> |
280 | <connection> | 315 | <connection> |
281 | <sender>m_destFormatSelector</sender> | 316 | <sender>m_destFormatSelector</sender> |
282 | <signal>activated(int)</signal> | 317 | <signal>activated(int)</signal> |
283 | <receiver>converter_base</receiver> | 318 | <receiver>converter_base</receiver> |
284 | <slot>selectedDestFormat(int)</slot> | 319 | <slot>selectedDestFormat(int)</slot> |
285 | </connection> | 320 | </connection> |
321 | <connection> | ||
322 | <sender>PushButton2</sender> | ||
323 | <signal>clicked()</signal> | ||
324 | <receiver>converter_base</receiver> | ||
325 | <slot>start_upgrade()</slot> | ||
326 | </connection> | ||
286 | <slot access="public">selectedDatabase(int)</slot> | 327 | <slot access="public">selectedDatabase(int)</slot> |
287 | <slot access="public">selectedDestFormat(int)</slot> | 328 | <slot access="public">selectedDestFormat(int)</slot> |
288 | <slot access="public">selectedSourceFormat(int)</slot> | 329 | <slot access="public">selectedSourceFormat(int)</slot> |
289 | <slot access="public">start_conversion()</slot> | 330 | <slot access="public">start_conversion()</slot> |
331 | <slot access="public">start_upgrade()</slot> | ||
290 | </connections> | 332 | </connections> |
291 | </UI> | 333 | </UI> |