From 0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 30 Jun 2011 00:15:53 +0000 Subject: TQt4 port piklab This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1238822 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/piklab-prog/cli_interactive.cpp | 88 ++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 49 deletions(-) (limited to 'src/piklab-prog/cli_interactive.cpp') diff --git a/src/piklab-prog/cli_interactive.cpp b/src/piklab-prog/cli_interactive.cpp index 148ba62..872a53e 100644 --- a/src/piklab-prog/cli_interactive.cpp +++ b/src/piklab-prog/cli_interactive.cpp @@ -15,7 +15,7 @@ # include #endif #include -#include +#include #include #include "progs/base/generic_prog.h" @@ -74,8 +74,8 @@ void CLI::Interactive::signalHandler(int n) _interactive->redisplayPrompt(); } -CLI::Interactive::Interactive(QObject *parent) - : QObject(parent, "interactive") +CLI::Interactive::Interactive(TQObject *tqparent) + : TQObject(tqparent, "interactive") { setView(_view); ::signal(SIGINT, signalHandler); @@ -84,7 +84,7 @@ CLI::Interactive::Interactive(QObject *parent) #else _stdin.open(IO_ReadOnly, stdin); #endif - QTimer::singleShot(0, this, SLOT(displayPrompt())); + TQTimer::singleShot(0, this, TQT_SLOT(displayPrompt())); } void CLI::Interactive::redisplayPrompt() @@ -101,7 +101,7 @@ void CLI::Interactive::displayPrompt() { #if defined(HAVE_READLINE) char *line = readline("> "); - _input = QString(line); + _input = TQString(line); if ( !_input.isEmpty() ) add_history(line); free(line); #else @@ -109,14 +109,14 @@ void CLI::Interactive::displayPrompt() fflush(stdout); char buffer[1000]; _stdin.readLine(buffer, 1000); - _input = QString(buffer); + _input = TQString(buffer); #endif lineRead(); } -CLI::ExitCode CLI::Interactive::processLine(const QString &s) +CLI::ExitCode CLI::Interactive::processLine(const TQString &s) { - QStringList words = QStringList::split(" ", s); + TQStringList words = TQStringList::split(" ", s); if ( words.count()==0 ) return ARG_ERROR; if ( words[0]=="command-list" || words[0]=="property-list" || words[0]=="range-list" || isPropertyList(words[0]) ) return static_cast
(_main)->list(words[0]); @@ -131,24 +131,24 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s) const CommandData *data = findCommandData(words[0]); if ( words[0]=="quit" ) return EXITING; if ( words[0]=="set" ) { - if ( words.count()==2 ) return static_cast
(_main)->executeSetCommand(words[1], QString::null); + if ( words.count()==2 ) return static_cast
(_main)->executeSetCommand(words[1], TQString()); if ( words.count()!=3 ) return errorExit(i18n("This command takes two arguments."), ARG_ERROR); return static_cast
(_main)->executeSetCommand(words[1], words[2]); } if ( words[0]=="unset" ) { if ( words.count()!=2 ) return errorExit(i18n("This command takes one argument."), ARG_ERROR); - return static_cast
(_main)->executeSetCommand(words[1], QString::null); + return static_cast
(_main)->executeSetCommand(words[1], TQString()); } if ( words[0]=="get" ) { if ( words.count()!=2 ) return errorExit(i18n("This command takes one argument."), ARG_ERROR); - QString s = static_cast
(_main)->executeGetCommand(words[1]); + TQString s = static_cast
(_main)->executeGetCommand(words[1]); if ( !s.isEmpty() ) log(Log::LineType::Normal, words[1] + ": " + s); return OK; } if ( words[0]=="help" ) return static_cast
(_main)->list("command-list"); if ( words[0]=="x" ) { if ( words.count()!=2 && words.count()!=3 ) return errorExit(i18n("This command takes one or two argument."), ARG_ERROR); - return executeRegister(words[1], words.count()==3 ? words[2] : QString::null); + return executeRegister(words[1], words.count()==3 ? words[2] : TQString()); } if ( words[0]=="break" ) { if ( words.count()==3 ) { @@ -158,11 +158,11 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s) if ( !ok ) return errorExit(i18n("Number format not recognized."), ARG_ERROR); PURL::Url dummy; Breakpoint::Data data(dummy, address); - if ( Breakpoint::list().contains(data) ) return okExit(i18n("Breakpoint already set at %1.").arg(toHexLabel(address, nbChars(NumberBase::Hex, address)))); + if ( Breakpoint::list().tqcontains(data) ) return okExit(i18n("Breakpoint already set at %1.").tqarg(toHexLabel(address, nbChars(NumberBase::Hex, address)))); Breakpoint::list().append(data); Breakpoint::list().setAddress(data, address); Breakpoint::list().setState(data, Breakpoint::Active); - return okExit(i18n("Breakpoint set at %1.").arg(toHexLabel(address, nbChars(NumberBase::Hex, address)))); + return okExit(i18n("Breakpoint set at %1.").tqarg(toHexLabel(address, nbChars(NumberBase::Hex, address)))); } return errorExit(i18n("The first argument should be \"e\"."), ARG_ERROR); } @@ -174,11 +174,11 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s) if (_device) nbc = _device->nbCharsAddress(); else for (uint i=0; iexit(OK); -#else - QCoreApplication::exit(OK); -#endif + tqApp->exit(OK); return; } - QTimer::singleShot(0, this, SLOT(displayPrompt())); + TQTimer::singleShot(0, this, TQT_SLOT(displayPrompt())); } CLI::ExitCode CLI::Interactive::registerList() @@ -246,11 +242,11 @@ CLI::ExitCode CLI::Interactive::registerList() const Coff::Object *coff = Debugger::manager->coff(); const Pic::RegistersData &rdata = data.registersData(); log(Log::LineType::Normal, i18n("Special Function Registers:")); - QValueVector list = Pic::sfrList(data); - for (uint i=0; i list = Pic::sfrList(data); + for (uint i=0; igroup().name()!="pic" ) return errorExit(i18n("No register."), NOT_SUPPORTED_ERROR); const Pic::Data &data = static_cast(*_device); const Pic::RegistersData &rdata = data.registersData(); - QValueVector list = Pic::variableList(data, *coff); + TQValueVector list = Pic::variableList(data, *coff); if ( list.count()==0 ) log(Log::LineType::Normal, i18n("No variable.")); - for (uint i=0; i(*_device); const Coff::Object *coff = Debugger::manager->coff(); @@ -279,15 +275,15 @@ Address CLI::Interactive::findRegisterAddress(const QString &name) if ( address>rdata.addressFromIndex(rdata.nbRegisters()-1) ) return Address(); return address; } - QValueVector sfrs = Pic::sfrList(data); + TQValueVector sfrs = Pic::sfrList(data); for (uint i=0; i variables = coff->variables(); - if ( variables.contains(name) ) return variables[name]; + TQMap variables = coff->variables(); + if ( variables.tqcontains(name) ) return variables[name]; return Address(); } -CLI::ExitCode CLI::Interactive::executeRegister(const QString &name, const QString &value) +CLI::ExitCode CLI::Interactive::executeRegister(const TQString &name, const TQString &value) { if ( Debugger::manager->debugger()==0 ) return errorExit(i18n("You need to start the debugging session first (with \"start\")."), ARG_ERROR); const Pic::Data &data = static_cast(*_device); @@ -296,7 +292,7 @@ CLI::ExitCode CLI::Interactive::executeRegister(const QString &name, const QStri bool ok; ulong v = fromAnyLabel(value, &ok); if ( !ok ) return errorExit(i18n("Number format not recognized."), ARG_ERROR); - if ( v>maxValue(NumberBase::Hex, nbChars) ) return errorExit(i18n("The given value is too large (max: %1).").arg(toHexLabel(maxValue(NumberBase::Hex, nbChars), nbChars)), ARG_ERROR); + if ( v>maxValue(NumberBase::Hex, nbChars) ) return errorExit(i18n("The given value is too large (max: %1).").tqarg(toHexLabel(maxValue(NumberBase::Hex, nbChars), nbChars)), ARG_ERROR); Register::TypeData rtd; if ( name.lower()=="w" || name.lower()=="wreg" ) rtd = static_cast(Debugger::manager->debugger())->deviceSpecific()->wregTypeData(); @@ -309,38 +305,32 @@ CLI::ExitCode CLI::Interactive::executeRegister(const QString &name, const QStri } if ( value.isEmpty() ) { if ( !Debugger::manager->readRegister(rtd) ) return ARG_ERROR; - return okExit(i18n("%1 = %2").arg(name.upper()).arg(toHexLabel(Register::list().value(rtd), nbChars))); + return okExit(i18n("%1 = %2").tqarg(name.upper()).tqarg(toHexLabel(Register::list().value(rtd), nbChars))); } return (Debugger::manager->writeRegister(rtd, v) ? OK : EXEC_ERROR); } -CLI::ExitCode CLI::Interactive::executeRawCommands(const QString &filename) +CLI::ExitCode CLI::Interactive::executeRawCommands(const TQString &filename) { - QFile file(filename); - if ( !file.open(IO_ReadOnly) ) return errorExit(i18n("Could not open filename \"%1\".").arg(filename), ARG_ERROR); + TQFile file(filename); + if ( !file.open(IO_ReadOnly) ) return errorExit(i18n("Could not open filename \"%1\".").tqarg(filename), ARG_ERROR); if ( Programmer::manager->programmer()==0 ) { Programmer::manager->createProgrammer(_device); if ( !Programmer::manager->programmer()->simpleConnectHardware() ) return EXEC_ERROR; } Programmer::Base *programmer = Programmer::manager->programmer(); for (;;) { - QString s; -#if QT_VERSION<0x040000 + TQString s; if ( file.readLine(s, 1000)==-1 ) break; -#else - char buffer[1000]; - if ( file.readLine(buffer, 1000)==-1 ) break; - s += buffer; -#endif bool write = !s.startsWith(" "); s = s.stripWhiteSpace(); if ( s.isEmpty() ) continue; if (write) { if ( !programmer->hardware()->rawWrite(s) ) return EXEC_ERROR; } else { - QString rs; + TQString rs; if ( !programmer->hardware()->rawRead(s.length(), rs) ) return EXEC_ERROR; - if ( rs!=s ) log(Log::LineType::Warning, i18n("Read string is different than expected: %1 (%2).").arg(rs).arg(s)); + if ( rs!=s ) log(Log::LineType::Warning, i18n("Read string is different than expected: %1 (%2).").tqarg(rs).tqarg(s)); } } return okExit(i18n("End of command file reached.")); -- cgit v1.2.3