forked from qt-creator/qt-creator
ProjectExplorer: Limit the usage of qMakePair
Make the code less verbose. Change-Id: If9fe08a6a7538d34c80ca97a2aec21a2bd6e5d22 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -207,7 +207,7 @@ public:
|
||||
virtual QVariantMap upgrade(const QVariantMap &data) = 0;
|
||||
|
||||
protected:
|
||||
using Change = QPair<QLatin1String,QLatin1String>;
|
||||
using Change = QPair<QLatin1String, QLatin1String>;
|
||||
QVariantMap renameKeys(const QList<Change> &changes, QVariantMap map) const;
|
||||
|
||||
private:
|
||||
|
@@ -306,9 +306,8 @@ private:
|
||||
parserCheckBoxes.clear();
|
||||
for (const CustomParserSettings &s : ProjectExplorerPlugin::customParsers()) {
|
||||
const auto checkBox = new QCheckBox(s.displayName, this);
|
||||
connect(checkBox, &QCheckBox::stateChanged,
|
||||
this, &SelectionWidget::selectionChanged);
|
||||
parserCheckBoxes << qMakePair(checkBox, s.id);
|
||||
connect(checkBox, &QCheckBox::stateChanged, this, &SelectionWidget::selectionChanged);
|
||||
parserCheckBoxes.push_back({checkBox, s.id});
|
||||
layout->addWidget(checkBox);
|
||||
}
|
||||
setSelectedParsers(parsers);
|
||||
|
@@ -236,7 +236,7 @@ static void dirEntries(QFutureInterface<ResultType> &futureInterface, const File
|
||||
for (const FilePath &entry : entries) {
|
||||
if (futureInterface.isCanceled())
|
||||
return;
|
||||
result.append(qMakePair(entry, fileType(entry)));
|
||||
result.push_back({entry, fileType(entry)});
|
||||
}
|
||||
futureInterface.reportResult(result);
|
||||
}
|
||||
|
@@ -616,7 +616,7 @@ HeaderPaths GccToolChain::builtInHeaderPaths(const Utils::Environment &env,
|
||||
if (!originalTargetTriple.isEmpty())
|
||||
arguments << "-target" << originalTargetTriple;
|
||||
|
||||
const std::optional<HeaderPaths> cachedPaths = headerCache->check(qMakePair(env, arguments));
|
||||
const std::optional<HeaderPaths> cachedPaths = headerCache->check({env, arguments});
|
||||
if (cachedPaths)
|
||||
return cachedPaths.value();
|
||||
|
||||
@@ -624,7 +624,7 @@ HeaderPaths GccToolChain::builtInHeaderPaths(const Utils::Environment &env,
|
||||
arguments,
|
||||
env);
|
||||
extraHeaderPathsFunction(paths);
|
||||
headerCache->insert(qMakePair(env, arguments), paths);
|
||||
headerCache->insert({env, arguments}, paths);
|
||||
|
||||
qCDebug(gccLog) << "Reporting header paths to code model:";
|
||||
for (const HeaderPath &hp : qAsConst(paths)) {
|
||||
|
@@ -1532,8 +1532,7 @@ KitAspectWidget *EnvironmentKitAspect::createConfigWidget(Kit *k) const
|
||||
|
||||
KitAspect::ItemList EnvironmentKitAspect::toUserOutput(const Kit *k) const
|
||||
{
|
||||
return { qMakePair(tr("Environment"),
|
||||
EnvironmentItem::toStringList(environmentChanges(k)).join("<br>")) };
|
||||
return {{tr("Environment"), EnvironmentItem::toStringList(environmentChanges(k)).join("<br>")}};
|
||||
}
|
||||
|
||||
Id EnvironmentKitAspect::id()
|
||||
|
@@ -19,7 +19,7 @@ static QPair<FilePath, int> parseFileName(const QString &input)
|
||||
{
|
||||
QString fileName = input;
|
||||
if (fileName.startsWith("LINK") || fileName.startsWith("cl"))
|
||||
return qMakePair(FilePath(), -1);
|
||||
return {{}, -1};
|
||||
|
||||
// Extract linenumber (if it is there):
|
||||
int linenumber = -1;
|
||||
@@ -39,7 +39,7 @@ static QPair<FilePath, int> parseFileName(const QString &input)
|
||||
}
|
||||
}
|
||||
const QString normalized = FileUtils::normalizedPathName(fileName);
|
||||
return qMakePair(FilePath::fromUserInput(normalized), linenumber);
|
||||
return {FilePath::fromUserInput(normalized), linenumber};
|
||||
}
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
@@ -3247,7 +3247,7 @@ QList<QPair<CommandLine, ProcessHandle>> ProjectExplorerPlugin::runningRunContro
|
||||
const QList<RunControl *> runControls = allRunControls();
|
||||
for (RunControl *rc : runControls) {
|
||||
if (rc->isRunning())
|
||||
processes << qMakePair(rc->commandLine(), rc->applicationProcessHandle());
|
||||
processes.push_back({rc->commandLine(), rc->applicationProcessHandle()});
|
||||
}
|
||||
return processes;
|
||||
}
|
||||
@@ -3420,7 +3420,7 @@ void ProjectExplorerPluginPrivate::addToRecentProjects(const FilePath &filePath,
|
||||
|
||||
if (m_recentProjects.count() > m_maxRecentProjects)
|
||||
m_recentProjects.removeLast();
|
||||
m_recentProjects.prepend(qMakePair(filePath, displayName));
|
||||
m_recentProjects.push_front({filePath, displayName});
|
||||
m_lastOpenDirectory = filePath.absolutePath();
|
||||
emit m_instance->recentProjectsChanged();
|
||||
}
|
||||
@@ -3947,10 +3947,10 @@ void ProjectExplorerPluginPrivate::removeFile()
|
||||
|
||||
const FilePath filePath = currentNode->filePath();
|
||||
using NodeAndPath = QPair<const Node *, FilePath>;
|
||||
QList<NodeAndPath> filesToRemove{qMakePair(currentNode, currentNode->filePath())};
|
||||
QList<NodeAndPath> filesToRemove{{currentNode, currentNode->filePath()}};
|
||||
QList<NodeAndPath> siblings;
|
||||
for (const Node * const n : ProjectTree::siblingsWithSameBaseName(currentNode))
|
||||
siblings << qMakePair(n, n->filePath());
|
||||
siblings.push_back({n, n->filePath()});
|
||||
|
||||
RemoveFileDialog removeFileDialog(filePath, ICore::dialogParent());
|
||||
if (removeFileDialog.exec() != QDialog::Accepted)
|
||||
|
@@ -486,7 +486,7 @@ void RunSettingsWidget::addSubWidget(QWidget *widget, QLabel *label)
|
||||
l->addWidget(label, l->rowCount(), 0, 1, -1);
|
||||
l->addWidget(widget, l->rowCount(), 0, 1, -1);
|
||||
|
||||
m_subWidgets.append(qMakePair(widget, label));
|
||||
m_subWidgets.push_back({widget, label});
|
||||
}
|
||||
|
||||
void RunSettingsWidget::removeSubWidgets()
|
||||
|
@@ -635,7 +635,7 @@ QStringList SessionManagerPrivate::dependenciesOrder() const
|
||||
return p->projectFilePath().toString() == proPath;
|
||||
});
|
||||
});
|
||||
unordered << qMakePair(proName, depList);
|
||||
unordered.push_back({proName, depList});
|
||||
}
|
||||
|
||||
while (!unordered.isEmpty()) {
|
||||
|
@@ -338,7 +338,7 @@ void TargetSetupWidget::reportIssues(int index)
|
||||
QPair<Task::TaskType, QString> TargetSetupWidget::findIssues(const BuildInfo &info)
|
||||
{
|
||||
if (m_projectPath.isEmpty() || !info.factory)
|
||||
return qMakePair(Task::Unknown, QString());
|
||||
return {Task::Unknown, {}};
|
||||
|
||||
QString buildDir = info.buildDirectory.toString();
|
||||
Tasks issues;
|
||||
@@ -364,7 +364,7 @@ QPair<Task::TaskType, QString> TargetSetupWidget::findIssues(const BuildInfo &in
|
||||
}
|
||||
if (!text.isEmpty())
|
||||
text = QLatin1String("<nobr>") + text;
|
||||
return qMakePair(highestType, text);
|
||||
return {highestType, text};
|
||||
}
|
||||
|
||||
TargetSetupWidget::BuildInfoStore::~BuildInfoStore()
|
||||
|
@@ -930,7 +930,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
+ startOffset, positions.top() + linePos.y());
|
||||
const QSize linkSize(endOffset - startOffset, linkLine.height());
|
||||
const QRectF linkRect(linkPos, linkSize);
|
||||
m_hrefs << qMakePair(linkRect, range.format.anchorHref());
|
||||
m_hrefs.push_back({linkRect, range.format.anchorHref()});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -596,7 +596,7 @@ static QPair<QString, QString> rawIdData(const QVariantMap &data)
|
||||
const QString raw = data.value(QLatin1String(ID_KEY)).toString();
|
||||
const int pos = raw.indexOf(QLatin1Char(':'));
|
||||
QTC_ASSERT(pos > 0, return qMakePair(QString::fromLatin1("unknown"), QString::fromLatin1("unknown")));
|
||||
return qMakePair(raw.mid(0, pos), raw.mid(pos + 1));
|
||||
return {raw.mid(0, pos), raw.mid(pos + 1)};
|
||||
}
|
||||
|
||||
QByteArray ToolChainFactory::idFromMap(const QVariantMap &data)
|
||||
|
@@ -157,7 +157,7 @@ public:
|
||||
autoRoot->appendChild(autoNode);
|
||||
manualRoot->appendChild(manualNode);
|
||||
|
||||
m_languageMap.insert(l, qMakePair(autoNode, manualNode));
|
||||
m_languageMap.insert(l, {autoNode, manualNode});
|
||||
}
|
||||
|
||||
m_model.rootItem()->appendChild(autoRoot);
|
||||
|
@@ -27,6 +27,8 @@ using namespace Utils;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
using StringVariantPair = std::pair<const QString, QVariant>;
|
||||
|
||||
namespace {
|
||||
|
||||
const char OBSOLETE_VERSION_KEY[] = "ProjectExplorer.Project.Updater.FileVersion";
|
||||
@@ -331,13 +333,13 @@ UserFileAccessor::merge(const MergingSettingsAccessor::SettingsMergeData &global
|
||||
return std::nullopt;
|
||||
|
||||
if (isHouseKeepingKey(key) || global.key == USER_STICKY_KEYS_KEY)
|
||||
return qMakePair(key, mainValue);
|
||||
return {{key, mainValue}};
|
||||
|
||||
if (!stickyKeys.contains(global.key) && secondaryValue != mainValue && !secondaryValue.isNull())
|
||||
return qMakePair(key, secondaryValue);
|
||||
return {{key, secondaryValue}};
|
||||
if (!mainValue.isNull())
|
||||
return qMakePair(key, mainValue);
|
||||
return qMakePair(key, secondaryValue);
|
||||
return {{key, mainValue}};
|
||||
return {{key, secondaryValue}};
|
||||
}
|
||||
|
||||
// When saving settings...
|
||||
@@ -360,7 +362,7 @@ SettingsMergeFunction UserFileAccessor::userStickyTrackerFunction(QStringList &s
|
||||
return std::nullopt;
|
||||
|
||||
if (isHouseKeepingKey(key))
|
||||
return qMakePair(key, main);
|
||||
return {{key, main}};
|
||||
|
||||
// Ignore house keeping keys:
|
||||
if (key == USER_STICKY_KEYS_KEY)
|
||||
@@ -369,7 +371,7 @@ SettingsMergeFunction UserFileAccessor::userStickyTrackerFunction(QStringList &s
|
||||
// Track keys that changed in main from the value in secondary:
|
||||
if (main != secondary && !secondary.isNull() && !stickyKeys.contains(global.key))
|
||||
stickyKeys.append(global.key);
|
||||
return qMakePair(key, main);
|
||||
return {{key, main}};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -471,15 +473,10 @@ QVariantMap UserFileVersion14Upgrader::upgrade(const QVariantMap &map)
|
||||
|
||||
QVariantMap UserFileVersion15Upgrader::upgrade(const QVariantMap &map)
|
||||
{
|
||||
QList<Change> changes;
|
||||
changes.append(qMakePair(QLatin1String("ProjectExplorer.Project.Updater.EnvironmentId"),
|
||||
QLatin1String("EnvironmentId")));
|
||||
// This is actually handled in the SettingsAccessor itself:
|
||||
// changes.append(qMakePair(QLatin1String("ProjectExplorer.Project.Updater.FileVersion"),
|
||||
// QLatin1String("Version")));
|
||||
changes.append(qMakePair(QLatin1String("ProjectExplorer.Project.UserStickyKeys"),
|
||||
QLatin1String("UserStickyKeys")));
|
||||
|
||||
const QList<Change> changes{{QLatin1String("ProjectExplorer.Project.Updater.EnvironmentId"),
|
||||
QLatin1String("EnvironmentId")},
|
||||
{QLatin1String("ProjectExplorer.Project.UserStickyKeys"),
|
||||
QLatin1String("UserStickyKeys")}};
|
||||
return renameKeys(changes, QVariantMap(map));
|
||||
}
|
||||
|
||||
@@ -744,12 +741,12 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
|
||||
return Utils::transform(entry.toList(), &UserFileVersion18Upgrader::process);
|
||||
case QVariant::Map:
|
||||
return Utils::transform<QMap<QString, QVariant>>(
|
||||
entry.toMap().toStdMap(), [](const std::pair<const QString, QVariant> &item) {
|
||||
entry.toMap().toStdMap(), [](const StringVariantPair &item) -> StringVariantPair {
|
||||
const QString key = (item.first
|
||||
== "AutotoolsProjectManager.MakeStep.AdditionalArguments"
|
||||
? QString("AutotoolsProjectManager.MakeStep.MakeArguments")
|
||||
: item.first);
|
||||
return qMakePair(key, UserFileVersion18Upgrader::process(item.second));
|
||||
return {key, UserFileVersion18Upgrader::process(item.second)};
|
||||
});
|
||||
default:
|
||||
return entry;
|
||||
@@ -798,24 +795,24 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const QString
|
||||
return Utils::transform(entry.toList(),
|
||||
std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path));
|
||||
case QVariant::Map:
|
||||
return Utils::transform<QVariantMap>(
|
||||
entry.toMap().toStdMap(), [&](const std::pair<const QString, QVariant> &item) {
|
||||
if (path.size() == 2 && path.at(1).startsWith("ProjectExplorer.Target.RunConfiguration.")) {
|
||||
if (argsKeys.contains(item.first))
|
||||
return qMakePair(QString("RunConfiguration.Arguments"), item.second);
|
||||
if (wdKeys.contains(item.first))
|
||||
return qMakePair(QString("RunConfiguration.WorkingDirectory"), item.second);
|
||||
if (termKeys.contains(item.first))
|
||||
return qMakePair(QString("RunConfiguration.UseTerminal"), item.second);
|
||||
if (libsKeys.contains(item.first))
|
||||
return qMakePair(QString("RunConfiguration.UseLibrarySearchPath"), item.second);
|
||||
if (dyldKeys.contains(item.first))
|
||||
return qMakePair(QString("RunConfiguration.UseDyldImageSuffix"), item.second);
|
||||
}
|
||||
QStringList newPath = path;
|
||||
newPath.append(item.first);
|
||||
return qMakePair(item.first, UserFileVersion19Upgrader::process(item.second, newPath));
|
||||
});
|
||||
return Utils::transform<QVariantMap>(entry.toMap().toStdMap(),
|
||||
[&](const StringVariantPair &item) -> StringVariantPair {
|
||||
if (path.size() == 2 && path.at(1).startsWith("ProjectExplorer.Target.RunConfiguration.")) {
|
||||
if (argsKeys.contains(item.first))
|
||||
return {"RunConfiguration.Arguments", item.second};
|
||||
if (wdKeys.contains(item.first))
|
||||
return {"RunConfiguration.WorkingDirectory", item.second};
|
||||
if (termKeys.contains(item.first))
|
||||
return {"RunConfiguration.UseTerminal", item.second};
|
||||
if (libsKeys.contains(item.first))
|
||||
return {"RunConfiguration.UseLibrarySearchPath", item.second};
|
||||
if (dyldKeys.contains(item.first))
|
||||
return {"RunConfiguration.UseDyldImageSuffix", item.second};
|
||||
}
|
||||
QStringList newPath = path;
|
||||
newPath.append(item.first);
|
||||
return {item.first, UserFileVersion19Upgrader::process(item.second, newPath)};
|
||||
});
|
||||
default:
|
||||
return entry;
|
||||
}
|
||||
@@ -833,8 +830,8 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
|
||||
return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process);
|
||||
case QVariant::Map:
|
||||
return Utils::transform<QMap<QString, QVariant>>(
|
||||
entry.toMap().toStdMap(), [](const std::pair<const QString, QVariant> &item) {
|
||||
auto res = qMakePair(item.first, item.second);
|
||||
entry.toMap().toStdMap(), [](const StringVariantPair &item) {
|
||||
StringVariantPair res = {item.first, item.second};
|
||||
if (item.first == "ProjectExplorer.ProjectConfiguration.Id"
|
||||
&& item.second == "Qbs.Deploy")
|
||||
res.second = QVariant("ProjectExplorer.DefaultDeployConfiguration");
|
||||
@@ -865,8 +862,8 @@ QVariant UserFileVersion21Upgrader::process(const QVariant &entry)
|
||||
return entryMap;
|
||||
}
|
||||
return Utils::transform<QVariantMap>(
|
||||
entryMap.toStdMap(), [](const std::pair<const QString, QVariant> &item) {
|
||||
return qMakePair(item.first, UserFileVersion21Upgrader::process(item.second));
|
||||
entryMap.toStdMap(), [](const StringVariantPair &item) -> StringVariantPair{
|
||||
return {item.first, UserFileVersion21Upgrader::process(item.second)};
|
||||
});
|
||||
}
|
||||
default:
|
||||
|
Reference in New Issue
Block a user