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/kommanderwidget.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/kommanderwidget.cpp')
-rw-r--r-- | kommander/widget/kommanderwidget.cpp | 244 |
1 files changed, 122 insertions, 122 deletions
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; |