summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/euroconv/calcdisplay.cpp40
-rw-r--r--noncore/tools/euroconv/currency.h10
2 files changed, 43 insertions, 7 deletions
diff --git a/noncore/tools/euroconv/calcdisplay.cpp b/noncore/tools/euroconv/calcdisplay.cpp
index 1659858..898de81 100644
--- a/noncore/tools/euroconv/calcdisplay.cpp
+++ b/noncore/tools/euroconv/calcdisplay.cpp
@@ -1,216 +1,248 @@
/****************************************************************************
*
* File: calcdisplay.cpp
*
* Description:
*
*
* Authors: Eric Santonacci <Eric.Santonacci@talc.fr>
*
* Requirements: Qt
*
* $Id$
*
***************************************************************************/
#include <stdio.h>
#include <qvbox.h>
#include <qpixmap.h>
#include "currency.h"
#include "calcdisplay.h"
LCDDisplay::LCDDisplay( QWidget *parent, const char *name )
: QHBox( parent, name ){
this->setMargin(5);
this->setSpacing(5);
// Create display
QVBox *vbxlayout = new QVBox (this);
/*************** Top LCD ***********************/
grpbxTop = new QHGroupBox(vbxlayout, "grpbxTop");
grpbxStyle = grpbxTop->frameStyle();
grpbxTop->setMaximumHeight(48);
cbbxTop = new QComboBox(grpbxTop, "cbbxTop");
cbbxTop->setMaximumWidth(50);
cbbxTop->insertStrList(aCurrency);
lcdTop = new QLCDNumber(10, grpbxTop, "lcdTop");
lcdTop->setMode( QLCDNumber::DEC );
lcdTop->setSmallDecimalPoint(true);
lcdTop->setSegmentStyle(QLCDNumber::Flat);
/************** Bottom LCD ************************/
grpbxBottom = new QHGroupBox(vbxlayout, "grpbxBottom");
grpbxBottom->setMaximumHeight(46);
grpbxBottom->setFrameStyle(0);
grpbxBottom->setFrameShadow(QFrame::MShadow);
cbbxBottom = new QComboBox(grpbxBottom, "cbbxBottom");
cbbxBottom->setMaximumWidth(50);
cbbxBottom->insertStrList(aCurrency);
lcdBottom = new QLCDNumber(10, grpbxBottom, "lcdBottom");
lcdBottom->setMode( QLCDNumber::DEC );
lcdBottom->setSmallDecimalPoint(true);
lcdBottom->setSegmentStyle(QLCDNumber::Flat);
// set combo box signals
connect(cbbxTop, SIGNAL(activated(int)), this, SLOT(cbbxChange()));
connect(cbbxBottom, SIGNAL(activated(int)), this, SLOT(cbbxChange()));
btnSwap = new QPushButton(this, "swap");
QPixmap imgSwap((const char**) swap_xpm);
btnSwap->setPixmap(imgSwap);
btnSwap->setFixedSize(20,40);
// set signal
connect(btnSwap, SIGNAL(clicked()), this, SLOT(swapLCD()));
// set default LCD to top
iCurrentLCD = 0;
}
/***********************************************************************
* SLOT: Display value in the correct LCD
**********************************************************************/
void LCDDisplay::setValue(double dSrcValue){
double dDstValue=0;
int iSrcIndex;
int iDstIndex;
// get item index of the focused
if(!iCurrentLCD){
iSrcIndex = cbbxTop->currentItem();
iDstIndex = cbbxBottom->currentItem();
}else{
iSrcIndex = cbbxBottom->currentItem();
iDstIndex = cbbxTop->currentItem();
}
if(iSrcIndex == iDstIndex)
dDstValue = dSrcValue;
else{
if(iSrcIndex){
// we are NOT in Euro as iDstIndex <> 0
// Convert to Euro
dDstValue = x2Euro(iSrcIndex, dSrcValue);
dDstValue = Euro2x(iDstIndex, dDstValue);
}else
// We are in Euro
dDstValue = Euro2x(iDstIndex, dSrcValue);
}
if(!iCurrentLCD){
lcdTop->display(dSrcValue);
lcdBottom->display(dDstValue);
}else{
lcdBottom->display(dSrcValue);
lcdTop->display(dDstValue);
}
}
/***********************************************************************
* SLOT: Swap output keypad between LCD displays
**********************************************************************/
void LCDDisplay::swapLCD(void){
double dCurrentValue;
// get current value
if(!iCurrentLCD){
// iCurrentLCD = 0, lcdTop has current focus and is going to loose
// it
dCurrentValue = lcdTop->value();
iCurrentLCD = 1;
grpbxTop->setFrameStyle(0);
grpbxBottom->setFrameStyle(grpbxStyle);
}else{
dCurrentValue = lcdBottom->value();
iCurrentLCD = 0;
grpbxTop->setFrameStyle(grpbxStyle);
grpbxBottom->setFrameStyle(0);
}
setValue(dCurrentValue);
}
/***********************************************************************
* SLOT: Currency change
**********************************************************************/
void LCDDisplay::cbbxChange(void){
double dCurrentValue;
// get current value
if(!iCurrentLCD){
dCurrentValue = lcdTop->value();
}else{
dCurrentValue = lcdBottom->value();
}
setValue(dCurrentValue);
}
/***********************************************************************
* Euro2x converts dValue from Euro to the currency which combo box
* index is provided in iIndex.
**********************************************************************/
double LCDDisplay::Euro2x(int iIndex, double dValue){
switch (iIndex){
case 0: // Euro
return(dValue);
break;
case 1: // FF: French Francs
- return(dValue*FF);
+ return(dValue*FRF);
break;
case 2: // DM: Deutch Mark
- return(dValue*DM);
+ return(dValue*DEM);
+ break;
+
+ case 3: // BEL Belgium Francs
+ return(dValue*BEF);
+ break;
+
+ case 4: // ITL Itialian Lire
+ return(dValue*ITL);
+ break;
+
+ case 5: // LUF Luxemburg
+ return(dValue*LUF);
+ break;
+
+ case 6: // IEP Irish Pound
+ return(dValue*IEP);
break;
default:
return 0;
}//switch (iIndex)
}// fct Eur2x
/***********************************************************************
* x2Euro converts dValue to Euro from the currency which combo box
* index is provided in iIndex.
**********************************************************************/
double LCDDisplay::x2Euro(int iIndex, double dValue){
switch (iIndex){
case 0: // Euro
return(dValue);
break;
case 1: // FF: French Francs
- return(dValue/FF);
+ return(dValue/FRF);
break;
case 2: // DM: Deutch Mark
- return(dValue/DM);
+ return(dValue/DEM);
+ break;
+
+ case 3: // BEL Belgium Francs
+ return(dValue/BEF);
+ break;
+
+ case 4: // ITL Itialian Lire
+ return(dValue/ITL);
+ break;
+
+ case 5: // LUF Luxemburg
+ return(dValue/LUF);
+ break;
+
+ case 6: // IEP Irish Pound
+ return(dValue/IEP);
break;
}//switch (iIndex)
// we shouldn't come here
return 0;
}// fct x2Euro
diff --git a/noncore/tools/euroconv/currency.h b/noncore/tools/euroconv/currency.h
index d9ee75c..6ca4d09 100644
--- a/noncore/tools/euroconv/currency.h
+++ b/noncore/tools/euroconv/currency.h
@@ -1,20 +1,24 @@
/****************************************************************************
*
* File: currency.h
*
* Description: define constant for currency compare Euro
*
*
* Authors: Eric Santonacci <Eric.Santonacci@talc.fr>
*
*
* $Id$
*
***************************************************************************/
// 1 Euro equal....
#define EURO 1 // Euro
-#define FF 6.55957 // French Francs
-#define DM 1.9594 // Deutch Mark
+#define FRF 6.55957 // French Francs
+#define DEM 1.9594 // Deutch Mark
+#define BEF 40.3399 // Belgium Francs
+#define ITL 1936.27 // Italian Lire
+#define LUF 40.3399 // Luxemburg
+#define IEP 0.787564 // Irish Pound
-static const char* aCurrency[] = { "Euro", "FF", "DM", 0 };
+static const char* aCurrency[] = { "Euro", "FRF", "DEM", "BEF", "ITL", "LUF", "IEP", 0 };