# HG changeset patch # User John Schneiderman # Date 1402762246 0 # Node ID 1a17dc71451019742cf20e964f3f58c41716705d # Parent d051e4094072d949c068d67f6db8791c443a4983 Added missing signal for options which take multiple values. ti: - diff -r d051e4094072 -r 1a17dc714510 src/UNIT_TESTS/qargsut.hpp --- a/src/UNIT_TESTS/qargsut.hpp Sat Jun 14 15:26:18 2014 +0000 +++ b/src/UNIT_TESTS/qargsut.hpp Sat Jun 14 16:10:46 2014 +0000 @@ -549,6 +549,7 @@ { const char* argvValue[5] = { shortValueTest, "1", "2", "3", "4" }; QArgs args(5, argvValue); + QSignalSpy valueSignal(&args, SIGNAL(argumentValues(QChar,QList))); args.addSupported('v', "values", "Multiple values short test.", true); try @@ -559,6 +560,15 @@ QVERIFY(2 == values.at(1)); QVERIFY(3 == values.at(2)); QVERIFY(4 == values.at(3)); + QVERIFY(valueSignal.isValid()); + QVERIFY(valueSignal.count() == 1); + QList< QVariant > arguments(valueSignal.takeAt(0)); + QVERIFY(arguments.count() == 2); + QVERIFY(arguments.at(0).toString() == "v"); + QVERIFY(arguments.at(1).toList().at(0) == "1"); + QVERIFY(arguments.at(1).toList().at(1) == "2"); + QVERIFY(arguments.at(1).toList().at(2) == "3"); + QVERIFY(arguments.at(1).toList().at(3) == "4"); } catch (runtime_error& error) { @@ -1246,7 +1256,6 @@ const char* argvValue[2] = { shortValueTest, "-2" }; QArgs args(2, argvValue); QSignalSpy valueSignal(&args, SIGNAL(argumentValue(QChar,qint32))); - args.addSupported('v', "value", "32-bit value short test", true); QVERIFY(static_cast(args.value('v', value)) == static_cast(-2)); diff -r d051e4094072 -r 1a17dc714510 src/qargs.h --- a/src/qargs.h Sat Jun 14 15:26:18 2014 +0000 +++ b/src/qargs.h Sat Jun 14 16:10:46 2014 +0000 @@ -205,6 +205,15 @@ * value is used. */ void argumentValue(const QChar& argument, const QString& value) const; + /** + * @brief Provided String Argument Values + * @details The signal that is fired when an argument is provided by a user + * with multiple consecutive values. + * + * @param[in] argument The short name option that was provided. + * @param[in] values The contents supplied by the user. + */ + void argumentValues(const QChar& argument, const QList& values) const; //} @@ -506,11 +515,12 @@ /** * @brief Argument Option Values * @details Provides access to the values from a short or long named - * argument supplied by the user from the command-line. In addition, all - * argument values provided by the user are verified for both being valid - * and required. The default support for the expected types are: signed - * integers, unsigned integers, single precision, double precision, - * characters, and strings. + * argument supplied by the user from the command-line. Once the value for + * the option is determined the signal for the argument values is fired. In + * addition, all argument values provided by the user are verified for both + * being valid and required. The default support for the expected types + * are: signed integers, unsigned integers, single precision, + * double precision, characters, and strings. * * @param[in] shortName The short-name of the argument option. * @param[in] defaultValue The value to use when an argument is not @@ -674,6 +684,14 @@ if (values.isEmpty()) values.append(defaultValue); + if (NULL != QCoreApplication::instance()) + { + QList suppliedValues; + for (auto value : values) + suppliedValues.append(value); + emit argumentValues(shortName, suppliedValues); + } + return values; }