summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/test/converter.cpp36
-rw-r--r--libopie/pim/test/converter_base.ui233
2 files changed, 234 insertions, 35 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,64 +1,68 @@
+#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();
- }
-private:
- void convertContact();
-
-};
-
+Converter::Converter(){
+}
-void ConvertXMLToSQL::convertContact(){
+void Converter::start_conversion(){
qWarning("Converting Contacts from XML to SQL..");
// Creating backends to the requested databases..
OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
QString::null );
OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null,
QString::null );
// Put the created backends into frontends to access them
OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml",
QString::null , xmlBackend, true );
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;
}
int main( int argc, char** argv ) {
QPEApplication a( argc, argv );
- ConvertXMLToSQL dlg;
+ Converter dlg;
a.showMainWidget( &dlg );
// dlg. showMaximized ( );
return a.exec();
}
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
@@ -2,42 +2,237 @@
<class>converter_base</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>converter_base</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<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>
- <widget>
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1</cstring>
- </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <grid>
<property stdset="1">
- <name>geometry</name>
- <rect>
- <x>340</x>
- <y>40</y>
- <width>210</width>
- <height>20</height>
- </rect>
+ <name>margin</name>
+ <number>4</number>
</property>
<property stdset="1">
- <name>text</name>
- <string>Converter from XML-&gt;SQL</string>
+ <name>spacing</name>
+ <number>6</number>
</property>
- </widget>
+ <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>TextLabel3_2</cstring>
+ </property>
+ <property stdset="1">
+ <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>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>