From e7810bdfec718c3364e31c2d32357ec0fd2fda77 Mon Sep 17 00:00:00 2001 From: ar Date: Fri, 21 May 2004 21:03:21 +0000 Subject: - convert qDebug to odebug --- (limited to 'noncore/tools/pimconverter') 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 @@ #include "converter.h" -#include -#include -#include -#include - +/* OPIE */ #include +#include #include // Include SQL related header files #define __USE_SQL #include +/* QT */ +#include +#include +#include +#include + + using namespace Opie; using namespace Pim; Converter::Converter(): - m_selectedDatabase( ADDRESSBOOK ), - m_selectedSourceFormat( XML ), - m_selectedDestFormat( SQL ) + 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 + 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; + m_selectedDatabase = num; } void Converter::selectedDestFormat( int num ) { - m_selectedDestFormat = num; + m_selectedDestFormat = num; } void Converter::selectedSourceFormat( int num ) { - m_selectedSourceFormat = 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:{ - sourceDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); - } - break; - case TODOLIST:{ - sourceDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); - }break; - case DATEBOOK:{ - sourceDB = OPimAccessFactory::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:{ - sourceDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); - } - break; - case TODOLIST:{ - sourceDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); - }break; - case DATEBOOK:{ - sourceDB = OPimAccessFactory::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:{ - destDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); - } - break; - case TODOLIST:{ - destDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); - }break; - case DATEBOOK:{ - destDB = OPimAccessFactory::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:{ - destDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); - } - break; - case TODOLIST:{ - destDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); - }break; - case DATEBOOK:{ - destDB = OPimAccessFactory::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 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 ){ - qDebug( "Adding uid: %d", uidList[i] ); - OPimRecord* rec = sourceDB -> record( uidList[i] ); - destDB -> add( rec ); - m_progressBar->setProgress( ++count ); - } - - // Now commit data.. - destDB -> save(); - - // Delete the frontends. Backends will be deleted automatically, too ! - // We have to cast them back to delete them properly ! - switch( m_selectedDatabase ){ - case ADDRESSBOOK: - delete static_cast (sourceDB); - delete static_cast (destDB); - break; - case TODOLIST: - delete static_cast (sourceDB); - delete static_cast (destDB); - break; - case DATEBOOK: - delete static_cast (sourceDB); - delete static_cast (destDB); - break; - default: - qWarning( "Unknown database selected (%d)", m_selectedDatabase ); - return; - } - - - qWarning("Conversion is finished and needed %d ms !", t.elapsed()); + + // Creating backends to the requested databases.. + OPimBase* sourceDB; + OPimBase* destDB; + + switch( m_selectedSourceFormat ){ + case XML: + odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl; + switch( m_selectedDatabase ){ + case ADDRESSBOOK:{ + sourceDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); + } + break; + case TODOLIST:{ + sourceDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); + }break; + case DATEBOOK:{ + sourceDB = OPimAccessFactory::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); + } + break; + default: + owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; + return; + } + break; + case SQL: + odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl; + switch( m_selectedDatabase ){ + case ADDRESSBOOK:{ + sourceDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); + } + break; + case TODOLIST:{ + sourceDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); + }break; + case DATEBOOK:{ + sourceDB = OPimAccessFactory::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); + } + break; + default: + owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; + return; + } + break; + default: + owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl; + return; + } + + switch ( m_selectedDestFormat ){ + case XML: + odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl; + switch( m_selectedDatabase ){ + case ADDRESSBOOK:{ + destDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); + } + break; + case TODOLIST:{ + destDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); + }break; + case DATEBOOK:{ + destDB = OPimAccessFactory::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); + } + break; + default: + owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; + return; + } + break; + case SQL: + odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl; + switch( m_selectedDatabase ){ + case ADDRESSBOOK:{ + destDB = OPimAccessFactory::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); + } + break; + case TODOLIST:{ + destDB = OPimAccessFactory::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); + }break; + case DATEBOOK:{ + destDB = OPimAccessFactory::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); + } + break; + default: + owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; + return; + } + break; + default: + owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl; + return; + } + + if ( !sourceDB || !destDB ) + return; + + sourceDB -> load(); + destDB -> load(); + + QTime t; + t.start(); + + // Clean the dest-database if requested (isChecked) + if ( m_eraseDB -> isChecked() ){ + odebug << "Clearing destination database!" << oendl; + destDB -> clear(); + } + + // Now transmit every pim-item from the source database to the destination -database + QArray uidList = sourceDB->records(); + odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl; + m_progressBar->setTotalSteps( uidList.count() ); + int count = 0; + for ( uint i = 0; i < uidList.count(); ++i ){ + odebug << "Adding uid: " << uidList[i] << "" << oendl; + OPimRecord* rec = sourceDB -> record( uidList[i] ); + destDB -> add( rec ); + m_progressBar->setProgress( ++count ); + } + + // Now commit data.. + destDB -> save(); + + // Delete the frontends. Backends will be deleted automatically, too ! + // We have to cast them back to delete them properly ! + switch( m_selectedDatabase ){ + case ADDRESSBOOK: + delete static_cast (sourceDB); + delete static_cast (destDB); + break; + case TODOLIST: + delete static_cast (sourceDB); + delete static_cast (destDB); + break; + case DATEBOOK: + delete static_cast (sourceDB); + delete static_cast (destDB); + break; + default: + owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl; + return; + } + + + owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl; } int main( int argc, char** argv ) { - QPEApplication a( argc, argv ); + QPEApplication a( argc, argv ); - Converter dlg; + Converter dlg; - a.showMainWidget( &dlg ); - // dlg. showMaximized ( ); + a.showMainWidget( &dlg ); + // dlg. showMaximized ( ); - return a.exec(); + return a.exec(); } -- cgit v0.9.0.2