use initializer lists

Change-Id: I82b04601f1db52197b3dc625b6b7e0f143c1c8b6
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Tim Jenssen
2019-01-18 20:25:30 +01:00
parent 620086109a
commit a78e3e5dd5
23 changed files with 33 additions and 38 deletions

View File

@@ -180,7 +180,7 @@ public:
bool setData(int column, const QVariant &data, int role) override bool setData(int column, const QVariant &data, int role) override
{ {
if (column == LoadedColumn && role == Qt::CheckStateRole) if (column == LoadedColumn && role == Qt::CheckStateRole)
return m_view->setPluginsEnabled(QSet<PluginSpec *>() << m_spec, data.toBool()); return m_view->setPluginsEnabled({m_spec}, data.toBool());
return false; return false;
} }

View File

@@ -1202,7 +1202,7 @@ void PropertiesView::MView::onClassMembersChanged(QList<MClassMember> &classMemb
&MClass::members, &MClass::setMembers); &MClass::members, &MClass::setMembers);
foreach (DElement *element, m_diagramElements) { foreach (DElement *element, m_diagramElements) {
if (showMembers.contains(element->modelUid())) { if (showMembers.contains(element->modelUid())) {
assignModelElement<DClass, bool>(QList<DElement *>() << element, SelectionSingle, true, assignModelElement<DClass, bool>(QList<DElement *>({element}), SelectionSingle, true,
&DClass::showAllMembers, &DClass::setShowAllMembers); &DClass::showAllMembers, &DClass::setShowAllMembers);
} }
} }

View File

@@ -510,9 +510,9 @@ void Wizard::_q_pageAdded(int pageId)
nextItem = d->m_wizardProgress->item(nextId); nextItem = d->m_wizardProgress->item(nextId);
if (prevItem) if (prevItem)
prevItem->setNextItems(QList<WizardProgressItem *>() << item); prevItem->setNextItems({item});
if (nextItem) if (nextItem)
item->setNextItems(QList<WizardProgressItem *>() << nextItem); item->setNextItems({nextItem});
} }
void Wizard::_q_pageRemoved(int pageId) void Wizard::_q_pageRemoved(int pageId)
@@ -626,7 +626,7 @@ QList<WizardProgressItem *> WizardProgressPrivate::singlePathBetween(WizardProgr
// When we had X->A in addition and "from" was X and "to" was C, this would not work // When we had X->A in addition and "from" was X and "to" was C, this would not work
// (it should return the shortest path which would be X->A->C). // (it should return the shortest path which would be X->A->C).
if (item->nextItems().contains(toItem)) if (item->nextItems().contains(toItem))
return QList<WizardProgressItem *>() << toItem; return {toItem};
QHash<WizardProgressItem *, QHash<WizardProgressItem *, bool> > visitedItemsToParents; QHash<WizardProgressItem *, QHash<WizardProgressItem *, bool> > visitedItemsToParents;
QList<QPair<WizardProgressItem *, WizardProgressItem *> > workingItems; // next to prev item QList<QPair<WizardProgressItem *, WizardProgressItem *> > workingItems; // next to prev item
@@ -662,7 +662,7 @@ QList<WizardProgressItem *> WizardProgressPrivate::singlePathBetween(WizardProgr
return path; return path;
itItem = visitedItemsToParents.constFind(it); itItem = visitedItemsToParents.constFind(it);
} }
return QList<WizardProgressItem *>(); return {};
} }
void WizardProgressPrivate::updateReachableItems() void WizardProgressPrivate::updateReachableItems()

View File

