diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:54:04 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:54:04 +0000 |
commit | dc6b8e72fed2586239e3514819238c520636c9d9 (patch) | |
tree | 88b200df0a0b7fab9d6f147596173556f1ed9a13 /kommander/widget/kommanderfunctions.cpp | |
parent | 6927d4436e54551917f600b706a8d6109e49de1c (diff) | |
download | tdewebdev-dc6b8e72fed2586239e3514819238c520636c9d9.tar.gz tdewebdev-dc6b8e72fed2586239e3514819238c520636c9d9.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1157656 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/widget/kommanderfunctions.cpp')
-rw-r--r-- | kommander/widget/kommanderfunctions.cpp | 160 |
1 files changed, 80 insertions, 80 deletions
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(); } |