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/common/cli | |
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/common/cli')
-rw-r--r-- | src/common/cli/cli_global.cpp | 8 | ||||
-rw-r--r-- | src/common/cli/cli_global.h | 6 | ||||
-rw-r--r-- | src/common/cli/cli_log.cpp | 30 | ||||
-rw-r--r-- | src/common/cli/cli_log.h | 10 | ||||
-rw-r--r-- | src/common/cli/cli_main.cpp | 22 | ||||
-rw-r--r-- | src/common/cli/cli_main.h | 25 | ||||
-rw-r--r-- | src/common/cli/cli_pfile.cpp | 6 |
7 files changed, 46 insertions, 61 deletions
diff --git a/src/common/cli/cli_global.cpp b/src/common/cli/cli_global.cpp index 4d58bdd..b30aaee 100644 --- a/src/common/cli/cli_global.cpp +++ b/src/common/cli/cli_global.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ #include "cli_global.h" -#include <qdir.h> +#include <tqdir.h> #include "common/global/purl.h" #include "cli_log.h" @@ -18,14 +18,14 @@ bool CLI::_isInteractive = false; CLI::View *CLI::_view = 0; CLI::MainBase *CLI::_main = 0; -CLI::ExitCode CLI::errorExit(const QString &message, ExitCode code) +CLI::ExitCode CLI::errorExit(const TQString &message, ExitCode code) { Q_ASSERT( code!=OK ); _view->log(Log::LineType::SoftError, message); return code; } -CLI::ExitCode CLI::okExit(const QString &message) +CLI::ExitCode CLI::okExit(const TQString &message) { _view->log(Log::LineType::Information, message); return OK; @@ -33,5 +33,5 @@ CLI::ExitCode CLI::okExit(const QString &message) PURL::Directory CLI::runDirectory() { - return PURL::Directory(QDir::currentDirPath()); + return PURL::Directory(TQDir::currentDirPath()); } diff --git a/src/common/cli/cli_global.h b/src/common/cli/cli_global.h index b90f36e..e89c1e7 100644 --- a/src/common/cli/cli_global.h +++ b/src/common/cli/cli_global.h @@ -9,7 +9,7 @@ #ifndef CLI_GLOBAL_H #define CLI_GLOBAL_H -#include <qstring.h> +#include <tqstring.h> namespace PURL { class Directory; } namespace CLI @@ -19,8 +19,8 @@ class View; class MainBase; enum ExitCode { EXITING = 1, OK = 0, ARG_ERROR = -1, NOT_SUPPORTED_ERROR = -2, FILE_ERROR = -3, EXEC_ERROR = -4 }; -extern ExitCode errorExit(const QString &message, ExitCode code); -extern ExitCode okExit(const QString &message); +extern ExitCode errorExit(const TQString &message, ExitCode code); +extern ExitCode okExit(const TQString &message); extern PURL::Directory runDirectory(); extern bool _force; diff --git a/src/common/cli/cli_log.cpp b/src/common/cli/cli_log.cpp index 603d5f8..948675b 100644 --- a/src/common/cli/cli_log.cpp +++ b/src/common/cli/cli_log.cpp @@ -11,53 +11,37 @@ #include "common/global/global.h" #include "cli_global.h" -void CLI::View::doLog(Log::LineType type, const QString &text, Log::Action) +void CLI::View::doLog(Log::LineType type, const TQString &text, Log::Action) { - QString s = text + "\n"; + TQString s = text + "\n"; switch (type.type()) { case Log::LineType::Error: case Log::LineType::SoftError: s = "Error: " + s; break; case Log::LineType::Warning: s = "Warning: " + s; break; default: break; } -#if QT_VERSION<0x040000 if ( type==Log::LineType::Error || type==Log::LineType::SoftError ) fprintf(stderr, "%s", s.latin1()); else fprintf(stdout, "%s", s.latin1()); -#else - QByteArray ba = s.toLatin1(); - if ( type==Log::LineType::Error || type==Log::LineType::SoftError ) fprintf(stderr, "%s", ba.constData()); - else fprintf(stdout, "%s", ba.constData()); -#endif } -void CLI::View::doLog(Log::DebugLevel, const QString &text, Log::Action) +void CLI::View::doLog(Log::DebugLevel, const TQString &text, Log::Action) { - QString s = text + "\n"; -#if QT_VERSION<0x040000 + TQString s = text + "\n"; fprintf(stdout, "%s", s.latin1()); -#else - QByteArray ba = s.toLatin1(); - fprintf(stdout, "%s", ba.constData()); -#endif } -void CLI::View::appendToLastLine(const QString &text) +void CLI::View::appendToLastLine(const TQString &text) { -#if QT_VERSION<0x040000 fprintf(stdout, "%s", text.latin1()); -#else - QByteArray ba = text.toLatin1(); - fprintf(stdout, "%s", ba.constData()); -#endif } -void CLI::View::sorry(const QString &message, const QString &details) +void CLI::View::sorry(const TQString &message, const TQString &details) { if ( details.isEmpty() ) log(Log::LineType::Error, message, Log::Immediate); else log(Log::LineType::Error, message + " (" + details + ")", Log::Immediate); } -bool CLI::View::askContinue(const QString &message) +bool CLI::View::askContinue(const TQString &message) { log(Log::LineType::Warning, message + " " + (_force ? i18n("*yes*") : i18n("*no*")), Log::Immediate); if (_force) return true; diff --git a/src/common/cli/cli_log.h b/src/common/cli/cli_log.h index 2fa83dc..7585b05 100644 --- a/src/common/cli/cli_log.h +++ b/src/common/cli/cli_log.h @@ -17,15 +17,15 @@ namespace CLI class View : public Log::View { public: - virtual void appendToLastLine(const QString &text); + virtual void appendToLastLine(const TQString &text); virtual void clear() {} - virtual void sorry(const QString &message, const QString &details); - virtual bool askContinue(const QString &message); + virtual void sorry(const TQString &message, const TQString &details); + virtual bool askContinue(const TQString &message); virtual void logUserAbort(); private: - virtual void doLog(Log::LineType type, const QString &text, Log::Action action); - virtual void doLog(Log::DebugLevel level, const QString &text, Log::Action action); + virtual void doLog(Log::LineType type, const TQString &text, Log::Action action); + virtual void doLog(Log::DebugLevel level, const TQString &text, Log::Action action); }; } // namespace diff --git a/src/common/cli/cli_main.cpp b/src/common/cli/cli_main.cpp index 7d75dbb..11537a7 100644 --- a/src/common/cli/cli_main.cpp +++ b/src/common/cli/cli_main.cpp @@ -12,7 +12,7 @@ #include "common/global/about.h" //----------------------------------------------------------------------------- -const CLI::CommandData *CLI::findCommandData(const QString &command) +const CLI::CommandData *CLI::findCommandData(const TQString &command) { for (uint i=0; NORMAL_COMMAND_DATA[i].name; i++) if ( NORMAL_COMMAND_DATA[i].name==command ) return &NORMAL_COMMAND_DATA[i]; @@ -22,23 +22,23 @@ const CLI::CommandData *CLI::findCommandData(const QString &command) return 0; } -CLI::ExitCode CLI::findCommand(const QString &s) +CLI::ExitCode CLI::findCommand(const TQString &s) { if ( s.isEmpty() ) return errorExit(i18n("No command specified"), ARG_ERROR); const CommandData *data = findCommandData(s); - if ( data==0 ) return errorExit(i18n("Unknown command: %1").arg(s), ARG_ERROR); + if ( data==0 ) return errorExit(i18n("Unknown command: %1").tqarg(s), ARG_ERROR); return OK; } //----------------------------------------------------------------------------- -bool CLI::isPropertyList(const QString &s) +bool CLI::isPropertyList(const TQString &s) { for (uint i=0; PROPERTY_DATA[i].name; i++) if ( s==PROPERTY_DATA[i].list ) return true; return false; } -bool CLI::isProperty(const QString &s) +bool CLI::isProperty(const TQString &s) { for (uint i=0; PROPERTY_DATA[i].name; i++) if ( s==PROPERTY_DATA[i].name ) return true; @@ -112,7 +112,7 @@ CLI::ExitCode CLI::propertyList() //----------------------------------------------------------------------------- CLI::MainBase::MainBase(Properties properties) - : QObject(0, "main"), _properties(properties) + : TQObject(0, "main"), _properties(properties) { Q_ASSERT( _main==0 ); _main = this; @@ -136,7 +136,7 @@ CLI::OptionList CLI::MainBase::optionList(const char *fileDescription) const opt.description = 0; opt.def = 0; if ( PROPERTY_DATA[i].help==0 ) { - Q_ASSERT( QString(PROPERTY_DATA[i].name)!=PROPERTY_DATA[i].optName ); + Q_ASSERT( TQString(PROPERTY_DATA[i].name)!=PROPERTY_DATA[i].optName ); opt.name = PROPERTY_DATA[i].name; // alias list.append(opt); } else { @@ -164,7 +164,7 @@ CLI::OptionList CLI::MainBase::optionList(const char *fileDescription) const return list; } -CLI::ExitCode CLI::MainBase::list(const QString &command) +CLI::ExitCode CLI::MainBase::list(const TQString &command) { if ( command=="command-list" ) return commandList(); if ( command=="property-list" ) return propertyList(); @@ -179,10 +179,10 @@ CLI::ExitCode CLI::MainBase::doRun() for (uint i=0; PROPERTY_DATA[i].name; i++) { if ( PROPERTY_DATA[i].optName==0 ) continue; // alias or interactive only if ( !_args->isSet(PROPERTY_DATA[i].name) ) continue; - QString option = _args->getOption(PROPERTY_DATA[i].name); + TQString option = _args->getOption(PROPERTY_DATA[i].name); ExitCode code = executeSetCommand(PROPERTY_DATA[i].name, option); if ( code!=OK ) return code; - log(Log::LineType::Information, QString("%1: %2").arg(PROPERTY_DATA[i].name).arg(executeGetCommand(PROPERTY_DATA[i].name))); + log(Log::LineType::Information, TQString("%1: %2").tqarg(PROPERTY_DATA[i].name).tqarg(executeGetCommand(PROPERTY_DATA[i].name))); } // process default lists @@ -197,7 +197,7 @@ CLI::ExitCode CLI::MainBase::doRun() if ( code!=OK || interactive ) return code; // find command - QString command = _args->getOption("command"); + TQString command = _args->getOption("command"); code = findCommand(command); if ( code!=OK ) return code; diff --git a/src/common/cli/cli_main.h b/src/common/cli/cli_main.h index 9b54c70..b0d71cb 100644 --- a/src/common/cli/cli_main.h +++ b/src/common/cli/cli_main.h @@ -17,8 +17,8 @@ namespace CLI { //----------------------------------------------------------------------------- enum Property { NoProperty = 0, HasForce = 1, HasInteractiveMode = 2 }; -Q_DECLARE_FLAGS(Properties, Property) -Q_DECLARE_OPERATORS_FOR_FLAGS(Properties) +TQ_DECLARE_FLAGS(Properties, Property) +TQ_DECLARE_OPERATORS_FOR_FLAGS(Properties) extern const KCmdLineOptions OPTIONS[]; //----------------------------------------------------------------------------- @@ -29,8 +29,8 @@ struct CommandData { }; extern const CommandData NORMAL_COMMAND_DATA[]; extern const CommandData INTERACTIVE_COMMAND_DATA[]; -extern const CommandData *findCommandData(const QString &command); -extern ExitCode findCommand(const QString &s); +extern const CommandData *findCommandData(const TQString &command); +extern ExitCode findCommand(const TQString &s); extern ExitCode commandList(); //----------------------------------------------------------------------------- @@ -39,8 +39,8 @@ struct PropertyData const char *name, *optName, *alias, *help, *list, *listHelp; }; extern const PropertyData PROPERTY_DATA[]; -extern bool isPropertyList(const QString &s); -extern bool isProperty(const QString &s); +extern bool isPropertyList(const TQString &s); +extern bool isProperty(const TQString &s); extern ExitCode propertyList(); //----------------------------------------------------------------------------- @@ -55,18 +55,19 @@ private: }; //----------------------------------------------------------------------------- -class MainBase : public QObject, public Log::Base +class MainBase : public TQObject, public Log::Base { Q_OBJECT + TQ_OBJECT public: MainBase(Properties properties); virtual OptionList optionList(const char *fileDescription) const; virtual ExitCode doRun(); - virtual ExitCode list(const QString &listName); - virtual ExitCode prepareCommand(const QString &command) = 0; - virtual ExitCode executeCommand(const QString &command) = 0; - virtual ExitCode executeSetCommand(const QString &property, const QString &value) = 0; - virtual QString executeGetCommand(const QString &property) = 0; + virtual ExitCode list(const TQString &listName); + virtual ExitCode prepareCommand(const TQString &command) = 0; + virtual ExitCode executeCommand(const TQString &command) = 0; + virtual ExitCode executeSetCommand(const TQString &property, const TQString &value) = 0; + virtual TQString executeGetCommand(const TQString &property) = 0; protected: Properties _properties; diff --git a/src/common/cli/cli_pfile.cpp b/src/common/cli/cli_pfile.cpp index 96add3a..e984e52 100644 --- a/src/common/cli/cli_pfile.cpp +++ b/src/common/cli/cli_pfile.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ #include "common/global/pfile.h" -#include <qfile.h> +#include <tqfile.h> //----------------------------------------------------------------------------- bool PURL::File::openForWrite() @@ -17,7 +17,7 @@ bool PURL::File::openForWrite() _file->setName(url().filepath()); if ( !_file->open(IO_WriteOnly) ) { _error = i18n("Could not open file for writing."); - _log.sorry(_error, i18n("File: %1").arg(_file->name())); + _log.sorry(_error, i18n("File: %1").tqarg(_file->name())); return false; } return true; @@ -35,7 +35,7 @@ bool PURL::File::openForRead() _file->setName(_url.filepath()); if ( !_file->open(IO_ReadOnly) ) { _error = i18n("Could not open file for reading."); - _log.sorry(_error, i18n("File: %1").arg(_file->name())); + _log.sorry(_error, i18n("File: %1").tqarg(_file->name())); return false; } return true; |