diff options
Diffstat (limited to 'kommander/widget')
-rw-r--r-- | kommander/widget/expression.cpp | 100 | ||||
-rw-r--r-- | kommander/widget/expression.h | 46 | ||||
-rw-r--r-- | kommander/widget/function.h | 6 | ||||
-rw-r--r-- | kommander/widget/functionlib.cpp | 248 | ||||
-rw-r--r-- | kommander/widget/invokeclass.cpp | 18 | ||||
-rw-r--r-- | kommander/widget/invokeclass.h | 28 | ||||
-rw-r--r-- | kommander/widget/kmdrmainwindow.cpp | 6 | ||||
-rw-r--r-- | kommander/widget/kmdrmainwindow.h | 2 | ||||
-rw-r--r-- | kommander/widget/kommanderfunctions.cpp | 160 | ||||
-rw-r--r-- | kommander/widget/kommanderwidget.cpp | 244 | ||||
-rw-r--r-- | kommander/widget/kommanderwidget.h | 114 | ||||
-rw-r--r-- | kommander/widget/kommanderwindow.cpp | 6 | ||||
-rw-r--r-- | kommander/widget/kommanderwindow.h | 8 | ||||
-rw-r--r-- | kommander/widget/myprocess.cpp | 36 | ||||
-rw-r--r-- | kommander/widget/myprocess.h | 12 | ||||
-rw-r--r-- | kommander/widget/parsenode.cpp | 32 | ||||
-rw-r--r-- | kommander/widget/parsenode.h | 22 | ||||
-rw-r--r-- | kommander/widget/parser.cpp | 98 | ||||
-rw-r--r-- | kommander/widget/parser.h | 56 | ||||
-rw-r--r-- | kommander/widget/parserdata.cpp | 16 | ||||
-rw-r--r-- | kommander/widget/parserdata.h | 18 |
21 files changed, 638 insertions, 638 deletions
diff --git a/kommander/widget/expression.cpp b/kommander/widget/expression.cpp index 88d46b51..d29d94e8 100644 --- a/kommander/widget/expression.cpp +++ b/kommander/widget/expression.cpp @@ -22,17 +22,17 @@ Expression::Expression() : m_start(0), m_error(false) { } -Expression::Expression(const QString& expr) +Expression::Expression(const TQString& expr) { *this = expr; } -Expression& Expression::operator=(const QString& s) +Expression& Expression::operator=(const TQString& s) { m_start = 0; m_error = false; m_parts.clear(); - const QString single = "()<>!+-/*%"; + const TQString single = "()<>!+-/*%"; int start = 0; int len = s.length(); int i = 0; @@ -41,30 +41,30 @@ Expression& Expression::operator=(const QString& s) if (((s[i] == '>' || s[i] == '<' || s[i] == '=' || s[i] == '!') && s[i + 1] == '=') || (s[i] == '<' && s[i + 1] == '>')) { - m_parts.append(QVariant(s.mid(i, 2))); + m_parts.append(TQVariant(s.mid(i, 2))); i += 2; } else if (s[i].isDigit()) { i++; bool decimal = false; - while (i < len && (s[i].isDigit() || (!decimal && s[i] == QChar('.')))) + while (i < len && (s[i].isDigit() || (!decimal && s[i] == TQChar('.')))) { if (s[i] == '.') decimal = true; i++; } if (decimal) - m_parts.append(QVariant(s.mid(start, i - start).toDouble())); + m_parts.append(TQVariant(s.mid(start, i - start).toDouble())); else - m_parts.append(QVariant(s.mid(start, i - start).toInt())); + m_parts.append(TQVariant(s.mid(start, i - start).toInt())); } else if (single.contains(s[i])) - m_parts.append(QVariant(QString(s[i++]))); + m_parts.append(TQVariant(TQString(s[i++]))); else if (s[i] == '\"') { i++; while (i < len && s[i] != '\"') i++; - m_parts.append(QVariant(s.mid(start + 1, i - start - 1))); + m_parts.append(TQVariant(s.mid(start + 1, i - start - 1))); i++; } else if (s[i].isSpace()) while (i < len && s[i].isSpace()) @@ -73,25 +73,25 @@ Expression& Expression::operator=(const QString& s) { while (i < len && !s[i].isSpace()) i++; - QString keyword = s.mid(start, i - start); + TQString keyword = s.mid(start, i - start); if (keyword == "true") - m_parts.append(QVariant(true)); + m_parts.append(TQVariant(true)); else if (keyword == "false") - m_parts.append(QVariant(false)); + m_parts.append(TQVariant(false)); else /* will be deprecated soon */ - m_parts.append(QVariant(keyword)); + m_parts.append(TQVariant(keyword)); } start = i; } return *this; } -QString Expression::next() const +TQString Expression::next() const { if (m_start < m_parts.count()) return m_parts[m_start].toString(); else - return QString(); + return TQString(); } bool Expression::validate() @@ -100,11 +100,11 @@ bool Expression::validate() setError(); return !m_error; } -Expression::Type Expression::commonType(const QVariant v1, const QVariant v2) const +Expression::Type Expression::commonType(const TQVariant v1, const TQVariant v2) const { - if (v1.type() == QVariant::String || v2.type() == QVariant::String) + if (v1.type() == TQVariant::String || v2.type() == TQVariant::String) return TypeString; - else if (v1.type() == QVariant::Double || v2.type() == QVariant::Double) + else if (v1.type() == TQVariant::Double || v2.type() == TQVariant::Double) return TypeDouble; return TypeInt; } @@ -115,7 +115,7 @@ static int expression_compareDouble(const double A, const double B) } -int Expression::compare(const QVariant v1, const QVariant v2) const +int Expression::compare(const TQVariant v1, const TQVariant v2) const { switch (commonType(v1, v2)) { case TypeString: return v1.toString().compare(v2.toString()); @@ -132,22 +132,22 @@ void Expression::setError(int pos) m_error = true; } -QVariant Expression::parseNumber() +TQVariant Expression::parseNumber() { if (!validate()) return -1; return m_parts[m_start++]; } -QVariant Expression::parseMinus() +TQVariant Expression::parseMinus() { if (!validate()) return -1; bool sign = next() == "-"; if (sign) { m_start++; - QVariant value = parseNumber(); - if (value.type() == QVariant::Double) + TQVariant value = parseNumber(); + if (value.type() == TQVariant::Double) return -value.toDouble(); else return -value.toInt(); @@ -158,13 +158,13 @@ QVariant Expression::parseMinus() -QVariant Expression::parseBracket() +TQVariant Expression::parseBracket() { if (!validate()) return -1; if (next() == "(") { m_start++; - QVariant value = parse(); + TQVariant value = parse(); if (next() == ")") m_start++; else @@ -176,15 +176,15 @@ QVariant Expression::parseBracket() } -QVariant Expression::parseMultiply() +TQVariant Expression::parseMultiply() { if (!validate()) return -1; - QVariant value = parseBracket(); - QString op = next(); + TQVariant value = parseBracket(); + TQString op = next(); while (op == "*" || op == "/" || op == "%") { m_start++; - QVariant value2 = parseBracket(); + TQVariant value2 = parseBracket(); Type mode = commonType(value, value2); if (op == "*") { @@ -216,15 +216,15 @@ QVariant Expression::parseMultiply() return value; } -QVariant Expression::parseAdd() +TQVariant Expression::parseAdd() { if (!validate()) return -1; - QVariant value = parseMultiply(); - QString op = next(); + TQVariant value = parseMultiply(); + TQString op = next(); while (op == "+" || op == "-") { m_start++; - QVariant value2 = parseMultiply(); + TQVariant value2 = parseMultiply(); Type mode = commonType(value, value2); if (op == "+") if (mode == TypeDouble) @@ -241,15 +241,15 @@ QVariant Expression::parseAdd() return value; } -QVariant Expression::parseComparison() +TQVariant Expression::parseComparison() { if (!validate()) return -1; - QVariant value = parseAdd(); - QString cmp = next(); + TQVariant value = parseAdd(); + TQString cmp = next(); if (cmp == "<" || cmp == "<=" || cmp == "==" || cmp == ">=" || cmp == ">" || cmp == "<>" || cmp == "!=") { m_start++; - QVariant value2 = parseAdd(); + TQVariant value2 = parseAdd(); if (cmp == "<") return compare(value, value2) < 0; else if (cmp == "<=") @@ -266,7 +266,7 @@ QVariant Expression::parseComparison() return value; } -QVariant Expression::parseNot() +TQVariant Expression::parseNot() { if (next() == "!" || next() == "not") { @@ -277,10 +277,10 @@ QVariant Expression::parseNot() return parseComparison(); } -QVariant Expression::parseAnd() +TQVariant Expression::parseAnd() { if (!validate()) return -1; - QVariant value = parseNot(); + TQVariant value = parseNot(); while (next() == "&&" || next() == "and") { m_start++; @@ -290,10 +290,10 @@ QVariant Expression::parseAnd() return value; } -QVariant Expression::parseOr() +TQVariant Expression::parseOr() { if (!validate()) return -1; - QVariant value = parseAnd(); + TQVariant value = parseAnd(); while (next() == "||" || next() == "or") { m_start++; @@ -302,31 +302,31 @@ QVariant Expression::parseOr() return value; } -QVariant Expression::parse() +TQVariant Expression::parse() { return parseOr(); } -QVariant Expression::value(bool* valid) +TQVariant Expression::value(bool* valid) { m_start = 0; m_error = false; - QVariant val = parse(); + TQVariant val = parse(); if (valid) *valid = !m_error && m_start == m_parts.count(); return val; } -QVariant Expression::value(const QString& s, bool* valid) +TQVariant Expression::value(const TQString& s, bool* valid) { *this = s; return value(valid); } -bool Expression::isTrue(const QString& s, bool* valid) +bool Expression::isTrue(const TQString& s, bool* valid) { - QVariant v = value(s, valid); - return (v.type() == QVariant::String && !v.toString().isNull()) || - (v.type() != QVariant::String && v.toInt() != 0); + TQVariant v = value(s, valid); + return (v.type() == TQVariant::String && !v.toString().isNull()) || + (v.type() != TQVariant::String && v.toInt() != 0); } diff --git a/kommander/widget/expression.h b/kommander/widget/expression.h index 7ab163e2..2302ba46 100644 --- a/kommander/widget/expression.h +++ b/kommander/widget/expression.h @@ -17,59 +17,59 @@ #ifndef _HAVE_EXPRESSION_H_ #define _HAVE_EXPRESSION_H_ -#include <qstring.h> -#include <qvaluelist.h> -#include <qvariant.h> +#include <tqstring.h> +#include <tqvaluelist.h> +#include <tqvariant.h> class Expression { public: Expression(); - Expression(const QString& expr); + Expression(const TQString& expr); /* set string to parse */ - Expression& operator=(const QString& s); + Expression& operator=(const TQString& s); /* calculate value */ - QVariant value(bool* valid = 0); + TQVariant value(bool* valid = 0); /* equivalent of setString(s) and value(valid) */ - QVariant value(const QString& s, bool* valid = 0); + TQVariant value(const TQString& s, bool* valid = 0); /* equivalent of setString(s) and checking if value(valid) is true */ - bool isTrue(const QString& s, bool* valid = 0); + bool isTrue(const TQString& s, bool* valid = 0); private: enum Type {TypeInt, TypeDouble, TypeString}; /* parsing function - top-down approach */ /* parse terminal (number or string) */ - QVariant parseNumber(); + TQVariant parseNumber(); /* parse -x expression */ - QVariant parseMinus(); + TQVariant parseMinus(); /* parse (x) expression */ - QVariant parseBracket(); + TQVariant parseBracket(); /* parse x*y, x/y and x%y expressions */ - QVariant parseMultiply(); + TQVariant parseMultiply(); /* parse x+y and x-y expressions */ - QVariant parseAdd(); + TQVariant parseAdd(); /* parse !x and (equivalent) not x expressions */ - QVariant parseNot(); + TQVariant parseNot(); /* parse x==y, x<=y, x>=y, x<y and x>y expressions */ - QVariant parseComparison(); + TQVariant parseComparison(); /* parse x && y, (equivalent) x and y expressions */ - QVariant parseAnd(); + TQVariant parseAnd(); /* parse x || y and (equivalent) x or y expressions */ - QVariant parseOr(); + TQVariant parseOr(); /* starting point of parsing - just call first function above */ - QVariant parse(); + TQVariant parse(); /* check if we still have next argument */ bool validate(); /* return next argument to parse or null if there is none */ - QString next() const; + TQString next() const; /* set error position for future error reporting */ void setError(int pos = -1); - /* compare various types of QVariant (strings, floats, ints */ - int compare(const QVariant v1, const QVariant v2) const; + /* compare various types of TQVariant (strings, floats, ints */ + int compare(const TQVariant v1, const TQVariant v2) const; /* return common type for binary operations */ - Type commonType(const QVariant v1, const QVariant v2) const; + Type commonType(const TQVariant v1, const TQVariant v2) const; - QValueList<QVariant> m_parts; + TQValueList<TQVariant> m_parts; uint m_start; bool m_error; uint m_errorPosition; diff --git a/kommander/widget/function.h b/kommander/widget/function.h index fbd8b99b..47631b22 100644 --- a/kommander/widget/function.h +++ b/kommander/widget/function.h @@ -18,12 +18,12 @@ #define _HAVE_FUNCTION_H_ #include "parsenode.h" -#include <qvaluevector.h> +#include <tqvaluevector.h> class Parser; -typedef QValueVector<ParseNode> ParameterList; -typedef QValueVector<Parse::ValueType> TypeList; +typedef TQValueVector<ParseNode> ParameterList; +typedef TQValueVector<Parse::ValueType> TypeList; typedef ParseNode(*FunctionPointer)(Parser*, const ParameterList&); class Function diff --git a/kommander/widget/functionlib.cpp b/kommander/widget/functionlib.cpp index d763ff96..416207b7 100644 --- a/kommander/widget/functionlib.cpp +++ b/kommander/widget/functionlib.cpp @@ -26,10 +26,10 @@ #include <iostream> #include <stdlib.h> -#include <qfile.h> -#include <qtextstream.h> -#include <qstringlist.h> -#include <qmetaobject.h> +#include <tqfile.h> +#include <tqtextstream.h> +#include <tqstringlist.h> +#include <tqmetaobject.h> #include <kdebug.h> #include <kmessagebox.h> @@ -57,7 +57,7 @@ static ParseNode f_stringContains(Parser*, const ParameterList& params) static ParseNode f_stringCompare(Parser*, const ParameterList& params) { - int result = QString::compare(params[0].toString(),params[1].toString()); + int result = TQString::compare(params[0].toString(),params[1].toString()); if (result < 0) { result = -1; @@ -163,7 +163,7 @@ static ParseNode f_return(Parser* p, const ParameterList& params) static ParseNode f_stringRound(Parser*, const ParameterList& params) { - QString s; + TQString s; s.sprintf("%."+params[1].toString()+"f", params[0].toDouble()); return s; } @@ -191,22 +191,22 @@ static ParseNode f_echo(Parser*, const ParameterList& params) /******************* File function ********************************/ static ParseNode f_fileRead(Parser*, const ParameterList& params) { - QFile file(params[0].toString()); + TQFile file(params[0].toString()); if (!file.exists() || !file.open(IO_ReadOnly)) return ParseNode(""); - QTextStream text(&file); + TQTextStream text(&file); return text.read(); } static ParseNode f_fileWrite(Parser*, const ParameterList& params) { - QString fname = params[0].toString(); + TQString fname = params[0].toString(); if (fname.isEmpty()) return 0; - QFile file(fname); + TQFile file(fname); if (!file.open(IO_WriteOnly)) return 0; - QTextStream text(&file); + TQTextStream text(&file); for (uint i=1; i<params.count(); i++) text << params[i].toString(); return 1; @@ -214,13 +214,13 @@ static ParseNode f_fileWrite(Parser*, const ParameterList& params) static ParseNode f_fileAppend(Parser*, const ParameterList& params) { - QString fname = params[0].toString(); + TQString fname = params[0].toString(); if (fname.isEmpty()) return 0; - QFile file(fname); + TQFile file(fname); if (!file.open(IO_WriteOnly | IO_Append)) return 0; - QTextStream text(&file); + TQTextStream text(&file); for (uint i=1; i<params.count(); i++) text << params[i].toString(); return 1; @@ -228,7 +228,7 @@ static ParseNode f_fileAppend(Parser*, const ParameterList& params) static ParseNode f_fileExists(Parser*, const ParameterList& params) { - QFile file(params[0].toString()); + TQFile file(params[0].toString()); if (!file.exists()) return 0; else @@ -238,20 +238,20 @@ static ParseNode f_fileExists(Parser*, const ParameterList& params) static ParseNode f_executeSlot(Parser* parser, const ParameterList& params) { ParameterList::ConstIterator it = params.begin(); - QString slotName = (*it).toString()+"("; + TQString slotName = (*it).toString()+"("; ++it; - QString widgetName = (*it).toString(); + TQString widgetName = (*it).toString(); KommanderWidget* widget = parser->currentWidget(); if (!widget) return ParseNode::error("unknown widget"); widget = widget->widgetByName(widgetName); if (!widget) return ParseNode::error("unknown widget"); - QObject *object = widget->object(); + TQObject *object = widget->object(); if (!object) return ParseNode::error("unknown widget"); - QStrList slotSignatures = object->metaObject()->slotNames(true); - QStringList slotNames = QStringList::fromStrList(slotSignatures); + TQStrList slotSignatures = object->metaObject()->slotNames(true); + TQStringList slotNames = TQStringList::fromStrList(slotSignatures); int slotNum = -1; uint i = 0; while (i < slotNames.count()) @@ -265,7 +265,7 @@ static ParseNode f_executeSlot(Parser* parser, const ParameterList& params) } if (slotNum == -1) return ParseNode::error("unknown function"); - QStringList args; + TQStringList args; ++it; // skip widget while (it != params.end()) { @@ -283,17 +283,17 @@ static ParseNode f_executeSlot(Parser* parser, const ParameterList& params) /******************* DCOP function ********************************/ static ParseNode f_dcopid(Parser*, const ParameterList& ) { - return QString(kapp->dcopClient()->appId()); + return TQString(kapp->dcopClient()->appId()); } static ParseNode f_pid(Parser*, const ParameterList& ) { - return QString::number(getpid()); + return TQString::number(getpid()); } static ParseNode f_parentPid(Parser*p, const ParameterList& ) { - return p->variable("_PARENTPID").toString().isEmpty() ? QString::number(getppid()) : p->variable("_PARENTPID"); + return p->variable("_PARENTPID").toString().isEmpty() ? TQString::number(getppid()) : p->variable("_PARENTPID"); } static ParseNode f_internalDcop(Parser* parser, const ParameterList& params) @@ -312,7 +312,7 @@ static ParseNode f_internalDcop(Parser* parser, const ParameterList& params) widget = widget->widgetByName(params[1].toString()); if (!widget) return ParseNode::error("unknown widget"); - QStringList args; + TQStringList args; ParameterList::ConstIterator it = params.begin(); ++it; // skip function ++it; // skip widget @@ -327,12 +327,12 @@ static ParseNode f_internalDcop(Parser* parser, const ParameterList& params) static ParseNode f_dcop(Parser*, const ParameterList& params) { - QCString appId = params[0].toString().latin1(); - QCString object = params[1].toString().latin1(); - QString function = params[2].toString().section('(', 0, 0); - QStringList items = QStringList::split(",", params[2].toString().section('(', 1, 1).section(')', 0, 0)); - QByteArray byteData; - QDataStream byteDataStream(byteData, IO_WriteOnly); + TQCString appId = params[0].toString().latin1(); + TQCString object = params[1].toString().latin1(); + TQString function = params[2].toString().section('(', 0, 0); + TQStringList items = TQStringList::split(",", params[2].toString().section('(', 1, 1).section(')', 0, 0)); + TQByteArray byteData; + TQDataStream byteDataStream(byteData, IO_WriteOnly); if (items.count() != params.count() - 3) { @@ -340,7 +340,7 @@ static ParseNode f_dcop(Parser*, const ParameterList& params) return ParseNode(); } int i = 3; - for (QStringList::Iterator it = items.begin(); it != items.end(); ++it) + for (TQStringList::Iterator it = items.begin(); it != items.end(); ++it) { *it = (*it).stripWhiteSpace(); if (*it == "int") @@ -353,16 +353,16 @@ static ParseNode f_dcop(Parser*, const ParameterList& params) byteDataStream << params[i++].toDouble(); else if (*it == "bool") byteDataStream << (bool)params[i++].toInt(); - else if (*it == "QStringList") + else if (*it == "TQStringList") if (params[i].toString().find('\n') != -1) - byteDataStream << QStringList::split("\n", params[i++].toString(), true); + byteDataStream << TQStringList::split("\n", params[i++].toString(), true); else - byteDataStream << QStringList::split("\\n", params[i++].toString(), true); + byteDataStream << TQStringList::split("\\n", params[i++].toString(), true); else byteDataStream << params[i++].toString(); } - function.append(QString("(%1)").arg(items.join(","))); - QCString replyType, byteReply; + function.append(TQString("(%1)").arg(items.join(","))); + TQCString replyType, byteReply; DCOPClient* cl = KApplication::dcopClient(); if (!cl || !cl->call(appId, object, function.latin1(), byteData, replyType, byteReply)) @@ -370,10 +370,10 @@ static ParseNode f_dcop(Parser*, const ParameterList& params) qDebug("DCOP failure"); return ParseNode(); } - QDataStream byteReplyStream(byteReply, IO_ReadOnly); - if (replyType == "QString") + TQDataStream byteReplyStream(byteReply, IO_ReadOnly); + if (replyType == "TQString") { - QString text; + TQString text; byteReplyStream >> text; return text; } @@ -389,15 +389,15 @@ static ParseNode f_dcop(Parser*, const ParameterList& params) byteReplyStream >> b; return b; } - else if (replyType == "QStringList") + else if (replyType == "TQStringList") { - QStringList text; + TQStringList text; byteReplyStream >> text; return text.join("\n"); } else if(replyType != "void") { - qDebug("%s", QString("DCOP return type %1 is not yet implemented.").arg(replyType.data()).latin1()); + qDebug("%s", TQString("DCOP return type %1 is not yet implemented.").arg(replyType.data()).latin1()); } return ParseNode(); @@ -405,14 +405,14 @@ static ParseNode f_dcop(Parser*, const ParameterList& params) static ParseNode f_createWidget(Parser* p, const ParameterList& params) { - QString widgetName = params[0].toString(); - QString widgetType = params[1].toString(); - QString parentName = params[2].toString(); + TQString widgetName = params[0].toString(); + TQString widgetType = params[1].toString(); + TQString parentName = params[2].toString(); KommanderWidget *widget = p->currentWidget()->widgetByName(parentName); if (!widget) return ParseNode::error("unknown widget"); - QWidget *parent = dynamic_cast<QWidget*>(widget->object()); - QWidget *w = KommanderFactory::createWidget(widgetType, parent, widgetName.latin1()); + TQWidget *parent = dynamic_cast<TQWidget*>(widget->object()); + TQWidget *w = KommanderFactory::createWidget(widgetType, parent, widgetName.latin1()); if (w) w->adjustSize(); return ParseNode(); @@ -420,7 +420,7 @@ static ParseNode f_createWidget(Parser* p, const ParameterList& params) static ParseNode f_widgetExists(Parser* p, const ParameterList& params) { - QString widgetName = params[0].toString(); + TQString widgetName = params[0].toString(); KommanderWidget *widget = p->currentWidget()->widgetByName(widgetName); return (widget ? true : false); } @@ -428,33 +428,33 @@ static ParseNode f_widgetExists(Parser* p, const ParameterList& params) static ParseNode f_connect(Parser* p, const ParameterList& params) { - QString sender = params[0].toString(); - QString signal = QString::number(QSIGNAL_CODE) + params[1].toString(); - QString receiver = params[2].toString(); - QString slot = QString::number(QSLOT_CODE) + params[3].toString(); + TQString sender = params[0].toString(); + TQString signal = TQString::number(QSIGNAL_CODE) + params[1].toString(); + TQString receiver = params[2].toString(); + TQString slot = TQString::number(QSLOT_CODE) + params[3].toString(); KommanderWidget *senderW = p->currentWidget()->widgetByName(sender); if (!senderW) return ParseNode::error("unknown widget"); KommanderWidget *receiverW = p->currentWidget()->widgetByName(receiver); if (!receiverW) return ParseNode::error("unknown widget"); - dynamic_cast<QObject*>(senderW)->connect(dynamic_cast<QObject*>(senderW), signal.ascii(), dynamic_cast<QObject*>(receiverW), slot.ascii()); + dynamic_cast<TQObject*>(senderW)->connect(dynamic_cast<TQObject*>(senderW), signal.ascii(), dynamic_cast<TQObject*>(receiverW), slot.ascii()); return ParseNode(); } static ParseNode f_disconnect(Parser* p, const ParameterList& params) { - QString sender = params[0].toString(); - QString signal = QString::number(QSIGNAL_CODE) + params[1].toString(); - QString receiver = params[2].toString(); - QString slot = QString::number(QSLOT_CODE) + params[3].toString(); + TQString sender = params[0].toString(); + TQString signal = TQString::number(QSIGNAL_CODE) + params[1].toString(); + TQString receiver = params[2].toString(); + TQString slot = TQString::number(QSLOT_CODE) + params[3].toString(); KommanderWidget *senderW = p->currentWidget()->widgetByName(sender); if (!senderW) return ParseNode::error("unknown widget"); KommanderWidget *receiverW = p->currentWidget()->widgetByName(receiver); if (!receiverW) return ParseNode::error("unknown widget"); - dynamic_cast<QObject*>(senderW)->disconnect(dynamic_cast<QObject*>(senderW), signal.ascii(), dynamic_cast<QObject*>(receiverW), slot.ascii()); + dynamic_cast<TQObject*>(senderW)->disconnect(dynamic_cast<TQObject*>(senderW), signal.ascii(), dynamic_cast<TQObject*>(receiverW), slot.ascii()); return ParseNode(); } @@ -462,7 +462,7 @@ static ParseNode f_disconnect(Parser* p, const ParameterList& params) static ParseNode f_exec(Parser* P, const ParameterList& params) { MyProcess proc(P->currentWidget()); - QString text; + TQString text; // qDebug("Trying %s", params[0].toString().latin1()); if (params.count() > 1) text = proc.run(params[0].toString().local8Bit(), params[1].toString()); @@ -475,7 +475,7 @@ static ParseNode f_execBackground(Parser* P, const ParameterList& params) { MyProcess proc(P->currentWidget()); proc.setBlocking(false); - QString text; + TQString text; qDebug("Trying %s", params[0].toString().latin1()); if (params.count() > 1) text = proc.run(params[0].toString().local8Bit(), params[1].toString()); @@ -486,23 +486,23 @@ static ParseNode f_execBackground(Parser* P, const ParameterList& params) static ParseNode f_dialog(Parser* P, const ParameterList& params) { - QString a_dialog = params[0].toString().local8Bit(); - QString a_params = params[1].toString().local8Bit(); + TQString a_dialog = params[0].toString().local8Bit(); + TQString a_params = params[1].toString().local8Bit(); - QString pFileName = P->currentWidget()->global("_KDDIR") + QString("/") + a_dialog; - QFileInfo pDialogFile(pFileName); + TQString pFileName = P->currentWidget()->global("_KDDIR") + TQString("/") + a_dialog; + TQFileInfo pDialogFile(pFileName); if (!pDialogFile.exists()) { pFileName = a_dialog; pDialogFile.setFile(pFileName); if (!pDialogFile.exists()) - return QString(); + return TQString(); } - QString cmd = QString("kmdr-executor %1 %2 _PARENTPID=%3 _PARENTDCOPID=kmdr-executor-%4") + TQString cmd = TQString("kmdr-executor %1 %2 _PARENTPID=%3 _PARENTDCOPID=kmdr-executor-%4") .arg(pFileName).arg(a_params).arg(getpid()).arg(getpid()); MyProcess proc(P->currentWidget()); - QString text; + TQString text; text = proc.run(cmd); return text; @@ -515,7 +515,7 @@ static ParseNode f_i18n(Parser*, const ParameterList& params) static ParseNode f_env(Parser*, const ParameterList& params) { - return QString(getenv(params[0].toString().latin1())); + return TQString(getenv(params[0].toString().latin1())); } /******************* Array functions ********************************/ @@ -537,16 +537,16 @@ static ParseNode f_arrayKeys(Parser* P, const ParameterList& params) { if (!P->isArray(params[0].toString())) return ParseNode(); - return QStringList(P->array(params[0].toString()).keys()).join("\n"); + return TQStringList(P->array(params[0].toString()).keys()).join("\n"); } static ParseNode f_arrayValues(Parser* P, const ParameterList& params) { if (!P->isArray(params[0].toString())) return ParseNode(); - QValueList<ParseNode> values = P->array(params[0].toString()).values(); - QString array; - for (QValueList<ParseNode>::ConstIterator it = values.begin(); it != values.end(); ++it ) + TQValueList<ParseNode> values = P->array(params[0].toString()).values(); + TQString array; + for (TQValueList<ParseNode>::ConstIterator it = values.begin(); it != values.end(); ++it ) array += (*it).toString() + '\n'; return array; } @@ -560,18 +560,18 @@ static ParseNode f_arrayRemove(Parser* P, const ParameterList& params) static ParseNode f_arrayToString(Parser* P, const ParameterList& params) { - QString name = params[0].toString(); + TQString name = params[0].toString(); if (!P->isArray(name)) return ParseNode(); - QString array; - QStringList keys = P->array(name).keys(); - QValueList<ParseNode> values = P->array(name).values(); + TQString array; + TQStringList keys = P->array(name).keys(); + TQValueList<ParseNode> values = P->array(name).values(); - QStringList::Iterator it = keys.begin(); - QValueList<ParseNode>::Iterator itval = values.begin(); + TQStringList::Iterator it = keys.begin(); + TQValueList<ParseNode>::Iterator itval = values.begin(); while (*it) { - array += QString("%1\t%2\n").arg(*it).arg((*itval).toString()); + array += TQString("%1\t%2\n").arg(*it).arg((*itval).toString()); ++it; ++itval; } @@ -580,11 +580,11 @@ static ParseNode f_arrayToString(Parser* P, const ParameterList& params) static ParseNode f_arrayFromString(Parser* P, const ParameterList& params) { - QString name = params[0].toString(); - QStringList lines = QStringList::split("\n", params[1].toString()); - for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) + TQString name = params[0].toString(); + TQStringList lines = TQStringList::split("\n", params[1].toString()); + for (TQStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { - QString key = (*it).section('\t', 0, 0).stripWhiteSpace(); + TQString key = (*it).section('\t', 0, 0).stripWhiteSpace(); if (!key.isEmpty()) P->setArray(name, key, (*it).section('\t', 1)); } @@ -594,16 +594,16 @@ static ParseNode f_arrayFromString(Parser* P, const ParameterList& params) static ParseNode f_arrayIndexedFromString(Parser* P, const ParameterList& params) { - QString name = params[0].toString(); - QStringList lines; + TQString name = params[0].toString(); + TQStringList lines; if (params.count() == 2) - lines = QStringList::split('\t', params[1].toString(), true); + lines = TQStringList::split('\t', params[1].toString(), true); else - lines = QStringList::split(params[2].toString(), params[1].toString(), true); + lines = TQStringList::split(params[2].toString(), params[1].toString(), true); int i = 0; - for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) + for (TQStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { - P->setArray(name, QString::number(i), (*it)); + P->setArray(name, TQString::number(i), (*it)); i++; } return ParseNode(); @@ -611,28 +611,28 @@ static ParseNode f_arrayIndexedFromString(Parser* P, const ParameterList& params static ParseNode f_arrayIndexedToString(Parser* P, const ParameterList& params) { - QString name = params[0].toString(); + TQString name = params[0].toString(); if (!P->isArray(name)) return ParseNode(); - QString separator = "\t"; + TQString separator = "\t"; if (params.count() == 2) separator = params[1].toString(); - QString array; + TQString array; int count = P->array(name).keys().count(); - QValueList<ParseNode> values = P->array(name).values(); + TQValueList<ParseNode> values = P->array(name).values(); for (int i = 0; i < count; i++) { if (i != 0) array.append(separator); - array.append(P->arrayValue(name, QString::number(i)).toString()); + array.append(P->arrayValue(name, TQString::number(i)).toString()); } return array; } static ParseNode f_arrayIndexedRemoveElements(Parser* P, const ParameterList& params) { - QString name = params[0].toString(); + TQString name = params[0].toString(); if (!P->isArray(name)) return ParseNode(); int key = params[1].toInt(); @@ -641,29 +641,29 @@ static ParseNode f_arrayIndexedRemoveElements(Parser* P, const ParameterList& pa num = params[2].toInt() - 1; if (num < 0) num = 0; - QString array; - QStringList keys = P->array(name).keys(); + TQString array; + TQStringList keys = P->array(name).keys(); int count = keys.count(); if (key + num > count - 1 || key < 0) return ParseNode(); //out of index range for (int i = 0; i < count; i++) { - if (keys.contains(QString::number(i)) != 1) + if (keys.contains(TQString::number(i)) != 1) return ParseNode(); //array is not indexed } for (int i = key; i <= key + num; i++) { - P->unsetArray(name, QString::number(i)); + P->unsetArray(name, TQString::number(i)); } int j = key; for (int i = key + num + 1; i < count; i++) { - P->setArray(name, QString::number(j), P->arrayValue(name, QString::number(i))); + P->setArray(name, TQString::number(j), P->arrayValue(name, TQString::number(i))); j++; } for (int i = 1; i <= num + 1; i++) { - P->unsetArray(name, QString::number(count - i)); + P->unsetArray(name, TQString::number(count - i)); } return ParseNode(); } @@ -671,27 +671,27 @@ static ParseNode f_arrayIndexedRemoveElements(Parser* P, const ParameterList& pa static ParseNode f_arrayIndexedInsertElements(Parser* P, const ParameterList& params) { - QString name = params[0].toString(); + TQString name = params[0].toString(); if (!P->isArray(name)) return ParseNode(); int key = params[1].toInt(); - QStringList keys = P->array(name).keys(); + TQStringList keys = P->array(name).keys(); int count = keys.count(); if (key > count || key < 0) return ParseNode(); //out of index range - QString separator = "\t"; + TQString separator = "\t"; if (params.count() == 4) separator = params[3].toString(); - QStringList elements = QStringList::split(separator, params[2].toString(), true); + TQStringList elements = TQStringList::split(separator, params[2].toString(), true); int num = elements.count(); for (int i = count - 1; i >= key; i--) { - P->setArray(name, QString::number(i + num), P->arrayValue(name, QString::number(i))); + P->setArray(name, TQString::number(i + num), P->arrayValue(name, TQString::number(i))); } int i = key; - for (QStringList::Iterator it = elements.begin(); it != elements.end(); ++it ) + for (TQStringList::Iterator it = elements.begin(); it != elements.end(); ++it ) { - P->setArray(name, QString::number(i), (*it)); + P->setArray(name, TQString::number(i), (*it)); i++; } return ParseNode(); @@ -700,7 +700,7 @@ static ParseNode f_arrayIndexedInsertElements(Parser* P, const ParameterList& pa /********** input functions *********************/ static ParseNode f_inputColor(Parser*, const ParameterList& params) { - QColor color; + TQColor color; if (params.count()) color.setNamedColor(params[0].toString()); KColorDialog::getColor(color); @@ -709,7 +709,7 @@ static ParseNode f_inputColor(Parser*, const ParameterList& params) static ParseNode f_inputText(Parser*, const ParameterList& params) { - QString value; + TQString value; if (params.count() > 2) value = params[2].toString(); return KInputDialog::getText(params[0].toString(), params[1].toString(), value); @@ -717,11 +717,11 @@ static ParseNode f_inputText(Parser*, const ParameterList& params) static ParseNode f_inputPassword(Parser*, const ParameterList& params) { - QCString value; + TQCString value; if (params.count() > 1) value = params[1].toString().local8Bit(); KPasswordDialog::getPassword(value, params[0].toString()); - return QString::fromLocal8Bit(value); + return TQString::fromLocal8Bit(value); } static ParseNode f_inputValue(Parser*, const ParameterList& params) @@ -741,7 +741,7 @@ static ParseNode f_inputValueDouble(Parser*, const ParameterList& params) static ParseNode f_inputOpenFile(Parser*, const ParameterList& params) { - QString startdir, filter, caption; + TQString startdir, filter, caption; if (params.count() > 0) startdir = params[0].toString(); if (params.count() > 1) @@ -753,7 +753,7 @@ static ParseNode f_inputOpenFile(Parser*, const ParameterList& params) static ParseNode f_inputOpenFiles(Parser*, const ParameterList& params) { - QString startdir, filter, caption; + TQString startdir, filter, caption; if (params.count() > 0) startdir = params[0].toString(); if (params.count() > 1) @@ -765,7 +765,7 @@ static ParseNode f_inputOpenFiles(Parser*, const ParameterList& params) static ParseNode f_inputSaveFile(Parser*, const ParameterList& params) { - QString startdir, filter, caption; + TQString startdir, filter, caption; if (params.count() > 0) startdir = params[0].toString(); if (params.count() > 1) @@ -777,7 +777,7 @@ static ParseNode f_inputSaveFile(Parser*, const ParameterList& params) static ParseNode f_inputDirectory(Parser*, const ParameterList& params) { - QString startdir, caption; + TQString startdir, caption; if (params.count() > 0) startdir = params[0].toString(); if (params.count() > 1) @@ -787,7 +787,7 @@ static ParseNode f_inputDirectory(Parser*, const ParameterList& params) static ParseNode f_message_info(Parser*, const ParameterList& params) { - QString text, caption; + TQString text, caption; if (params.count() > 0) text = params[0].toString(); if (params.count() > 1) @@ -798,7 +798,7 @@ static ParseNode f_message_info(Parser*, const ParameterList& params) static ParseNode f_message_error(Parser*, const ParameterList& params) { - QString text, caption; + TQString text, caption; if (params.count() > 0) text = params[0].toString(); if (params.count() > 1) @@ -810,7 +810,7 @@ static ParseNode f_message_error(Parser*, const ParameterList& params) static ParseNode f_message_warning(Parser*, const ParameterList& params) { int result; - QString text, caption, button1, button2, button3; + TQString text, caption, button1, button2, button3; if (params.count() > 0) text = params[0].toString(); if (params.count() > 1) @@ -843,7 +843,7 @@ static ParseNode f_message_warning(Parser*, const ParameterList& params) static ParseNode f_message_question(Parser*, const ParameterList& params) { int result; - QString text, caption, button1, button2, button3; + TQString text, caption, button1, button2, button3; if (params.count() > 0) text = params[0].toString(); if (params.count() > 1) @@ -875,12 +875,12 @@ static ParseNode f_message_question(Parser*, const ParameterList& params) static ParseNode f_read_setting(Parser* parser, const ParameterList& params) { - QString def; + TQString def; if (params.count() > 1) def = params[1].toString(); if (parser->currentWidget()) { - QString fname = parser->currentWidget()->fileName(); + TQString fname = parser->currentWidget()->fileName(); if (fname.isEmpty()) return ParseNode(); KConfig cfg("kommanderrc", true); @@ -894,7 +894,7 @@ static ParseNode f_write_setting(Parser* parser, const ParameterList& params) { if (parser->currentWidget()) { - QString fname = parser->currentWidget()->fileName(); + TQString fname = parser->currentWidget()->fileName(); if (fname.isEmpty()) return ParseNode(); KConfig cfg("kommanderrc", false); diff --git a/kommander/widget/invokeclass.cpp b/kommander/widget/invokeclass.cpp index b5de4678..866f629b 100644 --- a/kommander/widget/invokeclass.cpp +++ b/kommander/widget/invokeclass.cpp @@ -12,27 +12,27 @@ #include "invokeclass.h" -#include <qcolor.h> -#include <qregexp.h> +#include <tqcolor.h> +#include <tqregexp.h> -InvokeClass::InvokeClass(QObject *parent):QObject(parent) +InvokeClass::InvokeClass(TQObject *parent):TQObject(parent) { m_acceptedSlots = acceptedSlots(); } -void InvokeClass::invokeSlot(QObject *object, const QString& slot, QStringList args) +void InvokeClass::invokeSlot(TQObject *object, const TQString& slot, TQStringList args) { - QString invokeName = slot; + TQString invokeName = slot; invokeName = invokeName.mid(invokeName.find('(')); - invokeName.prepend(QString::number(QSIGNAL_CODE) + "invoke"); - QString slotName = QString::number(QSLOT_CODE) + slot; + invokeName.prepend(TQString::number(QSIGNAL_CODE) + "invoke"); + TQString slotName = TQString::number(QSLOT_CODE) + slot; connect(this, invokeName.ascii(), object, slotName.ascii()); if (args.count() == 0) emit invoke(); else { - QString slotArgStr = slot.section(QRegExp("\\(|\\)"), 1); + TQString slotArgStr = slot.section(TQRegExp("\\(|\\)"), 1); uint argNum = slotArgStr.contains(',') + 1; for (uint i = args.count(); i < argNum; i++) args << ""; @@ -52,7 +52,7 @@ void InvokeClass::invokeSlot(QObject *object, const QString& slot, QStringList a else if (slotArgStr == m_acceptedSlots[6]) emit invoke(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt()); else if (slotArgStr == m_acceptedSlots[7]) - emit invoke(QColor(args[0])); + emit invoke(TQColor(args[0])); } disconnect(this, invokeName.ascii(), object, slotName.ascii()); diff --git a/kommander/widget/invokeclass.h b/kommander/widget/invokeclass.h index 61688b3e..4b1a8c0b 100644 --- a/kommander/widget/invokeclass.h +++ b/kommander/widget/invokeclass.h @@ -13,43 +13,43 @@ #ifndef INVOKECLASS_H #define INVOKECLASS_H -#include <qobject.h> -#include <qstringlist.h> +#include <tqobject.h> +#include <tqstringlist.h> -class InvokeClass : public QObject { +class InvokeClass : public TQObject { Q_OBJECT public: - InvokeClass(QObject *parent); - void invokeSlot(QObject *object, const QString& slot, QStringList args); + InvokeClass(TQObject *parent); + void invokeSlot(TQObject *object, const TQString& slot, TQStringList args); - static QStringList acceptedSlots() + static TQStringList acceptedSlots() { - static QStringList acceptedSlots; - acceptedSlots << "const QString&"; - acceptedSlots << "const QString&,const QString&"; + static TQStringList acceptedSlots; + acceptedSlots << "const TQString&"; + acceptedSlots << "const TQString&,const TQString&"; acceptedSlots << "bool"; acceptedSlots << "int"; acceptedSlots << "int,int"; acceptedSlots << "int,int,int"; acceptedSlots << "int,int,int,int"; - acceptedSlots << "const QColor&"; + acceptedSlots << "const TQColor&"; return acceptedSlots; } signals: void invoke(); - void invoke(const QString&); - void invoke(const QString&,const QString&); + void invoke(const TQString&); + void invoke(const TQString&,const TQString&); void invoke(bool); void invoke(int); void invoke(int,int); void invoke(int,int,int); void invoke(int,int,int,int); - void invoke(const QColor&); + void invoke(const TQColor&); private: - QStringList m_acceptedSlots; + TQStringList m_acceptedSlots; }; diff --git a/kommander/widget/kmdrmainwindow.cpp b/kommander/widget/kmdrmainwindow.cpp index cfe79d0c..e123a035 100644 --- a/kommander/widget/kmdrmainwindow.cpp +++ b/kommander/widget/kmdrmainwindow.cpp @@ -11,12 +11,12 @@ // #include "kmdrmainwindow.h" -#include <qtimer.h> +#include <tqtimer.h> -KmdrMainWindow::KmdrMainWindow(QWidget *parent, const char *name, WFlags f) +KmdrMainWindow::KmdrMainWindow(TQWidget *parent, const char *name, WFlags f) : KMainWindow(parent, name, f) { - QTimer::singleShot(10, this, SIGNAL(initialize())); + TQTimer::singleShot(10, this, TQT_SIGNAL(initialize())); } diff --git a/kommander/widget/kmdrmainwindow.h b/kommander/widget/kmdrmainwindow.h index 059b514e..6637ffc8 100644 --- a/kommander/widget/kmdrmainwindow.h +++ b/kommander/widget/kmdrmainwindow.h @@ -21,7 +21,7 @@ class KmdrMainWindow : public KMainWindow { Q_OBJECT public: - KmdrMainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose); + KmdrMainWindow(TQWidget *parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose); ~KmdrMainWindow(); diff --git a/kommander/widget/kommanderfunctions.cpp b/kommander/widget/kommanderfunctions.cpp index a5a678db..6ef6e6f0 100644 --- a/kommander/widget/kommanderfunctions.cpp +++ b/kommander/widget/kommanderfunctions.cpp @@ -17,9 +17,9 @@ #include <iostream> #include <stdlib.h> -#include <qfile.h> -#include <qregexp.h> -#include <qtextstream.h> +#include <tqfile.h> +#include <tqregexp.h> +#include <tqtextstream.h> #include <dcopclient.h> #include <kapplication.h> @@ -33,7 +33,7 @@ #include "expression.h" #include "parser.h" -QString KommanderWidget::evalFunction(const QString& function, const QStringList& args) +TQString KommanderWidget::evalFunction(const TQString& function, const TQStringList& args) { switch (SpecialInformation::function(Group::Kommander, function)) { case Kommander::widgetText: @@ -43,56 +43,56 @@ QString KommanderWidget::evalFunction(const QString& function, const QStringList case Kommander::dcopid: return kapp->dcopClient()->appId(); case Kommander::pid: - return QString().setNum(getpid()); + return TQString().setNum(getpid()); case Kommander::null: - return QString(); + return TQString(); case Kommander::comment: - return QString("#"); + return TQString("#"); case Kommander::exec: return execCommand(args[0]); case Kommander::dcop: return DCOPQuery(args); case Kommander::parentPid: - return global("_PARENTPID").isEmpty() ? QString().setNum(getppid()) : global("_PARENTPID"); + return global("_PARENTPID").isEmpty() ? TQString().setNum(getppid()) : global("_PARENTPID"); case Kommander::env: - return QString(getenv(args[0].latin1())); + return TQString(getenv(args[0].latin1())); case Kommander::i18n: return KGlobal::locale()->translate(args[0]); case Kommander::global: return global(args[0]); case Kommander::setGlobal: setGlobal(args[0], args[1]); - return QString(); + return TQString(); case Kommander::debug: qDebug("%s", args[0].latin1()); fflush(stderr); - return QString::null; + return TQString::null; case Kommander::echo: for (uint i=0; i<args.count(); i++) std::cout << args[i].latin1(); fflush(stdout); - return QString::null; + return TQString::null; case Kommander::readSetting: { - QString fname = fileName(); + TQString fname = fileName(); if (!fname.isEmpty()) { KConfig cfg("kommanderrc", true); cfg.setGroup(fname); return cfg.readEntry(args[0], args[1]); } - return QString::null; + return TQString::null; } case Kommander::writeSetting: { - QString fname = fileName(); + TQString fname = fileName(); if (!fname.isEmpty()) { KConfig cfg("kommanderrc", false); cfg.setGroup(fname); cfg.writeEntry(args[0], args[1]); } - return QString::null; + return TQString::null; } case Kommander::dialog: if (args.count() > 1) @@ -103,73 +103,73 @@ QString KommanderWidget::evalFunction(const QString& function, const QStringList { Expression expr(args[0]); bool ok; - QVariant value = expr.value(&ok); - return ok ? value.toString() : QString(); + TQVariant value = expr.value(&ok); + return ok ? value.toString() : TQString(); } default: - return QString(); + return TQString(); } } -QString KommanderWidget::evalExecBlock(const QStringList& args, const QString& s, int& pos) +TQString KommanderWidget::evalExecBlock(const TQStringList& args, const TQString& s, int& pos) { int f = s.find("@execEnd", pos); if (f == -1) { printError(i18n("Unterminated @execBegin ... @execEnd block.")); - return QString(); + return TQString(); } else { - QString shell = args.count() ? args[0] : QString(); + TQString shell = args.count() ? args[0] : TQString(); int start = pos; - pos = f + QString("@execEnd").length()+1; + pos = f + TQString("@execEnd").length()+1; return execCommand(evalAssociatedText(s.mid(start, f - start)), shell); } } -QString KommanderWidget::evalForEachBlock(const QStringList& args, const QString& s, int& pos) +TQString KommanderWidget::evalForEachBlock(const TQStringList& args, const TQString& s, int& pos) { int f = s.find("@end", pos); //FIXME: better detection of block boundaries if (f == -1) { printError(i18n("Unterminated @forEach ... @end block.")); - return QString(); + return TQString(); } else { int start = pos; - pos = f + QString("@end").length()+1; - QString var = args[0]; - QStringList loop = QStringList::split("\n", args[1]); - QString output; - QString block = substituteVariable(s.mid(start, f - start), QString("%1_count").arg(var), - QString::number(loop.count())); - QString varidx = QString("%1_index").arg(var); + pos = f + TQString("@end").length()+1; + TQString var = args[0]; + TQStringList loop = TQStringList::split("\n", args[1]); + TQString output; + TQString block = substituteVariable(s.mid(start, f - start), TQString("%1_count").arg(var), + TQString::number(loop.count())); + TQString varidx = TQString("%1_index").arg(var); for (uint i=0; i<loop.count(); i++) - output += evalAssociatedText(substituteVariable(substituteVariable(block, varidx, QString::number(i+1)), + output += evalAssociatedText(substituteVariable(substituteVariable(block, varidx, TQString::number(i+1)), var, loop[i])); return output; } } -QString KommanderWidget::evalForBlock(const QStringList& args, const QString& s, int& pos) +TQString KommanderWidget::evalForBlock(const TQStringList& args, const TQString& s, int& pos) { int f = s.find("@end", pos); //FIXME: better detection of block boundaries if (f == -1) { printError(i18n("Unterminated @forEach ... @end block.")); - return QString(); + return TQString(); } else { int start = pos; - pos = f + QString("@end").length()+1; - QString block = s.mid(start, f - start); - QString variable = args[0]; + pos = f + TQString("@end").length()+1; + TQString block = s.mid(start, f - start); + TQString variable = args[0]; Expression expr; int loopstart = expr.value(args[1]).toInt(); @@ -182,16 +182,16 @@ QString KommanderWidget::evalForBlock(const QStringList& args, const QString& s, loopstep = 1; } - QString output; + TQString output; for (int i=loopstart; i<=loopend; i+=loopstep) { - output += evalAssociatedText(substituteVariable(block, variable, QString::number(i))); + output += evalAssociatedText(substituteVariable(block, variable, TQString::number(i))); } return output; } } -QString KommanderWidget::evalIfBlock(const QStringList& args, const QString& s, int& pos) +TQString KommanderWidget::evalIfBlock(const TQStringList& args, const TQString& s, int& pos) { int f = s.find("@endif", pos); //FIXME: better detection of block boundaries; add error message @@ -199,32 +199,32 @@ QString KommanderWidget::evalIfBlock(const QStringList& args, const QString& s, { pos = s.length()+1; printError(i18n("Unterminated @if ... @endif block.")); - return QString(); + return TQString(); } else { - QString block = s.mid(pos, f - pos); - pos = f + QString("@endif").length()+1; + TQString block = s.mid(pos, f - pos); + pos = f + TQString("@endif").length()+1; Expression expr; if (expr.isTrue(args[0])) return evalAssociatedText(block); - return QString(); + return TQString(); } } -QString KommanderWidget::evalSwitchBlock(const QStringList& args, const QString& s, int& pos) +TQString KommanderWidget::evalSwitchBlock(const TQStringList& args, const TQString& s, int& pos) { int f = s.find("@end", pos); //FIXME: better detection of block boundaries; add error message if (f == -1) { printError(i18n("Unterminated @switch ... @end block.")); - return QString(); + return TQString(); } else { - QString block = s.mid(pos, f - pos); - pos = f + QString("@end").length()+1; + TQString block = s.mid(pos, f - pos); + pos = f + TQString("@end").length()+1; f = parseBlockBoundary(block, 0, "@case"); bool finished = f == -1; while (!finished) @@ -237,99 +237,99 @@ QString KommanderWidget::evalSwitchBlock(const QStringList& args, const QString& finished = true; } bool ok; - QString value = parseBrackets(block, f, ok); + TQString value = parseBrackets(block, f, ok); if (!ok) break; if (value == args[0] || value == "*") return evalAssociatedText(block.mid(f, end-f)); f = end; } - return QString(); + return TQString(); } } -QString KommanderWidget::evalArrayFunction(const QString& function, const QStringList& args) +TQString KommanderWidget::evalArrayFunction(const TQString& function, const TQStringList& args) { Parser parser(internalParserData()); int fname = SpecialInformation::function(Group::Array, function); - QString array = args[0].startsWith("_") ? args[0] : QString("_")+ args[0]; + TQString array = args[0].startsWith("_") ? args[0] : TQString("_")+ args[0]; if (fname == Array::setValue) parser.setArray(array, args[1], args[2]); else if (fname == Array::fromString) { - QStringList lines = QStringList::split("\n", args[1]); - for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it) + TQStringList lines = TQStringList::split("\n", args[1]); + for (TQStringList::Iterator it = lines.begin(); it != lines.end(); ++it) { - QString key = (*it).section('\t', 0, 0).stripWhiteSpace(); + TQString key = (*it).section('\t', 0, 0).stripWhiteSpace(); if (!key.isEmpty()) parser.setArray(array, key, (*it).section('\t', 1)); } } else if (!parser.isArray(array)) - return QString(); + return TQString(); else switch (fname) { case Array::value: return parser.arrayValue(array, args[1]).toString(); case Array::keys: { - const QMap<QString, ParseNode> map = parser.array(array); - QStringList keys; - for (QMap<QString, ParseNode>::ConstIterator it = map.begin(); it != map.end(); ++it) + const TQMap<TQString, ParseNode> map = parser.array(array); + TQStringList keys; + for (TQMap<TQString, ParseNode>::ConstIterator it = map.begin(); it != map.end(); ++it) keys.append(it.key()); return keys.join("\n"); } case Array::values: { - const QMap<QString, ParseNode> map = parser.array(array); - QStringList values; - for (QMap<QString, ParseNode>::ConstIterator it = map.begin(); it != map.end(); ++it) + const TQMap<TQString, ParseNode> map = parser.array(array); + TQStringList values; + for (TQMap<TQString, ParseNode>::ConstIterator it = map.begin(); it != map.end(); ++it) values.append(it.data().toString()); return values.join("\n"); } case Array::clear: parser.unsetArray(array); - return QString(); + return TQString(); case Array::remove: parser.unsetArray(array, args[1]); - return QString(); + return TQString(); case Array::count: - return QString::number(parser.array(array).count()); + return TQString::number(parser.array(array).count()); case Array::toString: { - const QMap<QString, ParseNode> map = parser.array(array); - QString arraystring; - for (QMap<QString, ParseNode>::ConstIterator it = map.begin(); it != map.end(); ++it) - arraystring += QString("%1\t%2\n").arg(it.key()).arg(it.data().toString()); + const TQMap<TQString, ParseNode> map = parser.array(array); + TQString arraystring; + for (TQMap<TQString, ParseNode>::ConstIterator it = map.begin(); it != map.end(); ++it) + arraystring += TQString("%1\t%2\n").arg(it.key()).arg(it.data().toString()); return arraystring; } default: - return QString(); + return TQString(); } - return QString(); + return TQString(); } -QString KommanderWidget::evalWidgetFunction(const QString& identifier, const QString& s, int& pos) +TQString KommanderWidget::evalWidgetFunction(const TQString& identifier, const TQString& s, int& pos) { KommanderWidget* pWidget = parseWidget(identifier); if (!pWidget) { printError(i18n("Unknown widget: @%1.").arg(identifier)); - return QString(); + return TQString(); } if (s[pos] == '.') { pos++; bool ok = true; - QString function = parseIdentifier(s, pos); - QStringList args = parseFunction("DCOP", function, s, pos, ok); + TQString function = parseIdentifier(s, pos); + TQStringList args = parseFunction("DCOP", function, s, pos, ok); if (!ok) - return QString(); + return TQString(); args.prepend(pWidget->widgetName()); - QString prototype = SpecialInformation::prototype(Group::DCOP, + TQString prototype = SpecialInformation::prototype(Group::DCOP, SpecialInformation::function(Group::DCOP, function)); return localDCOPQuery(prototype, args); } @@ -337,12 +337,12 @@ QString KommanderWidget::evalWidgetFunction(const QString& identifier, const QSt { printError(i18n("Infinite loop: @%1 called inside @%2.").arg(pWidget->widgetName()) .arg(pWidget->widgetName())); - return QString(); + return TQString(); } else if (!pWidget->hasAssociatedText()) { printError(i18n("Script for @%1 is empty.").arg(pWidget->widgetName())); - return QString(); + return TQString(); } return pWidget->evalAssociatedText(); } diff --git a/kommander/widget/kommanderwidget.cpp b/kommander/widget/kommanderwidget.cpp index 525f662b..4cfbba8c 100644 --- a/kommander/widget/kommanderwidget.cpp +++ b/kommander/widget/kommanderwidget.cpp @@ -26,16 +26,16 @@ #include <kprocess.h> /* QT INCLUDES */ -#include <qcstring.h> -#include <qdatastream.h> -#include <qfileinfo.h> -#include <qobject.h> -#include <qobjectlist.h> -#include <qregexp.h> -#include <qstring.h> -#include <qstringlist.h> -#include <qvaluelist.h> -#include <qvariant.h> +#include <tqcstring.h> +#include <tqdatastream.h> +#include <tqfileinfo.h> +#include <tqobject.h> +#include <tqobjectlist.h> +#include <tqregexp.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> +#include <tqvariant.h> /* UNIX INCLUDES */ @@ -51,7 +51,7 @@ #include "parserdata.h" #include "kommanderwindow.h" -KommanderWidget::KommanderWidget(QObject *a_thisObject) +KommanderWidget::KommanderWidget(TQObject *a_thisObject) { m_thisObject = a_thisObject; } @@ -60,14 +60,14 @@ KommanderWidget::~KommanderWidget() { } -void KommanderWidget::setAssociatedText(const QStringList& a_associations) +void KommanderWidget::setAssociatedText(const TQStringList& a_associations) { m_associatedText = a_associations; while(m_associatedText.count() < (states().count())) - m_associatedText += QString(); // sync states and associations + m_associatedText += TQString(); // sync states and associations } -QStringList KommanderWidget::associatedText() const +TQStringList KommanderWidget::associatedText() const { return m_associatedText; } @@ -81,48 +81,48 @@ bool KommanderWidget::hasAssociatedText() } -void KommanderWidget::setPopulationText(const QString& a_txt) +void KommanderWidget::setPopulationText(const TQString& a_txt) { m_populationText = a_txt; } -QString KommanderWidget::populationText() const +TQString KommanderWidget::populationText() const { return m_populationText; } -QStringList KommanderWidget::states() const +TQStringList KommanderWidget::states() const { return m_states; } -QStringList KommanderWidget::displayStates() const +TQStringList KommanderWidget::displayStates() const { return m_displayStates; } -void KommanderWidget::setStates(const QStringList& a_states) +void KommanderWidget::setStates(const TQStringList& a_states) { m_states = a_states; } -void KommanderWidget::setDisplayStates(const QStringList& a_displayStates) +void KommanderWidget::setDisplayStates(const TQStringList& a_displayStates) { m_displayStates = a_displayStates; } -QString KommanderWidget::evalAssociatedText() // expands and returns associated text as a string +TQString KommanderWidget::evalAssociatedText() // expands and returns associated text as a string { int index = ( states().findIndex( currentState()) ); if (index == -1) { printError(i18n("Invalid state for associated text.")); - return QString(); + return TQString(); } return evalAssociatedText(m_associatedText[index]); } -QString KommanderWidget::evalAssociatedText(const QString& a_text) +TQString KommanderWidget::evalAssociatedText(const TQString& a_text) { /* New internal parser is used if global flag is set */ if ((KommanderWidget::useInternalParser && !a_text.startsWith("#!")) || a_text.startsWith("#!kommander")) @@ -132,14 +132,14 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) p.setString(a_text); if (!p.setString(a_text) || !p.parse()) printError(i18n("Line %1: %2.\n").arg(p.errorLine()+1).arg(p.errorMessage())); - return QString(); + return TQString(); } /* Old macro-only parser is implemented below */ bool parserType = KommanderWidget::useInternalParser; KommanderWidget::useInternalParser = false; //shebang is used, switch to old parser - QString evalText; + TQString evalText; int pos = 0, baseTextLength = a_text.length(); while (pos < baseTextLength) { @@ -159,7 +159,7 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) continue; } - QString identifier = parseIdentifier(a_text, pos); + TQString identifier = parseIdentifier(a_text, pos); /* comment */ if (identifier.isEmpty()) { @@ -176,16 +176,16 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) continue; } bool ok = true; - QStringList args; + TQStringList args; /* Standard, non-prefixed special */ if (identifier == "if") // if required special handling as it takes expression { - QString arg = parseBrackets(a_text, pos, ok); + TQString arg = parseBrackets(a_text, pos, ok); if (!ok) - return QString(); + return TQString(); args.append(evalAssociatedText(arg)); evalText += evalIfBlock(args, a_text, pos); } @@ -193,7 +193,7 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) { args = parseFunction("Kommander", identifier, a_text, pos, ok); if (!ok) - return QString(); + return TQString(); else if (identifier == "execBegin") evalText += evalExecBlock(args, a_text, pos); else if (identifier == "forEach") @@ -214,10 +214,10 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) else if (a_text[pos] == '.') { pos++; - QString function = parseIdentifier(a_text, pos); + TQString function = parseIdentifier(a_text, pos); args = parseFunction(identifier, function, a_text, pos, ok); if (!ok) - return QString(); + return TQString(); switch (SpecialInformation::group(identifier)) { case Group::Array: @@ -236,13 +236,13 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) evalText += Parser::function(internalParserData(), "input_" + function, args); break; default: - return QString(); + return TQString(); } } else { printError(i18n("Unknown special: \'%1\'.").arg(identifier)); - return QString(); + return TQString(); } } @@ -251,14 +251,14 @@ QString KommanderWidget::evalAssociatedText(const QString& a_text) } -QString KommanderWidget::DCOPQuery(const QStringList& a_query) +TQString KommanderWidget::DCOPQuery(const TQStringList& a_query) { - QString app = a_query[0]; + TQString app = a_query[0]; app.remove("\""); - QCString appId = app.latin1(), object = a_query[1].latin1(); + TQCString appId = app.latin1(), object = a_query[1].latin1(); // parse function arguments - QString function = a_query[2], pTypes; + TQString function = a_query[2], pTypes; function.remove(' '); int start = function.find('('); bool ok = false; @@ -272,18 +272,18 @@ QString KommanderWidget::DCOPQuery(const QStringList& a_query) if (!ok) { printError(i18n("Unmatched parenthesis in DCOP call \'%1\'.").arg(a_query[2])); - return QString(); + return TQString(); } - const QStringList argTypes = parseArgs(pTypes, ok); + const TQStringList argTypes = parseArgs(pTypes, ok); if (!ok || argTypes.count() != a_query.count() - 3) { printError(i18n("Incorrect arguments in DCOP call \'%1\'.").arg(a_query[2])); - return QString(); + return TQString(); } - QCString replyType; - QByteArray byteData, byteReply; - QDataStream byteDataStream(byteData, IO_WriteOnly); + TQCString replyType; + TQByteArray byteData, byteReply; + TQDataStream byteDataStream(byteData, IO_WriteOnly); for (uint i=0 ; i<argTypes.count(); i++) { if (argTypes[i] == "int") byteDataStream << a_query[i+3].toInt(); @@ -295,11 +295,11 @@ QString KommanderWidget::DCOPQuery(const QStringList& a_query) byteDataStream << a_query[i+3].toDouble(); else if (argTypes[i] == "bool") byteDataStream << (bool)(a_query[i+3] != "false" && a_query[i+3] != "false" && a_query[i+3] != "0"); - else if (argTypes[i] == "QStringList") + else if (argTypes[i] == "TQStringList") if (a_query[i+3].find('\n') != -1) - byteDataStream << QStringList::split("\n", a_query[i+3], true); + byteDataStream << TQStringList::split("\n", a_query[i+3], true); else - byteDataStream << QStringList::split("\\n", a_query[i+3], true); + byteDataStream << TQStringList::split("\\n", a_query[i+3], true); else byteDataStream << a_query[i+3]; } @@ -308,13 +308,13 @@ QString KommanderWidget::DCOPQuery(const QStringList& a_query) if (!cl || !cl->call(appId, object, function.latin1(), byteData, replyType, byteReply)) { printError(i18n("Tried to perform DCOP query, but failed.")); - return QString(); + return TQString(); } - QDataStream byteReplyStream(byteReply, IO_ReadOnly); - if (replyType == "QString") + TQDataStream byteReplyStream(byteReply, IO_ReadOnly); + if (replyType == "TQString") { - QString text; + TQString text; byteReplyStream >> text; return text; } @@ -322,17 +322,17 @@ QString KommanderWidget::DCOPQuery(const QStringList& a_query) { int i; byteReplyStream >> i; - return QString::number(i); + return TQString::number(i); } else if(replyType == "bool") { bool b; byteReplyStream >> b; - return QString::number(b); + return TQString::number(b); } - else if (replyType == "QStringList") + else if (replyType == "TQStringList") { - QStringList text; + TQStringList text; byteReplyStream >> text; return text.join("\n"); } @@ -341,12 +341,12 @@ QString KommanderWidget::DCOPQuery(const QStringList& a_query) printError(i18n("DCOP return type %1 is not yet implemented.").arg(replyType.data())); } - return QString(); + return TQString(); } -QString KommanderWidget::localDCOPQuery(const QString function, const QStringList& args) +TQString KommanderWidget::localDCOPQuery(const TQString function, const TQStringList& args) { - QStringList pArgs; + TQStringList pArgs; pArgs.append(kapp->dcopClient()->appId()); pArgs.append("KommanderIf"); pArgs.append(function); @@ -355,10 +355,10 @@ QString KommanderWidget::localDCOPQuery(const QString function, const QStringLis return DCOPQuery(pArgs); } -QString KommanderWidget::localDCOPQuery(const QString function, const QString& arg1, - const QString& arg2, const QString& arg3, const QString& arg4) +TQString KommanderWidget::localDCOPQuery(const TQString function, const TQString& arg1, + const TQString& arg2, const TQString& arg3, const TQString& arg4) { - QStringList pArgs; + TQStringList pArgs; pArgs.append(kapp->dcopClient()->appId()); pArgs.append("KommanderIf"); pArgs.append(function); @@ -372,53 +372,53 @@ QString KommanderWidget::localDCOPQuery(const QString function, const QString& a } -QString KommanderWidget::execCommand(const QString& a_command, const QString& a_shell) const +TQString KommanderWidget::execCommand(const TQString& a_command, const TQString& a_shell) const { MyProcess proc(this); - QString text = proc.run(a_command.local8Bit(), a_shell.latin1()); + TQString text = proc.run(a_command.local8Bit(), a_shell.latin1()); //FIXME check if exec was successful return text; } -QString KommanderWidget::runDialog(const QString& a_dialog, const QString& a_params) +TQString KommanderWidget::runDialog(const TQString& a_dialog, const TQString& a_params) { - QString pFileName = localDCOPQuery("global(QString)", "_KDDIR") + QString("/") + a_dialog; - QFileInfo pDialogFile(pFileName); + TQString pFileName = localDCOPQuery("global(TQString)", "_KDDIR") + TQString("/") + a_dialog; + TQFileInfo pDialogFile(pFileName); if (!pDialogFile.exists()) { pFileName = a_dialog; pDialogFile.setFile(pFileName); if (!pDialogFile.exists()) - return QString(); + return TQString(); } - QString cmd = QString("kmdr-executor %1 %2 _PARENTPID=%3 _PARENTDCOPID=kmdr-executor-%4") + TQString cmd = TQString("kmdr-executor %1 %2 _PARENTPID=%3 _PARENTDCOPID=kmdr-executor-%4") .arg(pFileName).arg(a_params).arg(getpid()).arg(getpid()); return execCommand(cmd); } -void KommanderWidget::printError(const QString& a_error) const +void KommanderWidget::printError(const TQString& a_error) const { if (showErrors) { KDialogBase* dialog = new KDialogBase("Error", KDialogBase::Yes | KDialogBase::No | KDialogBase::Cancel, KDialogBase::Yes, KDialogBase::No, 0, 0, true, false, i18n("Continue"), i18n("Continue && Ignore Next Errors"), i18n("Stop")); - switch (KMessageBox::createKMessageBox(dialog, QMessageBox::Warning, - i18n("<qt>Error in widget <b>%1</b>:<p><i>%2</i></qt>").arg(QString(m_thisObject->name())) - .arg(a_error), QStringList(), QString(), 0, 0)) + switch (KMessageBox::createKMessageBox(dialog, TQMessageBox::Warning, + i18n("<qt>Error in widget <b>%1</b>:<p><i>%2</i></qt>").arg(TQString(m_thisObject->name())) + .arg(a_error), TQStringList(), TQString(), 0, 0)) { case KDialogBase::No: showErrors = false; case KDialogBase::Yes: break; case KDialogBase::Cancel: - if (parentDialog()->inherits("QDialog")) + if (parentDialog()->inherits("TQDialog")) { parentDialog()->close(); exit(-1); } - else if (parentDialog()->inherits("QMainWindow")) + else if (parentDialog()->inherits("TQMainWindow")) kapp->quit(); } } @@ -430,7 +430,7 @@ void KommanderWidget::printError(const QString& a_error) const -QString KommanderWidget::parseIdentifier(const QString& s, int& from) const +TQString KommanderWidget::parseIdentifier(const TQString& s, int& from) const { uint start = from; while (start < s.length() && s[start].isSpace()) @@ -442,14 +442,14 @@ QString KommanderWidget::parseIdentifier(const QString& s, int& from) const return s.mid(start, end-start); } -QString KommanderWidget::parseBrackets(const QString& s, int& from, bool& ok) const +TQString KommanderWidget::parseBrackets(const TQString& s, int& from, bool& ok) const { ok = true; uint start = from; while (start < s.length() && s[start].isSpace()) start++; if (start == s.length() || s[start] != '(') - return QString(); + return TQString(); bool quoteSingle = false, quoteDouble = false; int brackets = 1; for (uint end = start+1; end < s.length(); end++) @@ -470,13 +470,13 @@ QString KommanderWidget::parseBrackets(const QString& s, int& from, bool& ok) co } } ok = false; - return QString(); + return TQString(); } -QStringList KommanderWidget::parseArgs(const QString& s, bool &ok) +TQStringList KommanderWidget::parseArgs(const TQString& s, bool &ok) { - QStringList argList; + TQStringList argList; bool quoteDouble = false, quoteSingle = false; uint i, start = 0, brackets=0; for (i = 0; i < s.length(); i++) @@ -495,7 +495,7 @@ QStringList KommanderWidget::parseArgs(const QString& s, bool &ok) quoteDouble = !quoteDouble; else if (s[i] == ',' && !quoteDouble && !quoteSingle) { - QString arg = s.mid(start, i - start).stripWhiteSpace(); + TQString arg = s.mid(start, i - start).stripWhiteSpace(); if (!arg.isEmpty()) argList.append(evalAssociatedText(parseQuotes(arg))); start = i+1; @@ -504,7 +504,7 @@ QStringList KommanderWidget::parseArgs(const QString& s, bool &ok) } if (!quoteDouble && !quoteSingle) { - QString arg = s.mid(start, s.length() - start + 1).stripWhiteSpace(); + TQString arg = s.mid(start, s.length() - start + 1).stripWhiteSpace(); if (!arg.isEmpty()) argList.append(evalAssociatedText(parseQuotes(arg))); } @@ -513,11 +513,11 @@ QStringList KommanderWidget::parseArgs(const QString& s, bool &ok) return argList; } -QString KommanderWidget::parseQuotes(const QString& s) const +TQString KommanderWidget::parseQuotes(const TQString& s) const { if (s[0] == s[s.length()-1] && (s[0] == '\'' || s[0] == '\"')) { - QMemArray<QChar> buf(s.length()); + TQMemArray<TQChar> buf(s.length()); int start = 0; int end = s.length() - 1; for (int i=1; i<end; i++) @@ -538,51 +538,51 @@ QString KommanderWidget::parseQuotes(const QString& s) const } else buf[start++] = s[i]; - return QString(buf, start); + return TQString(buf, start); //return s.mid(1, s.length()-2); } else return s; } -bool KommanderWidget::isWidget(const QString& a_name) const +bool KommanderWidget::isWidget(const TQString& a_name) const { return parseWidget(a_name); } -KommanderWidget* KommanderWidget::widgetByName(const QString& a_name) const +KommanderWidget* KommanderWidget::widgetByName(const TQString& a_name) const { return parseWidget(a_name); } -KommanderWidget* KommanderWidget::parseWidget(const QString& widgetName) const +KommanderWidget* KommanderWidget::parseWidget(const TQString& widgetName) const { - if (QString(parentDialog()->name()) == widgetName) + if (TQString(parentDialog()->name()) == widgetName) return dynamic_cast <KommanderWidget*>(parentDialog()); - QCString s = widgetName.lower() == "self" ? m_thisObject->name() : widgetName.latin1(); - QObject* childObj = parentDialog()->child(s); + TQCString s = widgetName.lower() == "self" ? m_thisObject->name() : widgetName.latin1(); + TQObject* childObj = parentDialog()->child(s); /* if (!childObj) { Parser parser(internalParserData()); - QString variableValue = parser.variable(widgetName).toString(); + TQString variableValue = parser.variable(widgetName).toString(); s = variableValue.lower() == "self" ? m_thisObject->name() : variableValue.latin1(); childObj = parentDialog()->child(s); }*/ return dynamic_cast <KommanderWidget*>(childObj); } -QStringList KommanderWidget::parseFunction(const QString& group, const QString& function, - const QString& s, int& from, bool& ok) +TQStringList KommanderWidget::parseFunction(const TQString& group, const TQString& function, + const TQString& s, int& from, bool& ok) { ok = true; bool success = false; - QString arg = parseBrackets(s, from, ok); + TQString arg = parseBrackets(s, from, ok); if (!ok) { printError(i18n("Unmatched parenthesis after \'%1\'.").arg(function)); - return QString(); + return TQString(); } - const QStringList args = parseArgs(arg, ok); + const TQStringList args = parseArgs(arg, ok); int gname = SpecialInformation::group(group); int fname = SpecialInformation::function(gname, function); bool extraArg = gname == Group::DCOP; @@ -611,7 +611,7 @@ QStringList KommanderWidget::parseFunction(const QString& group, const QString& return args; } -int KommanderWidget::parseBlockBoundary(const QString& s, int from, const QStringList& args) const +int KommanderWidget::parseBlockBoundary(const TQString& s, int from, const TQStringList& args) const { int shortest = -1; for (uint i=0; i<args.count(); i++) @@ -625,10 +625,10 @@ int KommanderWidget::parseBlockBoundary(const QString& s, int from, const QStrin -QString KommanderWidget::substituteVariable(QString text, QString variable, QString value) const +TQString KommanderWidget::substituteVariable(TQString text, TQString variable, TQString value) const { - QString var = QString("@%1").arg(variable); - QString newtext; + TQString var = TQString("@%1").arg(variable); + TQString newtext; int newpos, pos = 0; while (true) { @@ -649,40 +649,40 @@ QString KommanderWidget::substituteVariable(QString text, QString variable, QStr -QWidget* KommanderWidget::parentDialog() const +TQWidget* KommanderWidget::parentDialog() const { - QObject *superParent = m_thisObject; + TQObject *superParent = m_thisObject; while (superParent->parent()) { superParent = superParent->parent(); - if (superParent->inherits("QDialog") || superParent->inherits("QMainWindow")) + if (superParent->inherits("TQDialog") || superParent->inherits("TQMainWindow")) break; } - return (QWidget*)superParent; + return (TQWidget*)superParent; } -QString KommanderWidget::global(const QString& variableName) +TQString KommanderWidget::global(const TQString& variableName) { - QString var = variableName.startsWith("_") ? variableName : QString("_")+ variableName; + TQString var = variableName.startsWith("_") ? variableName : TQString("_")+ variableName; Parser parser(internalParserData()); return parser.variable(var).toString(); } -void KommanderWidget::setGlobal(const QString& variableName, const QString& value) +void KommanderWidget::setGlobal(const TQString& variableName, const TQString& value) { - QString var = variableName.startsWith("_") ? variableName : QString("_")+ variableName; + TQString var = variableName.startsWith("_") ? variableName : TQString("_")+ variableName; Parser parser(internalParserData()); parser.setVariable(var, value); } -QString KommanderWidget::handleDCOP(const int function, const QStringList& args) +TQString KommanderWidget::handleDCOP(const int function, const TQStringList& args) { - QWidget* current = dynamic_cast<QWidget*>(m_thisObject); + TQWidget* current = dynamic_cast<TQWidget*>(m_thisObject); if (!current) - return QString(); + return TQString(); switch(function) { case DCOP::setEnabled: current->setEnabled( args[0] != "false" && args[0] != "0"); @@ -694,15 +694,15 @@ QString KommanderWidget::handleDCOP(const int function, const QStringList& args) return current->className(); case DCOP::children: { - QStringList matching; - QObjectList* widgets = current->queryList("QWidget", 0, false, args.count() == 0 || args[0] != "false"); - for (QObject* w = widgets->first(); w; w = widgets->next()) + TQStringList matching; + TQObjectList* widgets = current->queryList("TQWidget", 0, false, args.count() == 0 || args[0] != "false"); + for (TQObject* w = widgets->first(); w; w = widgets->next()) if (w->name() && (dynamic_cast<KommanderWidget*>(w))) matching.append(w->name()); return matching.join("\n"); } } - return QString(); + return TQString(); } bool KommanderWidget::isFunctionSupported(int f) @@ -720,21 +720,21 @@ ParserData* KommanderWidget::internalParserData() const return m_parserData; } -QString KommanderWidget::fileName() +TQString KommanderWidget::fileName() { KommanderWindow* window = dynamic_cast<KommanderWindow*>(parentDialog()); if (window) - return QString(window->fileName()); + return TQString(window->fileName()); else - return QString(); + return TQString(); } -QString KommanderWidget::widgetName() const +TQString KommanderWidget::widgetName() const { if (m_thisObject) - return QString::fromLatin1(m_thisObject->name()); + return TQString::fromLatin1(m_thisObject->name()); else - return QString(); + return TQString(); } bool KommanderWidget::inEditor = false; diff --git a/kommander/widget/kommanderwidget.h b/kommander/widget/kommanderwidget.h index 90a748b2..c9576010 100644 --- a/kommander/widget/kommanderwidget.h +++ b/kommander/widget/kommanderwidget.h @@ -23,11 +23,11 @@ #include "kommander_export.h" /* QT INCLUDES */ -#include <qmap.h> -#include <qobject.h> -#include <qpair.h> -#include <qstring.h> -#include <qstringlist.h> +#include <tqmap.h> +#include <tqobject.h> +#include <tqpair.h> +#include <tqstring.h> +#include <tqstringlist.h> class ParserData; @@ -35,64 +35,64 @@ class KOMMANDER_EXPORT KommanderWidget { friend class MyProcess; public: - KommanderWidget(QObject *); + KommanderWidget(TQObject *); virtual ~KommanderWidget(); //List of available states. Most widgets have only one state, but f. e. radiobutton has both // 'checked' and 'unchecked' - virtual QStringList states() const; - virtual QStringList displayStates() const; - virtual QString currentState() const = 0; + virtual TQStringList states() const; + virtual TQStringList displayStates() const; + virtual TQString currentState() const = 0; virtual bool isKommanderWidget() const = 0; // Associated script - virtual void setAssociatedText(const QStringList& a_associations); - virtual QStringList associatedText() const; + virtual void setAssociatedText(const TQStringList& a_associations); + virtual TQStringList associatedText() const; virtual bool hasAssociatedText(); // Execute default script, expanding all @macros. - virtual QString evalAssociatedText(); + virtual TQString evalAssociatedText(); // Execute given script, expanding all @macros. - virtual QString evalAssociatedText(const QString&); + virtual TQString evalAssociatedText(const TQString&); // Evaluate given Kommander function using given args. - virtual QString evalFunction(const QString& function, const QStringList& args); + virtual TQString evalFunction(const TQString& function, const TQStringList& args); // Parse and evaluate function for given widget, converting it to appropriate DCOP call. - virtual QString evalWidgetFunction(const QString& identifier, const QString& s, int& pos); + virtual TQString evalWidgetFunction(const TQString& identifier, const TQString& s, int& pos); // Evaluate given array function using given args. - virtual QString evalArrayFunction(const QString&, const QStringList&); + virtual TQString evalArrayFunction(const TQString&, const TQStringList&); // Parse and evaluate given execBegin..execEnd block. - virtual QString evalExecBlock(const QStringList&, const QString& s, int& pos); + virtual TQString evalExecBlock(const TQStringList&, const TQString& s, int& pos); // Parse and evaluate given forEach..end block. - virtual QString evalForEachBlock(const QStringList&, const QString& s, int& pos); + virtual TQString evalForEachBlock(const TQStringList&, const TQString& s, int& pos); // Parse and evaluate given for..end block. - virtual QString evalForBlock(const QStringList&, const QString& s, int& pos); + virtual TQString evalForBlock(const TQStringList&, const TQString& s, int& pos); // Parse and evaluate given switch..case..end block. - virtual QString evalSwitchBlock(const QStringList&, const QString& s, int& pos); + virtual TQString evalSwitchBlock(const TQStringList&, const TQString& s, int& pos); // Parse and evaluate given if..endif block. - virtual QString evalIfBlock(const QStringList&, const QString& s, int& pos); + virtual TQString evalIfBlock(const TQStringList&, const TQString& s, int& pos); // Population text. It will become widgetText after populate() is called - virtual QString populationText() const; - virtual void setPopulationText(const QString&); + virtual TQString populationText() const; + virtual void setPopulationText(const TQString&); virtual void populate() = 0; // Handles all widget-specific DCOP calls - virtual QString handleDCOP(int function, const QStringList& args = QStringList()); + virtual TQString handleDCOP(int function, const TQStringList& args = TQStringList()); // Checks if appropriate function is supported by widget. By default all functions // are reported as supported: use this to allow recognizing incorrect function calls. virtual bool isFunctionSupported(int function); // Checks if the function is common widget function (i. e. supported by all widgets) virtual bool isCommonFunction(int function); // Checks if the string is a valid widget name) - virtual bool isWidget(const QString& a_name) const; + virtual bool isWidget(const TQString& a_name) const; // Returns widget from name - virtual KommanderWidget* widgetByName(const QString& a_name) const; + virtual KommanderWidget* widgetByName(const TQString& a_name) const; // Returns current widget name; - virtual QString widgetName() const; + virtual TQString widgetName() const; // Returns filename associated with the dialog - virtual QString fileName(); + virtual TQString fileName(); - QObject* object() { return m_thisObject;} + TQObject* object() { return m_thisObject;} // Recognizes editor vs executor mode @@ -102,55 +102,55 @@ public: // Default parser static bool useInternalParser; // Return global variable value - QString global(const QString& variableName); + TQString global(const TQString& variableName); // Set global variable value - void setGlobal(const QString& variableName, const QString& value); + void setGlobal(const TQString& variableName, const TQString& value); protected: - virtual void setStates(const QStringList& a_states); - virtual void setDisplayStates(const QStringList& a_displayStates); + virtual void setStates(const TQStringList& a_states); + virtual void setDisplayStates(const TQStringList& a_displayStates); // Execute DCOP query and return its result or null on failure - // Only QString and int are now handled - QString DCOPQuery(const QStringList& args); - QString localDCOPQuery(const QString function, const QStringList& args = QStringList()); - QString localDCOPQuery(const QString function, const QString& arg1, - const QString& arg2, const QString& arg3 = QString::null, - const QString& arg4 = QString::null); + // Only TQString and int are now handled + TQString DCOPQuery(const TQStringList& args); + TQString localDCOPQuery(const TQString function, const TQStringList& args = TQStringList()); + TQString localDCOPQuery(const TQString function, const TQString& arg1, + const TQString& arg2, const TQString& arg3 = TQString::null, + const TQString& arg4 = TQString::null); // Execute given command, return its result - QString execCommand(const QString& a_command, const QString& a_shell = QString::null) const; + TQString execCommand(const TQString& a_command, const TQString& a_shell = TQString::null) const; // Find and run dialog (with optional parameters) - QString runDialog(const QString& a_dialog, const QString& a_params = QString::null); + TQString runDialog(const TQString& a_dialog, const TQString& a_params = TQString::null); // Display error message a_error; display current class name if no other is given - void printError(const QString& a_error) const; + void printError(const TQString& a_error) const; // Auxiliary functions for parser // Find matching brackets starting from current position - QString parseBrackets(const QString& s, int& from, bool& ok) const; + TQString parseBrackets(const TQString& s, int& from, bool& ok) const; // Return identifier: the longest string of letters and numbers starting from i - QString parseIdentifier(const QString& s, int& from) const; + TQString parseIdentifier(const TQString& s, int& from) const; // Parse arguments for given function. Returns list of arguments without quotations - QStringList parseArgs(const QString& s, bool &ok); + TQStringList parseArgs(const TQString& s, bool &ok); // Remove quotes from given identifier - QString parseQuotes(const QString& s) const; + TQString parseQuotes(const TQString& s) const; // Parse function - QStringList parseFunction(const QString& group, const QString& function, - const QString& s, int& from, bool& ok); + TQStringList parseFunction(const TQString& group, const TQString& function, + const TQString& s, int& from, bool& ok); // Detect and return block boundary - int parseBlockBoundary(const QString& s, int from, const QStringList& args) const; + int parseBlockBoundary(const TQString& s, int from, const TQStringList& args) const; // Parse given identifier as widget name - KommanderWidget* parseWidget(const QString& name) const; + KommanderWidget* parseWidget(const TQString& name) const; // Return parent dialog of this widget - QWidget* parentDialog() const; - QString substituteVariable(QString text, QString variable, QString value) const; + TQWidget* parentDialog() const; + TQString substituteVariable(TQString text, TQString variable, TQString value) const; ParserData* internalParserData() const; - QObject *m_thisObject; - QStringList m_states; - QStringList m_displayStates; - QStringList m_associatedText; - QString m_populationText; + TQObject *m_thisObject; + TQStringList m_states; + TQStringList m_displayStates; + TQStringList m_associatedText; + TQString m_populationText; // Internal parser data static ParserData* m_parserData; diff --git a/kommander/widget/kommanderwindow.cpp b/kommander/widget/kommanderwindow.cpp index b536eb87..e8b597b2 100644 --- a/kommander/widget/kommanderwindow.cpp +++ b/kommander/widget/kommanderwindow.cpp @@ -15,7 +15,7 @@ #include "kommanderwindow.h" -KommanderWindow::KommanderWindow(QObject* object) : KommanderWidget(object) +KommanderWindow::KommanderWindow(TQObject* object) : KommanderWidget(object) { } @@ -24,12 +24,12 @@ KommanderWindow::~KommanderWindow() } -void KommanderWindow::setFileName(const QString& s) +void KommanderWindow::setFileName(const TQString& s) { m_fileName = s; } -QString KommanderWindow::fileName() +TQString KommanderWindow::fileName() { return m_fileName; } diff --git a/kommander/widget/kommanderwindow.h b/kommander/widget/kommanderwindow.h index 023bd395..18c0ee29 100644 --- a/kommander/widget/kommanderwindow.h +++ b/kommander/widget/kommanderwindow.h @@ -21,14 +21,14 @@ class KOMMANDER_EXPORT KommanderWindow : public KommanderWidget { public: - KommanderWindow(QObject *); + KommanderWindow(TQObject *); virtual ~KommanderWindow(); - virtual void setFileName(const QString& s); - virtual QString fileName(); + virtual void setFileName(const TQString& s); + virtual TQString fileName(); protected: private: - QString m_fileName; + TQString m_fileName; }; diff --git a/kommander/widget/myprocess.cpp b/kommander/widget/myprocess.cpp index e7e05e3b..59eb67fb 100644 --- a/kommander/widget/myprocess.cpp +++ b/kommander/widget/myprocess.cpp @@ -19,9 +19,9 @@ #include <klocale.h> /* QT INCLUDES */ -#include <qapplication.h> -#include <qobject.h> -#include <qstring.h> +#include <tqapplication.h> +#include <tqobject.h> +#include <tqstring.h> /* OTHER INCLUDES */ #include "myprocess.h" @@ -32,15 +32,15 @@ MyProcess::MyProcess(const KommanderWidget *a_atw) { } -void qt_enter_modal(QWidget *widget); -void qt_leave_modal(QWidget *widget); +void qt_enter_modal(TQWidget *widget); +void qt_leave_modal(TQWidget *widget); void MyProcess::setBlocking(bool blocking) { m_blocking = blocking; } -QString MyProcess::output() const +TQString MyProcess::output() const { return m_output; } @@ -59,16 +59,16 @@ void MyProcess::cancel() } } -QString MyProcess::run(const QString& a_command, const QString& a_shell) +TQString MyProcess::run(const TQString& a_command, const TQString& a_shell) { - QString at = a_command.stripWhiteSpace(); + TQString at = a_command.stripWhiteSpace(); if (at.isEmpty()) { emit processExited(0); - return QString(); + return TQString(); } - QString shellName = a_shell; + TQString shellName = a_shell; if (shellName.isEmpty()) shellName = "/bin/sh"; @@ -85,24 +85,24 @@ QString MyProcess::run(const QString& a_command, const QString& a_shell) mProcess = new KProcess; (*mProcess) << shellName.latin1(); - connect(mProcess, SIGNAL(receivedStdout(KProcess*, char*, int)), - SLOT(slotReceivedStdout(KProcess*, char*, int))); - connect(mProcess, SIGNAL(processExited(KProcess*)), SLOT(slotProcessExited(KProcess*))); + connect(mProcess, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), + TQT_SLOT(slotReceivedStdout(KProcess*, char*, int))); + connect(mProcess, TQT_SIGNAL(processExited(KProcess*)), TQT_SLOT(slotProcessExited(KProcess*))); if(!mProcess->start(KProcess::NotifyOnExit, KProcess::All)) { m_atw->printError(i18n("<qt>Failed to start shell process<br><b>%1</b></qt>").arg(shellName)); - return QString(); + return TQString(); } mProcess->writeStdin(m_input, m_input.length()); mProcess->closeStdin(); if (!m_blocking) - return QString(); + return TQString(); else { - QWidget dummy(0, 0, WType_Dialog | WShowModal); - dummy.setFocusPolicy(QWidget::NoFocus); + TQWidget dummy(0, 0, WType_Dialog | WShowModal); + dummy.setFocusPolicy(TQWidget::NoFocus); m_loopStarted = true; qt_enter_modal(&dummy); qApp->enter_loop(); @@ -117,7 +117,7 @@ QString MyProcess::run(const QString& a_command, const QString& a_shell) void MyProcess::slotReceivedStdout(KProcess*, char* a_buffer, int a_len) { - m_output += QString::fromLocal8Bit(a_buffer, a_len); + m_output += TQString::fromLocal8Bit(a_buffer, a_len); emit processReceivedStdout(this, a_buffer, a_len); } diff --git a/kommander/widget/myprocess.h b/kommander/widget/myprocess.h index 8487f170..36af1b48 100644 --- a/kommander/widget/myprocess.h +++ b/kommander/widget/myprocess.h @@ -20,8 +20,8 @@ #include <kprocess.h> /* QT INCLUDES */ -#include <qstring.h> -#include <qobject.h> +#include <tqstring.h> +#include <tqobject.h> #include "kommander_export.h" class KommanderWidget; @@ -33,12 +33,12 @@ public: MyProcess(const KommanderWidget *); // Run given command, using a_shell as a shell (this can be overridden by shebang in the first line) // Process is run in blocking mode. - QString run(const QString& a_command, const QString& a_shell = "/bin/sh"); + TQString run(const TQString& a_command, const TQString& a_shell = "/bin/sh"); // Kill running process void cancel(); void setBlocking(bool blocking); bool isBlocking() const; - QString output() const; + TQString output() const; signals: void processExited(MyProcess*); void processReceivedStdout(MyProcess*, char*, int); @@ -47,8 +47,8 @@ private slots: void slotProcessExited(KProcess*); protected: const KommanderWidget *m_atw; - QString m_output; - QCString m_input; + TQString m_output; + TQCString m_input; bool m_loopStarted; bool m_blocking; bool m_handleOutput; diff --git a/kommander/widget/parsenode.cpp b/kommander/widget/parsenode.cpp index d080e114..492c00fb 100644 --- a/kommander/widget/parsenode.cpp +++ b/kommander/widget/parsenode.cpp @@ -22,7 +22,7 @@ ParseNode::ParseNode() : m_type(ValueNone), m_context(-1) { } -ParseNode::ParseNode(const QString& s) : m_type(ValueString), m_string(s), m_context(-1) +ParseNode::ParseNode(const TQString& s) : m_type(ValueString), m_string(s), m_context(-1) { } @@ -38,16 +38,16 @@ ParseNode::ParseNode(double d) : m_type(ValueDouble), m_double(d), m_context(-1) { } -ParseNode::ParseNode(Keyword k) : m_type(ValueKeyword), m_keyword(k), m_string(QString::null), m_context(-1) +ParseNode::ParseNode(Keyword k) : m_type(ValueKeyword), m_keyword(k), m_string(TQString::null), m_context(-1) { } -ParseNode::ParseNode(Keyword k, const QString& name) : m_type(ValueKeyword), m_keyword(k), m_context(-1) +ParseNode::ParseNode(Keyword k, const TQString& name) : m_type(ValueKeyword), m_keyword(k), m_context(-1) { - m_string = (k == Variable) ? name : QString::null; + m_string = (k == Variable) ? name : TQString::null; } -ParseNode ParseNode::error(const QString& s) +ParseNode ParseNode::error(const TQString& s) { ParseNode p; p.m_string = s; @@ -65,13 +65,13 @@ Keyword ParseNode::keyword() const return isKeyword() ? m_keyword : Invalid; } -QString ParseNode::toString() const +TQString ParseNode::toString() const { switch(type()) { case ValueString: return m_string; - case ValueInt: return QString::number(m_int); - case ValueDouble: return QString::number(m_double); - default: return QString(); + case ValueInt: return TQString::number(m_int); + case ValueDouble: return TQString::number(m_double); + default: return TQString(); } } @@ -120,14 +120,14 @@ bool ParseNode::isVariable() const return type() == ValueKeyword && keyword() == Variable; } -QString ParseNode::variableName() const +TQString ParseNode::variableName() const { - return isVariable() ? m_string : QString(); + return isVariable() ? m_string : TQString(); } -QString ParseNode::errorMessage() const +TQString ParseNode::errorMessage() const { - return isValid() ? QString() : m_string; + return isValid() ? TQString() : m_string; } @@ -168,7 +168,7 @@ bool ParseNode::operator==(bool b) const return toBool() == b; } -bool ParseNode::operator==(const QString& s) const +bool ParseNode::operator==(const TQString& s) const { return toString() == s; } @@ -215,13 +215,13 @@ void ParseNode::setValue(double d) m_double = d; } -void ParseNode::setValue(const QString& s) +void ParseNode::setValue(const TQString& s) { m_type = ValueString; m_string = s; } -void ParseNode::setVariable(const QString& name) +void ParseNode::setVariable(const TQString& name) { m_type = ValueKeyword; m_keyword = Variable; diff --git a/kommander/widget/parsenode.h b/kommander/widget/parsenode.h index aa657d35..42ffbf71 100644 --- a/kommander/widget/parsenode.h +++ b/kommander/widget/parsenode.h @@ -17,7 +17,7 @@ #ifndef _HAVE_PARSENODE_H_ #define _HAVE_PARSENODE_H_ -#include <qstring.h> +#include <tqstring.h> namespace Parse { @@ -40,7 +40,7 @@ public: /* Default constructor */ ParseNode(); /* Create node from string */ - ParseNode(const QString& s); + ParseNode(const TQString& s); /* Create node from integer */ ParseNode(int i); /* Create node from integer */ @@ -50,16 +50,16 @@ public: /* Create node from keyword */ ParseNode(Parse::Keyword k); /* Create node from keyword and variable name */ - ParseNode(Parse::Keyword k, const QString& s); + ParseNode(Parse::Keyword k, const TQString& s); /* Create error node with optional error message */ - static ParseNode error(const QString& s); + static ParseNode error(const TQString& s); /* Return current type */ Parse::ValueType type() const; /* Return current keyword if appropriate */ Parse::Keyword keyword() const; /* Cast value to string */ - QString toString() const; + TQString toString() const; /* Cast value to integer */ int toInt() const; /* Cast value to double */ @@ -75,9 +75,9 @@ public: /* Check if current value is a variable */ bool isVariable() const; /* Return the name of variable */ - QString variableName() const; + TQString variableName() const; /* Return error message if applicable */ - QString errorMessage() const; + TQString errorMessage() const; /* Calculate common type for two nodes */ Parse::ValueType commonType(const ParseNode& p) const; /* Find common type and compare values */ @@ -85,7 +85,7 @@ public: /* Various comparing functions */ bool operator==(int i) const; bool operator==(bool b) const; - bool operator==(const QString& s) const; + bool operator==(const TQString& s) const; bool operator==(const ParseNode& p) const; bool operator!=(const ParseNode& p) const; bool operator>=(const ParseNode& p) const; @@ -97,9 +97,9 @@ public: /* set value as double */ void setValue(double d); /* set value as string */ - void setValue(const QString& s); + void setValue(const TQString& s); /* set value as variable */ - void setVariable(const QString& name); + void setVariable(const TQString& name); /* check if it is correct value */ bool isValue() const; /* for setting some context information, f. e. for bug reporting */ @@ -114,7 +114,7 @@ private: double m_double; Parse::Keyword m_keyword; }; - QString m_string; + TQString m_string; int m_context; }; diff --git a/kommander/widget/parser.cpp b/kommander/widget/parser.cpp index 1424d6c7..04748e45 100644 --- a/kommander/widget/parser.cpp +++ b/kommander/widget/parser.cpp @@ -22,23 +22,23 @@ using namespace Parse; -QString unescape(QString s) +TQString unescape(TQString s) { return s.replace("\\\"", "\"").replace("\\t", "\t").replace("\\n", "\n").replace("\\\\", "\\"); } -Parser::Parser(ParserData* pData) : m_data(pData), m_start(0), m_error(QString::null), m_errorPosition(0), +Parser::Parser(ParserData* pData) : m_data(pData), m_start(0), m_error(TQString::null), m_errorPosition(0), m_widget(0) { } -Parser::Parser(ParserData* pData, const QString& expr) : m_data(pData), m_start(0), - m_error(QString::null), m_errorPosition(0), m_widget(0) +Parser::Parser(ParserData* pData, const TQString& expr) : m_data(pData), m_start(0), + m_error(TQString::null), m_errorPosition(0), m_widget(0) { setString(expr); } -bool Parser::setString(const QString& s) +bool Parser::setString(const TQString& s) { reset(); m_parts.clear(); @@ -78,7 +78,7 @@ bool Parser::setString(const QString& s) else if (s[start].isDigit()) // number: 1000 or 2.45 { bool decimal = false; - for (i = start+1; s[i].isDigit() || (!decimal && s[i] == QChar('.')); i++) + for (i = start+1; s[i].isDigit() || (!decimal && s[i] == TQChar('.')); i++) if (s[i] == '.') decimal = true; if (decimal) @@ -91,7 +91,7 @@ bool Parser::setString(const QString& s) { for (i = start+1; s[i].isLetterOrNumber() || s[i] == '_'; i++) ; - QString name = s.mid(start, i - start); + TQString name = s.mid(start, i - start); insertNode(ParseNode(m_data->stringToKeyword(name), name), lines); start = i; } // comment @@ -131,28 +131,28 @@ void Parser::insertNode(ParseNode p, int line) m_parts.append(p); } -QString Parser::errorMessage() const +TQString Parser::errorMessage() const { return m_error; } -QString Parser::function(ParserData* data, const QString& name, const QStringList& params) +TQString Parser::function(ParserData* data, const TQString& name, const TQStringList& params) { ParameterList par; - for (QStringList::ConstIterator Iter = params.begin(); Iter != params.end(); ++Iter) + for (TQStringList::ConstIterator Iter = params.begin(); Iter != params.end(); ++Iter) par.append(*Iter); Function f = data->function(name); return f.execute(0, par).toString(); } -QString Parser::expression(Mode mode) +TQString Parser::expression(Mode mode) { reset(); ParseNode p = parseExpression(mode); if (!isError()) return p.toString(); else - return QString(); + return TQString(); } bool Parser::isError() const @@ -206,14 +206,14 @@ ParseNode Parser::parseValue(Mode mode) { if (tryKeyword(LeftBracket, CheckOnly)) { - QString index = parseValue(mode).toString(); + TQString index = parseValue(mode).toString(); tryKeyword(RightBracket); - QString arr = p.variableName(); + TQString arr = p.variableName(); return arrayValue(arr, index); } else if (tryKeyword(Dot, CheckOnly)) { - QString value = variable(p.variableName()).toString(); + TQString value = variable(p.variableName()).toString(); if (m_widget && m_widget->isWidget(value)) { m_start--; @@ -300,7 +300,7 @@ ParseNode Parser::parseAdd(Mode mode) { if (k == Plus) if (type == ValueString) - p = QString(p.toString() + p2.toString()); + p = TQString(p.toString() + p2.toString()); else if (type == ValueDouble) p = p.toDouble() + p2.toDouble(); else @@ -410,7 +410,7 @@ ParseNode Parser::parseExpression(Mode mode) ParseNode Parser::parseFunction(Mode mode) { int pos = m_start; - QString name = next().variableName(); + TQString name = next().variableName(); Function f = m_data->function(name); m_start++; ParameterList params; @@ -440,10 +440,10 @@ ParseNode Parser::parseFunction(Mode mode) return ParseNode(); } -ParseNode Parser::parseWidget(Mode mode, const QString &widgetName) +ParseNode Parser::parseWidget(Mode mode, const TQString &widgetName) { int pos = m_start; - QString widget; + TQString widget; if (widgetName.isNull()) widget = nextVariable(mode); else @@ -452,7 +452,7 @@ ParseNode Parser::parseWidget(Mode mode, const QString &widgetName) if (!tryKeyword(Dot)) return ParseNode(); - QString var = nextVariable(); + TQString var = nextVariable(); if (var.isNull()) return ParseNode(); ParameterList params; @@ -483,10 +483,10 @@ ParseNode Parser::parseWidget(Mode mode, const QString &widgetName) ParseNode Parser::parseAssignment(Mode mode) { - QString var = nextVariable(); + TQString var = nextVariable(); if (tryKeyword(LeftBracket, CheckOnly)) { - QString index = parseValue(mode).toString(); + TQString index = parseValue(mode).toString(); tryKeyword(RightBracket); tryKeyword(Assign); ParseNode p = parseExpression(mode); @@ -501,7 +501,7 @@ ParseNode Parser::parseAssignment(Mode mode) } else if (tryKeyword(Dot, CheckOnly)) { - QString value = variable(var).toString(); + TQString value = variable(var).toString(); if (m_widget && m_widget->isWidget(value)) { m_start--; @@ -585,7 +585,7 @@ Parse::Flow Parser::parseWhile(Mode mode) Parse::Flow Parser::parseFor(Mode mode) { m_start++; - QString var = nextVariable(); + TQString var = nextVariable(); tryKeyword(Assign); int start = parseExpression(mode).toInt(); tryKeyword(To); @@ -620,16 +620,16 @@ Parse::Flow Parser::parseFor(Mode mode) Parse::Flow Parser::parseForeach(Mode mode) { m_start++; - QString var = nextVariable(); + TQString var = nextVariable(); tryKeyword(In); - QString arr = nextVariable(); + TQString arr = nextVariable(); tryKeyword(Do); int start = m_start; Parse::Flow flow = FlowStandard; if (isArray(arr) && array(arr).count()) { - const QMap<QString, ParseNode> A = array(arr); - for (QMapConstIterator<QString, ParseNode> It = A.begin(); It != A.end(); ++It) + const TQMap<TQString, ParseNode> A = array(arr); + for (TQMapConstIterator<TQString, ParseNode> It = A.begin(); It != A.end(); ++It) { m_start = start; setVariable(var, It.key()); @@ -652,7 +652,7 @@ Parse::Flow Parser::parseForeach(Mode mode) void Parser::parseSwitch(Mode mode) { m_start++; - QString var = nextVariable(); + TQString var = nextVariable(); ParseNode caseValue = variable(var); bool executed = false; tryKeyword(Semicolon, CheckOnly); @@ -688,7 +688,7 @@ Flow Parser::parseCommand(Mode mode) return FlowBreak; else if (isFunction()) { - QString name = next().variableName(); + TQString name = next().variableName(); parseFunction(mode); if (name == "return" && mode == Execute) return FlowExit; @@ -749,7 +749,7 @@ bool Parser::tryVariable(Mode mode) { if (next().isVariable()) { - QString name = next().variableName(); + TQString name = next().variableName(); m_start++; return true; } @@ -758,17 +758,17 @@ bool Parser::tryVariable(Mode mode) return false; } -QString Parser::nextVariable(Mode mode) +TQString Parser::nextVariable(Mode mode) { if (next().isVariable()) { - QString name = next().variableName(); + TQString name = next().variableName(); m_start++; return name; } else if (mode == Execute) setError(i18n("Expected variable")); - return QString(); + return TQString(); } @@ -785,16 +785,16 @@ bool Parser::isWidget() const void Parser::reset() { m_start = 0; - m_error = QString::null; + m_error = TQString::null; m_errorPosition = 0; } -void Parser::setError(const QString& msg) +void Parser::setError(const TQString& msg) { setError(msg, m_start); } -void Parser::setError(const QString& msg, int pos) +void Parser::setError(const TQString& msg, int pos) { if (m_error.isNull()) { @@ -803,7 +803,7 @@ void Parser::setError(const QString& msg, int pos) } } -void Parser::setVariable(const QString& name, ParseNode value) +void Parser::setVariable(const TQString& name, ParseNode value) { if (isGlobal(name)) m_globalVariables[name] = value; @@ -811,7 +811,7 @@ void Parser::setVariable(const QString& name, ParseNode value) m_variables[name] = value; } -ParseNode Parser::variable(const QString& name) const +ParseNode Parser::variable(const TQString& name) const { if (isGlobal(name)) return m_globalVariables.contains(name) ? m_globalVariables[name] : ParseNode(); @@ -819,17 +819,17 @@ ParseNode Parser::variable(const QString& name) const return m_variables.contains(name) ? m_variables[name] : ParseNode(); } -bool Parser::isGlobal(const QString& name) const +bool Parser::isGlobal(const TQString& name) const { return !name.isEmpty() && name[0] == '_'; } -bool Parser::isVariable(const QString& name) const +bool Parser::isVariable(const TQString& name) const { return m_variables.contains(name) || m_globalVariables.contains(name); } -void Parser::unsetVariable(const QString& key) +void Parser::unsetVariable(const TQString& key) { if (isGlobal(key)) m_globalVariables.remove(key); @@ -837,7 +837,7 @@ void Parser::unsetVariable(const QString& key) m_variables.remove(key); } -const QMap<QString, ParseNode>& Parser::array(const QString& name) const +const TQMap<TQString, ParseNode>& Parser::array(const TQString& name) const { if (isGlobal(name)) return m_globalArrays[name]; @@ -845,12 +845,12 @@ const QMap<QString, ParseNode>& Parser::array(const QString& name) const return m_arrays[name]; } -bool Parser::isArray(const QString& name) const +bool Parser::isArray(const TQString& name) const { return m_arrays.contains(name) || m_globalArrays.contains(name); } -void Parser::setArray(const QString& name, const QString& key, ParseNode value) +void Parser::setArray(const TQString& name, const TQString& key, ParseNode value) { if (isGlobal(name)) m_globalArrays[name][key] = value; @@ -858,7 +858,7 @@ void Parser::setArray(const QString& name, const QString& key, ParseNode value) m_arrays[name][key] = value; } -void Parser::unsetArray(const QString& name, const QString& key) +void Parser::unsetArray(const TQString& name, const TQString& key) { if (isGlobal(name)) { @@ -876,7 +876,7 @@ void Parser::unsetArray(const QString& name, const QString& key) } } -ParseNode Parser::arrayValue(const QString& name, const QString& key) const +ParseNode Parser::arrayValue(const TQString& name, const TQString& key) const { if (!isArray(name)) return ParseNode(); @@ -893,7 +893,7 @@ KommanderWidget* Parser::currentWidget() const return m_widget; } -QMap<QString, ParseNode> Parser::m_globalVariables; -QMap<QString, QMap<QString, ParseNode> > Parser::m_globalArrays; +TQMap<TQString, ParseNode> Parser::m_globalVariables; +TQMap<TQString, TQMap<TQString, ParseNode> > Parser::m_globalArrays; diff --git a/kommander/widget/parser.h b/kommander/widget/parser.h index 6dc66258..3ad7d59c 100644 --- a/kommander/widget/parser.h +++ b/kommander/widget/parser.h @@ -20,9 +20,9 @@ #include "kommander_export.h" #include "parsenode.h" -#include <qvaluevector.h> -#include <qstringlist.h> -#include <qmap.h> +#include <tqvaluevector.h> +#include <tqstringlist.h> +#include <tqmap.h> class KommanderWidget; class ParserData; @@ -31,43 +31,43 @@ class Parser { public: Parser(ParserData* data); - Parser(ParserData* data, const QString& expr); + Parser(ParserData* data, const TQString& expr); // set string to parse - bool setString(const QString& s); + bool setString(const TQString& s); // set Kommander widget associated with parser void setWidget(KommanderWidget* w); // parse generic expression - QString expression(Parse::Mode mode = Parse::Execute); + TQString expression(Parse::Mode mode = Parse::Execute); // execute single command; return true if ok bool command(Parse::Mode mode = Parse::Execute); // special class method to execute single parser function without creating parser object - static QString function(ParserData* data, const QString& name, const QStringList& params); + static TQString function(ParserData* data, const TQString& name, const TQStringList& params); // execute whole block; return true if ok bool parse(Parse::Mode mode = Parse::Execute); // return line of errorneous node int errorLine() const; // return error message - QString errorMessage() const; + TQString errorMessage() const; // check if this is a name of standard variable - bool isVariable(const QString& name) const; + bool isVariable(const TQString& name) const; // set variable value - void setVariable(const QString& name, ParseNode value); + void setVariable(const TQString& name, ParseNode value); // unset variable - void unsetVariable(const QString& key); + void unsetVariable(const TQString& key); // get variable value - ParseNode variable(const QString& name) const; + ParseNode variable(const TQString& name) const; // access associative array - const QMap<QString, ParseNode>& array(const QString& name) const; + const TQMap<TQString, ParseNode>& array(const TQString& name) const; // check if this is a name of an array - bool isArray(const QString& name) const; + bool isArray(const TQString& name) const; // set array key - void setArray(const QString& name, const QString& key, ParseNode value); + void setArray(const TQString& name, const TQString& key, ParseNode value); // unset array key or whole array - void unsetArray(const QString& name, const QString& key = QString::null); + void unsetArray(const TQString& name, const TQString& key = TQString::null); // array value - ParseNode arrayValue(const QString& name, const QString& key) const; + ParseNode arrayValue(const TQString& name, const TQString& key) const; // get associated widget KommanderWidget* currentWidget() const; @@ -110,7 +110,7 @@ private: // parse parameters ParseNode parseFunction(Parse::Mode mode = Parse::Execute); // parse widget function - ParseNode parseWidget(Parse::Mode mode = Parse::Execute, const QString &widgetName = QString::null); + ParseNode parseWidget(Parse::Mode mode = Parse::Execute, const TQString &widgetName = TQString::null); // parse assignment ParseNode parseAssignment(Parse::Mode mode = Parse::Execute); @@ -139,9 +139,9 @@ private: bool tryVariable(Parse::Mode mode = Parse::Execute); // get the name of the next node treated as variable - QString nextVariable(Parse::Mode mode = Parse::Execute); + TQString nextVariable(Parse::Mode mode = Parse::Execute); // check whether variable/array name is global (preceded with _) - bool isGlobal(const QString& name) const; + bool isGlobal(const TQString& name) const; // check if next item is a function bool isFunction() const; // check if next item is a widget @@ -150,8 +150,8 @@ private: // reset to default state void reset(); // set error state if no error was set before; err is expected symbol that wasn't found - void setError(const QString& msg); - void setError(const QString& msg, int pos); + void setError(const TQString& msg); + void setError(const TQString& msg, int pos); // check whether parsing was successful bool isError() const; @@ -160,21 +160,21 @@ private: // current parsing position uint m_start; // current error message - QString m_error; + TQString m_error; // in case of error, this keeps position of first error uint m_errorPosition; // parsing nodes - QValueVector<ParseNode> m_parts; + TQValueVector<ParseNode> m_parts; // variables - QMap<QString, ParseNode> m_variables; + TQMap<TQString, ParseNode> m_variables; // arrays - QMap<QString, QMap<QString, ParseNode> > m_arrays; + TQMap<TQString, TQMap<TQString, ParseNode> > m_arrays; // Kommander KommanderWidget* m_widget; // global variables - static QMap<QString, ParseNode> m_globalVariables; + static TQMap<TQString, ParseNode> m_globalVariables; // global arrays - static QMap<QString, QMap<QString, ParseNode> > m_globalArrays; + static TQMap<TQString, TQMap<TQString, ParseNode> > m_globalArrays; }; #endif diff --git a/kommander/widget/parserdata.cpp b/kommander/widget/parserdata.cpp index f803283e..274d7220 100644 --- a/kommander/widget/parserdata.cpp +++ b/kommander/widget/parserdata.cpp @@ -25,24 +25,24 @@ KeywordGroup ParserData::keywordGroup(Keyword k) const return GroupMisc; } -Keyword ParserData::stringToKeyword(const QString& s) const +Keyword ParserData::stringToKeyword(const TQString& s) const { - QString k = s.lower(); + TQString k = s.lower(); if (m_keywords.contains(k)) return m_keywords[k]; else return Variable; } -QString ParserData::keywordToString(Parse::Keyword k) const +TQString ParserData::keywordToString(Parse::Keyword k) const { - for (QMapConstIterator<QString, Keyword> it = m_keywords.begin(); it != m_keywords.end(); ++it) + for (TQMapConstIterator<TQString, Keyword> it = m_keywords.begin(); it != m_keywords.end(); ++it) if (it.data() == k) return it.key(); - return QString(); + return TQString(); } -bool ParserData::registerFunction(const QString& name, Function f) +bool ParserData::registerFunction(const TQString& name, Function f) { m_functions[name.lower()] = f; return true; @@ -114,12 +114,12 @@ ParserData::ParserData() registerStandardFunctions(); } -bool ParserData::isFunction(const QString& name) const +bool ParserData::isFunction(const TQString& name) const { return m_functions.contains(name.lower()); } -const Function& ParserData::function(const QString& name) const +const Function& ParserData::function(const TQString& name) const { return m_functions[name.lower()]; } diff --git a/kommander/widget/parserdata.h b/kommander/widget/parserdata.h index 4c7f8d50..e427e600 100644 --- a/kommander/widget/parserdata.h +++ b/kommander/widget/parserdata.h @@ -19,7 +19,7 @@ #include "parsenode.h" #include "function.h" -#include <qmap.h> +#include <tqmap.h> class ParserData { public: @@ -28,22 +28,22 @@ public: /* Return group of given keyword */ Parse::KeywordGroup keywordGroup(Parse::Keyword k) const; /* Convert string to keyword */ - Parse::Keyword stringToKeyword(const QString& s) const; + Parse::Keyword stringToKeyword(const TQString& s) const; /* Convert keyword to string */ - QString keywordToString(Parse::Keyword k) const; + TQString keywordToString(Parse::Keyword k) const; /* register a function */ - bool registerFunction(const QString& name, Function f); + bool registerFunction(const TQString& name, Function f); /* check if this is a name of standard function */ - bool isFunction(const QString& name) const; + bool isFunction(const TQString& name) const; /* Return function with given name. Warning: this function has undefined behavior when there is no such function. */ - const Function& function(const QString& name) const; + const Function& function(const TQString& name) const; private: // register standard function void registerStandardFunctions(); - QMap<QString, Parse::Keyword> m_keywords; - QMap<Parse::Keyword, Parse::KeywordGroup> m_groups; - QMap<QString, Function> m_functions; + TQMap<TQString, Parse::Keyword> m_keywords; + TQMap<Parse::Keyword, Parse::KeywordGroup> m_groups; + TQMap<TQString, Function> m_functions; }; |