summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calc2/engine.cpp133
-rw-r--r--noncore/tools/clock/setAlarm.cpp2
-rw-r--r--noncore/tools/pimconverter/converter.cpp334
3 files changed, 240 insertions, 229 deletions
diff --git a/noncore/tools/calc2/engine.cpp b/noncore/tools/calc2/engine.cpp
index e843e29..74cd701 100644
--- a/noncore/tools/calc2/engine.cpp
+++ b/noncore/tools/calc2/engine.cpp
@@ -1,214 +1,221 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "engine.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+
+/* QT */
#include <qstring.h>
-#include <math.h>
#include <qlcdnumber.h>
+/* STD */
+#include <math.h>
+
Data Engine::evalStack (Data num, bool inbrace = FALSE)
{
if (state != sError) {
Instruction *i;
// Pop the next op from the stack
while (!stack.isEmpty () && (braces || !inbrace)) {
i = stack.pop ();
// Check this ops prec vs next ops prec
if (!stack.isEmpty ())
- if (i->precedence <= stack.top()->precedence)
- i->acc = evalStack (i->acc, inbrace);
+ if (i->precedence <= stack.top()->precedence)
+ i->acc = evalStack (i->acc, inbrace);
// Evaluate this instruction
num = i->eval (num);
// Error-check ( change this to work for all types )
if (isnan (num.dbl) || isinf (num.dbl)) {
- qDebug ("bad result from operation");
- state = sError;
- clearData(&num);
- return num;
+ odebug << "bad result from operation" << oendl;
+ state = sError;
+ clearData(&num);
+ return num;
}
}
}
return num;
}
// Plugins call this to request the stack be evaluated
void Engine::eval ()
{
num = evalStack (num);
if (state != sError) {
displayData(num);
state = sStart;
}
// if the user didnt close all their braces, its no big deal
braces = 0;
}
void Engine::immediateInstruction (Instruction * i)
{
if (state != sError) {
i->setRep(currentRep);
num = i->eval (num);
displayData(num);
state = sStart;
}
}
void Engine::pushInstruction (Instruction * i)
{
if (state != sError) {
i->setRep(currentRep);
i->acc = num;
stack.push (i);
state = sStart;
}
}
void Engine::pushValue (char v)
{
if (state == sAppend) {
bool ok = FALSE;
switch (currentRep) {
- case rDouble:
- displayString.append(v);
- num.dbl=displayString.toDouble(&ok);
- break;
- case rFraction:
- break;
- default:
- displayString.append(v);
- num.i=displayString.toInt(&ok, calcBase());
+ case rDouble:
+ displayString.append(v);
+ num.dbl=displayString.toDouble(&ok);
+ break;
+ case rFraction:
+ break;
+ default:
+ displayString.append(v);
+ num.i=displayString.toInt(&ok, calcBase());
};
if (!ok) {
- state = sError;
- odebug << "pushValue() - num->string conversion" << oendl;
+ state = sError;
+ odebug << "pushValue() - num->string conversion" << oendl;
} else {
- const QString constString = displayString;
- emit(display(constString));
+ const QString constString = displayString;
+ emit(display(constString));
};
} else if (state == sStart) {
softReset();
displayString.truncate(0);
state = sAppend;
pushValue (v);
} else if (state == sError) {
- qDebug ("in error state");
+ odebug << "in error state" << oendl;
return;
}
}
void Engine::del ()
{
bool ok;
switch (currentRep) {
- case rDouble:
- displayString.truncate(displayString.length());
- num.dbl=displayString.toDouble(&ok);
- break;
- case rFraction:
- odebug << "not available" << oendl;
- break;
- default:
- displayString.truncate(displayString.length());
- num.i = displayString.toInt(&ok, calcBase());
+ case rDouble:
+ displayString.truncate(displayString.length());
+ num.dbl=displayString.toDouble(&ok);
+ break;
+ case rFraction:
+ odebug << "not available" << oendl;
+ break;
+ default:
+ displayString.truncate(displayString.length());
+ num.i = displayString.toInt(&ok, calcBase());
};
if (!ok) {
- state = sError;
- odebug << "del() - num->string conversion" << oendl;
+ state = sError;
+ odebug << "del() - num->string conversion" << oendl;
} else {
- const QString constString = displayString;
- emit(display(constString));
+ const QString constString = displayString;
+ emit(display(constString));
};
}
void Engine::displayData(Data d) {
switch (currentRep) {
- case rDouble:
- displayString.setNum(d.dbl);
- break;
- case rFraction:
- odebug << "fractional display not yet impl" << oendl;
- break;
- default:
- displayString.setNum(d.i, calcBase());
- break;
+ case rDouble:
+ displayString.setNum(d.dbl);
+ break;
+ case rFraction:
+ odebug << "fractional display not yet impl" << oendl;
+ break;
+ default:
+ displayString.setNum(d.i, calcBase());
+ break;
};
const QString constString= displayString;
emit(display(constString));
}
// Returns the base when Rep is an integer type
int Engine::calcBase () {
switch (currentRep) {
- case rBin:
- return 2;
- case rOct:
- return 8;
- case rDec:
- return 10;
- case rHex:
- return 16;
- default:
- state = sError;
- odebug << "Error - attempt to calc base for non-integer" << oendl;
- return 10;
+ case rBin:
+ return 2;
+ case rOct:
+ return 8;
+ case rDec:
+ return 10;
+ case rHex:
+ return 16;
+ default:
+ state = sError;
+ odebug << "Error - attempt to calc base for non-integer" << oendl;
+ return 10;
};
}
// Special instruction for internal use only
class iOpenBrace:public Instruction {
public:
- iOpenBrace (Engine *e):Instruction (100) {engine = e;};
- ~iOpenBrace () {};
+ iOpenBrace (Engine *e):Instruction (100) {engine = e;};
+ ~iOpenBrace () {};
- Data eval (Data num) {
- engine->decBraces();
- return num;
- };
+ Data eval (Data num) {
+ engine->decBraces();
+ return num;
+ };
private:
- Engine *engine;
+ Engine *engine;
};
void Engine::openBrace() {
pushInstruction(new iOpenBrace(this));
}
void Engine::closeBrace() {
braces++;evalStack(num,TRUE);
}
// will need to show and hide display widgets
void Engine::setRepresentation(Representation r) {
currentRep = r;
clearData(&num);
clearData(&mem);
state = sStart;
}
void Engine::clearData(Data *d) {
d->i = d->fraction.numerator = d->fraction.denominator = 0;
d->dbl = 0;
}
diff --git a/noncore/tools/clock/setAlarm.cpp b/noncore/tools/clock/setAlarm.cpp
index 9d5fc49..049af8d 100644
--- a/noncore/tools/clock/setAlarm.cpp
+++ b/noncore/tools/clock/setAlarm.cpp
@@ -1,224 +1,224 @@
/***************************************************************************
// setAlarm.cpp - description
// -------------------
// Created: Wed Mar 13 19:47:24 2002
// copyright : (C) 2002 by ljp
// email : ljp@llornkcor.com
//
***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "setAlarm.h"
#include <opie2/ofileselector.h>
#include <opie2/ofiledialog.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qstring.h>
#include <qlabel.h>
#include <qlcdnumber.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qslider.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qbuttongroup.h>
#include <qcheckbox.h>
using namespace Opie::Ui;
Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "Set_Alarm" );
resize( 240, 101 );
setMaximumSize( QSize( 240, 320 ) );
move(0,45);
setCaption( tr( "Set Alarm" ) );
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
Set_AlarmLayout = new QGridLayout( this );
Set_AlarmLayout->setSpacing( 6 );
Set_AlarmLayout->setMargin( 11 );
TextLabel1 = new QLabel( this, "TextLabel1" );
TextLabel1->setText( tr( "Hour" ) );
Set_AlarmLayout->addWidget( TextLabel1, 0, 0 );
TextLabel2 = new QLabel( this, "TextLabel2" );
TextLabel2->setText( tr( "Minute" ) );
Set_AlarmLayout->addMultiCellWidget( TextLabel2, 0, 0, 1, 2 );
Hour_Slider = new QSlider( this, "Hour_Slider" );
Hour_Slider->setPageStep( 1);
Hour_Slider->setOrientation( QSlider::Horizontal );
connect(Hour_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeHour(int)));
Set_AlarmLayout->addWidget( Hour_Slider, 2, 0 );
Hour_LCDNumber = new QLCDNumber( this, "Hour_LCDNumber" );
Hour_LCDNumber->setFrameShape( QLCDNumber::Box );
Hour_LCDNumber->setFrameShadow( QLCDNumber::Plain );
Hour_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
Set_AlarmLayout->addWidget( Hour_LCDNumber, 1, 0 );
Minute_Slider = new QSlider( this, "Minute_Slider" );
Minute_Slider->setMaxValue( 59);
Minute_Slider->setPageStep( 1);
Minute_Slider->setOrientation( QSlider::Horizontal );
connect(Minute_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeMinute(int)));
Set_AlarmLayout->addMultiCellWidget( Minute_Slider, 2, 2, 1, 2 );
Minute_LCDNumber = new QLCDNumber( this, "Minute_LCDNumber" );
Minute_LCDNumber->setFrameShape( QLCDNumber::Box );
Minute_LCDNumber->setFrameShadow( QLCDNumber::Plain );
Minute_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
Set_AlarmLayout->addMultiCellWidget( Minute_LCDNumber, 1, 1, 1, 2 );
Am_RadioButton = new QRadioButton( this, "Am_RadioButton" );
Am_RadioButton->setText( tr( "AM" ) );
Am_RadioButton->setChecked(TRUE);
connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool)));
Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 );
Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" );
Pm_RadioButton->setText( tr( "PM" ) );
connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool)));
Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 );
useMp3Check = new QCheckBox ( tr( "mp3 alarm" ), this );
useMp3Check-> setFocusPolicy ( QWidget::NoFocus );
Set_AlarmLayout->addMultiCellWidget( useMp3Check, 2, 3, 3, 4 );
TextLabel3 = new QLabel( this, "TextLabel3" );
TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) );
Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 );
Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" );
Snooze_LCDNumber->setFrameShape( QLCDNumber::Box );
Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain );
Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 );
SnoozeSlider = new QSlider( this, "SnoozeSlider" );
SnoozeSlider->setMaxValue( 60 );
SnoozeSlider->setOrientation( QSlider::Horizontal );
connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int)));
Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 4, 4, 1, 2 );
Config config( "qpe" );
config.setGroup("Time");
bool ok;
bool ampm = config.readBoolEntry( "AMPM", TRUE );
QString alarmHour=config.readEntry("clockAlarmHour","8");
int i_alarmHour = alarmHour.toInt(&ok,10);
QString alarmMinute=config.readEntry("clockAlarmMinute","0");
QString snoozeTime=config.readEntry("clockAlarmSnooze","0");
if(ampm) {
Hour_Slider->setMaxValue( 12);
Hour_Slider->setMinValue( 1);
if( i_alarmHour > 12) {
i_alarmHour = i_alarmHour - 12;
Pm_RadioButton->setChecked(TRUE);
}
else if ( i_alarmHour == 0 ) {
i_alarmHour = 12;
}
Hour_Slider->setValue( i_alarmHour );
Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
} else {
Hour_Slider->setMaxValue( 23);
Hour_Slider->setMinValue( 0);
Hour_Slider->setValue( i_alarmHour);
Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
Am_RadioButton->hide();
Pm_RadioButton->hide();
}
if( config.readBoolEntry("mp3Alarm") )
useMp3Check->setChecked(true);
// signals and slots connections
connect(useMp3Check,SIGNAL(toggled(bool)),this,SLOT(slotChangemp3CkeckBox(bool)));
}
Set_Alarm::~Set_Alarm()
{
}
void Set_Alarm::slotChangeHour(int hour)
{
Hour_LCDNumber->display(hour);
}
void Set_Alarm::slotChangeMinute(int minute)
{
Minute_LCDNumber->display(minute);
}
void Set_Alarm::slotChangeSnooze(int minute)
{
Snooze_LCDNumber->display(minute);
}
void Set_Alarm::amButtonToggled(bool b)
{
if ( b)
Pm_RadioButton->setChecked(FALSE);
}
void Set_Alarm::pmButtonToggled(bool b)
{
if (b)
Am_RadioButton->setChecked(FALSE);
}
void Set_Alarm::cleanUp()
{
}
void Set_Alarm::slotChangemp3CkeckBox(bool b) {
Config config( "qpe" );
config.setGroup("Time");
if(b) {
QMap<QString, QStringList> map;
map.insert(tr("All"), QStringList() );
QStringList text;
text << "audio/*";
map.insert(tr("Audio"), text );
QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);//,"", "*", this );
// QString str = Opie::OFileDialog::getOpenFileName( 2,"/");//,"", "*", this );
if(!str.isEmpty() ) {
- qDebug(str);
+ odebug << str << oendl;
config.writeEntry("mp3Alarm",1);
config.writeEntry("mp3File",str);
}
} else {
config.writeEntry("mp3Alarm",0);
config.writeEntry("mp3File","");
}
}
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 <qdatetime.h>
-#include <qprogressbar.h>
-#include <qcombobox.h>
-#include <qcheckbox.h>
-
+/* OPIE */
#include <qpe/qpeapplication.h>
+#include <opie2/odebug.h>
#include <opie2/opimglobal.h>
// Include SQL related header files
#define __USE_SQL
#include <opie2/opimaccessfactory.h>
+/* QT */
+#include <qdatetime.h>
+#include <qprogressbar.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+
+
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<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
- }
- break;
- case TODOLIST:{
- sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
- }break;
- case DATEBOOK:{
- 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:{
- sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" );
- }
- break;
- case TODOLIST:{
- sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" );
- }break;
- 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:{
- destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
- }
- break;
- case TODOLIST:{
- destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
- }break;
- case DATEBOOK:{
- 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:{
- destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" );
- }
- break;
- case TODOLIST:{
- destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" );
- }break;
- case DATEBOOK:{
- 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 ){
- 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<OPimContactAccess*> (sourceDB);
- delete static_cast<OPimContactAccess*> (destDB);
- break;
- case TODOLIST:
- delete static_cast<OPimTodoAccess*> (sourceDB);
- delete static_cast<OPimTodoAccess*> (destDB);
- break;
- case DATEBOOK:
- delete static_cast<ODateBookAccess*> (sourceDB);
- delete static_cast<ODateBookAccess*> (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<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
+ }
+ break;
+ case TODOLIST:{
+ sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
+ }break;
+ case DATEBOOK:{
+ sourceDB = OPimAccessFactory<ODateBookAccess>::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<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" );
+ }
+ break;
+ case TODOLIST:{
+ sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" );
+ }break;
+ case DATEBOOK:{
+ sourceDB = OPimAccessFactory<ODateBookAccess>::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<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
+ }
+ break;
+ case TODOLIST:{
+ destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
+ }break;
+ case DATEBOOK:{
+ destDB = OPimAccessFactory<ODateBookAccess>::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<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" );
+ }
+ break;
+ case TODOLIST:{
+ destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" );
+ }break;
+ case DATEBOOK:{
+ destDB = OPimAccessFactory<ODateBookAccess>::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<int> 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<OPimContactAccess*> (sourceDB);
+ delete static_cast<OPimContactAccess*> (destDB);
+ break;
+ case TODOLIST:
+ delete static_cast<OPimTodoAccess*> (sourceDB);
+ delete static_cast<OPimTodoAccess*> (destDB);
+ break;
+ case DATEBOOK:
+ delete static_cast<ODateBookAccess*> (sourceDB);
+ delete static_cast<ODateBookAccess*> (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();
}