@@ -218,7 +218,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
m_diagnosticView->setWindowTitle(tr("Clang-Tidy and Clazy Issues")); m_diagnosticView->setWindowTitle(tr("Clang-Tidy and Clazy Issues"));
foreach (auto * const model, foreach (auto * const model,
QList<QAbstractItemModel *>() << m_diagnosticModel << m_diagnosticFilterModel) { QList<QAbstractItemModel *>({m_diagnosticModel, m_diagnosticFilterModel})) {
connect(model, &QAbstractItemModel::rowsInserted, connect(model, &QAbstractItemModel::rowsInserted,
this, &ClangTidyClazyTool::handleStateUpdate); this, &ClangTidyClazyTool::handleStateUpdate);
connect(model, &QAbstractItemModel::rowsRemoved, connect(model, &QAbstractItemModel::rowsRemoved,

View File

@@ -132,7 +132,7 @@ void DiagnosticView::suppressCurrentDiagnostic()
QList<QAction *> DiagnosticView::customActions() const QList<QAction *> DiagnosticView::customActions() const
{ {
return QList<QAction *>() << m_suppressAction; return {m_suppressAction};
} }
bool DiagnosticView::eventFilter(QObject *watched, QEvent *event) bool DiagnosticView::eventFilter(QObject *watched, QEvent *event)

View File

@@ -895,7 +895,7 @@ bool DocumentManager::saveModifiedDocumentsSilently(const QList<IDocument *> &do
bool DocumentManager::saveModifiedDocumentSilently(IDocument *document, bool *canceled, bool DocumentManager::saveModifiedDocumentSilently(IDocument *document, bool *canceled,
QList<IDocument *> *failedToClose) QList<IDocument *> *failedToClose)
{ {
return saveModifiedDocumentsSilently(QList<IDocument *>() << document, canceled, failedToClose); return saveModifiedDocumentsSilently({document}, canceled, failedToClose);
} }
/*! /*!
@@ -957,7 +957,7 @@ bool DocumentManager::saveModifiedDocument(IDocument *document, const QString &m
const QString &alwaysSaveMessage, bool *alwaysSave, const QString &alwaysSaveMessage, bool *alwaysSave,
QList<IDocument *> *failedToClose) QList<IDocument *> *failedToClose)
{ {
return saveModifiedDocuments(QList<IDocument *>() << document, message, canceled, return saveModifiedDocuments({document}, message, canceled,
alwaysSaveMessage, alwaysSave, failedToClose); alwaysSaveMessage, alwaysSave, failedToClose);
} }

View File

@@ -2189,7 +2189,7 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
// close existing editors for the new file name // close existing editors for the new file name
IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath); IDocument *otherDocument = DocumentModel::documentForFilePath(absoluteFilePath);
if (otherDocument) if (otherDocument)
EditorManager::closeDocuments(QList<IDocument *>() << otherDocument, false); EditorManager::closeDocuments({otherDocument}, false);
} }
emit m_instance->aboutToSave(document); emit m_instance->aboutToSave(document);
@@ -2569,9 +2569,8 @@ void EditorManager::revertToSaved()
void EditorManager::closeEditor(IEditor *editor, bool askAboutModifiedEditors) void EditorManager::closeEditor(IEditor *editor, bool askAboutModifiedEditors)
{ {
if (!editor) if (editor)
return; closeEditors({editor}, askAboutModifiedEditors);
closeEditors(QList<IEditor *>() << editor, askAboutModifiedEditors);
} }
void EditorManager::closeDocument(DocumentModel::Entry *entry) void EditorManager::closeDocument(DocumentModel::Entry *entry)
@@ -2581,7 +2580,7 @@ void EditorManager::closeDocument(DocumentModel::Entry *entry)
if (entry->isSuspended) if (entry->isSuspended)
DocumentModelPrivate::removeEntry(entry); DocumentModelPrivate::removeEntry(entry);
else else
closeDocuments(QList<IDocument *>() << entry->document); closeDocuments({entry->document});
} }
bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool askAboutModifiedEditors) bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool askAboutModifiedEditors)
@@ -2856,7 +2855,7 @@ QList<IEditor*> EditorManager::visibleEditors()
bool EditorManager::closeDocument(IDocument *document, bool askAboutModifiedEditors) bool EditorManager::closeDocument(IDocument *document, bool askAboutModifiedEditors)
{ {
return closeDocuments(QList<IDocument *>() << document, askAboutModifiedEditors); return closeDocuments({document}, askAboutModifiedEditors);
} }
bool EditorManager::closeDocuments(const QList<IDocument *> &documents, bool askAboutModifiedEditors) bool EditorManager::closeDocuments(const QList<IDocument *> &documents, bool askAboutModifiedEditors)

View File

@@ -46,10 +46,9 @@ BasicLocatorFilterTest::~BasicLocatorFilterTest() = default;
QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText) QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText)
{ {
doBeforeLocatorRun(); doBeforeLocatorRun();
const QList<ILocatorFilter *> filters = QList<ILocatorFilter *>() << m_filter;
m_filter->prepareSearch(searchText); m_filter->prepareSearch(searchText);
QFuture<LocatorFilterEntry> locatorSearch = Utils::runAsync(&Internal::runSearch, filters, QFuture<LocatorFilterEntry> locatorSearch = Utils::runAsync(
searchText); &Internal::runSearch, QList<ILocatorFilter *>({m_filter}), searchText);
locatorSearch.waitForFinished(); locatorSearch.waitForFinished();
doAfterLocatorRun(); doAfterLocatorRun();
return locatorSearch.results(); return locatorSearch.results();

View File

@@ -195,7 +195,7 @@ void TestCase::closeEditorAtEndOfTestCase(Core::IEditor *editor)
bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor) bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor)
{ {
return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor); return closeEditorsWithoutGarbageCollectorInvocation({editor});
} }
CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath, CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath,

View File

@@ -148,7 +148,7 @@ DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine)
DisassemblerAgentPrivate::~DisassemblerAgentPrivate() DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
{ {
EditorManager::closeDocuments(QList<IDocument *>() << document); EditorManager::closeDocuments({document});
document = nullptr; document = nullptr;
qDeleteAll(breakpointMarks); qDeleteAll(breakpointMarks);
} }

View File

@@ -96,7 +96,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) " wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) "
"for implementation purposes. You can add the form and class to an existing Qt Widget Project.")); "for implementation purposes. You can add the form and class to an existing Qt Widget Project."));
return QList<IWizardFactory *>() << wizard; return {wizard};
}); });
#endif #endif

View File

@@ -395,13 +395,10 @@ void HelpWidget::addSideBar()
shortcutMap.insert(Constants::HELP_OPENPAGES, cmd); shortcutMap.insert(Constants::HELP_OPENPAGES, cmd);
} }
QList<Core::SideBarItem *> itemList; QList<Core::SideBarItem *> itemList = {contentItem, indexItem, bookmarkItem, searchItem};
itemList << contentItem << indexItem << bookmarkItem << searchItem;
if (openPagesItem) if (openPagesItem)
itemList << openPagesItem; itemList << openPagesItem;
m_sideBar = new Core::SideBar(itemList, m_sideBar = new Core::SideBar(itemList, {contentItem, (openPagesItem ? openPagesItem : indexItem)});
QList<Core::SideBarItem *>() << contentItem
<< (openPagesItem ? openPagesItem : indexItem));
m_sideBar->setShortcutMap(shortcutMap); m_sideBar->setShortcutMap(shortcutMap);
m_sideBar->setCloseWhenEmpty(true); m_sideBar->setCloseWhenEmpty(true);
m_sideBarSplitter->insertWidget(0, m_sideBar); m_sideBarSplitter->insertWidget(0, m_sideBar);

View File

@@ -281,5 +281,5 @@ QList<QToolButton *> SearchSideBarItem::createToolBarWidgets()
reindexButton->setToolTip(tr("Regenerate Index")); reindexButton->setToolTip(tr("Regenerate Index"));
connect(reindexButton, &QAbstractButton::clicked, connect(reindexButton, &QAbstractButton::clicked,
static_cast<SearchWidget *>(widget()), &SearchWidget::reindexDocumentation); static_cast<SearchWidget *>(widget()), &SearchWidget::reindexDocumentation);
return QList<QToolButton *>() << reindexButton; return {reindexButton};
} }

View File

@@ -688,7 +688,7 @@ void AppOutputPane::tabChanged(int i)
void AppOutputPane::contextMenuRequested(const QPoint &pos, int index) void AppOutputPane::contextMenuRequested(const QPoint &pos, int index)
{ {
QList<QAction *> actions = QList<QAction *>() << m_closeCurrentTabAction << m_closeAllTabsAction << m_closeOtherTabsAction; const QList<QAction *> actions = {m_closeCurrentTabAction, m_closeAllTabsAction, m_closeOtherTabsAction};
QAction *action = QMenu::exec(actions, m_tabWidget->mapToGlobal(pos), nullptr, m_tabWidget); QAction *action = QMenu::exec(actions, m_tabWidget->mapToGlobal(pos), nullptr, m_tabWidget);
const int currentIdx = index != -1 ? index : currentIndex(); const int currentIdx = index != -1 ? index : currentIndex();
if (action == m_closeCurrentTabAction) { if (action == m_closeCurrentTabAction) {

View File

@@ -115,7 +115,7 @@ void BuildConfiguration::initialize(const BuildInfo *info)
QList<NamedWidget *> BuildConfiguration::createSubConfigWidgets() QList<NamedWidget *> BuildConfiguration::createSubConfigWidgets()
{ {
return QList<NamedWidget *>() << new BuildEnvironmentWidget(this); return {new BuildEnvironmentWidget(this)};
} }
QList<Core::Id> BuildConfiguration::knownStepLists() const QList<Core::Id> BuildConfiguration::knownStepLists() const

View File

@@ -553,7 +553,7 @@ bool BuildManager::buildLists(QList<BuildStepList *> bsls, const QStringList &pr
void BuildManager::appendStep(BuildStep *step, const QString &name) void BuildManager::appendStep(BuildStep *step, const QString &name)
{ {
bool success = buildQueueAppend(QList<BuildStep *>() << step, QStringList() << name); bool success = buildQueueAppend({step}, {name});
if (!success) { if (!success) {
d->m_outputWindow->popup(IOutputPane::NoModeSwitch); d->m_outputWindow->popup(IOutputPane::NoModeSwitch);
return; return;

View File

@@ -86,7 +86,7 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
QString projectFile = additionalParameters.toString(); QString projectFile = additionalParameters.toString();
for (Project *project : SessionManager::projects()) { for (Project *project : SessionManager::projects()) {
if (project->document() && projectFile == project->projectFilePath().toString()) if (project->document() && projectFile == project->projectFilePath().toString())
return filesForProjects(nameFilters, exclusionFilters, QList<Project *>() << project); return filesForProjects(nameFilters, exclusionFilters, {project});
} }
return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>()); return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>());
} }

View File

@@ -172,7 +172,7 @@ QList<QWizardPage *> ProjectFileWizardExtension::extensionPages(const IWizardFac
// Init context with page and projects // Init context with page and projects
m_context->page = new ProjectWizardPage; m_context->page = new ProjectWizardPage;
m_context->wizard = wizard; m_context->wizard = wizard;
return QList<QWizardPage *>() << m_context->page; return {m_context->page};
} }
bool ProjectFileWizardExtension::processFiles( bool ProjectFileWizardExtension::processFiles(

View File

@@ -83,7 +83,7 @@ void Search::rowEntered(const QModelIndex &index)
if (m_scene) { if (m_scene) {
ScxmlTag *tag = m_model->tag(m_proxyModel->mapToSource(index)); ScxmlTag *tag = m_model->tag(m_proxyModel->mapToSource(index));
if (tag) if (tag)
m_scene->highlightItems(QVector<ScxmlTag*>() << tag); m_scene->highlightItems({tag});
else else
m_scene->unhighlightAll(); m_scene->unhighlightAll();
} }

View File

@@ -202,7 +202,7 @@ void Structure::rowEntered(const QModelIndex &index)
QModelIndex ind = m_proxyModel->mapToSource(index); QModelIndex ind = m_proxyModel->mapToSource(index);
auto tag = static_cast<ScxmlTag*>(ind.internalPointer()); auto tag = static_cast<ScxmlTag*>(ind.internalPointer());
if (tag) if (tag)
m_scene->highlightItems(QVector<ScxmlTag*>() << tag); m_scene->highlightItems({tag});
else else
m_scene->unhighlightAll(); m_scene->unhighlightAll();
} }

View File

@@ -870,7 +870,7 @@ void GraphicsScene::highlightWarningItem(const ScxmlEditor::OutputPane::Warning
ScxmlTag *tag = tagByWarning(w); ScxmlTag *tag = tagByWarning(w);
if (tag) if (tag)
highlightItems(QVector<ScxmlTag*>() << tag); highlightItems({tag});
else else
unhighlightAll(); unhighlightAll();
} }

View File

@@ -66,7 +66,7 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters,
QTextCodec *codec = openEditorEncodings.value(fileName); QTextCodec *codec = openEditorEncodings.value(fileName);
if (!codec) if (!codec)
codec = Core::EditorManager::defaultTextCodec(); codec = Core::EditorManager::defaultTextCodec();
return new Utils::FileListIterator(QStringList(fileName), QList<QTextCodec *>() << codec); return new Utils::FileListIterator({fileName}, {codec});
} }
QVariant FindInCurrentFile::additionalParameters() const QVariant FindInCurrentFile::additionalParameters() const

View File

@@ -79,7 +79,7 @@ FileIterator *FindInFiles::files(const QStringList &nameFilters,
const QStringList &exclusionFilters, const QStringList &exclusionFilters,
const QVariant &additionalParameters) const const QVariant &additionalParameters) const
{ {
return new SubDirFileIterator(QStringList() << additionalParameters.toString(), return new SubDirFileIterator({additionalParameters.toString()},
nameFilters, nameFilters,
exclusionFilters, exclusionFilters,
EditorManager::defaultTextCodec()); EditorManager::defaultTextCodec());