diff --git a/src/cli/commandargument.h b/src/cli/commandargument.h index 821452d0..b9b01884 100644 --- a/src/cli/commandargument.h +++ b/src/cli/commandargument.h @@ -18,7 +18,7 @@ #ifndef COMMANDARGUMENT_H #define COMMANDARGUMENT_H -#include +#include class CommandArgument { diff --git a/src/cli/commandlineparser.cpp b/src/cli/commandlineparser.cpp index 2a796857..78b663ad 100644 --- a/src/cli/commandlineparser.cpp +++ b/src/cli/commandlineparser.cpp @@ -102,8 +102,15 @@ bool CommandLineParser::processArgs(const QStringList &args, { QString argument = *actualIt; bool ok = true; - if (actualNode->subNodes.contains(argument)) { - actualNode = &(*actualNode->subNodes.find(argument)); + bool isValidArg = false; + for (Node &n: actualNode->subNodes) { + if (n.argument.name() == argument) { + actualNode = &n; + isValidArg = true; + break; + } + } + if (isValidArg) { auto nextArg = actualNode->argument; m_foundArgs.append(nextArg); // check next is help @@ -142,10 +149,11 @@ bool CommandLineParser::processOptions(const QStringList &args, arg.remove(0, 2) : arg.remove(0, 1); // get option - auto optionIt = actualNode->options.end(); - for (const QStringList &sl: actualNode->options.keys()) { - if (sl.contains(arg)) { - optionIt = actualNode->options.find(sl); + auto endIt = actualNode->options.cend(); + auto optionIt = endIt; + for (auto i = actualNode->options.cbegin(); i != endIt; ++i) { + if ((*i).names().contains(arg)) { + optionIt = i; break; } } @@ -254,7 +262,7 @@ bool CommandLineParser::AddArgument(const CommandArgument &arg, } else { Node child; child.argument = arg; - n->subNodes.insert(child.argument.name(), child); + n->subNodes.append(child); } return res; } @@ -267,7 +275,7 @@ bool CommandLineParser::AddOption(const CommandOption &option, if (n == nullptr) { res = false; } else { - n->options.insert(option.names(), option); + n->options.append(option); } return res; } @@ -333,7 +341,7 @@ void CommandLineParser::printHelp(QStringList args, const Node *node) { QList subArgs; for (const Node &n: node->subNodes) subArgs.append(n.argument); - auto modifiedOptions = node->options.values(); + auto modifiedOptions = node->options; if (m_withHelp) modifiedOptions << helpOption; if (m_withVersion && node == &m_parseTree) { diff --git a/src/cli/commandlineparser.h b/src/cli/commandlineparser.h index 4ed1fda4..0b59d10e 100644 --- a/src/cli/commandlineparser.h +++ b/src/cli/commandlineparser.h @@ -65,8 +65,8 @@ private: subNodes == n.subNodes; } CommandArgument argument; - QMap options; - QMap subNodes; + QList options; + QList subNodes; }; Node m_parseTree; diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 9811cde4..db0e8871 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -87,13 +87,13 @@ void Controller::enableTrayIcon() { return; } ConfigHandler().setDisabledTrayIcon(false); - QAction *configAction = new QAction(tr("&Configuration")); + QAction *configAction = new QAction(tr("&Configuration"), this); connect(configAction, &QAction::triggered, this, &Controller::openConfigWindow); - QAction *infoAction = new QAction(tr("&Information")); + QAction *infoAction = new QAction(tr("&Information"), this); connect(infoAction, &QAction::triggered, this, &Controller::openInfoWindow); - QAction *quitAction = new QAction(tr("&Quit")); + QAction *quitAction = new QAction(tr("&Quit"), this); connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); diff --git a/src/main.cpp b/src/main.cpp index 1bab3e2a..30d5e1a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include int main(int argc, char *argv[]) { @@ -190,8 +191,8 @@ int main(int argc, char *argv[]) { QString newFilename(parser.value(filenameOption)); config.setFilenamePattern(newFilename); FileNameHandler fh; - qInfo().noquote() << QString("The new pattern is '%1'\n" - "Parsed pattern example: %2").arg(newFilename) + QTextStream(stdout) << QString("The new pattern is '%1'\n" + "Parsed pattern example: %2\n").arg(newFilename) .arg(fh.parsedPattern()); } if (tray) {