X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fcliparser.cpp;h=39be78b125cef87540b231bec3c50f3b7d7df848;hp=2116577db18c3e4f3650014b2740fe2601ae89a7;hb=c6a9c963d53a171394b5c25d9925661e2788cec3;hpb=965183188ee726036685fcba379c2559bd183247 diff --git a/src/common/cliparser.cpp b/src/common/cliparser.cpp index 2116577d..39be78b1 100644 --- a/src/common/cliparser.cpp +++ b/src/common/cliparser.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -24,41 +24,13 @@ #include #include -#ifdef HAVE_KDE -# include -#endif - -CliParser::CliParser() { +CliParser::CliParser() : AbstractCliParser() { } -#ifdef HAVE_KDE -void CliParser::addArgument(const QString &longName, const CliParserArg &arg) { - if(arg.shortName != 0) { - _cmdLineOptions.add(QByteArray().append(arg.shortName)); - } - _cmdLineOptions.add(longName.toUtf8(), ki18n(arg.help.toUtf8()), arg.def.toUtf8()); -} - -bool CliParser::init(const QStringList &) { - KCmdLineArgs::addCmdLineOptions(_cmdLineOptions); - return true; -} - -QString CliParser::value(const QString &longName) { - return KCmdLineArgs::parsedArgs()->getOption(longName.toUtf8()); -} - -bool CliParser::isSet(const QString &longName) { - return KCmdLineArgs::parsedArgs()->isSet(longName.toUtf8()); -} - -void CliParser::usage() { - KCmdLineArgs::usage(); -} - -#else -void CliParser::addArgument(const QString &longName, const CliParserArg &arg) { +void CliParser::addArgument(const QString &longName_, const CliParserArg &arg) { + QString longName = longName_; + longName.remove(QRegExp("\\s*<.*>\\s*")); // KCmdLineArgs takes args of the form "arg " if(argsHash.contains(longName)) qWarning() << "Warning: Multiple definition of argument" << longName; if(arg.shortName != 0 && !lnameOfShortArg(arg.shortName).isNull()) qWarning().nospace() << "Warning: Redefining shortName '" << arg.shortName << "' for " << longName << " previously defined for " << lnameOfShortArg(arg.shortName); @@ -212,7 +184,7 @@ void CliParser::usage() { if(arg.value().type == CliParserArg::CliArgOption && !arg.value().def.isNull()) { output.append(". Default is: ").append(arg.value().def); } - qWarning() << output.toLatin1(); + qWarning() << qPrintable(output); } } @@ -247,5 +219,3 @@ QString CliParser::lnameOfShortArg(const char arg) { } return QString(); } - -#endif