author | eilers <eilers> | 2003-09-29 07:41:45 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-09-29 07:41:45 (UTC) |
commit | b2e22408970ef548e23e9bbdcd87302f35fc6d4d (patch) (side-by-side diff) | |
tree | 9dd613f64fb333c3591a4aa2b080d1e9e984cddd | |
parent | 33a64fac931c3332bce9fb97e9996dc0e4c9d236 (diff) | |
download | opie-b2e22408970ef548e23e9bbdcd87302f35fc6d4d.zip opie-b2e22408970ef548e23e9bbdcd87302f35fc6d4d.tar.gz opie-b2e22408970ef548e23e9bbdcd87302f35fc6d4d.tar.bz2 |
Starting to develop a universal PIM-database converter
-rw-r--r-- | libopie/pim/test/converter.cpp | 34 | ||||
-rw-r--r-- | libopie/pim/test/converter_base.ui | 219 |
2 files changed, 226 insertions, 27 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 @@ +#include "converter.h" + +#include <qdatetime.h> +#include <qprogressbar.h> + #include <qpe/qpeapplication.h> #include <opie/ocontactaccess.h> #include <opie/ocontactaccessbackend_xml.h> #include <opie/ocontactaccessbackend_sql.h> -#include "converter_base.h" - -class ConvertXMLToSQL: public converter_base { -public: - ConvertXMLToSQL() - { - convertContact(); +Converter::Converter(){ } -private: - void convertContact(); - -}; - -void ConvertXMLToSQL::convertContact(){ +void Converter::start_conversion(){ qWarning("Converting Contacts from XML to SQL.."); // Creating backends to the requested databases.. @@ -34,19 +28,29 @@ void ConvertXMLToSQL::convertContact(){ OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", QString::null , sqlBackend, true ); + QTime t; + t.start(); + // Clean the sql-database.. sqlAccess->clear(); // Now trasmit every contact from the xml database to the sql-database OContactAccess::List contactList = xmlAccess->allRecords(); + m_progressBar->setTotalSteps( contactList.count() ); + int count = 0; if ( sqlAccess && xmlAccess ){ OContactAccess::List::Iterator it; - for ( it = contactList.begin(); it != contactList.end(); ++it ) + for ( it = contactList.begin(); it != contactList.end(); ++it ){ sqlAccess->add( *it ); + m_progressBar->setProgress( ++count ); + } } // Delete the frontends. Backends will be deleted automatically, too ! delete sqlAccess; + + qWarning("Conversion is finished and needed %d ms !", t.elapsed()); + delete xmlAccess; } @@ -54,7 +58,7 @@ int main( int argc, char** argv ) { QPEApplication a( argc, argv ); - ConvertXMLToSQL dlg; + Converter dlg; a.showMainWidget( &dlg ); // dlg. showMaximized ( ); diff --git a/libopie/pim/test/converter_base.ui b/libopie/pim/test/converter_base.ui index f680550..e9bf636 100644 --- a/libopie/pim/test/converter_base.ui +++ b/libopie/pim/test/converter_base.ui @@ -11,33 +11,228 @@ <rect> <x>0</x> <y>0</y> - <width>579</width> - <height>211</height> + <width>273</width> + <height>324</height> </rect> </property> <property stdset="1"> <name>caption</name> - <string>Form2</string> + <string>PIM-Database Converter</string> </property> + <property> + <name>layoutMargin</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>4</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="0" > + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox6</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Converter</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>4</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>4</number> + </property> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Select Database:</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Addressbook</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>TodoList</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>ComboBox1</cstring> + </property> + </widget> + </grid> + </widget> <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox2</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Source/Destination:</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1</cstring> + <cstring>TextLabel3_2</cstring> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>340</x> - <y>40</y> - <width>210</width> - <height>20</height> - </rect> + <name>text</name> + <string>to</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Select</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>XML</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>SQL (SQLite)</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>ComboBox2_3</cstring> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Convert from</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>XML</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>SQL (SQLite)</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>ComboBox2_2_2</cstring> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GroupBox4</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Progress:</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="0" > + <class>QProgressBar</class> + <property stdset="1"> + <name>name</name> + <cstring>m_progressBar</cstring> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>PushButton1</cstring> </property> <property stdset="1"> <name>text</name> - <string>Converter from XML->SQL</string> + <string>Go!</string> </property> </widget> + </vbox> + </widget> + </grid> </widget> +<connections> + <connection> + <sender>PushButton1</sender> + <signal>clicked()</signal> + <receiver>converter_base</receiver> + <slot>start_conversion()</slot> + </connection> + <slot access="public">start_conversion()</slot> +</connections> </UI> |