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