diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-10-24 08:40:54 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-11-14 18:24:18 +0000 |
commit | b5613da1391789fe661063ab9d30850aa96efd59 (patch) | |
tree | d38dba0aefb774dd32268ec94bea5ddc0c9cea0d /src/app/qbs | |
parent | f40667f6fb026fa1747a1e330d6e397bf79435c7 (diff) |
STL compatibility: use front() instead of first()
This is a simple find and replace with manual sanity check.
Change-Id: I82f0eb38b6a5a3b75a4ed38d97bdb6ce164d09b3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/app/qbs')
-rw-r--r-- | src/app/qbs/commandlinefrontend.cpp | 32 | ||||
-rw-r--r-- | src/app/qbs/parser/commandlineparser.cpp | 10 | ||||
-rw-r--r-- | src/app/qbs/parser/parsercommand.cpp | 6 |
3 files changed, 24 insertions, 24 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp index 2a6dae2b6..2c4290c46 100644 --- a/src/app/qbs/commandlinefrontend.cpp +++ b/src/app/qbs/commandlinefrontend.cpp @@ -374,7 +374,7 @@ void CommandLineFrontend::handleProjectsResolved() qApp->exit(runShell()); break; case StatusCommandType: - qApp->exit(printStatus(m_projects.first().projectData())); + qApp->exit(printStatus(m_projects.front().projectData())); break; case GenerateCommandType: checkGeneratorName(); @@ -431,20 +431,20 @@ int CommandLineFrontend::runShell() case 0: // No specific product, use project-global environment. break; case 1: - productToRun = productsToUse().values().first().first(); + productToRun = productsToUse().values().front().front(); break; default: throw ErrorInfo(Tr::tr("The command '%1' cannot take more than one product.")); } - RunEnvironment runEnvironment = m_projects.first().getRunEnvironment(productToRun, - m_parser.installOptions(m_projects.first().profile()), + RunEnvironment runEnvironment = m_projects.front().getRunEnvironment(productToRun, + m_parser.installOptions(m_projects.front().profile()), QProcessEnvironment::systemEnvironment(), m_settings); return runEnvironment.doRunShell(); } BuildOptions CommandLineFrontend::buildOptions(const Project &project) const { - BuildOptions options = m_parser.buildOptions(m_projects.first().profile()); + BuildOptions options = m_parser.buildOptions(m_projects.front().profile()); if (options.maxJobCount() <= 0) { const QString profileName = project.profile(); QBS_CHECK(!profileName.isEmpty()); @@ -541,8 +541,8 @@ int CommandLineFrontend::runTarget() throw ErrorInfo(Tr::tr("Cannot run: Product '%1' is not an application.") .arg(productToRun.name())); } - RunEnvironment runEnvironment = m_projects.first().getRunEnvironment(productToRun, - m_parser.installOptions(m_projects.first().profile()), + RunEnvironment runEnvironment = m_projects.front().getRunEnvironment(productToRun, + m_parser.installOptions(m_projects.front().profile()), QProcessEnvironment::systemEnvironment(), m_settings); return runEnvironment.doRunTarget(executableFilePath, m_parser.runArgs()); } @@ -560,8 +560,8 @@ void CommandLineFrontend::dumpNodesTree() { QFile stdOut; stdOut.open(stdout, QIODevice::WriteOnly); - const ErrorInfo error = m_projects.first().dumpNodesTree(stdOut, productsToUse() - .value(m_projects.first())); + const ErrorInfo error = m_projects.front().dumpNodesTree(stdOut, productsToUse() + .value(m_projects.front())); if (error.hasError()) throw error; } @@ -615,8 +615,8 @@ ProductData CommandLineFrontend::getTheOneRunnableProduct() QBS_CHECK(m_projects.count() == 1); // Has been checked earlier. if (m_parser.products().count() == 1) { - foreach (const ProductData &p, m_projects.first().projectData().allProducts()) { - if (p.name() == m_parser.products().first()) + foreach (const ProductData &p, m_projects.front().projectData().allProducts()) { + if (p.name() == m_parser.products().front()) return p; } QBS_CHECK(false); @@ -624,13 +624,13 @@ ProductData CommandLineFrontend::getTheOneRunnableProduct() QBS_CHECK(m_parser.products().count() == 0); QList<ProductData> runnableProducts; - foreach (const ProductData &p, m_projects.first().projectData().allProducts()) { + foreach (const ProductData &p, m_projects.front().projectData().allProducts()) { if (p.isRunnable()) runnableProducts << p; } if (runnableProducts.count() == 1) - return runnableProducts.first(); + return runnableProducts.front(); if (runnableProducts.isEmpty()) { throw ErrorInfo(Tr::tr("Cannot execute command '%1': Project has no runnable product.") @@ -642,7 +642,7 @@ ProductData CommandLineFrontend::getTheOneRunnableProduct() error.append(Tr::tr("Use the '--products' option with one of the following products:")); foreach (const ProductData &p, runnableProducts) { QString productRepr = QLatin1String("\t") + p.name(); - if (p.profile() != m_projects.first().profile()) { + if (p.profile() != m_projects.front().profile()) { productRepr.append(QLatin1String(" [")).append(p.profile()) .append(QLatin1Char(']')); } @@ -654,7 +654,7 @@ ProductData CommandLineFrontend::getTheOneRunnableProduct() void CommandLineFrontend::install() { Q_ASSERT(m_projects.count() == 1); - const Project project = m_projects.first(); + const Project project = m_projects.front(); InstallJob *installJob; if (m_parser.products().isEmpty()) { const Project::ProductSelection productSelection = m_parser.withNonDefaultProducts() @@ -662,7 +662,7 @@ void CommandLineFrontend::install() installJob = project.installAllProducts(m_parser.installOptions(project.profile()), productSelection); } else { - const Project project = m_projects.first(); + const Project project = m_projects.front(); const ProductMap products = productsToUse(); installJob = project.installSomeProducts(products.value(project), m_parser.installOptions(project.profile())); diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp index 434ddf126..c223ea735 100644 --- a/src/app/qbs/parser/commandlineparser.cpp +++ b/src/app/qbs/parser/commandlineparser.cpp @@ -321,16 +321,16 @@ void CommandLineParser::CommandLineParserPrivate::doParse() if (commandLine.isEmpty()) { // No command given, use default. command = commandPool.getCommand(BuildCommandType); } else { - command = commandFromString(commandLine.first()); + command = commandFromString(commandLine.front()); if (command) { commandLine.removeFirst(); } else { // No command given. - if (commandLine.first() == QLatin1String("-h") - || commandLine.first() == QLatin1String("--help")) { + if (commandLine.front() == QLatin1String("-h") + || commandLine.front() == QLatin1String("--help")) { command = commandPool.getCommand(HelpCommandType); commandLine.takeFirst(); - } else if (commandLine.first() == QLatin1String("-V") - || commandLine.first() == QLatin1String("--version")) { + } else if (commandLine.front() == QLatin1String("-V") + || commandLine.front() == QLatin1String("--version")) { command = commandPool.getCommand(VersionCommandType); commandLine.takeFirst(); } else { diff --git a/src/app/qbs/parser/parsercommand.cpp b/src/app/qbs/parser/parsercommand.cpp index dd07f2cce..7bf147cea 100644 --- a/src/app/qbs/parser/parsercommand.cpp +++ b/src/app/qbs/parser/parsercommand.cpp @@ -101,7 +101,7 @@ QList<CommandLineOption::Type> Command::actualSupportedOptions() const void Command::parseOption(QStringList &input) { - const QString optionString = input.first(); + const QString optionString = input.front(); QBS_CHECK(optionString.startsWith(QLatin1Char('-'))); input.removeFirst(); if (optionString.count() == 1) @@ -148,7 +148,7 @@ void Command::parseOption(QStringList &input) void Command::parseNext(QStringList &input) { QBS_CHECK(!input.empty()); - if (input.first().startsWith(QLatin1Char('-'))) + if (input.front().startsWith(QLatin1Char('-'))) parseOption(input); else parsePropertyAssignment(input.takeFirst()); @@ -392,7 +392,7 @@ QList<CommandLineOption::Type> RunCommand::supportedOptions() const void RunCommand::parseNext(QStringList &input) { QBS_CHECK(!input.empty()); - if (input.first() != QLatin1String("--")) { + if (input.front() != QLatin1String("--")) { Command::parseNext(input); return; } |