Commit c5a9c51c authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

quickopen: port foreach -> range-based for

parent 8cb82487
......@@ -113,7 +113,7 @@ void DocumentationQuickOpenProvider::setFilterText(const QString& text)
int internalSplit = 0;
int i = 0;
matchingIndexes(p->indexModel(), text, QModelIndex(), idxs, internalSplit);
foreach (const QModelIndex& idx, idxs) {
for (const QModelIndex& idx : qAsConst(idxs)) {
m_results.insert(split + i, QuickOpenDataPointer(new DocumentationQuickOpenItem(idx, p)));
i++;
}
......
......@@ -148,7 +148,7 @@ void ExpandingWidgetModel::clearExpanding()
{
clearMatchQualities();
QMap<QModelIndex, ExpandingWidgetModel::ExpandingType> oldExpandState = m_expandState;
foreach (QPointer<QWidget> widget, m_expandingWidgets) {
for (auto& widget : qAsConst(m_expandingWidgets)) {
delete widget;
}
......
......@@ -240,14 +240,16 @@ ProjectFileDataProvider::ProjectFileDataProvider()
this, &ProjectFileDataProvider::projectClosing);
connect(projectController, &IProjectController::projectOpened,
this, &ProjectFileDataProvider::projectOpened);
foreach (const auto project, projectController->projects()) {
const auto projects = projectController->projects();
for (auto* project : projects) {
projectOpened(project);
}
}
void ProjectFileDataProvider::projectClosing(IProject* project)
{
foreach (ProjectFileItem* file, KDevelop::allFiles(project->projectItem())) {
const auto files = KDevelop::allFiles(project->projectItem());
for (ProjectFileItem* file : files) {
fileRemovedFromSet(file);
}
}
......@@ -256,7 +258,8 @@ void ProjectFileDataProvider::projectOpened(IProject* project)
{
const int processAfter = 1000;
int processed = 0;
foreach (ProjectFileItem* file, KDevelop::allFiles(project->projectItem())) {
const auto files = KDevelop::allFiles(project->projectItem());
for (ProjectFileItem* file : files) {
fileAddedToSet(file);
if (++processed == processAfter) {
// prevent UI-lockup when a huge project was imported
......@@ -330,7 +333,8 @@ QSet<IndexedString> ProjectFileDataProvider::files() const
{
QSet<IndexedString> ret;
foreach (IProject* project, ICore::self()->projectController()->projects()) {
const auto projects = ICore::self()->projectController()->projects();
for (IProject* project : projects) {
ret += project->fileSet();
}
......
......@@ -159,7 +159,7 @@ void ProjectItemDataProvider::setFilterText(const QString& text)
}
KDevVarLengthArray<SubstringCache, 5> cache;
foreach (const QString& searchPart, search) {
for (const QString& searchPart : qAsConst(search)) {
cache.append(SubstringCache(searchPart));
}
......@@ -241,7 +241,8 @@ KDevelop::QuickOpenDataPointer ProjectItemDataProvider::data(uint pos) const
QList<Declaration*> decls = ctx->findDeclarations(filteredItem.m_id, CursorInRevision::invalid(), AbstractType::Ptr(), nullptr, DUContext::DirectQualifiedLookup);
//Filter out forward-declarations or duplicate imported declarations
foreach (Declaration* decl, decls) {
const auto unfilteredDecls = decls;
for (Declaration* decl : unfilteredDecls) {
bool filter = false;
if (decls.size() > 1 && decl->isForwardDeclaration()) {
filter = true;
......@@ -254,7 +255,7 @@ KDevelop::QuickOpenDataPointer ProjectItemDataProvider::data(uint pos) const
}
ret.reserve(ret.size() + decls.size());
foreach (Declaration* decl, decls) {
for (Declaration* decl : qAsConst(decls)) {
DUChainItem item;
item.m_item = decl;
item.m_text = decl->qualifiedIdentifier().toString();
......@@ -309,7 +310,7 @@ void ProjectItemDataProvider::reset()
m_addedItemsCountCache.markDirty();
KDevelop::DUChainReadLocker lock(DUChain::lock());
foreach (const IndexedString& u, m_files) {
for (const IndexedString& u : qAsConst(m_files)) {
uint count;
const KDevelop::CodeModelItem* items;
CodeModel::self().items(u, count, items);
......
......@@ -53,7 +53,7 @@ QStringList QuickOpenModel::allScopes() const
{
QStringList scopes;
for (const ProviderEntry& provider : m_providers) {
foreach (const QString& scope, provider.scopes) {
for (const QString& scope : provider.scopes) {
if (!scopes.contains(scope)) {
scopes << scope;
}
......@@ -162,7 +162,7 @@ void QuickOpenModel::textChanged(const QString& str)
beginResetModel();
m_filterText = str;
foreach (const ProviderEntry& provider, m_providers) {
for (const ProviderEntry& provider : qAsConst(m_providers)) {
if (provider.enabled) {
provider.provider->setFilterText(str);
}
......@@ -193,17 +193,15 @@ void QuickOpenModel::restart_internal(bool keepFilterText)
m_filterText.clear();
}
bool anyEnabled = false;
foreach (const ProviderEntry& e, m_providers) {
anyEnabled |= e.enabled;
}
bool anyEnabled = std::any_of(m_providers.constBegin(), m_providers.constEnd(), [](const ProviderEntry& e) {
return e.enabled;
});
if (!anyEnabled) {
return;
}
foreach (const ProviderEntry& provider, m_providers) {
for (const ProviderEntry& provider : qAsConst(m_providers)) {
if (!qobject_cast<QuickOpenFileSetInterface*>(provider.provider)) {
continue;
}
......@@ -214,7 +212,7 @@ void QuickOpenModel::restart_internal(bool keepFilterText)
}
}
foreach (const ProviderEntry& provider, m_providers) {
for (const ProviderEntry& provider : qAsConst(m_providers)) {
if (qobject_cast<QuickOpenFileSetInterface*>(provider.provider)) {
continue;
}
......
......@@ -840,7 +840,7 @@ struct CreateOutlineDialog
//Select the declaration that contains the cursor
if (cursorDecl && dialog) {
int num = 0;
foreach (const DUChainItem& item, items) {
for (const DUChainItem& item : qAsConst(items)) {
if (item.m_item.data() == cursorDecl) {
QModelIndex index(model->index(num, 0, QModelIndex()));
// Need to invoke the scrolling later. If we did it now, then it wouldn't have any effect,
......
......@@ -297,7 +297,7 @@ void QuickOpenWidget::updateProviders()
QStringList checkedItems;
if (ui.itemsButton->menu()) {
foreach (QObject* obj, ui.itemsButton->menu()->children()) {
for (QObject* obj : ui.itemsButton->menu()->children()) {
auto* box = qobject_cast<QAction*>(obj);
if (box) {
if (box->isChecked()) {
......@@ -312,7 +312,7 @@ void QuickOpenWidget::updateProviders()
QStringList checkedScopes;
if (ui.scopesButton->menu()) {
foreach (QObject* obj, ui.scopesButton->menu()->children()) {
for (QObject* obj : ui.scopesButton->menu()->children()) {
auto* box = qobject_cast<QAction*>(obj);
if (box) {
if (box->isChecked()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment