diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
commit | 0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 (patch) | |
tree | b95c0ca86c4876dd139af376b9f4afd8917cf0cd /src/piklab-prog/cmdline.cpp | |
parent | b79a2c28534cf09987eeeba3077fff9236df182a (diff) | |
download | piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.tar.gz piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.zip |
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
Diffstat (limited to 'src/piklab-prog/cmdline.cpp')
-rw-r--r-- | src/piklab-prog/cmdline.cpp | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/src/piklab-prog/cmdline.cpp b/src/piklab-prog/cmdline.cpp index 2ec4530..ec2cd38 100644 --- a/src/piklab-prog/cmdline.cpp +++ b/src/piklab-prog/cmdline.cpp @@ -15,7 +15,7 @@ # include <stdio.h> #endif #include <signal.h> -#include <qtimer.h> +#include <tqtimer.h> #include "devices/list/device_list.h" #include "devices/base/device_group.h" @@ -63,7 +63,7 @@ const KCmdLineOptions CLI::OPTIONS[] = { const Programmer::Group *CLI::_progGroup = 0; const Device::Data *CLI::_device = 0; HexBuffer::Format CLI::_format = HexBuffer::IHX32; -QString CLI::_port, CLI::_targetSelfPowered, CLI::_hardware; +TQString CLI::_port, CLI::_targetSelfPowered, CLI::_hardware; PURL::Directory CLI::_firmwareDir; PURL::Url CLI::_hexUrl, CLI::_coffUrl; Device::Memory *CLI::_memory = 0; @@ -74,7 +74,7 @@ CLI::ExitCode CLI::Main::formatList() { log(Log::LineType::Normal, i18n("Supported hex file formats:")); for (uint i=0; i<HexBuffer::Nb_Formats; i++) - log(Log::LineType::Normal, QString(" ") + HexBuffer::FORMATS[i]); + log(Log::LineType::Normal, TQString(" ") + HexBuffer::FORMATS[i]); return OK; } @@ -83,7 +83,7 @@ CLI::ExitCode CLI::Main::programmerList() log(Log::LineType::Normal, i18n("Supported programmers:")); Programmer::Lister::ConstIterator it; for (it=Programmer::lister().begin(); it!=Programmer::lister().end(); it++) - log(Log::LineType::Normal, " " + QString(it.data()->name())); + log(Log::LineType::Normal, " " + TQString(it.data()->name())); return OK; } @@ -96,8 +96,8 @@ CLI::ExitCode CLI::Main::hardwareList() if ( config==0 ) continue; FOR_EACH(PortType, type) { if ( !it.data()->isPortSupported(type) ) continue; - log(Log::LineType::Normal, "-" + QString(it.data()->name()) + " [" + type.label() + "]:"); - QStringList list = config->hardwareNames(type); + log(Log::LineType::Normal, "-" + TQString(it.data()->name()) + " [" + type.label() + "]:"); + TQStringList list = config->hardwareNames(type); for (uint k=0; k<uint(list.count()); k++) log(Log::LineType::Normal, " " + list[k]); } delete config; @@ -107,16 +107,16 @@ CLI::ExitCode CLI::Main::hardwareList() CLI::ExitCode CLI::Main::deviceList() { - QValueVector<QString> devices; + TQValueVector<TQString> devices; if ( _progGroup==0 ) { log(Log::LineType::Normal, i18n("Supported devices:")); devices = Programmer::lister().supportedDevices(); } else { - log(Log::LineType::Normal, i18n("Supported devices for \"%1\":").arg(_progGroup->label())); + log(Log::LineType::Normal, i18n("Supported devices for \"%1\":").tqarg(_progGroup->label())); devices = _progGroup->supportedDevices(); } qHeapSort(devices); - QString s; + TQString s; for (uint i=0; i<uint(devices.count()); i++) s += " " + devices[i]; log(Log::LineType::Normal, s + "\n"); return OK; @@ -124,16 +124,16 @@ CLI::ExitCode CLI::Main::deviceList() CLI::ExitCode CLI::Main::portList() { - if (_progGroup) log(Log::LineType::Normal, i18n("Detected ports supported by \"%1\":").arg(_progGroup->label())); + if (_progGroup) log(Log::LineType::Normal, i18n("Detected ports supported by \"%1\":").tqarg(_progGroup->label())); else log(Log::LineType::Normal, i18n("Detected ports:")); FOR_EACH(PortType, type) { if ( _progGroup && !_progGroup->isPortSupported(type) ) continue; - QString s = "- " + type.label() + ":"; + TQString s = "- " + type.label() + ":"; if ( !Port::isAvailable(type) ) { log(Log::LineType::Normal, s + i18n(" support disabled.")); continue; } - QStringList list = Port::probedDeviceList(type); + TQStringList list = Port::probedDeviceList(type); if ( list.count()==0 ) log(Log::LineType::Normal, s + i18n(" no port detected.")); else { log(Log::LineType::Normal, s); @@ -146,11 +146,11 @@ CLI::ExitCode CLI::Main::portList() CLI::ExitCode CLI::Main::rangeList() { log(Log::LineType::Normal, i18n("Memory ranges for PIC/dsPIC devices:")); - FOR_EACH(Pic::MemoryRangeType, type) log(Log::LineType::Normal, QString(" %1").arg(type.key())); + FOR_EACH(Pic::MemoryRangeType, type) log(Log::LineType::Normal, TQString(" %1").tqarg(type.key())); return OK; } -CLI::ExitCode CLI::Main::prepareCommand(const QString &command) +CLI::ExitCode CLI::Main::prepareCommand(const TQString &command) { const CommandData *data = findCommandData(command); CommandProperties properties = static_cast<CommandProperties>(data->properties); @@ -167,12 +167,12 @@ CLI::ExitCode CLI::Main::prepareCommand(const QString &command) if ( properties & InputHex ) { if (_memory) { if ( !file.openForRead() ) return FILE_ERROR; - QStringList errors, warnings; + TQStringList errors, warnings; Device::Memory::WarningTypes warningTypes; if ( !_memory->load(file.stream(), errors, warningTypes, warnings) ) - return errorExit(i18n("Could not load hex file \"%1\".").arg(errors[0]), FILE_ERROR); + return errorExit(i18n("Could not load hex file \"%1\".").tqarg(errors[0]), FILE_ERROR); if ( warningTypes!=Device::Memory::NoWarning ) - log(Log::LineType::Warning, i18n("Hex file seems incompatible with device \"%1\".").arg(warnings.join(" "))); + log(Log::LineType::Warning, i18n("Hex file seems incompatible with device \"%1\".").tqarg(warnings.join(" "))); } } else if ( properties & OutputHex ) { if ( !_force && _hexUrl.exists() ) return errorExit(i18n("Output hex filename already exists."), FILE_ERROR); @@ -196,7 +196,7 @@ CLI::Main::~Main() delete _range; } -CLI::ExitCode CLI::Main::list(const QString &command) +CLI::ExitCode CLI::Main::list(const TQString &command) { if ( MainBase::list(command)==OK ) return OK; if ( command=="format-list" ) return formatList(); @@ -226,12 +226,8 @@ CLI::ExitCode CLI::Main::prepareRun(bool &interactive) if (interactive) { _interactive = new Interactive(this); log(Log::LineType::Normal, i18n("Interactive mode: type help for help")); - log(Log::LineType::Normal, QString::null); -#if QT_VERSION<0x040000 - return ExitCode(qApp->exec()); -#else - return ExitCode(QCoreApplication::exec()); -#endif + log(Log::LineType::Normal, TQString()); + return ExitCode(tqApp->exec()); } // range @@ -242,7 +238,7 @@ CLI::ExitCode CLI::Main::prepareRun(bool &interactive) return OK; } -CLI::ExitCode CLI::Main::extractRange(const QString &range) +CLI::ExitCode CLI::Main::extractRange(const TQString &range) { delete _range; _range = 0; @@ -261,7 +257,7 @@ CLI::ExitCode CLI::Main::extractRange(const QString &range) return OK; } -CLI::ExitCode CLI::Main::executeCommand(const QString &command) +CLI::ExitCode CLI::Main::executeCommand(const TQString &command) { Programmer::Base *programmer = Programmer::manager->programmer(); if ( command=="connect" ) return (Programmer::manager->connectDevice() ? OK : EXEC_ERROR); @@ -303,7 +299,7 @@ CLI::ExitCode CLI::Main::executeCommand(const QString &command) PURL::File file(_hexUrl, *_view); if ( !file.openForWrite() ) return FILE_ERROR; if ( !_memory->save(file.stream(), _format) ) - return errorExit(i18n("Error while writing file \"%1\".").arg(_hexUrl.pretty()), FILE_ERROR); + return errorExit(i18n("Error while writing file \"%1\".").tqarg(_hexUrl.pretty()), FILE_ERROR); return OK; } if ( command=="erase" ) { @@ -332,25 +328,25 @@ CLI::ExitCode CLI::Main::checkProgrammer() if ( _progGroup->isSoftware() && _progGroup->supportedDevices().isEmpty() ) return errorExit(i18n("Please check installation of selected software debugger."), NOT_SUPPORTED_ERROR); if ( _device && !_progGroup->isSupported(_device->name()) ) - return errorExit(i18n("The selected device \"%1\" is not supported by the selected programmer.").arg(_device->name()), NOT_SUPPORTED_ERROR); + return errorExit(i18n("The selected device \"%1\" is not supported by the selected programmer.").tqarg(_device->name()), NOT_SUPPORTED_ERROR); if ( !_hardware.isEmpty() ) { ::Hardware::Config *config = _progGroup->hardwareConfig(); Port::Description pd = static_cast<Programmer::CliManager *>(Programmer::manager)->portDescription(); - bool ok = (config==0 || config->hardwareNames(pd.type).contains(_hardware)); + bool ok = (config==0 || config->hardwareNames(pd.type).tqcontains(_hardware)); delete config; - if ( !ok ) return errorExit(i18n("The selected programmer does not supported the specified hardware configuration (\"%1\").").arg(_hardware), NOT_SUPPORTED_ERROR); + if ( !ok ) return errorExit(i18n("The selected programmer does not supported the specified hardware configuration (\"%1\").").tqarg(_hardware), NOT_SUPPORTED_ERROR); } return OK; } -CLI::ExitCode CLI::Main::executeSetCommand(const QString &property, const QString &value) +CLI::ExitCode CLI::Main::executeSetCommand(const TQString &property, const TQString &value) { if ( property=="programmer" ) { _progGroup = 0; if ( value.isEmpty() ) return OK; _progGroup = Programmer::lister().group(value.lower()); if (_progGroup) return checkProgrammer(); - return errorExit(i18n("Unknown programmer \"%1\".").arg(value.lower()), ARG_ERROR); + return errorExit(i18n("Unknown programmer \"%1\".").tqarg(value.lower()), ARG_ERROR); } if ( property=="hardware" ) { _hardware = value; return OK; } if ( property=="device" || property=="processor" ) { @@ -358,10 +354,10 @@ CLI::ExitCode CLI::Main::executeSetCommand(const QString &property, const QStrin _device = 0; return OK; } - QString s = value.upper(); + TQString s = value.upper(); _device = Device::lister().data(s); Debugger::manager->updateDevice(); - if ( _device==0 ) return errorExit(i18n("Unknown device \"%1\".").arg(s), ARG_ERROR); + if ( _device==0 ) return errorExit(i18n("Unknown device \"%1\".").tqarg(s), ARG_ERROR); Debugger::manager->init(); return checkProgrammer(); } @@ -370,13 +366,13 @@ CLI::ExitCode CLI::Main::executeSetCommand(const QString &property, const QStrin _format = HexBuffer::IHX32; return OK; } - QString s = value.lower(); + TQString s = value.lower(); for (uint i=0; i<HexBuffer::Nb_Formats; i++) if ( s==HexBuffer::FORMATS[i] ) { _format = HexBuffer::Format(i); return OK; } - return errorExit(i18n("Unknown hex file format \"%1\".").arg(s), ARG_ERROR); + return errorExit(i18n("Unknown hex file format \"%1\".").tqarg(s), ARG_ERROR); } if ( property=="port" ) { _port = value; return OK; } if ( property=="firmware-dir" ) { _firmwareDir = value; return OK; } @@ -394,10 +390,10 @@ CLI::ExitCode CLI::Main::executeSetCommand(const QString &property, const QStrin if ( _device && !Debugger::manager->init() ) return ARG_ERROR; return OK; } - return errorExit(i18n("Unknown property \"%1\"").arg(property), ARG_ERROR); + return errorExit(i18n("Unknown property \"%1\"").tqarg(property), ARG_ERROR); } -QString CLI::Main::executeGetCommand(const QString &property) +TQString CLI::Main::executeGetCommand(const TQString &property) { if ( property=="programmer" ) { if ( _progGroup==0 ) return i18n("<not set>"); @@ -421,7 +417,7 @@ QString CLI::Main::executeGetCommand(const QString &property) if ( !_port.isEmpty() ) return _port; if ( _progGroup==0 ) return i18n("<not set>"); Port::Description pd = Programmer::GroupConfig::portDescription(*_progGroup); - QString s = pd.type.key(); + TQString s = pd.type.key(); if (pd.type.data().withDevice) s += " (" + pd.device + ")"; return s + " " + i18n("<from config>"); } @@ -432,7 +428,7 @@ QString CLI::Main::executeGetCommand(const QString &property) } if ( property=="target-self-powered" ) { if ( !_targetSelfPowered.isEmpty() ) return _targetSelfPowered; - return QString(readConfigEntry(Programmer::Config::TargetSelfPowered).toBool() ? "true" : "false") + " " + i18n("<from config>"); + return TQString(readConfigEntry(Programmer::Config::TargetSelfPowered).toBool() ? "true" : "false") + " " + i18n("<from config>"); } if ( property=="hex" ) { if ( !_hexUrl.isEmpty() ) return _hexUrl.pretty(); @@ -442,8 +438,8 @@ QString CLI::Main::executeGetCommand(const QString &property) if ( !_coffUrl.isEmpty() ) return _coffUrl.pretty(); return i18n("<not set>"); } - log(Log::LineType::SoftError, i18n("Unknown property \"%1\"").arg(property)); - return QString::null; + log(Log::LineType::SoftError, i18n("Unknown property \"%1\"").tqarg(property)); + return TQString(); } //----------------------------------------------------------------------------- |