From ae70312b1613e26b4ef89a2c9821d9531b82e987 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 22 Dec 2003 10:19:25 +0000 Subject: Finishing implementation of sql-backend for datebook. But I have to port the PIM datebook application to use it, before I could debug the whole stuff. Thus, PIM-Database backend is finished, but highly experimental. And some parts are still generic. For instance, the "queryByExample()" methods are not (or not fully) implemented. Todo: custom-entries not stored. The big show stopper: matchRegExp() (needed by OpieSearch) needs regular expression search in the database, which is not supported by sqlite ! Therefore we need either an extended sqlite or a workaround which would be very slow and memory consuming.. --- (limited to 'libopie/pim/test/converter.cpp') diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp index 650d119..bfdb605 100644 --- a/libopie/pim/test/converter.cpp +++ b/libopie/pim/test/converter.cpp @@ -9,6 +9,12 @@ #include #include +#include +#include +#include + +// #define _ADDRESSBOOK_ACCESS + Converter::Converter(){ } @@ -16,6 +22,8 @@ void Converter::start_conversion(){ qWarning("Converting Contacts from XML to SQL.."); // Creating backends to the requested databases.. + +#ifdef _ADDRESSBOOK_ACCESS OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter", QString::null ); @@ -26,14 +34,30 @@ void Converter::start_conversion(){ QString::null , xmlBackend, true ); OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql", - QString::null , sqlBackend, true ); + QString::null ); +#else + ODateBookAccessBackend* xmlBackend = new ODateBookAccessBackend_XML( "Converter", + QString::null ); + + ODateBookAccessBackend* sqlBackend = new ODateBookAccessBackend_SQL( QString::null, + QString::null ); + // Put the created backends into frontends to access them + ODateBookAccess* xmlAccess = new ODateBookAccess ( xmlBackend ); + + ODateBookAccess* sqlAccess = new ODateBookAccess ( sqlBackend ); + + xmlAccess->load(); + +#endif + QTime t; t.start(); - // Clean the sql-database.. +// Clean the sql-database.. sqlAccess->clear(); +#ifdef _ADDRESSBOOK_ACCESS // Now trasmit every contact from the xml database to the sql-database OContactAccess::List contactList = xmlAccess->allRecords(); m_progressBar->setTotalSteps( contactList.count() ); @@ -45,7 +69,22 @@ void Converter::start_conversion(){ m_progressBar->setProgress( ++count ); } } - +#else + // Now transmit every contact from the xml database to the sql-database + ODateBookAccess::List dateList = xmlAccess->allRecords(); + m_progressBar->setTotalSteps( dateList.count() ); + qWarning( "Number of elements to copy: %d", dateList.count() ); + + int count = 0; + if ( sqlAccess && xmlAccess ){ + ODateBookAccess::List::Iterator it; + for ( it = dateList.begin(); it != dateList.end(); ++it ){ + sqlAccess->add( *it ); + m_progressBar->setProgress( ++count ); + } + } + +#endif // Delete the frontends. Backends will be deleted automatically, too ! delete sqlAccess; -- cgit v0.9.0.2