diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-28 18:03:09 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-28 18:03:09 +0000 |
commit | 98d15d90b6a83e2df32d678013847e18b8a8c7e8 (patch) | |
tree | 02a588c0979fe1a40ae6216d1f831bb24de91a9f /katapult/plugins/catalogs/calculatorcatalog | |
parent | e0974f69b7603e3d8f2d936301e05535af25346e (diff) | |
download | katapult-98d15d90b6a83e2df32d678013847e18b8a8c7e8.tar.gz katapult-98d15d90b6a83e2df32d678013847e18b8a8c7e8.zip |
TQt4 port Katapult
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/katapult@1233929 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'katapult/plugins/catalogs/calculatorcatalog')
7 files changed, 99 insertions, 97 deletions
diff --git a/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.cpp b/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.cpp index 2a786f9..ff47f92 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.cpp +++ b/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.cpp @@ -28,7 +28,7 @@ #include <kurl.h> #include <klocale.h> -#include <qclipboard.h> +#include <tqclipboard.h> #include "calculatorcatalog.h" #include "expression.h" @@ -45,34 +45,34 @@ // Copied some code from KDE 3.5 to make it compile on 3.4. // insert (thousands)-"separator"s into the non-fractional part of str -static void _insertSeparator(QString &str, const QString &separator, const QString &decimalSymbol) +static void _insertSeparator(TQString &str, const TQString &separator, const TQString &decimalSymbol) { // leave fractional part untouched - QString mainPart = str.section(decimalSymbol, 0, 0); - QString fracPart = str.section(decimalSymbol, 1, 1, QString::SectionIncludeLeadingSep); - if (fracPart==decimalSymbol) fracPart=QString(); + TQString mainPart = str.section(decimalSymbol, 0, 0); + TQString fracPart = str.section(decimalSymbol, 1, 1, TQString::SectionIncludeLeadingSep); + if (fracPart==decimalSymbol) fracPart=TQString(); for (int pos = mainPart.length() - 3; pos > 0; pos -= 3) mainPart.insert(pos, separator); str = mainPart + fracPart; } -// This was KLocale::formatNumber(const QString&, bool, int) +// This was KLocale::formatNumber(const TQString&, bool, int) -static QString formatNumber(const QString &numStr) +static TQString formatNumber(const TQString &numStr) { - QString tmpString = numStr; + TQString tmpString = numStr; // Skip the sign (for now) bool neg = (tmpString[0] == '-'); if (neg || tmpString[0] == '+') tmpString.remove(0, 1); // Split off exponential part (including 'e'-symbol) - QString mantString = tmpString.section('e', 0, 0, QString::SectionCaseInsensitiveSeps); - QString expString = tmpString.section('e', 1, 1, QString::SectionCaseInsensitiveSeps | QString::SectionIncludeLeadingSep); - if (expString.length()==1) expString=QString(); + TQString mantString = tmpString.section('e', 0, 0, TQString::SectionCaseInsensitiveSeps); + TQString expString = tmpString.section('e', 1, 1, TQString::SectionCaseInsensitiveSeps | TQString::SectionIncludeLeadingSep); + if (expString.length()==1) expString=TQString(); // Replace dot with locale decimal separator - mantString.replace(QChar('.'), KGlobal::locale()->decimalSymbol()); + mantString.tqreplace(TQChar('.'), KGlobal::locale()->decimalSymbol()); // Insert the thousand separators _insertSeparator(mantString, KGlobal::locale()->thousandsSeparator(), KGlobal::locale()->decimalSymbol()); @@ -86,7 +86,7 @@ static QString formatNumber(const QString &numStr) #else // KDE_VERSION >= 3.5.0 -static QString formatNumber(const QString& numStr) +static TQString formatNumber(const TQString& numStr) { return KGlobal::locale()->formatNumber(numStr, false, 0); } @@ -103,15 +103,15 @@ ActionEvaluateExpression::~ActionEvaluateExpression() { } -QString ActionEvaluateExpression::text() const +TQString ActionEvaluateExpression::text() const { if (_expr->parseError()) { return i18n("Evaluate Expression"); } else { // Format result. int digits = _expr->catalog()->fracDigits(); - QChar f = _expr->catalog()->scientific() ? 'g' : 'f'; - QString num = QString::number(_expr->result(), f, digits); + TQChar f = _expr->catalog()->scientific() ? 'g' : 'f'; + TQString num = TQString::number(_expr->result(), f, digits); // Strip trailing zeroes. if (f == 'f' && digits != 0) { while (num.endsWith("0")) { @@ -126,7 +126,7 @@ QString ActionEvaluateExpression::text() const } } -QPixmap ActionEvaluateExpression::icon(int size) const +TQPixmap ActionEvaluateExpression::icon(int size) const { return KGlobal::iconLoader()->loadIcon("xcalc", KIcon::NoGroup, size); } @@ -150,12 +150,12 @@ void ActionEvaluateExpression::execute(const KatapultItem* item) const // Copy calculation and result into clipboard (unless there's a parse error). if (!_expr->parseError()) { - QClipboard *cb = QApplication::clipboard(); - QString s = _expr->catalog()->formatString(); - s.replace("%1", _expr->text()); - s.replace("%2", text()); - cb->setText(s, QClipboard::Clipboard); - cb->setText(s, QClipboard::Selection); + TQClipboard *cb = TQApplication::tqclipboard(); + TQString s = _expr->catalog()->formatString(); + s.tqreplace("%1", _expr->text()); + s.tqreplace("%2", text()); + cb->setText(s, TQClipboard::Clipboard); + cb->setText(s, TQClipboard::Selection); } } } diff --git a/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.h b/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.h index 6cf23bf..f04e65b 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.h +++ b/katapult/plugins/catalogs/calculatorcatalog/actionevalexpr.h @@ -39,8 +39,8 @@ class ActionEvaluateExpression : public KatapultAction virtual void execute(const KatapultItem*) const; virtual bool accepts(const KatapultItem*) const; - virtual QString text() const; - virtual QPixmap icon(int) const; + virtual TQString text() const; + virtual TQPixmap icon(int) const; private: //_expr needs to be mutable because accepts() is const. diff --git a/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.cpp b/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.cpp index c3c5f6d..2781cd2 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.cpp +++ b/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.cpp @@ -28,10 +28,10 @@ #include <knuminput.h> #include <kcombobox.h> -#include <qcheckbox.h> -#include <qbuttongroup.h> -#include <qradiobutton.h> -#include <qregexp.h> +#include <tqcheckbox.h> +#include <tqbuttongroup.h> +#include <tqradiobutton.h> +#include <tqregexp.h> #include <math.h> @@ -127,7 +127,7 @@ const CalculatorCatalog::Function CalculatorCatalog::degreesFunctionTable[] = K_EXPORT_COMPONENT_FACTORY( katapult_calculatorcatalog, KGenericFactory<CalculatorCatalog>( "katapult_calculatorcatalog" ) ) -CalculatorCatalog::CalculatorCatalog(QObject*, const char*, const QStringList&): _result(this, QString::null) +CalculatorCatalog::CalculatorCatalog(TQObject*, const char*, const TQStringList&): _result(this, TQString()) { ActionRegistry::self()->registerAction(new ActionEvaluateExpression()); @@ -141,8 +141,8 @@ CalculatorCatalog::~CalculatorCatalog() void CalculatorCatalog::queryChanged() { - int newStatus = 0; - QString cmd = query(); + int newtqStatus = 0; + TQString cmd = query(); if (cmd.isEmpty()) { reset(); @@ -154,10 +154,10 @@ void CalculatorCatalog::queryChanged() cmd = cmd.lower(); for (i = length - 1; i >= 0 && cmd[i].isLetter(); --i) { } if (i != length - 1) { - QString start = cmd.mid(i + 1); + TQString start = cmd.mid(i + 1); int lengthOfShortest = 9999, shortest = -1; for (int j = 0; radiansFunctionTable[j].name; ++j) { - if (QString(radiansFunctionTable[j].name).startsWith(start)) { + if (TQString(radiansFunctionTable[j].name).startsWith(start)) { if (radiansFunctionTable[j].length < lengthOfShortest) { lengthOfShortest = radiansFunctionTable[j].length; shortest = j; @@ -170,7 +170,7 @@ void CalculatorCatalog::queryChanged() } } //fix parse errors at end of expression, - //ie. close open parentheses, convert operators into NOPs + //ie. close open tqparentheses, convert operators into NOPs for (i = length - 1; i >= 0 && (cmd[i] == '(' || cmd[i] == ' '); --i) { } if (i < 0 || cmd[i] == '+' || cmd[i] == '-') { cmd.append("0"); @@ -203,31 +203,31 @@ void CalculatorCatalog::queryChanged() //set status. //add S_Multiple to make sure katapult doesn't auto-exec and close the window //add S_Active to make sure katapult doesn't start the hideTimer or clearTimer - newStatus = S_HasResults | S_Multiple | S_Active; + newtqStatus = S_HasResults | S_Multiple | S_Active; } else { - newStatus = 0; + newtqStatus = 0; } } - setStatus(newStatus); + settqStatus(newtqStatus); } void CalculatorCatalog::reset() { - _result.setText(QString::null); + _result.setText(TQString()); } -bool CalculatorCatalog::accepts(const QString& str) const +bool CalculatorCatalog::accepts(const TQString& str) const { //Heuristic to determine whether the string is an expression or not. //Accept anything containing [()+\\-/*^=.,0-9]. - return QRegExp("[()+\\-/*^=.,0-9]").search(str) >= 0; + return TQRegExp("[()+\\-/*^=.,0-9]").search(str) >= 0; } int CalculatorCatalog::getVarID(const char* name) { - VarNameToIdMap::iterator it = varNameToId.find(QString(name)); + VarNameToIdMap::iterator it = varNameToId.tqfind(TQString(name)); if (it == varNameToId.end()) { - _pendingVarName = QString(name); + _pendingVarName = TQString(name); return -1; } return *it; @@ -274,26 +274,26 @@ void CalculatorCatalog::writeSettings(KConfigBase* config) config->writeEntry("FormatString", formatString()); } -QWidget * CalculatorCatalog::configure() +TQWidget * CalculatorCatalog::configure() { CalculatorCatalogSettings* settings = new CalculatorCatalogSettings(); settings->fracDigits->setValue(_fracDigits); - connect(settings->fracDigits, SIGNAL(valueChanged(int)), this, SLOT(fracDigitsChanged(int))); + connect(settings->fracDigits, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(fracDigitsChanged(int))); settings->normal->setChecked(!scientific()); settings->scientific->setChecked(scientific()); - connect(settings->scientific, SIGNAL(toggled(bool)), this, SLOT(scientificChanged(bool))); + connect(settings->scientific, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(scientificChanged(bool))); settings->radians->setChecked(!degrees()); settings->degrees->setChecked(degrees()); - connect(settings->degrees, SIGNAL(toggled(bool)), this, SLOT(degreesChanged(bool))); + connect(settings->degrees, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(degreesChanged(bool))); settings->clipboard->setChecked(clipboard()); - connect(settings->clipboard, SIGNAL(toggled(bool)), this, SLOT(clipboardChanged(bool))); + connect(settings->clipboard, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(clipboardChanged(bool))); settings->formatString->setText(formatString()); - connect(settings->formatString, SIGNAL(textChanged(const QString&)), this, SLOT(formatStringChanged(const QString&))); + connect(settings->formatString, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(formatStringChanged(const TQString&))); return settings; } @@ -328,12 +328,12 @@ bool CalculatorCatalog::degrees() const return _bDegrees; } -void CalculatorCatalog::formatStringChanged(const QString& fmt) +void CalculatorCatalog::formatStringChanged(const TQString& fmt) { _formatString = fmt; } -QString CalculatorCatalog::formatString() const +TQString CalculatorCatalog::formatString() const { return _formatString; } diff --git a/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.h b/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.h index 88f03cc..e5f7d00 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.h +++ b/katapult/plugins/catalogs/calculatorcatalog/calculatorcatalog.h @@ -25,15 +25,15 @@ #include <kgenericfactory.h> -#include <qmap.h> -#include <qptrlist.h> -#include <qstring.h> -#include <qvaluevector.h> +#include <tqmap.h> +#include <tqptrlist.h> +#include <tqstring.h> +#include <tqvaluevector.h> #include "expression.h" #include "katapultcatalog.h" -class QWidget; +class TQWidget; typedef double (*FunPtr)(double); @@ -43,6 +43,7 @@ typedef double (*FunPtr)(double); class CalculatorCatalog : public KatapultCatalog { Q_OBJECT + TQ_OBJECT public: @@ -59,13 +60,13 @@ class CalculatorCatalog : public KatapultCatalog FunPtr fptr; }; - CalculatorCatalog(QObject*, const char*, const QStringList&); + CalculatorCatalog(TQObject*, const char*, const TQStringList&); virtual ~CalculatorCatalog(); //virtual void initialize(); virtual void readSettings(KConfigBase*); virtual void writeSettings(KConfigBase*); - virtual QWidget* configure(); + virtual TQWidget* configure(); int getVarID(const char*); double getVar(int) const; @@ -75,7 +76,7 @@ class CalculatorCatalog : public KatapultCatalog bool scientific() const; bool degrees() const; bool clipboard() const; - QString formatString() const; + TQString formatString() const; const Function* functionTable() const; protected: @@ -84,26 +85,26 @@ class CalculatorCatalog : public KatapultCatalog private: - typedef QMap<QString, int> VarNameToIdMap; - typedef QValueVector<double> VarIdToValueVector; + typedef TQMap<TQString, int> VarNameToIdMap; + typedef TQValueVector<double> VarIdToValueVector; static const Function radiansFunctionTable[]; static const Function degreesFunctionTable[]; void reset(); - bool accepts(const QString&) const; + bool accepts(const TQString&) const; Expression _result; // The one result (there's always one). VarNameToIdMap varNameToId; // Maps strings to IDs. VarIdToValueVector varIdToValue; // Maps IDs to values. - QString _pendingVarName; // Pending while rest of assignment is parsed. + TQString _pendingVarName; // Pending while rest of assignment is parsed. int _fracDigits; // Number of fractional digits. bool _bScientific; // Normal or scientific mode? bool _bDegrees; // Radians or degrees? bool _bClipboard; // Copy to clipboard? - QString _formatString; // for clipboard copy + TQString _formatString; // for clipboard copy private slots: @@ -111,7 +112,7 @@ class CalculatorCatalog : public KatapultCatalog void scientificChanged(bool); void degreesChanged(bool); void clipboardChanged(bool); - void formatStringChanged(const QString&); + void formatStringChanged(const TQString&); }; diff --git a/katapult/plugins/catalogs/calculatorcatalog/expression.cpp b/katapult/plugins/catalogs/calculatorcatalog/expression.cpp index 37e80bc..dfa4543 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/expression.cpp +++ b/katapult/plugins/catalogs/calculatorcatalog/expression.cpp @@ -29,12 +29,12 @@ #include "expression.h" -Expression::Expression(CalculatorCatalog* catalog, const QString& text): KatapultItem(), _catalog(catalog), _text(text) +Expression::Expression(CalculatorCatalog* catalog, const TQString& text): KatapultItem(), _catalog(catalog), _text(text) { evaluate(); } -QPixmap Expression::icon(int size) const +TQPixmap Expression::icon(int size) const { const char* icon = "checkmark"; if (_parseError) { @@ -43,12 +43,12 @@ QPixmap Expression::icon(int size) const return KGlobal::iconLoader()->loadIcon(icon, KIcon::NoGroup, size); } -QString Expression::text() const +TQString Expression::text() const { return _text; } -void Expression::setText(const QString& text) +void Expression::setText(const TQString& text) { _text = text; evaluate(); @@ -72,9 +72,9 @@ CalculatorCatalog* Expression::catalog() const void Expression::evaluate(bool assignments) const { if (!_text.isEmpty()) { - QString t = _text; + TQString t = _text; CalculatorCatalog::ParserControl cntrl; - cntrl.expression = t.replace(',', '.').ascii(); + cntrl.expression = t.tqreplace(',', '.').ascii(); cntrl.catalog = _catalog; cntrl.assignments = assignments; if (yyparse(&cntrl) == 0) { diff --git a/katapult/plugins/catalogs/calculatorcatalog/expression.h b/katapult/plugins/catalogs/calculatorcatalog/expression.h index 6d736f9..f7703c6 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/expression.h +++ b/katapult/plugins/catalogs/calculatorcatalog/expression.h @@ -33,13 +33,14 @@ class CalculatorCatalog; class Expression : public KatapultItem { Q_OBJECT + TQ_OBJECT public: - Expression(CalculatorCatalog*, const QString&); + Expression(CalculatorCatalog*, const TQString&); - virtual QPixmap icon(int) const; - virtual QString text() const; + virtual TQPixmap icon(int) const; + virtual TQString text() const; - void setText(const QString&); + void setText(const TQString&); double result() const; bool parseError() const; @@ -52,7 +53,7 @@ class Expression : public KatapultItem private: CalculatorCatalog* const _catalog; - QString _text; + TQString _text; mutable double _result; mutable bool _parseError; }; diff --git a/katapult/plugins/catalogs/calculatorcatalog/settings.ui b/katapult/plugins/catalogs/calculatorcatalog/settings.ui index 67c0faa..7ef86b9 100644 --- a/katapult/plugins/catalogs/calculatorcatalog/settings.ui +++ b/katapult/plugins/catalogs/calculatorcatalog/settings.ui @@ -1,10 +1,10 @@ <!DOCTYPE UI><UI version="3.2" stdsetdef="1"> <class>CalculatorCatalogSettings</class> -<widget class="QWidget"> +<widget class="TQWidget"> <property name="name"> <cstring>CalculatorCatalogSettings</cstring> </property> - <property name="geometry"> + <property name="tqgeometry"> <rect> <x>0</x> <y>0</y> @@ -19,15 +19,15 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLayoutWidget"> + <widget class="TQLayoutWidget"> <property name="name"> - <cstring>layout13</cstring> + <cstring>tqlayout13</cstring> </property> <hbox> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLabel"> + <widget class="TQLabel"> <property name="name"> <cstring>textLabel1</cstring> </property> @@ -57,15 +57,15 @@ </widget> </hbox> </widget> - <widget class="QLayoutWidget"> + <widget class="TQLayoutWidget"> <property name="name"> - <cstring>layout6</cstring> + <cstring>tqlayout6</cstring> </property> <hbox> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QButtonGroup"> + <widget class="TQButtonGroup"> <property name="name"> <cstring>buttonGroup2</cstring> </property> @@ -76,7 +76,7 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QRadioButton"> + <widget class="TQRadioButton"> <property name="name"> <cstring>normal</cstring> </property> @@ -87,7 +87,7 @@ <string>In normal mode, katapult will never show an exponent on a number.</string> </property> </widget> - <widget class="QRadioButton"> + <widget class="TQRadioButton"> <property name="name"> <cstring>scientific</cstring> </property> @@ -100,7 +100,7 @@ </widget> </vbox> </widget> - <widget class="QButtonGroup"> + <widget class="TQButtonGroup"> <property name="name"> <cstring>buttonGroup3</cstring> </property> @@ -111,7 +111,7 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QRadioButton"> + <widget class="TQRadioButton"> <property name="name"> <cstring>radians</cstring> </property> @@ -122,7 +122,7 @@ <string>Trigonometric functions expect and return angles in radians (2 pi radians is a full circle).</string> </property> </widget> - <widget class="QRadioButton"> + <widget class="TQRadioButton"> <property name="name"> <cstring>degrees</cstring> </property> @@ -137,7 +137,7 @@ </widget> </hbox> </widget> - <widget class="QButtonGroup"> + <widget class="TQButtonGroup"> <property name="name"> <cstring>clipboard</cstring> </property> @@ -154,15 +154,15 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLayoutWidget"> + <widget class="TQLayoutWidget"> <property name="name"> - <cstring>layout8</cstring> + <cstring>tqlayout8</cstring> </property> <hbox> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLabel"> + <widget class="TQLabel"> <property name="name"> <cstring>textLabel1_2</cstring> </property> @@ -173,14 +173,14 @@ <cstring>formatString</cstring> </property> </widget> - <widget class="QLineEdit"> + <widget class="TQLineEdit"> <property name="name"> <cstring>formatString</cstring> </property> </widget> </hbox> </widget> - <widget class="QLabel"> + <widget class="TQLabel"> <property name="name"> <cstring>textLabel1_3</cstring> </property> @@ -200,7 +200,7 @@ <property name="sizeType"> <enum>Expanding</enum> </property> - <property name="sizeHint"> + <property name="tqsizeHint"> <size> <width>20</width> <height>40</height> @@ -212,7 +212,7 @@ <tabstops> <tabstop>fracDigits</tabstop> </tabstops> -<layoutdefaults spacing="6" margin="11"/> +<tqlayoutdefaults spacing="6" margin="11"/> <includehints> <includehint>knuminput.h</includehint> </includehints> |