forked from qt-creator/qt-creator
Don't allocate unneeded temporary containers
Fix clazy warnings: allocating an unneeded temporary container [clazy-container-anti-pattern] Change-Id: I4b4c2c634eea650bbdf3c12d982a17f899fc94ec Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -49,8 +49,8 @@ namespace Utils {
|
||||
QMessageBox::StandardButtons SettingsAccessor::Issue::allButtons() const
|
||||
{
|
||||
QMessageBox::StandardButtons result = QMessageBox::NoButton;
|
||||
for (const QMessageBox::StandardButton &b : buttons.keys())
|
||||
result |= b;
|
||||
for (auto it = buttons.cbegin(); it != buttons.cend(); ++it)
|
||||
result |= it.key();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,7 @@ AvdDialog::AvdDialog(int minApiLevel, AndroidSdkManager *sdkManager, const QStri
|
||||
connect(&m_hideTipTimer, &QTimer::timeout, this, []() { Utils::ToolTip::hide(); });
|
||||
|
||||
parseDeviceDefinitionsList();
|
||||
for (const QString &type : DeviceTypeToStringMap.values())
|
||||
for (const QString &type : DeviceTypeToStringMap)
|
||||
m_avdDialog.deviceDefinitionTypeComboBox->addItem(type);
|
||||
|
||||
connect(m_avdDialog.deviceDefinitionTypeComboBox,
|
||||
|
@@ -101,7 +101,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
GTestVisitor visitor(document);
|
||||
visitor.accept(ast);
|
||||
|
||||
QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
||||
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
||||
QString proFile;
|
||||
const QList<CppTools::ProjectPart::Ptr> &ppList = modelManager->projectPart(filePath);
|
||||
if (!ppList.isEmpty())
|
||||
@@ -109,7 +109,8 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
else
|
||||
return false; // happens if shutting down while parsing
|
||||
|
||||
for (const GTestCaseSpec &testSpec : result.keys()) {
|
||||
for (auto it = result.cbegin(); it != result.cend(); ++it) {
|
||||
const GTestCaseSpec &testSpec = it.key();
|
||||
GTestParseResult *parseResult = new GTestParseResult(base);
|
||||
parseResult->itemType = TestTreeItem::TestSuite;
|
||||
parseResult->fileName = filePath;
|
||||
@@ -119,7 +120,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
parseResult->disabled = testSpec.disabled;
|
||||
parseResult->proFile = proFile;
|
||||
|
||||
for (const GTestCodeLocationAndType &location : result.value(testSpec)) {
|
||||
for (const GTestCodeLocationAndType &location : it.value()) {
|
||||
GTestParseResult *testSet = new GTestParseResult(base);
|
||||
testSet->name = location.m_name;
|
||||
testSet->fileName = filePath;
|
||||
@@ -134,7 +135,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
|
||||
futureInterface.reportResult(TestParseResultPtr(parseResult));
|
||||
}
|
||||
return !result.keys().isEmpty();
|
||||
return !result.isEmpty();
|
||||
}
|
||||
|
||||
bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
|
@@ -395,11 +395,10 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
|
||||
int TestResultModel::resultTypeCount(ResultType type) const
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (const auto &id : m_testResultCount.keys()) {
|
||||
for (auto it = m_testResultCount.cbegin(); it != m_testResultCount.cend(); ++it) {
|
||||
// if we got a result count from the framework prefer that over our counted results
|
||||
int reported = m_reportedSummary[id].value(type);
|
||||
result += reported != 0 ? reported : m_testResultCount.value(id).value(type);
|
||||
int reported = m_reportedSummary[it.key()].value(type);
|
||||
result += reported != 0 ? reported : it.value().value(type);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -507,9 +507,10 @@ void TestResultsPane::initializeFilterMenu()
|
||||
textAndType.insert(ResultType::MessageDebug, tr("Debug Messages"));
|
||||
textAndType.insert(ResultType::MessageWarn, tr("Warning Messages"));
|
||||
textAndType.insert(ResultType::MessageInternal, tr("Internal Messages"));
|
||||
for (ResultType result : textAndType.keys()) {
|
||||
for (auto it = textAndType.cbegin(); it != textAndType.cend(); ++it) {
|
||||
const ResultType &result = it.key();
|
||||
QAction *action = new QAction(m_filterMenu);
|
||||
action->setText(textAndType.value(result));
|
||||
action->setText(it.value());
|
||||
action->setCheckable(true);
|
||||
action->setChecked(result != ResultType::MessageInternal || !omitIntern);
|
||||
action->setData(int(result));
|
||||
|
@@ -70,13 +70,14 @@ void TestSettings::toSettings(QSettings *s) const
|
||||
s->setValue(popupOnFailKey, popupOnFail);
|
||||
s->setValue(runAfterBuildKey, int(runAfterBuild));
|
||||
// store frameworks and their current active and grouping state
|
||||
for (const Utils::Id &id : frameworks.keys()) {
|
||||
s->setValue(id.toString(), frameworks.value(id));
|
||||
for (auto it = frameworks.cbegin(); it != frameworks.cend(); ++it) {
|
||||
const Utils::Id &id = it.key();
|
||||
s->setValue(id.toString(), it.value());
|
||||
s->setValue(id.toString() + groupSuffix, frameworksGrouping.value(id));
|
||||
}
|
||||
// ..and the testtools as well
|
||||
for (const Utils::Id &id : tools.keys())
|
||||
s->setValue(id.toString(), tools.value(id));
|
||||
for (auto it = tools.cbegin(); it != tools.cend(); ++it)
|
||||
s->setValue(it.key().toString(), it.value());
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -1315,7 +1315,7 @@ void ClearCasePluginPrivate::diffActivity()
|
||||
}
|
||||
|
||||
if ((m_settings.diffType == GraphicalDiff) && (filever.count() == 1)) {
|
||||
QStringPair pair(filever.values().at(0));
|
||||
QStringPair pair(filever.first());
|
||||
diffGraphical(pair.first, pair.second);
|
||||
return;
|
||||
}
|
||||
|
@@ -430,7 +430,8 @@ bool Action::isEmpty() const
|
||||
|
||||
bool Action::isScriptable() const
|
||||
{
|
||||
return m_scriptableMap.values().contains(true);
|
||||
return std::find(m_scriptableMap.cbegin(), m_scriptableMap.cend(), true) !=
|
||||
m_scriptableMap.cend();
|
||||
}
|
||||
|
||||
bool Action::isScriptable(const Context &context) const
|
||||
|
@@ -83,7 +83,9 @@ QVariant CtfStatisticsModel::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
QString title = m_data.keys().at(index.row());
|
||||
auto it = m_data.cbegin();
|
||||
std::advance(it, index.row());
|
||||
const QString &title = it.key();
|
||||
|
||||
switch (role) {
|
||||
case Qt::TextAlignmentRole:
|
||||
|
@@ -176,8 +176,9 @@ void CtfTraceManager::load(const QString &filename)
|
||||
void CtfTraceManager::finalize()
|
||||
{
|
||||
bool userConsentToIgnoreDeepTraces = false;
|
||||
for (qint64 tid: m_threadModels.keys()) {
|
||||
if (m_threadModels[tid]->m_maxStackSize > 512) {
|
||||
auto it = m_threadModels.begin();
|
||||
while (it != m_threadModels.end()) {
|
||||
if (it.value()->m_maxStackSize > 512) {
|
||||
if (!userConsentToIgnoreDeepTraces) {
|
||||
QMessageBox::StandardButton answer
|
||||
= QMessageBox::question(Core::ICore::dialogParent(),
|
||||
@@ -192,8 +193,10 @@ void CtfTraceManager::finalize()
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_threadModels.remove(tid);
|
||||
m_threadRestrictions.remove(tid);
|
||||
m_threadRestrictions.remove(it.key());
|
||||
it = m_threadModels.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
for (CtfTimelineModel *model: m_threadModels) {
|
||||
|
@@ -500,8 +500,10 @@ void DebuggerMainWindow::savePersistentSettings() const
|
||||
|
||||
QVariantHash states;
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE TYPES: " << d->m_lastTypePerspectiveStates.keys();
|
||||
for (const QString &type : d->m_lastTypePerspectiveStates.keys()) {
|
||||
const PerspectiveState state = d->m_lastTypePerspectiveStates.value(type);
|
||||
for (auto it = d->m_lastTypePerspectiveStates.cbegin();
|
||||
it != d->m_lastTypePerspectiveStates.cend(); ++it) {
|
||||
const QString &type = it.key();
|
||||
const PerspectiveState &state = it.value();
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE TYPE " << type
|
||||
<< " HAS STATE: " << !state.mainWindowState.isEmpty();
|
||||
QTC_ASSERT(!state.mainWindowState.isEmpty(), continue);
|
||||
|
@@ -111,22 +111,24 @@ Client::~Client()
|
||||
using namespace TextEditor;
|
||||
// FIXME: instead of replacing the completion provider in the text document store the
|
||||
// completion provider as a prioritised list in the text document
|
||||
for (TextDocument *document : m_resetAssistProvider.keys())
|
||||
resetAssistProviders(document);
|
||||
for (Core::IEditor * editor : Core::DocumentModel::editorsForOpenedDocuments()) {
|
||||
for (auto it = m_resetAssistProvider.cbegin(); it != m_resetAssistProvider.cend(); ++it)
|
||||
resetAssistProviders(it.key());
|
||||
const QList<Core::IEditor *> &editors = Core::DocumentModel::editorsForOpenedDocuments();
|
||||
for (Core::IEditor *editor : editors) {
|
||||
if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) {
|
||||
TextEditorWidget *widget = textEditor->editorWidget();
|
||||
widget->setRefactorMarkers(RefactorMarker::filterOutType(widget->refactorMarkers(), id()));
|
||||
widget->removeHoverHandler(&m_hoverHandler);
|
||||
}
|
||||
}
|
||||
for (const DocumentUri &uri : m_highlights.keys()) {
|
||||
for (auto it = m_highlights.cbegin(); it != m_highlights.cend(); ++it) {
|
||||
const DocumentUri &uri = it.key();
|
||||
if (TextDocument *doc = TextDocument::textDocumentForFilePath(uri.toFilePath())) {
|
||||
if (TextEditor::SyntaxHighlighter *highlighter = doc->syntaxHighlighter())
|
||||
highlighter->clearAllExtraFormats();
|
||||
}
|
||||
}
|
||||
for (IAssistProcessor *processor : m_runningAssistProcessors)
|
||||
for (IAssistProcessor *processor : qAsConst(m_runningAssistProcessors))
|
||||
processor->setAsyncProposalAvailable(nullptr);
|
||||
updateEditorToolBar(m_openedDocument.keys());
|
||||
}
|
||||
@@ -910,11 +912,11 @@ bool Client::reset()
|
||||
m_serverCapabilities = ServerCapabilities();
|
||||
m_dynamicCapabilities.reset();
|
||||
m_diagnosticManager.clearDiagnostics();
|
||||
for (TextEditor::TextDocument *document : m_openedDocument.keys())
|
||||
document->disconnect(this);
|
||||
for (TextEditor::TextDocument *document : m_resetAssistProvider.keys())
|
||||
resetAssistProviders(document);
|
||||
for (TextEditor::IAssistProcessor *processor : m_runningAssistProcessors)
|
||||
for (auto it = m_openedDocument.cbegin(); it != m_openedDocument.cend(); ++it)
|
||||
it.key()->disconnect(this);
|
||||
for (auto it = m_resetAssistProvider.cbegin(); it != m_resetAssistProvider.cend(); ++it)
|
||||
resetAssistProviders(it.key());
|
||||
for (TextEditor::IAssistProcessor *processor : qAsConst(m_runningAssistProcessors))
|
||||
processor->setAsyncProposalAvailable(nullptr);
|
||||
m_runningAssistProcessors.clear();
|
||||
return true;
|
||||
@@ -1279,8 +1281,8 @@ void Client::initializeCallback(const InitializeRequest::Response &initResponse)
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
|
||||
for (TextEditor::TextDocument *document : m_openedDocument.keys())
|
||||
openDocument(document);
|
||||
for (auto it = m_openedDocument.cbegin(); it != m_openedDocument.cend(); ++it)
|
||||
openDocument(it.key());
|
||||
|
||||
emit initialized(m_serverCapabilities);
|
||||
}
|
||||
|
@@ -130,8 +130,8 @@ void DiagnosticManager::showDiagnostics(const DocumentUri &uri)
|
||||
|
||||
void DiagnosticManager::clearDiagnostics()
|
||||
{
|
||||
for (const DocumentUri &uri : m_diagnostics.keys())
|
||||
removeDiagnostics(uri);
|
||||
for (auto it = m_diagnostics.cbegin(); it != m_diagnostics.cend(); ++it)
|
||||
removeDiagnostics(it.key());
|
||||
}
|
||||
|
||||
QList<Diagnostic> DiagnosticManager::diagnosticsAt(const DocumentUri &uri, const Range &range) const
|
||||
|
@@ -299,8 +299,10 @@ QVector<Client *> LanguageClientManager::clientForSetting(const BaseSettings *se
|
||||
const BaseSettings *LanguageClientManager::settingForClient(Client *client)
|
||||
{
|
||||
QTC_ASSERT(managerInstance, return nullptr);
|
||||
for (const QString &id : managerInstance->m_clientsForSetting.keys()) {
|
||||
for (const Client *settingClient : managerInstance->m_clientsForSetting[id]) {
|
||||
for (auto it = managerInstance->m_clientsForSetting.cbegin();
|
||||
it != managerInstance->m_clientsForSetting.cend(); ++it) {
|
||||
const QString &id = it.key();
|
||||
for (const Client *settingClient : it.value()) {
|
||||
if (settingClient == client) {
|
||||
return Utils::findOrDefault(managerInstance->m_currentSettings,
|
||||
[id](BaseSettings *setting) {
|
||||
@@ -386,13 +388,13 @@ void LanguageClientManager::clientFinished(Client *client)
|
||||
client->log(tr("Unexpectedly finished. Restarting in %1 seconds.").arg(restartTimeoutS),
|
||||
Core::MessageManager::Flash);
|
||||
QTimer::singleShot(restartTimeoutS * 1000, client, [client]() { startClient(client); });
|
||||
for (TextEditor::TextDocument *document : m_clientForDocument.keys(client))
|
||||
client->deactivateDocument(document);
|
||||
for (auto it = m_clientForDocument.cbegin(); it != m_clientForDocument.cend(); ++it)
|
||||
client->deactivateDocument(it.key());
|
||||
} else {
|
||||
if (unexpectedFinish && !m_shuttingDown)
|
||||
client->log(tr("Unexpectedly finished."), Core::MessageManager::Flash);
|
||||
for (TextEditor::TextDocument *document : m_clientForDocument.keys(client))
|
||||
m_clientForDocument.remove(document);
|
||||
for (auto it = m_clientForDocument.cbegin(); it != m_clientForDocument.cend(); ++it)
|
||||
m_clientForDocument.remove(it.key());
|
||||
deleteClient(client);
|
||||
if (m_shuttingDown && m_clients.isEmpty())
|
||||
emit shutdownFinished();
|
||||
|
@@ -122,8 +122,8 @@ bool applyWorkspaceEdit(const WorkspaceEdit &edit)
|
||||
result |= applyTextDocumentEdit(documentChange);
|
||||
} else {
|
||||
const WorkspaceEdit::Changes &changes = edit.changes().value_or(WorkspaceEdit::Changes());
|
||||
for (const DocumentUri &file : changes.keys())
|
||||
result |= applyTextEdits(file, changes.value(file));
|
||||
for (auto it = changes.cbegin(); it != changes.cend(); ++it)
|
||||
result |= applyTextEdits(it.key(), it.value());
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
|
@@ -333,7 +333,7 @@ void SectionedProducts::setColumnCount(int columns)
|
||||
if (columns < 1)
|
||||
columns = 1;
|
||||
m_columnCount = columns;
|
||||
for (ProductGridView *view : m_gridViews.values()) {
|
||||
for (ProductGridView *view : qAsConst(m_gridViews)) {
|
||||
view->setColumnCount(columns);
|
||||
view->setFixedSize(view->viewportSizeHint());
|
||||
}
|
||||
@@ -361,7 +361,7 @@ void SectionedProducts::fetchNextImage()
|
||||
|
||||
if (QPixmapCache::find(nextUrl, nullptr)) {
|
||||
// this image is already cached it might have been added while downloading
|
||||
for (ProductListModel *model : m_productModels.values())
|
||||
for (ProductListModel *model : qAsConst(m_productModels))
|
||||
model->updateModelIndexesForUrl(nextUrl);
|
||||
fetchNextImage();
|
||||
return;
|
||||
@@ -387,7 +387,7 @@ void SectionedProducts::onImageDownloadFinished(QNetworkReply *reply)
|
||||
const QString url = imageUrl.toString();
|
||||
QPixmapCache::insert(url, pixmap.scaled(ProductListModel::defaultImageSize,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
for (ProductListModel *model : m_productModels.values())
|
||||
for (ProductListModel *model : qAsConst(m_productModels))
|
||||
model->updateModelIndexesForUrl(url);
|
||||
}
|
||||
} // handle error not needed - it's okay'ish to have no images as long as the rest works
|
||||
@@ -411,7 +411,7 @@ void SectionedProducts::addNewSection(const Section §ion, const QList<Core::
|
||||
gridModel->setColumnCount(m_columnCount);
|
||||
|
||||
m_productModels.insert(section, productModel);
|
||||
m_gridViews.insert(section, gridView);
|
||||
const auto it = m_gridViews.insert(section, gridView);
|
||||
|
||||
QFont f = font();
|
||||
f.setPixelSize(16);
|
||||
@@ -421,7 +421,7 @@ void SectionedProducts::addNewSection(const Section §ion, const QList<Core::
|
||||
auto vbox = qobject_cast<QVBoxLayout *>(scrollArea->widget()->layout());
|
||||
|
||||
// insert new section depending on its priority, but before the last (stretch) item
|
||||
int position = m_gridViews.keys().indexOf(section) * 2; // a section has a label and a grid
|
||||
int position = std::distance(m_gridViews.begin(), it) * 2; // a section has a label and a grid
|
||||
QTC_ASSERT(position <= vbox->count() - 1, position = vbox->count() - 1);
|
||||
vbox->insertWidget(position, sectionLabel);
|
||||
vbox->insertWidget(position + 1, gridView);
|
||||
@@ -442,7 +442,7 @@ void SectionedProducts::onTagClicked(const QString &tag)
|
||||
QList<Core::ListItem *> SectionedProducts::items()
|
||||
{
|
||||
QList<Core::ListItem *> result;
|
||||
for (const ProductListModel *model : m_productModels.values())
|
||||
for (const ProductListModel *model : qAsConst(m_productModels))
|
||||
result.append(model->items());
|
||||
return result;
|
||||
}
|
||||
|
@@ -348,8 +348,10 @@ struct McuTargetFactory
|
||||
QVector<McuPackage *> getMcuPackages() const
|
||||
{
|
||||
QVector<McuPackage *> packages;
|
||||
packages.append(boardSdkPkgs.values().toVector());
|
||||
packages.append(freeRTOSPkgs.values().toVector());
|
||||
for (auto *package : qAsConst(boardSdkPkgs))
|
||||
packages.append(package);
|
||||
for (auto *package : qAsConst(freeRTOSPkgs))
|
||||
packages.append(package);
|
||||
return packages;
|
||||
}
|
||||
|
||||
@@ -506,7 +508,8 @@ static QVector<McuTarget *> targetsFromDescriptions(const QList<McuTargetDescrip
|
||||
|
||||
packages->append(Utils::transform<QVector<McuPackage *> >(
|
||||
tcPkgs.values(), [&](McuToolChainPackage *tcPkg) { return tcPkg; }));
|
||||
packages->append(vendorPkgs.values().toVector());
|
||||
for (auto *package : vendorPkgs)
|
||||
packages->append(package);
|
||||
packages->append(targetFactory.getMcuPackages());
|
||||
|
||||
return mcuTargets;
|
||||
|
@@ -1961,7 +1961,8 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
||||
});
|
||||
|
||||
dd->m_documentFactory.addMimeType(QStringLiteral("inode/directory"));
|
||||
for (const QString &mimeType : dd->m_projectCreators.keys()) {
|
||||
for (auto it = dd->m_projectCreators.cbegin(); it != dd->m_projectCreators.cend(); ++it) {
|
||||
const QString &mimeType = it.key();
|
||||
dd->m_documentFactory.addMimeType(mimeType);
|
||||
Utils::MimeType mime = Utils::mimeTypeForName(mimeType);
|
||||
allGlobPatterns.append(mime.globPatterns());
|
||||
@@ -2345,8 +2346,8 @@ void ProjectExplorerPluginPrivate::determineSessionToRestoreAtStartup()
|
||||
QStringList ProjectExplorerPlugin::projectFileGlobs()
|
||||
{
|
||||
QStringList result;
|
||||
for (const QString &mt : dd->m_projectCreators.keys()) {
|
||||
Utils::MimeType mimeType = Utils::mimeTypeForName(mt);
|
||||
for (auto it = dd->m_projectCreators.cbegin(); it != dd->m_projectCreators.cend(); ++it) {
|
||||
Utils::MimeType mimeType = Utils::mimeTypeForName(it.key());
|
||||
if (mimeType.isValid()) {
|
||||
const QStringList patterns = mimeType.globPatterns();
|
||||
if (!patterns.isEmpty())
|
||||
@@ -3921,8 +3922,8 @@ const QList<CustomParserSettings> ProjectExplorerPlugin::customParsers()
|
||||
QStringList ProjectExplorerPlugin::projectFilePatterns()
|
||||
{
|
||||
QStringList patterns;
|
||||
for (const QString &mime : dd->m_projectCreators.keys()) {
|
||||
Utils::MimeType mt = Utils::mimeTypeForName(mime);
|
||||
for (auto it = dd->m_projectCreators.cbegin(); it != dd->m_projectCreators.cend(); ++it) {
|
||||
Utils::MimeType mt = Utils::mimeTypeForName(it.key());
|
||||
if (mt.isValid())
|
||||
patterns.append(mt.globPatterns());
|
||||
}
|
||||
@@ -3932,8 +3933,8 @@ QStringList ProjectExplorerPlugin::projectFilePatterns()
|
||||
bool ProjectExplorerPlugin::isProjectFile(const Utils::FilePath &filePath)
|
||||
{
|
||||
Utils::MimeType mt = Utils::mimeTypeForFile(filePath.toString());
|
||||
for (const QString &mime : dd->m_projectCreators.keys()) {
|
||||
if (mt.inherits(mime))
|
||||
for (auto it = dd->m_projectCreators.cbegin(); it != dd->m_projectCreators.cend(); ++it) {
|
||||
if (mt.inherits(it.key()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -4005,9 +4006,9 @@ void ProjectManager::registerProjectCreator(const QString &mimeType,
|
||||
Project *ProjectManager::openProject(const Utils::MimeType &mt, const Utils::FilePath &fileName)
|
||||
{
|
||||
if (mt.isValid()) {
|
||||
for (const QString &mimeType : dd->m_projectCreators.keys()) {
|
||||
if (mt.matchesName(mimeType))
|
||||
return dd->m_projectCreators[mimeType](fileName);
|
||||
for (auto it = dd->m_projectCreators.cbegin(); it != dd->m_projectCreators.cend(); ++it) {
|
||||
if (mt.matchesName(it.key()))
|
||||
return it.value()(fileName);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -4016,8 +4017,8 @@ Project *ProjectManager::openProject(const Utils::MimeType &mt, const Utils::Fil
|
||||
bool ProjectManager::canOpenProjectForMimeType(const Utils::MimeType &mt)
|
||||
{
|
||||
if (mt.isValid()) {
|
||||
for (const QString &mimeType : dd->m_projectCreators.keys()) {
|
||||
if (mt.matchesName(mimeType))
|
||||
for (auto it = dd->m_projectCreators.cbegin(); it != dd->m_projectCreators.cend(); ++it) {
|
||||
if (mt.matchesName(it.key()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -620,10 +620,13 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
||||
|
||||
// Filter out the properties which have a basic type e.g. int, string, bool
|
||||
QList<PropertyName> basicProperties;
|
||||
for (auto k : propertyMap.keys()) {
|
||||
if (propertyMap.value(k).empty()) {
|
||||
basicProperties.append(k);
|
||||
propertyMap.remove(k);
|
||||
auto it = propertyMap.begin();
|
||||
while (it != propertyMap.end()) {
|
||||
if (it.value().empty()) {
|
||||
basicProperties.append(it.key());
|
||||
it = propertyMap.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,20 +703,22 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
||||
// Second the section containing properties of complex type for which no specific template exists e.g. Button
|
||||
if (!propertyMap.empty()) {
|
||||
emptyTemplate = false;
|
||||
for (const auto &k : propertyMap.keys()) {
|
||||
TypeName parentTypeName = type.propertyTypeName(k);
|
||||
for (auto it = propertyMap.cbegin(); it != propertyMap.cend(); ++it) {
|
||||
const auto &key = it.key();
|
||||
TypeName parentTypeName = type.propertyTypeName(key);
|
||||
// alias resolution only possible with instance
|
||||
if (parentTypeName == "alias" && node.isValid())
|
||||
parentTypeName = node.instanceType(k);
|
||||
parentTypeName = node.instanceType(key);
|
||||
|
||||
qmlTemplate += "Section {\n";
|
||||
qmlTemplate += QStringLiteral("caption: \"%1 - %2\"\n").arg(QString::fromUtf8(k)).arg(QString::fromUtf8(parentTypeName));
|
||||
qmlTemplate += QStringLiteral("caption: \"%1 - %2\"\n")
|
||||
.arg(QString::fromUtf8(key), QString::fromUtf8(parentTypeName));
|
||||
qmlTemplate += anchorLeftRight;
|
||||
qmlTemplate += "expanded: false\n";
|
||||
qmlTemplate += "level: 1\n";
|
||||
qmlTemplate += "SectionLayout {\n";
|
||||
|
||||
auto properties = propertyMap.value(k);
|
||||
auto properties = it.value();
|
||||
Utils::sort(properties);
|
||||
|
||||
for (const auto &p : qAsConst(properties)) {
|
||||
|
@@ -262,12 +262,12 @@ ModelNode TransitionEditorView::addNewTransition()
|
||||
transition.validId();
|
||||
root.nodeListProperty("transitions").reparentHere(transition);
|
||||
|
||||
for (const QString &id : idPropertyList.keys()) {
|
||||
for (auto it = idPropertyList.cbegin(); it != idPropertyList.cend(); ++it) {
|
||||
ModelNode parallelAnimation = createModelNode("QtQuick.ParallelAnimation",
|
||||
2,
|
||||
12);
|
||||
transition.defaultNodeAbstractProperty().reparentHere(parallelAnimation);
|
||||
for (const QString &property : idPropertyList.value(id)) {
|
||||
for (const QString &property : it.value()) {
|
||||
ModelNode sequentialAnimation
|
||||
= createModelNode("QtQuick.SequentialAnimation", 2, 12);
|
||||
parallelAnimation.defaultNodeAbstractProperty().reparentHere(
|
||||
@@ -285,7 +285,7 @@ ModelNode TransitionEditorView::addNewTransition()
|
||||
12,
|
||||
{{"property", property},
|
||||
{"duration", 150}});
|
||||
propertyAnimation.bindingProperty("target").setExpression(id);
|
||||
propertyAnimation.bindingProperty("target").setExpression(it.key());
|
||||
sequentialAnimation.defaultNodeAbstractProperty().reparentHere(
|
||||
propertyAnimation);
|
||||
}
|
||||
|
@@ -111,7 +111,8 @@ static void setupIdRenamingHash(const ModelNode &modelNode, QHash<QString, QStri
|
||||
int number = 1;
|
||||
splitIdInBaseNameAndNumber(newId, &baseId, &number);
|
||||
|
||||
while (view->hasId(newId) || idRenamingHash.values().contains(newId)) {
|
||||
while (view->hasId(newId) || std::find(idRenamingHash.cbegin(),
|
||||
idRenamingHash.cend(), newId) != idRenamingHash.cend()) {
|
||||
newId = baseId + QString::number(number);
|
||||
number++;
|
||||
}
|
||||
|
@@ -979,7 +979,7 @@ QList<QmlTypeData> RewriterView::getQMLTypes() const
|
||||
qmlDataList.append(m_textToModelMerger->getQMLSingletons());
|
||||
|
||||
for (const QmlJS::ModelManagerInterface::CppData &cppData :
|
||||
QmlJS::ModelManagerInterface::instance()->cppData().values())
|
||||
QmlJS::ModelManagerInterface::instance()->cppData())
|
||||
for (const LanguageUtils::FakeMetaObject::ConstPtr &fakeMetaObject : cppData.exportedTypes) {
|
||||
for (const LanguageUtils::FakeMetaObject::Export &exportItem :
|
||||
fakeMetaObject->exports()) {
|
||||
|
@@ -155,14 +155,16 @@ void StylesheetMerger::syncId(ModelNode &outputNode, ModelNode &inputNode)
|
||||
|
||||
void StylesheetMerger::setupIdRenamingHash()
|
||||
{
|
||||
for (const ModelNode &node : m_templateView->rootModelNode().allSubModelNodesAndThisNode()) {
|
||||
const QList<ModelNode> &nodes = m_templateView->rootModelNode().allSubModelNodesAndThisNode();
|
||||
for (const ModelNode &node : nodes) {
|
||||
if (!node.id().isEmpty()) {
|
||||
QString newId = node.id();
|
||||
QString baseId;
|
||||
int number = 1;
|
||||
splitIdInBaseNameAndNumber(newId, &baseId, &number);
|
||||
|
||||
while (m_templateView->hasId(newId) || m_idReplacementHash.values().contains(newId)) {
|
||||
while (m_templateView->hasId(newId) || std::find(m_idReplacementHash.cbegin(),
|
||||
m_idReplacementHash.cend(), newId) != m_idReplacementHash.cend()) {
|
||||
newId = "stylesheet_auto_merge_" + baseId + QString::number(number);
|
||||
number++;
|
||||
}
|
||||
|
@@ -50,9 +50,8 @@ ColorSettings::ColorSettings(QWidget *parent)
|
||||
m_colorThemes = s->value(Constants::C_SETTINGS_COLORSETTINGS_COLORTHEMES).toMap();
|
||||
|
||||
m_ui.m_comboColorThemes->clear();
|
||||
for (const auto &key : m_colorThemes.keys())
|
||||
m_ui.m_comboColorThemes->addItem(key);
|
||||
|
||||
for (auto it = m_colorThemes.cbegin(); it != m_colorThemes.cend(); ++it)
|
||||
m_ui.m_comboColorThemes->addItem(it.key());
|
||||
m_ui.m_comboColorThemes->setCurrentText(s->value(Constants::C_SETTINGS_COLORSETTINGS_CURRENTCOLORTHEME).toString());
|
||||
}
|
||||
|
||||
@@ -74,9 +73,9 @@ void ColorSettings::selectTheme(int index)
|
||||
m_ui.m_colorThemeView->reset();
|
||||
if (!name.isEmpty() && m_colorThemes.contains(name)) {
|
||||
m_ui.m_colorThemeView->setEnabled(true);
|
||||
QVariantMap colordata = m_colorThemes[name].toMap();
|
||||
for (const auto &index : colordata.keys())
|
||||
m_ui.m_colorThemeView->setColor(index.toInt(), QColor(colordata[index].toString()));
|
||||
const QVariantMap colordata = m_colorThemes[name].toMap();
|
||||
for (auto it = colordata.cbegin(); it != colordata.cend(); ++it)
|
||||
m_ui.m_colorThemeView->setColor(it.key().toInt(), QColor(it.value().toString()));
|
||||
} else {
|
||||
m_ui.m_colorThemeView->setEnabled(false);
|
||||
}
|
||||
@@ -86,7 +85,7 @@ void ColorSettings::createTheme()
|
||||
{
|
||||
QString name = QInputDialog::getText(this, tr("Create New Color Theme"), tr("Theme ID"));
|
||||
if (!name.isEmpty()) {
|
||||
if (m_colorThemes.keys().contains(name)) {
|
||||
if (m_colorThemes.contains(name)) {
|
||||
QMessageBox::warning(this, tr("Cannot Create Theme"), tr("Theme %1 is already available.").arg(name));
|
||||
} else {
|
||||
m_ui.m_colorThemeView->reset();
|
||||
|
@@ -358,7 +358,7 @@ QString ScxmlTag::editorInfo(const QString &key) const
|
||||
|
||||
bool ScxmlTag::hasEditorInfo(const QString &key) const
|
||||
{
|
||||
return m_editorInfo.keys().contains(key);
|
||||
return m_editorInfo.contains(key);
|
||||
}
|
||||
|
||||
void ScxmlTag::setAttributeName(int ind, const QString &name)
|
||||
|
Reference in New Issue
Block a user