summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/kmymoneycalculator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmymoney2/widgets/kmymoneycalculator.cpp')
-rw-r--r--kmymoney2/widgets/kmymoneycalculator.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/kmymoney2/widgets/kmymoneycalculator.cpp b/kmymoney2/widgets/kmymoneycalculator.cpp
index 3e59331..8e1cbdd 100644
--- a/kmymoney2/widgets/kmymoneycalculator.cpp
+++ b/kmymoney2/widgets/kmymoneycalculator.cpp
@@ -23,9 +23,9 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qlabel.h>
-#include <qsignalmapper.h>
-#include <qregexp.h>
+#include <tqlabel.h>
+#include <tqsignalmapper.h>
+#include <tqregexp.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -38,19 +38,19 @@
#include "kmymoneycalculator.h"
-kMyMoneyCalculator::kMyMoneyCalculator(QWidget* parent, const char *name)
- : QFrame(parent, name)
+kMyMoneyCalculator::kMyMoneyCalculator(TQWidget* tqparent, const char *name)
+ : TQFrame(tqparent, name)
{
m_comma = KGlobal::locale()->monetaryDecimalSymbol()[0];
m_clearOperandOnDigit = false;
- QGridLayout* grid = new QGridLayout(this, 5, 5, 1, 2);
+ TQGridLayout* grid = new TQGridLayout(this, 5, 5, 1, 2);
- display = new QLabel(this);
- display->setBackgroundColor(QColor("#BDFFB4"));
+ display = new TQLabel(this);
+ display->setBackgroundColor(TQColor("#BDFFB4"));
- display->setFrameStyle( QFrame::Panel | QFrame::Sunken );
- display->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ display->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
+ display->tqsetAlignment(TQt::AlignRight | TQt::AlignVCenter);
grid->addMultiCellWidget(display, 0, 0, 0, 4);
buttons[0] = new KPushButton("0", this);
@@ -67,7 +67,7 @@ kMyMoneyCalculator::kMyMoneyCalculator(QWidget* parent, const char *name)
buttons[MINUS] = new KPushButton("-", this);
buttons[STAR] = new KPushButton("X", this);
buttons[COMMA] = new KPushButton(m_comma, this);
- buttons[EQUAL] = new KPushButton("=", this);
+ buttons[ETQUAL] = new KPushButton("=", this);
buttons[SLASH] = new KPushButton("/", this);
buttons[CLEAR] = new KPushButton("C", this);
buttons[CLEARALL] = new KPushButton("AC", this);
@@ -90,41 +90,41 @@ kMyMoneyCalculator::kMyMoneyCalculator(QWidget* parent, const char *name)
grid->addWidget(buttons[MINUS], 4, 3);
grid->addWidget(buttons[STAR], 3, 4);
grid->addWidget(buttons[SLASH], 4, 4);
- grid->addWidget(buttons[EQUAL], 4, 2);
+ grid->addWidget(buttons[ETQUAL], 4, 2);
grid->addWidget(buttons[PLUSMINUS], 2, 3);
grid->addWidget(buttons[PERCENT], 2, 4);
grid->addWidget(buttons[CLEAR], 1, 3);
grid->addWidget(buttons[CLEARALL], 1, 4);
- buttons[EQUAL]->setFocus();
+ buttons[ETQUAL]->setFocus();
op1 = 0.0;
stackedOp = op = 0;
- operand = QString();
+ operand = TQString();
changeDisplay("0");
// connect the digit signals through a signal mapper
- QSignalMapper* mapper = new QSignalMapper(this);
+ TQSignalMapper* mapper = new TQSignalMapper(TQT_TQOBJECT(this));
for(int i = 0; i < 10; ++i) {
- mapper->setMapping(buttons[i], i);
- connect(buttons[i], SIGNAL(clicked()), mapper, SLOT(map()));
+ mapper->setMapping(TQT_TQOBJECT(buttons[i]), i);
+ connect(buttons[i], TQT_SIGNAL(clicked()), mapper, TQT_SLOT(map()));
}
- connect(mapper, SIGNAL(mapped(int)), this, SLOT(digitClicked(int)));
+ connect(mapper, TQT_SIGNAL(mapped(int)), this, TQT_SLOT(digitClicked(int)));
// connect the calculation operations through another mapper
- mapper = new QSignalMapper(this);
- for(int i = PLUS; i <= EQUAL; ++i) {
- mapper->setMapping(buttons[i], i);
- connect(buttons[i], SIGNAL(clicked()), mapper, SLOT(map()));
+ mapper = new TQSignalMapper(TQT_TQOBJECT(this));
+ for(int i = PLUS; i <= ETQUAL; ++i) {
+ mapper->setMapping(TQT_TQOBJECT(buttons[i]), i);
+ connect(buttons[i], TQT_SIGNAL(clicked()), mapper, TQT_SLOT(map()));
}
- connect(mapper, SIGNAL(mapped(int)), this, SLOT(calculationClicked(int)));
+ connect(mapper, TQT_SIGNAL(mapped(int)), this, TQT_SLOT(calculationClicked(int)));
// connect all remaining signals
- connect(buttons[COMMA], SIGNAL(clicked()), SLOT(commaClicked()));
- connect(buttons[PLUSMINUS], SIGNAL(clicked()), SLOT(plusminusClicked()));
- connect(buttons[PERCENT], SIGNAL(clicked()), SLOT(percentClicked()));
- connect(buttons[CLEAR], SIGNAL(clicked()), SLOT(clearClicked()));
- connect(buttons[CLEARALL], SIGNAL(clicked()), SLOT(clearAllClicked()));
+ connect(buttons[COMMA], TQT_SIGNAL(clicked()), TQT_SLOT(commaClicked()));
+ connect(buttons[PLUSMINUS], TQT_SIGNAL(clicked()), TQT_SLOT(plusminusClicked()));
+ connect(buttons[PERCENT], TQT_SIGNAL(clicked()), TQT_SLOT(percentClicked()));
+ connect(buttons[CLEAR], TQT_SIGNAL(clicked()), TQT_SLOT(clearClicked()));
+ connect(buttons[CLEARALL], TQT_SIGNAL(clicked()), TQT_SLOT(clearAllClicked()));
for(int i = 0; i < MAX_BUTTONS; ++i) {
buttons[i]->setMinimumSize(40, 30);
@@ -146,11 +146,11 @@ kMyMoneyCalculator::~kMyMoneyCalculator()
void kMyMoneyCalculator::digitClicked(int button)
{
if(m_clearOperandOnDigit) {
- operand = QString();
+ operand = TQString();
m_clearOperandOnDigit = false;
}
- operand += QChar(button + 0x30);
+ operand += TQChar(button + 0x30);
if(operand.length() > 16)
operand = operand.left(16);
changeDisplay(operand);
@@ -160,7 +160,7 @@ void kMyMoneyCalculator::commaClicked(void)
{
if(operand.length() == 0)
operand = "0";
- if(operand.contains('.', FALSE) == 0)
+ if(operand.tqcontains('.', FALSE) == 0)
operand.append('.');
if(operand.length() > 16)
@@ -174,8 +174,8 @@ void kMyMoneyCalculator::plusminusClicked(void)
operand = m_result;
if(operand.length() > 0) {
- if(operand.find('-') != -1)
- operand.replace('-', QString());
+ if(operand.tqfind('-') != -1)
+ operand.tqreplace('-', TQString());
else
operand.prepend('-');
changeDisplay(operand);
@@ -184,7 +184,7 @@ void kMyMoneyCalculator::plusminusClicked(void)
void kMyMoneyCalculator::calculationClicked(int button)
{
- if(operand.length() == 0 && op != 0 && button == EQUAL) {
+ if(operand.length() == 0 && op != 0 && button == ETQUAL) {
op = 0;
m_result = normalizeString(op1);
changeDisplay(m_result);
@@ -237,7 +237,7 @@ void kMyMoneyCalculator::calculationClicked(int button)
if(error) {
op = 0;
changeDisplay("Error");
- operand = QString();
+ operand = TQString();
} else {
op1 = op2;
m_result = normalizeString(op1);
@@ -249,18 +249,18 @@ void kMyMoneyCalculator::calculationClicked(int button)
changeDisplay(m_result);
}
- if(button != EQUAL) {
+ if(button != ETQUAL) {
op = button;
} else {
op = 0;
emit signalResultAvailable();
}
- operand = QString();
+ operand = TQString();
}
-QString kMyMoneyCalculator::normalizeString(const double& val)
+TQString kMyMoneyCalculator::normalizeString(const double& val)
{
- QString str;
+ TQString str;
str.setNum(val, 'f');
int i = str.length();
while(i > 1 && str[i-1] == '0') {
@@ -290,7 +290,7 @@ void kMyMoneyCalculator::clearClicked(void)
void kMyMoneyCalculator::clearAllClicked(void)
{
- operand = QString();
+ operand = TQString();
op = 0;
changeDisplay("0");
}
@@ -315,93 +315,93 @@ void kMyMoneyCalculator::percentClicked(void)
}
}
-const QString kMyMoneyCalculator::result(void) const
+const TQString kMyMoneyCalculator::result(void) const
{
- QString txt = m_result;
- txt.replace(QRegExp("\\."), m_comma);
+ TQString txt = m_result;
+ txt.tqreplace(TQRegExp("\\."), m_comma);
if(txt[0] == '-') {
txt = txt.mid(1); // get rid of the minus sign
- QString mask;
+ TQString tqmask;
switch(KGlobal::locale()->negativeMonetarySignPosition()) {
case KLocale::ParensAround:
- mask = "(%1)";
+ tqmask = "(%1)";
break;
case KLocale::AfterQuantityMoney:
- mask = "%1-";
+ tqmask = "%1-";
break;
case KLocale::AfterMoney:
case KLocale::BeforeMoney:
- mask = "%1 -";
+ tqmask = "%1 -";
break;
case KLocale::BeforeQuantityMoney:
- mask = "-%1";
+ tqmask = "-%1";
break;
}
- txt = QString(mask).arg(txt);
+ txt = TQString(tqmask).tqarg(txt);
}
return txt;
}
-void kMyMoneyCalculator::changeDisplay(const QString& str)
+void kMyMoneyCalculator::changeDisplay(const TQString& str)
{
- QString txt = str;
- txt.replace(QRegExp("\\."), m_comma);
+ TQString txt = str;
+ txt.tqreplace(TQRegExp("\\."), m_comma);
display->setText("<b>" + txt + "</b>");
}
-void kMyMoneyCalculator::keyPressEvent(QKeyEvent* ev)
+void kMyMoneyCalculator::keyPressEvent(TQKeyEvent* ev)
{
int button = -1;
switch(ev->key()) {
- case Qt::Key_0:
- case Qt::Key_1:
- case Qt::Key_2:
- case Qt::Key_3:
- case Qt::Key_4:
- case Qt::Key_5:
- case Qt::Key_6:
- case Qt::Key_7:
- case Qt::Key_8:
- case Qt::Key_9:
+ case TQt::Key_0:
+ case TQt::Key_1:
+ case TQt::Key_2:
+ case TQt::Key_3:
+ case TQt::Key_4:
+ case TQt::Key_5:
+ case TQt::Key_6:
+ case TQt::Key_7:
+ case TQt::Key_8:
+ case TQt::Key_9:
if(m_clearOperandOnDigit) {
- operand = QString();
+ operand = TQString();
m_clearOperandOnDigit = false;
}
- button = ev->key() - Qt::Key_0;
+ button = ev->key() - TQt::Key_0;
break;
- case Qt::Key_Plus:
+ case TQt::Key_Plus:
button = PLUS;
break;
- case Qt::Key_Minus:
+ case TQt::Key_Minus:
button = MINUS;
break;
- case Qt::Key_Comma:
- case Qt::Key_Period:
+ case TQt::Key_Comma:
+ case TQt::Key_Period:
if(m_clearOperandOnDigit) {
- operand = QString();
+ operand = TQString();
m_clearOperandOnDigit = false;
}
button = COMMA;
break;
- case Qt::Key_Slash:
+ case TQt::Key_Slash:
button = SLASH;
break;
- case Qt::Key_Backspace:
+ case TQt::Key_Backspace:
button = CLEAR;
break;
- case Qt::Key_Asterisk:
+ case TQt::Key_Asterisk:
button = STAR;
break;
- case Qt::Key_Return:
- case Qt::Key_Enter:
- case Qt::Key_Equal:
- button = EQUAL;
+ case TQt::Key_Return:
+ case TQt::Key_Enter:
+ case TQt::Key_Equal:
+ button = ETQUAL;
break;
- case Qt::Key_Escape:
+ case TQt::Key_Escape:
button = CLEARALL;
break;
- case Qt::Key_Percent:
+ case TQt::Key_Percent:
button = PERCENT;
break;
default:
@@ -414,26 +414,26 @@ void kMyMoneyCalculator::keyPressEvent(QKeyEvent* ev)
m_clearOperandOnDigit = false;
}
-void kMyMoneyCalculator::setInitialValues(const QString& value, QKeyEvent* ev)
+void kMyMoneyCalculator::setInitialValues(const TQString& value, TQKeyEvent* ev)
{
bool negative = false;
// setup operand
operand = value;
- operand.replace(QRegExp(QString("\\")+KGlobal::locale()->thousandsSeparator()), QString());
- operand.replace(QRegExp(QString("\\")+m_comma), ".");
- if(operand.contains('(')) {
+ operand.tqreplace(TQRegExp(TQString("\\")+KGlobal::locale()->thousandsSeparator()), TQString());
+ operand.tqreplace(TQRegExp(TQString("\\")+m_comma), ".");
+ if(operand.tqcontains('(')) {
negative = true;
- operand.replace("(", QString());
- operand.replace(")", QString());
+ operand.tqreplace("(", TQString());
+ operand.tqreplace(")", TQString());
}
- if(operand.contains('-')) {
+ if(operand.tqcontains('-')) {
negative = true;
- operand.replace("-", QString());
+ operand.tqreplace("-", TQString());
}
if(operand.isEmpty())
operand = "0";
else if(negative)
- operand = QString("-%1").arg(operand);
+ operand = TQString("-%1").tqarg(operand);
changeDisplay(operand);