author | eilers <eilers> | 2004-05-16 15:24:11 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-05-16 15:24:11 (UTC) |
commit | 680c8c7a6db8f5b79a6541629f54465709b79b02 (patch) (side-by-side diff) | |
tree | 9d9b4c0d913ba14ac73bf5339ce2f259a10b33fa | |
parent | 703b468052367682959f0e1494eec4b3d12754a8 (diff) | |
download | opie-680c8c7a6db8f5b79a6541629f54465709b79b02.zip opie-680c8c7a6db8f5b79a6541629f54465709b79b02.tar.gz opie-680c8c7a6db8f5b79a6541629f54465709b79b02.tar.bz2 |
Opie PIM-Converter now uses the new OPimAccessFactory template..
-rw-r--r-- | noncore/tools/pimconverter/converter.cpp | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/noncore/tools/pimconverter/converter.cpp b/noncore/tools/pimconverter/converter.cpp index 1091f4a..2bd47a4 100644 --- a/noncore/tools/pimconverter/converter.cpp +++ b/noncore/tools/pimconverter/converter.cpp @@ -1,179 +1,158 @@ #include "converter.h" #include <qdatetime.h> #include <qprogressbar.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qpe/qpeapplication.h> -#include <opie2/ocontactaccess.h> -#include <opie2/ocontactaccessbackend_xml.h> -#include <opie2/ocontactaccessbackend_sql.h> - -#include <opie2/otodoaccess.h> -#include <opie2/otodoaccessxml.h> -#include <opie2/otodoaccesssql.h> - -#include <opie2/odatebookaccess.h> -#include <opie2/odatebookaccessbackend_xml.h> -#include <opie2/odatebookaccessbackend_sql.h> - -// #define _ADDRESSBOOK_ACCESS +#include <opie2/opimglobal.h> +// Include SQL related header files +#define __USE_SQL +#include <opie2/opimaccessfactory.h> using namespace Opie; +using namespace Pim; Converter::Converter(): m_selectedDatabase( ADDRESSBOOK ), m_selectedSourceFormat( XML ), m_selectedDestFormat( SQL ) { m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); m_eraseDB -> setChecked( true ); // Default erase on copy } void Converter::selectedDatabase( int num ) { m_selectedDatabase = num; } void Converter::selectedDestFormat( int num ) { m_selectedDestFormat = num; } void Converter::selectedSourceFormat( int num ) { m_selectedSourceFormat = num; } void Converter::start_conversion(){ // Creating backends to the requested databases.. OPimBase* sourceDB; OPimBase* destDB; switch( m_selectedSourceFormat ){ case XML: qDebug("XMLSourceDB = %d", m_selectedDatabase); switch( m_selectedDatabase ){ case ADDRESSBOOK:{ - OPimContactAccessBackend* sourceBackend = new OPimContactAccessBackend_XML( "Converter", QString::null ); - sourceDB = new OPimContactAccess ( "addressbook_xml", QString::null , sourceBackend, true ); + sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); } break; case TODOLIST:{ - OPimTodoAccessBackend* sourceBackend = new OPimTodoAccessXML( "Converter" ); - sourceDB = new OPimTodoAccess( sourceBackend ); + sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); }break; case DATEBOOK:{ - ODateBookAccessBackend_XML* sourceBackend = new ODateBookAccessBackend_XML( "Converter", QString::null ); - sourceDB = new ODateBookAccess ( sourceBackend ); + sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); } break; default: qWarning( "Unknown database selected (%d)", m_selectedDatabase ); return; } break; case SQL: qDebug("SQLSourceDB = %d", m_selectedDatabase); switch( m_selectedDatabase ){ case ADDRESSBOOK:{ - qDebug("SQLSourceDB = %d", m_selectedDatabase); - OPimContactAccessBackend* sourceBackend = new OPimContactAccessBackend_SQL( QString::null, QString::null ); - sourceDB = new OPimContactAccess ( "Converter", QString::null, sourceBackend, true ); - } + sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); + } break; case TODOLIST:{ - OPimTodoAccessBackend* sourceBackend = new OPimTodoAccessBackendSQL( QString::null ); - sourceDB = new OPimTodoAccess( sourceBackend ); + sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); }break; - case DATEBOOK: { - ODateBookAccessBackend_SQL* sourceBackend = new ODateBookAccessBackend_SQL( "Converter", QString::null ); - sourceDB = new ODateBookAccess ( sourceBackend ); - } + case DATEBOOK:{ + sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); + } break; default: qWarning( "Unknown database selected (%d)", m_selectedDatabase ); return; } break; default: qWarning( "Unknown source format selected (%d) !!", m_selectedSourceFormat ); return; } switch ( m_selectedDestFormat ){ case XML: qDebug("XMLDestDB = %d", m_selectedDatabase); switch( m_selectedDatabase ){ case ADDRESSBOOK:{ - OPimContactAccessBackend* destBackend = new OPimContactAccessBackend_XML( "Converter", QString::null ); - destDB = new OPimContactAccess ( "Converter", QString::null , destBackend, true ); - } + destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); + } break; case TODOLIST:{ - OPimTodoAccessBackend* destBackend = new OPimTodoAccessXML( "Converter" ); - destDB = new OPimTodoAccess( destBackend ); + destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); }break; case DATEBOOK:{ - ODateBookAccessBackend_XML* destBackend = new ODateBookAccessBackend_XML( "Converter", QString::null ); - destDB = new ODateBookAccess ( destBackend ); - } + destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); + } break; default: qWarning( "Unknown database selected (%d)", m_selectedDatabase ); return; } break; case SQL: qDebug("SQLDestDB = %d", m_selectedDatabase); switch( m_selectedDatabase ){ case ADDRESSBOOK:{ - OPimContactAccessBackend* destBackend = new OPimContactAccessBackend_SQL( QString::null, QString::null ); - destDB = new OPimContactAccess ( "addressbook_xml", QString::null , destBackend, true ); - } + destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); + } break; case TODOLIST:{ - OPimTodoAccessBackend* destBackend = new OPimTodoAccessBackendSQL( QString::null ); - destDB = new OPimTodoAccess( destBackend ); + destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); }break; case DATEBOOK:{ - ODateBookAccessBackend_SQL* destBackend = new ODateBookAccessBackend_SQL( "Converter", QString::null ); - destDB = new ODateBookAccess ( destBackend ); - } + destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); + } break; default: qWarning( "Unknown database selected (%d)", m_selectedDatabase ); return; } break; default: qWarning( "Unknown destination format selected (%d)!!", m_selectedDestFormat ); return; } if ( !sourceDB || !destDB ) return; sourceDB -> load(); destDB -> load(); QTime t; t.start(); // Clean the dest-database if requested (isChecked) if ( m_eraseDB -> isChecked() ){ qDebug( "Clearing destination database!" ); destDB -> clear(); } // Now transmit every pim-item from the source database to the destination -database QArray<int> uidList = sourceDB->records(); qDebug( "Try to move data for addressbook.. (%d items) ", uidList.count() ); m_progressBar->setTotalSteps( uidList.count() ); int count = 0; for ( uint i = 0; i < uidList.count(); ++i ){ |