summaryrefslogtreecommitdiff
Unidiff
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 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "engine.h" 21#include "engine.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
25
26/* QT */
22#include <qstring.h> 27#include <qstring.h>
23#include <math.h>
24#include <qlcdnumber.h> 28#include <qlcdnumber.h>
25 29
30/* STD */
31#include <math.h>
32
26Data Engine::evalStack (Data num, bool inbrace = FALSE) 33Data Engine::evalStack (Data num, bool inbrace = FALSE)
27{ 34{
28 if (state != sError) { 35 if (state != sError) {
29 Instruction *i; 36 Instruction *i;
30 37
31// Pop the next op from the stack 38// Pop the next op from the stack
32 while (!stack.isEmpty () && (braces || !inbrace)) { 39 while (!stack.isEmpty () && (braces || !inbrace)) {
33 i = stack.pop (); 40 i = stack.pop ();
34 41
35// Check this ops prec vs next ops prec 42// Check this ops prec vs next ops prec
36 if (!stack.isEmpty ()) 43 if (!stack.isEmpty ())
37 if (i->precedence <= stack.top()->precedence) 44 if (i->precedence <= stack.top()->precedence)
38 i->acc = evalStack (i->acc, inbrace); 45 i->acc = evalStack (i->acc, inbrace);
39 46
40// Evaluate this instruction 47// Evaluate this instruction
41 num = i->eval (num); 48 num = i->eval (num);
42 49
43// Error-check ( change this to work for all types ) 50// Error-check ( change this to work for all types )
44 if (isnan (num.dbl) || isinf (num.dbl)) { 51 if (isnan (num.dbl) || isinf (num.dbl)) {
45 qDebug ("bad result from operation"); 52 odebug << "bad result from operation" << oendl;
46 state = sError; 53 state = sError;
47 clearData(&num); 54 clearData(&num);
48 return num; 55 return num;
49 } 56 }
50 } 57 }
51 } 58 }
52 return num; 59 return num;
53} 60}
54 61
55// Plugins call this to request the stack be evaluated 62// Plugins call this to request the stack be evaluated
56void Engine::eval () 63void Engine::eval ()
57{ 64{
58 num = evalStack (num); 65 num = evalStack (num);
59 if (state != sError) { 66 if (state != sError) {
60 displayData(num); 67 displayData(num);
61 state = sStart; 68 state = sStart;
62 } 69 }
63// if the user didnt close all their braces, its no big deal 70// if the user didnt close all their braces, its no big deal
64 braces = 0; 71 braces = 0;
65} 72}
66 73
67void Engine::immediateInstruction (Instruction * i) 74void Engine::immediateInstruction (Instruction * i)
68{ 75{
69 if (state != sError) { 76 if (state != sError) {
70 i->setRep(currentRep); 77 i->setRep(currentRep);
71 num = i->eval (num); 78 num = i->eval (num);
72 displayData(num); 79 displayData(num);
73 state = sStart; 80 state = sStart;
74 } 81 }
75} 82}
76 83
77void Engine::pushInstruction (Instruction * i) 84void Engine::pushInstruction (Instruction * i)
78{ 85{
79 if (state != sError) { 86 if (state != sError) {
80 i->setRep(currentRep); 87 i->setRep(currentRep);
81 i->acc = num; 88 i->acc = num;
82 stack.push (i); 89 stack.push (i);
83 state = sStart; 90 state = sStart;
84 } 91 }
85} 92}
86 93
87void Engine::pushValue (char v) 94void Engine::pushValue (char v)
88{ 95{
89 if (state == sAppend) { 96 if (state == sAppend) {
90 bool ok = FALSE; 97 bool ok = FALSE;
91 switch (currentRep) { 98 switch (currentRep) {
92 case rDouble: 99 case rDouble:
93 displayString.append(v); 100 displayString.append(v);
94 num.dbl=displayString.toDouble(&ok); 101 num.dbl=displayString.toDouble(&ok);
95 break; 102 break;
96 case rFraction: 103 case rFraction:
97 break; 104 break;
98 default: 105 default:
99 displayString.append(v); 106 displayString.append(v);
100 num.i=displayString.toInt(&ok, calcBase()); 107 num.i=displayString.toInt(&ok, calcBase());
101 }; 108 };
102 if (!ok) { 109 if (!ok) {
103 state = sError; 110 state = sError;
104 odebug << "pushValue() - num->string conversion" << oendl; 111 odebug << "pushValue() - num->string conversion" << oendl;
105 } else { 112 } else {
106 const QString constString = displayString; 113 const QString constString = displayString;
107 emit(display(constString)); 114 emit(display(constString));
108 }; 115 };
109 116
110 } else if (state == sStart) { 117 } else if (state == sStart) {
111 softReset(); 118 softReset();
112 displayString.truncate(0); 119 displayString.truncate(0);
113 state = sAppend; 120 state = sAppend;
114 pushValue (v); 121 pushValue (v);
115 } else if (state == sError) { 122 } else if (state == sError) {
116 qDebug ("in error state"); 123 odebug << "in error state" << oendl;
117 return; 124 return;
118 } 125 }
119} 126}
120 127
121void Engine::del () 128void Engine::del ()
122{ 129{
123 bool ok; 130 bool ok;
124 switch (currentRep) { 131 switch (currentRep) {
125 case rDouble: 132 case rDouble:
126 displayString.truncate(displayString.length()); 133 displayString.truncate(displayString.length());
127 num.dbl=displayString.toDouble(&ok); 134 num.dbl=displayString.toDouble(&ok);
128 break; 135 break;
129 case rFraction: 136 case rFraction:
130 odebug << "not available" << oendl; 137 odebug << "not available" << oendl;
131 break; 138 break;
132 default: 139 default:
133 displayString.truncate(displayString.length()); 140 displayString.truncate(displayString.length());
134 num.i = displayString.toInt(&ok, calcBase()); 141 num.i = displayString.toInt(&ok, calcBase());
135 }; 142 };
136 143
137 if (!ok) { 144 if (!ok) {
138 state = sError; 145 state = sError;
139 odebug << "del() - num->string conversion" << oendl; 146 odebug << "del() - num->string conversion" << oendl;
140 } else { 147 } else {
141 const QString constString = displayString; 148 const QString constString = displayString;
142 emit(display(constString)); 149 emit(display(constString));
143 }; 150 };
144} 151}
145 152
146void Engine::displayData(Data d) { 153void Engine::displayData(Data d) {
147 switch (currentRep) { 154 switch (currentRep) {
148 case rDouble: 155 case rDouble:
149 displayString.setNum(d.dbl); 156 displayString.setNum(d.dbl);
150 break; 157 break;
151 case rFraction: 158 case rFraction:
152 odebug << "fractional display not yet impl" << oendl; 159 odebug << "fractional display not yet impl" << oendl;
153 break; 160 break;
154 default: 161 default:
155 displayString.setNum(d.i, calcBase()); 162 displayString.setNum(d.i, calcBase());
156 break; 163 break;
157 }; 164 };
158 const QString constString= displayString; 165 const QString constString= displayString;
159 emit(display(constString)); 166 emit(display(constString));
160} 167}
161 168
162// Returns the base when Rep is an integer type 169// Returns the base when Rep is an integer type
163int Engine::calcBase () { 170int Engine::calcBase () {
164 switch (currentRep) { 171 switch (currentRep) {
165 case rBin: 172 case rBin:
166 return 2; 173 return 2;
167 case rOct: 174 case rOct:
168 return 8; 175 return 8;
169 case rDec: 176 case rDec:
170 return 10; 177 return 10;
171 case rHex: 178 case rHex:
172 return 16; 179 return 16;
173 default: 180 default:
174 state = sError; 181 state = sError;
175 odebug << "Error - attempt to calc base for non-integer" << oendl; 182 odebug << "Error - attempt to calc base for non-integer" << oendl;
176 return 10; 183 return 10;
177 }; 184 };
178} 185}
179 186
180// Special instruction for internal use only 187// Special instruction for internal use only
181class iOpenBrace:public Instruction { 188class iOpenBrace:public Instruction {
182 public: 189 public:
183 iOpenBrace (Engine *e):Instruction (100) {engine = e;}; 190 iOpenBrace (Engine *e):Instruction (100) {engine = e;};
184 ~iOpenBrace () {}; 191 ~iOpenBrace () {};
185 192
186 Data eval (Data num) { 193 Data eval (Data num) {
187 engine->decBraces(); 194 engine->decBraces();
188 return num; 195 return num;
189 }; 196 };
190 private: 197 private:
191 Engine *engine; 198 Engine *engine;
192}; 199};
193 200
194void Engine::openBrace() { 201void Engine::openBrace() {
195 pushInstruction(new iOpenBrace(this)); 202 pushInstruction(new iOpenBrace(this));
196} 203}
197 204
198void Engine::closeBrace() { 205void Engine::closeBrace() {
199 braces++;evalStack(num,TRUE); 206 braces++;evalStack(num,TRUE);
200} 207}
201 208
202// will need to show and hide display widgets 209// will need to show and hide display widgets
203void Engine::setRepresentation(Representation r) { 210void Engine::setRepresentation(Representation r) {
204 currentRep = r; 211 currentRep = r;
205 clearData(&num); 212 clearData(&num);
206 clearData(&mem); 213 clearData(&mem);
207 state = sStart; 214 state = sStart;
208} 215}
209 216
210void Engine::clearData(Data *d) { 217void Engine::clearData(Data *d) {
211 d->i = d->fraction.numerator = d->fraction.denominator = 0; 218 d->i = d->fraction.numerator = d->fraction.denominator = 0;
212 d->dbl = 0; 219 d->dbl = 0;
213} 220}
214 221
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
@@ -120,105 +120,105 @@ Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl
120 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 ); 120 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 );
121 121
122 SnoozeSlider = new QSlider( this, "SnoozeSlider" ); 122 SnoozeSlider = new QSlider( this, "SnoozeSlider" );
123 SnoozeSlider->setMaxValue( 60 ); 123 SnoozeSlider->setMaxValue( 60 );
124 SnoozeSlider->setOrientation( QSlider::Horizontal ); 124 SnoozeSlider->setOrientation( QSlider::Horizontal );
125 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int))); 125 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int)));
126 126
127 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 4, 4, 1, 2 ); 127 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 4, 4, 1, 2 );
128 128
129 Config config( "qpe" ); 129 Config config( "qpe" );
130 config.setGroup("Time"); 130 config.setGroup("Time");
131 131
132 bool ok; 132 bool ok;
133 bool ampm = config.readBoolEntry( "AMPM", TRUE ); 133 bool ampm = config.readBoolEntry( "AMPM", TRUE );
134 QString alarmHour=config.readEntry("clockAlarmHour","8"); 134 QString alarmHour=config.readEntry("clockAlarmHour","8");
135 int i_alarmHour = alarmHour.toInt(&ok,10); 135 int i_alarmHour = alarmHour.toInt(&ok,10);
136 QString alarmMinute=config.readEntry("clockAlarmMinute","0"); 136 QString alarmMinute=config.readEntry("clockAlarmMinute","0");
137 QString snoozeTime=config.readEntry("clockAlarmSnooze","0"); 137 QString snoozeTime=config.readEntry("clockAlarmSnooze","0");
138 if(ampm) { 138 if(ampm) {
139 Hour_Slider->setMaxValue( 12); 139 Hour_Slider->setMaxValue( 12);
140 Hour_Slider->setMinValue( 1); 140 Hour_Slider->setMinValue( 1);
141 141
142 if( i_alarmHour > 12) { 142 if( i_alarmHour > 12) {
143 i_alarmHour = i_alarmHour - 12; 143 i_alarmHour = i_alarmHour - 12;
144 Pm_RadioButton->setChecked(TRUE); 144 Pm_RadioButton->setChecked(TRUE);
145 } 145 }
146 else if ( i_alarmHour == 0 ) { 146 else if ( i_alarmHour == 0 ) {
147 i_alarmHour = 12; 147 i_alarmHour = 12;
148 } 148 }
149 Hour_Slider->setValue( i_alarmHour ); 149 Hour_Slider->setValue( i_alarmHour );
150 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 150 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
151 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 151 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
152 } else { 152 } else {
153 Hour_Slider->setMaxValue( 23); 153 Hour_Slider->setMaxValue( 23);
154 Hour_Slider->setMinValue( 0); 154 Hour_Slider->setMinValue( 0);
155 Hour_Slider->setValue( i_alarmHour); 155 Hour_Slider->setValue( i_alarmHour);
156 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 156 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
157 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 157 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
158 Am_RadioButton->hide(); 158 Am_RadioButton->hide();
159 Pm_RadioButton->hide(); 159 Pm_RadioButton->hide();
160 } 160 }
161 if( config.readBoolEntry("mp3Alarm") ) 161 if( config.readBoolEntry("mp3Alarm") )
162 useMp3Check->setChecked(true); 162 useMp3Check->setChecked(true);
163 163
164 // signals and slots connections 164 // signals and slots connections
165 connect(useMp3Check,SIGNAL(toggled(bool)),this,SLOT(slotChangemp3CkeckBox(bool))); 165 connect(useMp3Check,SIGNAL(toggled(bool)),this,SLOT(slotChangemp3CkeckBox(bool)));
166} 166}
167 167
168Set_Alarm::~Set_Alarm() 168Set_Alarm::~Set_Alarm()
169{ 169{
170 170
171} 171}
172 172
173void Set_Alarm::slotChangeHour(int hour) 173void Set_Alarm::slotChangeHour(int hour)
174{ 174{
175 Hour_LCDNumber->display(hour); 175 Hour_LCDNumber->display(hour);
176} 176}
177 177
178void Set_Alarm::slotChangeMinute(int minute) 178void Set_Alarm::slotChangeMinute(int minute)
179{ 179{
180 Minute_LCDNumber->display(minute); 180 Minute_LCDNumber->display(minute);
181} 181}
182 182
183void Set_Alarm::slotChangeSnooze(int minute) 183void Set_Alarm::slotChangeSnooze(int minute)
184{ 184{
185 Snooze_LCDNumber->display(minute); 185 Snooze_LCDNumber->display(minute);
186} 186}
187 187
188void Set_Alarm::amButtonToggled(bool b) 188void Set_Alarm::amButtonToggled(bool b)
189{ 189{
190 if ( b) 190 if ( b)
191 Pm_RadioButton->setChecked(FALSE); 191 Pm_RadioButton->setChecked(FALSE);
192} 192}
193 193
194void Set_Alarm::pmButtonToggled(bool b) 194void Set_Alarm::pmButtonToggled(bool b)
195{ 195{
196 if (b) 196 if (b)
197 Am_RadioButton->setChecked(FALSE); 197 Am_RadioButton->setChecked(FALSE);
198} 198}
199 199
200void Set_Alarm::cleanUp() 200void Set_Alarm::cleanUp()
201{ 201{
202} 202}
203 203
204void Set_Alarm::slotChangemp3CkeckBox(bool b) { 204void Set_Alarm::slotChangemp3CkeckBox(bool b) {
205 Config config( "qpe" ); 205 Config config( "qpe" );
206 config.setGroup("Time"); 206 config.setGroup("Time");
207 if(b) { 207 if(b) {
208 QMap<QString, QStringList> map; 208 QMap<QString, QStringList> map;
209 map.insert(tr("All"), QStringList() ); 209 map.insert(tr("All"), QStringList() );
210 QStringList text; 210 QStringList text;
211 text << "audio/*"; 211 text << "audio/*";
212 map.insert(tr("Audio"), text ); 212 map.insert(tr("Audio"), text );
213 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);//,"", "*", this ); 213 QString str = OFileDialog::getOpenFileName( 2,"/", QString::null, map);//,"", "*", this );
214// QString str = Opie::OFileDialog::getOpenFileName( 2,"/");//,"", "*", this ); 214// QString str = Opie::OFileDialog::getOpenFileName( 2,"/");//,"", "*", this );
215 if(!str.isEmpty() ) { 215 if(!str.isEmpty() ) {
216 qDebug(str); 216 odebug << str << oendl;
217 config.writeEntry("mp3Alarm",1); 217 config.writeEntry("mp3Alarm",1);
218 config.writeEntry("mp3File",str); 218 config.writeEntry("mp3File",str);
219 } 219 }
220 } else { 220 } else {
221 config.writeEntry("mp3Alarm",0); 221 config.writeEntry("mp3Alarm",0);
222 config.writeEntry("mp3File",""); 222 config.writeEntry("mp3File","");
223 } 223 }
224} 224}
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 @@
1#include "converter.h" 1#include "converter.h"
2 2
3#include <qdatetime.h> 3/* OPIE */
4#include <qprogressbar.h>
5#include <qcombobox.h>
6#include <qcheckbox.h>
7
8#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
9 5
6#include <opie2/odebug.h>
10#include <opie2/opimglobal.h> 7#include <opie2/opimglobal.h>
11// Include SQL related header files 8// Include SQL related header files
12#define __USE_SQL 9#define __USE_SQL
13#include <opie2/opimaccessfactory.h> 10#include <opie2/opimaccessfactory.h>
14 11
12/* QT */
13#include <qdatetime.h>
14#include <qprogressbar.h>
15#include <qcombobox.h>
16#include <qcheckbox.h>
17
18
15using namespace Opie; 19using namespace Opie;
16using namespace Pim; 20using namespace Pim;
17 21
18Converter::Converter(): 22Converter::Converter():
19 m_selectedDatabase( ADDRESSBOOK ), 23 m_selectedDatabase( ADDRESSBOOK ),
20 m_selectedSourceFormat( XML ), 24 m_selectedSourceFormat( XML ),
21 m_selectedDestFormat( SQL ) 25 m_selectedDestFormat( SQL )
22{ 26{
23 m_dataBaseSelector -> setCurrentItem( m_selectedDatabase ); 27 m_dataBaseSelector -> setCurrentItem( m_selectedDatabase );
24 m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat ); 28 m_sourceFormatSelector -> setCurrentItem( m_selectedSourceFormat );
25 m_destFormatSelector -> setCurrentItem( m_selectedDestFormat ); 29 m_destFormatSelector -> setCurrentItem( m_selectedDestFormat );
26 m_eraseDB -> setChecked( true ); // Default erase on copy 30 m_eraseDB -> setChecked( true ); // Default erase on copy
27} 31}
28 32
29void Converter::selectedDatabase( int num ) 33void Converter::selectedDatabase( int num )
30{ 34{
31 m_selectedDatabase = num; 35 m_selectedDatabase = num;
32} 36}
33 37
34void Converter::selectedDestFormat( int num ) 38void Converter::selectedDestFormat( int num )
35{ 39{
36 m_selectedDestFormat = num; 40 m_selectedDestFormat = num;
37} 41}
38 42
39void Converter::selectedSourceFormat( int num ) 43void Converter::selectedSourceFormat( int num )
40{ 44{
41 m_selectedSourceFormat = num; 45 m_selectedSourceFormat = num;
42} 46}
43 47
44void Converter::start_conversion(){ 48void Converter::start_conversion(){
45 49
46 // Creating backends to the requested databases.. 50 // Creating backends to the requested databases..
47 OPimBase* sourceDB; 51 OPimBase* sourceDB;
48 OPimBase* destDB; 52 OPimBase* destDB;
49 53
50 switch( m_selectedSourceFormat ){ 54 switch( m_selectedSourceFormat ){
51 case XML: 55 case XML:
52 qDebug("XMLSourceDB = %d", m_selectedDatabase); 56 odebug << "XMLSourceDB = " << m_selectedDatabase << "" << oendl;
53 switch( m_selectedDatabase ){ 57 switch( m_selectedDatabase ){
54 case ADDRESSBOOK:{ 58 case ADDRESSBOOK:{
55 sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); 59 sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
56 } 60 }
57 break; 61 break;
58 case TODOLIST:{ 62 case TODOLIST:{
59 sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); 63 sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
60 }break; 64 }break;
61 case DATEBOOK:{ 65 case DATEBOOK:{
62 sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); 66 sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" );
63 } 67 }
64 break; 68 break;
65 default: 69 default:
66 qWarning( "Unknown database selected (%d)", m_selectedDatabase ); 70 owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl;
67 return; 71 return;
68 } 72 }
69 break; 73 break;
70 case SQL: 74 case SQL:
71 qDebug("SQLSourceDB = %d", m_selectedDatabase); 75 odebug << "SQLSourceDB = " << m_selectedDatabase << "" << oendl;
72 switch( m_selectedDatabase ){ 76 switch( m_selectedDatabase ){
73 case ADDRESSBOOK:{ 77 case ADDRESSBOOK:{
74 sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); 78 sourceDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" );
75 } 79 }
76 break; 80 break;
77 case TODOLIST:{ 81 case TODOLIST:{
78 sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); 82 sourceDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" );
79 }break; 83 }break;
80 case DATEBOOK:{ 84 case DATEBOOK:{
81 sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); 85 sourceDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" );
82 } 86 }
83 break; 87 break;
84 default: 88 default:
85 qWarning( "Unknown database selected (%d)", m_selectedDatabase ); 89 owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl;
86 return; 90 return;
87 } 91 }
88 break; 92 break;
89 default: 93 default:
90 qWarning( "Unknown source format selected (%d) !!", m_selectedSourceFormat ); 94 owarn << "Unknown source format selected (" << m_selectedSourceFormat << ") !!" << oendl;
91 return; 95 return;
92 } 96 }
93 97
94 switch ( m_selectedDestFormat ){ 98 switch ( m_selectedDestFormat ){
95 case XML: 99 case XML:
96 qDebug("XMLDestDB = %d", m_selectedDatabase); 100 odebug << "XMLDestDB = " << m_selectedDatabase << "" << oendl;
97 switch( m_selectedDatabase ){ 101 switch( m_selectedDatabase ){
98 case ADDRESSBOOK:{ 102 case ADDRESSBOOK:{
99 destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" ); 103 destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::XML, "converter" );
100 } 104 }
101 break; 105 break;
102 case TODOLIST:{ 106 case TODOLIST:{
103 destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" ); 107 destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "converter" );
104 }break; 108 }break;
105 case DATEBOOK:{ 109 case DATEBOOK:{
106 destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" ); 110 destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::XML, "converter" );
107 } 111 }
108 break; 112 break;
109 default: 113 default:
110 qWarning( "Unknown database selected (%d)", m_selectedDatabase ); 114 owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl;
111 return; 115 return;
112 } 116 }
113 break; 117 break;
114 case SQL: 118 case SQL:
115 qDebug("SQLDestDB = %d", m_selectedDatabase); 119 odebug << "SQLDestDB = " << m_selectedDatabase << "" << oendl;
116 switch( m_selectedDatabase ){ 120 switch( m_selectedDatabase ){
117 case ADDRESSBOOK:{ 121 case ADDRESSBOOK:{
118 destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" ); 122 destDB = OPimAccessFactory<OPimContactAccess>::create( OPimGlobal::CONTACTLIST, OPimGlobal::SQL, "converter" );
119 } 123 }
120 break; 124 break;
121 case TODOLIST:{ 125 case TODOLIST:{
122 destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" ); 126 destDB = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::SQL, "converter" );
123 }break; 127 }break;
124 case DATEBOOK:{ 128 case DATEBOOK:{
125 destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" ); 129 destDB = OPimAccessFactory<ODateBookAccess>::create( OPimGlobal::DATEBOOK, OPimGlobal::SQL, "converter" );
126 } 130 }
127 break; 131 break;
128 default: 132 default:
129 qWarning( "Unknown database selected (%d)", m_selectedDatabase ); 133 owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl;
130 return; 134 return;
131 } 135 }
132 break; 136 break;
133 default: 137 default:
134 qWarning( "Unknown destination format selected (%d)!!", m_selectedDestFormat ); 138 owarn << "Unknown destination format selected (" << m_selectedDestFormat << ")!!" << oendl;
135 return; 139 return;
136 } 140 }
137 141
138 if ( !sourceDB || !destDB ) 142 if ( !sourceDB || !destDB )
139 return; 143 return;
140 144
141 sourceDB -> load(); 145 sourceDB -> load();
142 destDB -> load(); 146 destDB -> load();
143 147
144 QTime t; 148 QTime t;
145 t.start(); 149 t.start();
146 150
147 // Clean the dest-database if requested (isChecked) 151 // Clean the dest-database if requested (isChecked)
148 if ( m_eraseDB -> isChecked() ){ 152 if ( m_eraseDB -> isChecked() ){
149 qDebug( "Clearing destination database!" ); 153 odebug << "Clearing destination database!" << oendl;
150 destDB -> clear(); 154 destDB -> clear();
151 } 155 }
152 156
153 // Now transmit every pim-item from the source database to the destination -database 157 // Now transmit every pim-item from the source database to the destination -database
154 QArray<int> uidList = sourceDB->records(); 158 QArray<int> uidList = sourceDB->records();
155 qDebug( "Try to move data for addressbook.. (%d items) ", uidList.count() ); 159 odebug << "Try to move data for addressbook.. (" << uidList.count() << " items) " << oendl;
156 m_progressBar->setTotalSteps( uidList.count() ); 160 m_progressBar->setTotalSteps( uidList.count() );
157 int count = 0; 161 int count = 0;
158 for ( uint i = 0; i < uidList.count(); ++i ){ 162 for ( uint i = 0; i < uidList.count(); ++i ){
159 qDebug( "Adding uid: %d", uidList[i] ); 163 odebug << "Adding uid: " << uidList[i] << "" << oendl;
160 OPimRecord* rec = sourceDB -> record( uidList[i] ); 164 OPimRecord* rec = sourceDB -> record( uidList[i] );
161 destDB -> add( rec ); 165 destDB -> add( rec );
162 m_progressBar->setProgress( ++count ); 166 m_progressBar->setProgress( ++count );
163 } 167 }
164 168
165 // Now commit data.. 169 // Now commit data..
166 destDB -> save(); 170 destDB -> save();
167 171
168 // Delete the frontends. Backends will be deleted automatically, too ! 172 // Delete the frontends. Backends will be deleted automatically, too !
169 // We have to cast them back to delete them properly ! 173 // We have to cast them back to delete them properly !
170 switch( m_selectedDatabase ){ 174 switch( m_selectedDatabase ){
171 case ADDRESSBOOK: 175 case ADDRESSBOOK:
172 delete static_cast<OPimContactAccess*> (sourceDB); 176 delete static_cast<OPimContactAccess*> (sourceDB);
173 delete static_cast<OPimContactAccess*> (destDB); 177 delete static_cast<OPimContactAccess*> (destDB);
174 break; 178 break;
175 case TODOLIST: 179 case TODOLIST:
176 delete static_cast<OPimTodoAccess*> (sourceDB); 180 delete static_cast<OPimTodoAccess*> (sourceDB);
177 delete static_cast<OPimTodoAccess*> (destDB); 181 delete static_cast<OPimTodoAccess*> (destDB);
178 break; 182 break;
179 case DATEBOOK: 183 case DATEBOOK:
180 delete static_cast<ODateBookAccess*> (sourceDB); 184 delete static_cast<ODateBookAccess*> (sourceDB);
181 delete static_cast<ODateBookAccess*> (destDB); 185 delete static_cast<ODateBookAccess*> (destDB);
182 break; 186 break;
183 default: 187 default:
184 qWarning( "Unknown database selected (%d)", m_selectedDatabase ); 188 owarn << "Unknown database selected (" << m_selectedDatabase << ")" << oendl;
185 return; 189 return;
186 } 190 }
187 191
188 192
189 qWarning("Conversion is finished and needed %d ms !", t.elapsed()); 193 owarn << "Conversion is finished and needed " << t.elapsed() << " ms !" << oendl;
190} 194}
191 195
192int main( int argc, char** argv ) { 196int main( int argc, char** argv ) {
193 197
194 QPEApplication a( argc, argv ); 198 QPEApplication a( argc, argv );
195 199
196 Converter dlg; 200 Converter dlg;
197 201
198 a.showMainWidget( &dlg ); 202 a.showMainWidget( &dlg );
199 // dlg. showMaximized ( ); 203 // dlg. showMaximized ( );
200 204
201 return a.exec(); 205 return a.exec();
202 206
203} 207}