summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/kmymoneyedit.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-05 06:00:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-05 06:00:29 +0000
commitfecb0e67b23e8b83ba7fc881bb57bc48c0852d62 (patch)
tree6b8614802f0d01b353bc9ba78aff2090846c198e /kmymoney2/widgets/kmymoneyedit.cpp
parentdadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (diff)
downloadkmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.tar.gz
kmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.zip
TQt4 port kmymoney
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239855 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/widgets/kmymoneyedit.cpp')
-rw-r--r--kmymoney2/widgets/kmymoneyedit.cpp190
1 files changed, 95 insertions, 95 deletions
diff --git a/kmymoney2/widgets/kmymoneyedit.cpp b/kmymoney2/widgets/kmymoneyedit.cpp
index 87be674..2e59e32 100644
--- a/kmymoney2/widgets/kmymoneyedit.cpp
+++ b/kmymoney2/widgets/kmymoneyedit.cpp
@@ -19,10 +19,10 @@
// ----------------------------------------------------------------------------
// QT Includes
-#include <qapplication.h>
-#include <qdesktopwidget.h>
-#include <qwidget.h>
-#include <qvbox.h>
+#include <tqapplication.h>
+#include <tqdesktopwidget.h>
+#include <tqwidget.h>
+#include <tqvbox.h>
// ----------------------------------------------------------------------------
// KDE Includes
@@ -42,14 +42,14 @@
#include "kmymoneycalculator.h"
#include "../mymoney/mymoneymoney.h"
-kMyMoneyMoneyValidator::kMyMoneyMoneyValidator(QObject * parent, const char * name) :
- QDoubleValidator(parent, name)
+kMyMoneyMoneyValidator::kMyMoneyMoneyValidator(TQObject * tqparent, const char * name) :
+ TQDoubleValidator(tqparent, name)
{
}
kMyMoneyMoneyValidator::kMyMoneyMoneyValidator( double bottom, double top, int decimals,
- QObject * parent, const char * name ) :
- QDoubleValidator(bottom, top, decimals, parent, name)
+ TQObject * tqparent, const char * name ) :
+ TQDoubleValidator(bottom, top, decimals, tqparent, name)
{
}
@@ -57,9 +57,9 @@ kMyMoneyMoneyValidator::kMyMoneyMoneyValidator( double bottom, double top, int d
* The code of the following function is taken from kdeui/knumvalidator.cpp
* and adjusted to always use the monetary symbols defined in the KDE control center
*/
-QValidator::State kMyMoneyMoneyValidator::validate( QString & input, int & _p ) const
+TQValidator::State kMyMoneyMoneyValidator::validate( TQString & input, int & _p ) const
{
- QString s = input;
+ TQString s = input;
KLocale * l = KGlobal::locale();
// ok, we have to re-format the number to have:
// 1. decimalSymbol == '.'
@@ -67,62 +67,62 @@ QValidator::State kMyMoneyMoneyValidator::validate( QString & input, int & _p )
// 3. positiveSign == <empty>
// 4. thousandsSeparator() == <empty> (we don't check that there
// are exactly three decimals between each separator):
- QString d = l->monetaryDecimalSymbol(),
+ TQString d = l->monetaryDecimalSymbol(),
n = l->negativeSign(),
p = l->positiveSign(),
t = l->monetaryThousandsSeparator();
// first, delete p's and t's:
if ( !p.isEmpty() )
- for ( int idx = s.find( p ) ; idx >= 0 ; idx = s.find( p, idx ) )
+ for ( int idx = s.tqfind( p ) ; idx >= 0 ; idx = s.tqfind( p, idx ) )
s.remove( idx, p.length() );
if ( !t.isEmpty() )
- for ( int idx = s.find( t ) ; idx >= 0 ; idx = s.find( t, idx ) )
+ for ( int idx = s.tqfind( t ) ; idx >= 0 ; idx = s.tqfind( t, idx ) )
s.remove( idx, t.length() );
// then, replace the d's and n's
- if ( ( !n.isEmpty() && n.find('.') != -1 ) ||
- ( !d.isEmpty() && d.find('-') != -1 ) ) {
+ if ( ( !n.isEmpty() && n.tqfind('.') != -1 ) ||
+ ( !d.isEmpty() && d.tqfind('-') != -1 ) ) {
// make sure we don't replace something twice:
- kdWarning() << "KDoubleValidator: decimal symbol contains '-' or "
- "negative sign contains '.' -> improve algorithm" << endl;
+ kdWarning() << "KDoubleValidator: decimal symbol tqcontains '-' or "
+ "negative sign tqcontains '.' -> improve algorithm" << endl;
return Invalid;
}
if ( !d.isEmpty() && d != "." )
- for ( int idx = s.find( d ) ; idx >= 0 ; idx = s.find( d, idx + 1 ) )
- s.replace( idx, d.length(), ".");
+ for ( int idx = s.tqfind( d ) ; idx >= 0 ; idx = s.tqfind( d, idx + 1 ) )
+ s.tqreplace( idx, d.length(), ".");
if ( !n.isEmpty() && n != "-" )
- for ( int idx = s.find( n ) ; idx >= 0 ; idx = s.find( n, idx + 1 ) )
- s.replace( idx, n.length(), "-" );
+ for ( int idx = s.tqfind( n ) ; idx >= 0 ; idx = s.tqfind( n, idx + 1 ) )
+ s.tqreplace( idx, n.length(), "-" );
// Take care of monetary parens around the value if selected via
// the locale settings.
// If the lead-in or lead-out paren is present, remove it
- // before passing the string to the QDoubleValidator
+ // before passing the string to the TQDoubleValidator
if(l->negativeMonetarySignPosition() == KLocale::ParensAround
|| l->positiveMonetarySignPosition() == KLocale::ParensAround) {
- QRegExp regExp("^(\\()?([\\d-\\.]*)(\\))?$");
- if(s.find(regExp) != -1) {
+ TQRegExp regExp("^(\\()?([\\d-\\.]*)(\\))?$");
+ if(s.tqfind(regExp) != -1) {
s = regExp.cap(2);
}
}
- // check for non numeric values (QDoubleValidator allows an 'e', we don't)
- QRegExp nonNumeric("[^\\d-\\.]+");
- if(s.find(nonNumeric) != -1)
+ // check for non numeric values (TQDoubleValidator allows an 'e', we don't)
+ TQRegExp nonNumeric("[^\\d-\\.]+");
+ if(s.tqfind(nonNumeric) != -1)
return Invalid;
// check for minus sign trailing the number
- QRegExp trailingMinus("^([^-]*)\\w*-$");
- if(s.find(trailingMinus) != -1) {
- s = QString("-%1").arg(trailingMinus.cap(1));
+ TQRegExp trailingMinus("^([^-]*)\\w*-$");
+ if(s.tqfind(trailingMinus) != -1) {
+ s = TQString("-%1").tqarg(trailingMinus.cap(1));
}
// check for the maximum allowed number of decimal places
- int decPos = s.find('.');
+ int decPos = s.tqfind('.');
if(decPos != -1) {
if(decimals() == 0)
return Invalid;
@@ -131,10 +131,10 @@ QValidator::State kMyMoneyMoneyValidator::validate( QString & input, int & _p )
}
// If we have just a single minus sign, we are done
- if(s == QString("-"))
+ if(s == TQString("-"))
return Acceptable;
- QValidator::State rc = QDoubleValidator::validate( s, _p );
+ TQValidator::State rc = TQDoubleValidator::validate( s, _p );
if(rc == Acceptable) {
// If the numeric value is acceptable, we check if the parens
@@ -144,7 +144,7 @@ QValidator::State kMyMoneyMoneyValidator::validate( QString & input, int & _p )
// only, if the locale settings have it enabled.
if(l->negativeMonetarySignPosition() == KLocale::ParensAround
|| l->positiveMonetarySignPosition() == KLocale::ParensAround) {
- int tmp = input.contains('(') - input.contains(')');
+ int tmp = input.tqcontains('(') - input.tqcontains(')');
if(tmp > 0)
rc = Intermediate;
else if(tmp < 0)
@@ -154,8 +154,8 @@ QValidator::State kMyMoneyMoneyValidator::validate( QString & input, int & _p )
return rc;
}
-kMyMoneyEdit::kMyMoneyEdit(QWidget *parent, const char *name, const int prec)
- : QHBox(parent, name)
+kMyMoneyEdit::kMyMoneyEdit(TQWidget *tqparent, const char *name, const int prec)
+ : TQHBox(tqparent, name)
{
m_prec = prec;
if(prec < -1 || prec > 20)
@@ -163,8 +163,8 @@ kMyMoneyEdit::kMyMoneyEdit(QWidget *parent, const char *name, const int prec)
init();
}
-kMyMoneyEdit::kMyMoneyEdit(const MyMoneySecurity& sec, QWidget *parent, const char *name)
- : QHBox(parent, name)
+kMyMoneyEdit::kMyMoneyEdit(const MyMoneySecurity& sec, TQWidget *tqparent, const char *name)
+ : TQHBox(tqparent, name)
{
m_prec = MyMoneyMoney::denomToPrec(sec.smallestAccountFraction());
init();
@@ -209,29 +209,29 @@ void kMyMoneyEdit::init(void)
setFocusProxy(m_edit);
// Yes, just a simple double validator !
- kMyMoneyMoneyValidator *validator = new kMyMoneyMoneyValidator(this);
+ kMyMoneyMoneyValidator *validator = new kMyMoneyMoneyValidator(TQT_TQOBJECT(this));
m_edit->setValidator(validator);
- m_edit->setAlignment(AlignRight | AlignVCenter);
+ m_edit->tqsetAlignment(AlignRight | AlignVCenter);
- m_calculatorFrame = new QVBox(this, 0, WType_Popup);
+ m_calculatorFrame = new TQVBox(this, 0, WType_Popup);
- m_calculatorFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
+ m_calculatorFrame->setFrameStyle(TQFrame::PopupPanel | TQFrame::Raised);
m_calculatorFrame->setLineWidth(3);
m_calculator = new kMyMoneyCalculator(m_calculatorFrame);
m_calculatorFrame->setFixedSize(m_calculator->width()+3, m_calculator->height()+3);
m_calculatorFrame->hide();
- m_calcButton = new KPushButton(QIconSet(QPixmap(KGlobal::iconLoader()->iconPath("kcalc", -KIcon::SizeSmall))), QString(""), this);
- m_calcButton->setFixedWidth( m_calcButton->sizeHint().width() );
- m_calcButton->setFixedHeight(m_edit->sizeHint().height());
+ m_calcButton = new KPushButton(TQIconSet(TQPixmap(KGlobal::iconLoader()->iconPath("kcalc", -KIcon::SizeSmall))), TQString(""), this);
+ m_calcButton->setFixedWidth( m_calcButton->tqsizeHint().width() );
+ m_calcButton->setFixedHeight(m_edit->tqsizeHint().height());
m_calcButton->setFocusProxy(m_edit);
- QPixmap pixmap;
+ TQPixmap pixmap;
pixmap.loadFromData(resetButtonImage, sizeof(resetButtonImage), "PNG", 0);
- m_resetButton = new KPushButton(QIconSet(pixmap), QString(""), this);
- m_resetButton->setFixedWidth( m_resetButton->sizeHint().width() );
- m_resetButton->setFixedHeight(m_edit->sizeHint().height());
+ m_resetButton = new KPushButton(TQIconSet(pixmap), TQString(""), this);
+ m_resetButton->setFixedWidth( m_resetButton->tqsizeHint().width() );
+ m_resetButton->setFixedHeight(m_edit->tqsizeHint().height());
m_resetButton->setEnabled(false);
m_resetButton->setFocusProxy(m_edit);
@@ -242,13 +242,13 @@ void kMyMoneyEdit::init(void)
setSpacing(0);
- connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(theTextChanged(const QString&)));
- connect(m_calculator, SIGNAL(signalResultAvailable()), this, SLOT(slotCalculatorResult()));
- connect(m_calcButton, SIGNAL(clicked()), this, SLOT(slotCalculatorOpen()));
- connect(m_resetButton, SIGNAL(clicked()), this, SLOT(resetText()));
+ connect(m_edit, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(theTextChanged(const TQString&)));
+ connect(m_calculator, TQT_SIGNAL(signalResultAvailable()), this, TQT_SLOT(slotCalculatorResult()));
+ connect(m_calcButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotCalculatorOpen()));
+ connect(m_resetButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(resetText()));
}
-void kMyMoneyEdit::setValidator(const QValidator* v)
+void kMyMoneyEdit::setValidator(const TQValidator* v)
{
m_edit->setValidator(v);
}
@@ -281,7 +281,7 @@ bool kMyMoneyEdit::isValid(void) const
MyMoneyMoney kMyMoneyEdit::value(void) const
{
- QString txt = m_edit->text();
+ TQString txt = m_edit->text();
ensureFractionalPart(txt);
MyMoneyMoney money(txt);
if(m_prec != -1)
@@ -292,11 +292,11 @@ MyMoneyMoney kMyMoneyEdit::value(void) const
void kMyMoneyEdit::setValue(const MyMoneyMoney& value)
{
// load the value into the widget but don't use thousandsSeparators
- QString txt = value.formatMoney("", m_prec, false);
+ TQString txt = value.formatMoney("", m_prec, false);
loadText(txt);
}
-void kMyMoneyEdit::loadText(const QString& txt)
+void kMyMoneyEdit::loadText(const TQString& txt)
{
m_edit->setText(txt);
if(isEnabled() && !txt.isEmpty())
@@ -307,7 +307,7 @@ void kMyMoneyEdit::loadText(const QString& txt)
void kMyMoneyEdit::clearText(void)
{
- m_text = QString();
+ m_text = TQString();
m_edit->setText(m_text);
}
@@ -317,12 +317,12 @@ void kMyMoneyEdit::resetText(void)
m_resetButton->setEnabled(false);
}
-void kMyMoneyEdit::theTextChanged(const QString & theText)
+void kMyMoneyEdit::theTextChanged(const TQString & theText)
{
KLocale * l = KGlobal::locale();
- QString d = l->monetaryDecimalSymbol();
- QString l_text = theText;
- QString nsign, psign;
+ TQString d = l->monetaryDecimalSymbol();
+ TQString l_text = theText;
+ TQString nsign, psign;
if(l->negativeMonetarySignPosition() == KLocale::ParensAround
|| l->positiveMonetarySignPosition() == KLocale::ParensAround) {
nsign = psign = "(";
@@ -333,14 +333,14 @@ void kMyMoneyEdit::theTextChanged(const QString & theText)
int i = 0;
if(isEnabled()) {
- QValidator::State state = m_edit->validator()->validate( l_text, i);
- if(state == QValidator::Intermediate) {
+ TQValidator::State state = m_edit->validator()->validate( l_text, i);
+ if(state == TQValidator::Intermediate) {
if(l_text.length() == 1) {
if(l_text != d && l_text != nsign && l_text != psign && l_text != "-")
- state = QValidator::Invalid;
+ state = TQValidator::Invalid;
}
}
- if (state==QValidator::Invalid)
+ if (state==TQValidator::Invalid)
m_edit->setText(previousText);
else {
previousText = l_text;
@@ -352,16 +352,16 @@ void kMyMoneyEdit::theTextChanged(const QString & theText)
void kMyMoneyEdit::ensureFractionalPart(void)
{
- QString s(m_edit->text());
+ TQString s(m_edit->text());
ensureFractionalPart(s);
m_edit->setText(s);
}
-void kMyMoneyEdit::ensureFractionalPart(QString& s) const
+void kMyMoneyEdit::ensureFractionalPart(TQString& s) const
{
KLocale* locale = KGlobal::locale();
- QString decimalSymbol = locale->monetaryDecimalSymbol();
+ TQString decimalSymbol = locale->monetaryDecimalSymbol();
if(decimalSymbol.isEmpty())
decimalSymbol = ".";
@@ -369,19 +369,19 @@ void kMyMoneyEdit::ensureFractionalPart(QString& s) const
// followed by the required number of 0s
if (!s.isEmpty()) {
if(m_prec > 0) {
- if (!s.contains(decimalSymbol)) {
+ if (!s.tqcontains(decimalSymbol)) {
s += decimalSymbol;
for (int i=0; i < m_prec; i++)
s += "0";
}
} else if(m_prec == 0) {
- while(s.contains(decimalSymbol)) {
- int pos = s.findRev(decimalSymbol);
+ while(s.tqcontains(decimalSymbol)) {
+ int pos = s.tqfindRev(decimalSymbol);
if(pos != -1) {
s.truncate(pos);
}
}
- } else if(s.contains(decimalSymbol)) { // m_prec == -1 && fraction
+ } else if(s.tqcontains(decimalSymbol)) { // m_prec == -1 && fraction
// no trailing zeroes
while(s.endsWith("0")) {
s.truncate(s.length()-1);
@@ -393,19 +393,19 @@ void kMyMoneyEdit::ensureFractionalPart(QString& s) const
}
}
-bool kMyMoneyEdit::eventFilter(QObject * /* o */ , QEvent *e )
+bool kMyMoneyEdit::eventFilter(TQObject * /* o */ , TQEvent *e )
{
bool rc = false;
// we want to catch some keys that are usually handled by
// the base class (e.g. '+', '-', etc.)
- if(e->type() == QEvent::KeyPress) {
- QKeyEvent *k = static_cast<QKeyEvent *> (e);
+ if(e->type() == TQEvent::KeyPress) {
+ TQKeyEvent *k = TQT_TQKEYEVENT (e);
rc = true;
switch(k->key()) {
- case Qt::Key_Plus:
- case Qt::Key_Minus:
+ case TQt::Key_Plus:
+ case TQt::Key_Minus:
if(m_edit->hasSelectedText()) {
m_edit->cut();
}
@@ -416,7 +416,7 @@ bool kMyMoneyEdit::eventFilter(QObject * /* o */ , QEvent *e )
// in case of '-' we do not enter the calculator when
// the current position is the beginning and there is
// no '-' sign at the first position.
- if(k->key() == Qt::Key_Minus) {
+ if(k->key() == TQt::Key_Minus) {
if(m_edit->cursorPosition() == 0 && m_edit->text()[0] != '-') {
rc = false;
break;
@@ -424,9 +424,9 @@ bool kMyMoneyEdit::eventFilter(QObject * /* o */ , QEvent *e )
}
// otherwise, tricky fall through here!
- case Qt::Key_Slash:
- case Qt::Key_Asterisk:
- case Qt::Key_Percent:
+ case TQt::Key_Slash:
+ case TQt::Key_Asterisk:
+ case TQt::Key_Percent:
if(m_edit->hasSelectedText()) {
// remove the selected text
m_edit->cut();
@@ -439,7 +439,7 @@ bool kMyMoneyEdit::eventFilter(QObject * /* o */ , QEvent *e )
break;
}
- } else if(e->type() == QEvent::FocusOut) {
+ } else if(e->type() == TQEvent::FocusOut) {
if(!m_edit->text().isEmpty() || !allowEmpty)
ensureFractionalPart();
@@ -457,7 +457,7 @@ void kMyMoneyEdit::slotCalculatorOpen(void)
calculatorOpen(0);
}
-void kMyMoneyEdit::calculatorOpen(QKeyEvent* k)
+void kMyMoneyEdit::calculatorOpen(TQKeyEvent* k)
{
m_calculator->setInitialValues(m_edit->text(), k);
@@ -466,18 +466,18 @@ void kMyMoneyEdit::calculatorOpen(QKeyEvent* k)
// usually, the calculator widget is shown underneath the MoneyEdit widget
// if it does not fit on the screen, we show it above this widget
- QPoint p = mapToGlobal(QPoint(0,0));
- if(p.y() + height() + h > QApplication::desktop()->height())
+ TQPoint p = mapToGlobal(TQPoint(0,0));
+ if(p.y() + height() + h > TQApplication::desktop()->height())
p.setY(p.y() - h);
else
p.setY(p.y() + height());
// usually, it is shown left aligned. If it does not fit, we align it
// to the right edge of the widget
- if(p.x() + w > QApplication::desktop()->width())
+ if(p.x() + w > TQApplication::desktop()->width())
p.setX(p.x() + width() - w);
- QRect r = m_calculator->geometry();
+ TQRect r = m_calculator->tqgeometry();
r.moveTopLeft(p);
m_calculatorFrame->setGeometry(r);
m_calculatorFrame->show();
@@ -486,7 +486,7 @@ void kMyMoneyEdit::calculatorOpen(QKeyEvent* k)
void kMyMoneyEdit::slotCalculatorResult(void)
{
- QString result;
+ TQString result;
if(m_calculator != 0) {
m_calculatorFrame->hide();
m_edit->setText(m_calculator->result());
@@ -496,11 +496,11 @@ void kMyMoneyEdit::slotCalculatorResult(void)
}
}
-QWidget* kMyMoneyEdit::focusWidget(void) const
+TQWidget* kMyMoneyEdit::tqfocusWidget(void) const
{
- QWidget* w = m_edit;
+ TQWidget* w = m_edit;
while(w->focusProxy())
- w = w->focusProxy();
+ w = TQT_TQWIDGET(w->focusProxy());
return w;
}
@@ -534,7 +534,7 @@ bool kMyMoneyEdit::isEmptyAllowed(void) const
return allowEmpty;
}
-void kMyMoneyEdit::setHint(const QString& hint) const
+void kMyMoneyEdit::setHint(const TQString& hint) const
{
if(m_edit)
m_edit->setHint(hint);
@@ -549,11 +549,11 @@ bool kMyMoneyEdit::isReadOnly(void) const
void kMyMoneyEdit::setReadOnly(bool readOnly)
{
- // we use the QLineEdit::setReadOnly() method directly to avoid
+ // we use the TQLineEdit::setReadOnly() method directly to avoid
// changing the background between readonly and read/write mode
// as it is done by the KLineEdit code.
if(m_edit)
- m_edit->QLineEdit::setReadOnly(readOnly);
+ m_edit->TQLineEdit::setReadOnly(readOnly);
}
#include "kmymoneyedit.moc"