QCommandLineOption: improve runtime warnings

Change-Id: I48a278acf3a8eb0cfa829deb65cf65dfd8ec23af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2013-08-31 00:32:30 +02:00 committed by The Qt Project
parent b508dc98a5
commit 32fa8ab704
2 changed files with 6 additions and 6 deletions

View File

@ -193,16 +193,16 @@ void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
{
names.clear();
if (nameList.isEmpty())
qWarning("Options must have at least one name");
qWarning("QCommandLineOption: Options must have at least one name");
foreach (const QString &name, nameList) {
if (name.isEmpty())
qWarning("Option names cannot be empty");
qWarning("QCommandLineOption: Option names cannot be empty");
else if (name.startsWith(QLatin1Char('-')))
qWarning("Option names cannot start with a '-'");
qWarning("QCommandLineOption: Option names cannot start with a '-'");
else if (name.startsWith(QLatin1Char('/')))
qWarning("Option names cannot start with a '/'");
qWarning("QCommandLineOption: Option names cannot start with a '/'");
else if (name.contains(QLatin1Char('=')))
qWarning("Option names cannot contain a '='");
qWarning("QCommandLineOption: Option names cannot contain a '='");
else
names.append(name);
}

View File

@ -98,7 +98,7 @@ void tst_QCommandLineParser::testInvalidOptions()
{
QCoreApplication app(empty_argc, empty_argv);
QCommandLineParser parser;
QTest::ignoreMessage(QtWarningMsg, "Option names cannot start with a '-'");
QTest::ignoreMessage(QtWarningMsg, "QCommandLineOption: Option names cannot start with a '-'");
parser.addOption(QCommandLineOption(QStringLiteral("-v"), QStringLiteral("Displays version information.")));
}