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

kdevplastform/debugger: port foreach -> range-based for

parent cc85d8d7
......@@ -83,8 +83,10 @@ BreakpointModel::BreakpointModel(QObject* parent)
connect(this, &BreakpointModel::dataChanged, this, &BreakpointModel::updateMarks);
if (KDevelop::ICore::self()->partController()) { //TODO remove if
foreach(KParts::Part* p, KDevelop::ICore::self()->partController()->parts())
const auto parts = KDevelop::ICore::self()->partController()->parts();
for (KParts::Part* p : parts) {
slotPartAdded(p);
}
connect(KDevelop::ICore::self()->partController(),
&IPartController::partAdded,
this,
......@@ -457,7 +459,7 @@ void KDevelop::BreakpointModel::updateMarks()
return;
//add marks
foreach (Breakpoint* breakpoint, d->breakpoints) {
for (Breakpoint* breakpoint : qAsConst(d->breakpoints)) {
if (breakpoint->kind() != Breakpoint::CodeBreakpoint) continue;
if (breakpoint->line() == -1) continue;
IDocument *doc = ICore::self()->documentController()->documentForUrl(breakpoint->url());
......@@ -481,16 +483,17 @@ void KDevelop::BreakpointModel::updateMarks()
}
//remove marks
foreach (IDocument *doc, ICore::self()->documentController()->openDocuments()) {
const auto documents = ICore::self()->documentController()->openDocuments();
for (IDocument* doc : documents) {
KTextEditor::MarkInterface *mark = qobject_cast<KTextEditor::MarkInterface*>(doc->textDocument());
if (!mark) continue;
{
QSignalBlocker blocker(doc->textDocument());
foreach (KTextEditor::Mark *m, mark->marks()) {
for (KTextEditor::Mark* m : mark->marks()) {
if (!(m->type & AllBreakpointMarks)) continue;
IF_DEBUG( qCDebug(DEBUGGER) << m->line << m->type; )
foreach (Breakpoint* breakpoint, d->breakpoints) {
for (Breakpoint* breakpoint : qAsConst(d->breakpoints)) {
if (breakpoint->kind() != Breakpoint::CodeBreakpoint) continue;
if (doc->url() == breakpoint->url() && m->line == breakpoint->line()) {
goto continueNextMark;
......@@ -506,7 +509,7 @@ void KDevelop::BreakpointModel::updateMarks()
void BreakpointModel::documentSaved(KDevelop::IDocument* doc)
{
IF_DEBUG( qCDebug(DEBUGGER); )
foreach (Breakpoint* breakpoint, d->breakpoints) {
for (Breakpoint* breakpoint : qAsConst(d->breakpoints)) {
if (breakpoint->movingCursor()) {
if (breakpoint->movingCursor()->document() != doc->textDocument()) continue;
if (breakpoint->movingCursor()->line() == breakpoint->line()) continue;
......@@ -518,7 +521,7 @@ void BreakpointModel::documentSaved(KDevelop::IDocument* doc)
}
void BreakpointModel::aboutToDeleteMovingInterfaceContent(KTextEditor::Document* document)
{
foreach (Breakpoint* breakpoint, d->breakpoints) {
for (Breakpoint* breakpoint : qAsConst(d->breakpoints)) {
if (breakpoint->movingCursor() && breakpoint->movingCursor()->document() == document) {
breakpoint->setMovingCursor(nullptr);
}
......@@ -548,7 +551,7 @@ void BreakpointModel::save()
KConfigGroup breakpoints = ICore::self()->activeSession()->config()->group("Breakpoints");
breakpoints.writeEntry("number", d->breakpoints.count());
int i = 0;
foreach (Breakpoint* b, d->breakpoints) {
for (Breakpoint* b : qAsConst(d->breakpoints)) {
KConfigGroup g = breakpoints.group(QString::number(i));
b->save(g);
++i;
......@@ -657,10 +660,8 @@ void BreakpointModel::registerBreakpoint(Breakpoint* breakpoint)
Breakpoint* BreakpointModel::breakpoint(const QUrl& url, int line) const
{
foreach (Breakpoint* b, d->breakpoints) {
if (b->url() == url && b->line() == line) {
return b;
}
}
return nullptr;
auto it = std::find_if(d->breakpoints.constBegin(), d->breakpoints.constEnd(), [&](Breakpoint* b) {
return (b->url() == url && b->line() == line);
});
return (it != d->breakpoints.constEnd()) ? *it : nullptr;
}
......@@ -96,7 +96,7 @@ void FrameStackModel::setThreads(const QVector<ThreadItem>& threads)
QModelIndex FrameStackModelPrivate::indexForThreadNumber(int threadNumber)
{
int i=0;
foreach (const auto &t, m_threads) {
for (const auto& t : qAsConst(m_threads)) {
if (t.nr == threadNumber) {
return q->index(i, 0);
}
......@@ -330,7 +330,7 @@ int FrameStackModel::currentThread() const
QModelIndex FrameStackModel::currentThreadIndex() const
{
int i = 0;
foreach (const ThreadItem &t, d->m_threads) {
for (const ThreadItem& t : qAsConst(d->m_threads)) {
if (t.nr == currentThread()) {
return index(i, 0);
}
......
......@@ -140,7 +140,8 @@ void IBreakpointController::debuggerStateChanged(IDebugSession::DebuggerState st
return;
//breakpoint state changes when session started or stopped
foreach (Breakpoint* breakpoint, model->breakpoints()) {
const auto breakpoints = model->breakpoints();
for (Breakpoint* breakpoint : breakpoints) {
if (state == IDebugSession::StartingState) {
auto& dirty = m_dirty[breakpoint];
......@@ -163,7 +164,8 @@ void IBreakpointController::sendMaybeAll()
if (!model)
return;
foreach (Breakpoint *breakpoint, model->breakpoints()) {
const auto breakpoints = model->breakpoints();
for (Breakpoint* breakpoint : breakpoints) {
sendMaybe(breakpoint);
}
}
......
......@@ -71,7 +71,8 @@ void IVariableController::stateChanged(IDebugSession::DebuggerState state)
d->activeFrame = -1;
} else if (state == IDebugSession::EndedState || state == IDebugSession::NotStartedState) {
// Remove all locals.
foreach (Locals *l, variableCollection()->allLocals()) {
const auto locals = variableCollection()->allLocals();
for (Locals* l : locals) {
l->deleteChildren();
l->setHasMore(false);
}
......@@ -102,7 +103,8 @@ void IVariableController::handleEvent(IDebugSession::event_t event)
case IDebugSession::thread_or_frame_changed:
qCDebug(DEBUGGER) << d->autoUpdate;
if (!(d->autoUpdate & UpdateLocals)) {
foreach (Locals *l, variableCollection()->allLocals()) {
const auto locals = variableCollection()->allLocals();
for (Locals* l : locals) {
if (!l->isExpanded() && !l->childCount()) {
l->setHasMore(true);
}
......
......@@ -39,7 +39,8 @@ namespace {
static QUrl rebaseMatchingUrl(const QUrl& toRebase, const KConfigGroup& config, const QString& baseEntry, const QString& rebaseEntry)
{
const QUrl::UrlFormattingOption matchOpts = QUrl::NormalizePathSegments;
foreach (const QString &group, config.groupList()) {
const auto configGroups = config.groupList();
for (const QString& group : configGroups) {
KConfigGroup pathCfg = config.group(group);
const QString baseStr = pathCfg.readEntry(baseEntry, QUrl()).url(matchOpts);
const QString searchStr = toRebase.url(matchOpts);
......@@ -185,14 +186,14 @@ public:
endResetModel();
}
void saveToConfiguration(KConfigGroup config)
void saveToConfiguration(KConfigGroup config) const
{
qCDebug(DEBUGGER) << m_paths.count();
KConfigGroup cfg = config.group(PathMappings::pathMappingsEntry);
cfg.writeEntry("Count", m_paths.count());
int i=0;
foreach (const Path &p, m_paths) {
for (const Path& p : m_paths) {
i++;
KConfigGroup pCfg = cfg.group(QString::number(i));
pCfg.writeEntry(PathMappings::pathMappingRemoteEntry, p.remote);
......@@ -240,7 +241,8 @@ PathMappingsWidget::PathMappingsWidget(QWidget* parent): QWidget(parent)
void PathMappingsWidget::deletePath()
{
foreach (const QModelIndex &i, m_pathMappingTable->selectionModel()->selectedRows()) {
const auto selectedRows = m_pathMappingTable->selectionModel()->selectedRows();
for (const QModelIndex& i : selectedRows) {
m_pathMappingTable->model()->removeRow(i.row(), i.parent());
}
}
......
......@@ -36,8 +36,10 @@ TreeItem::TreeItem(TreeModel* model, TreeItem *parent)
TreeItem::~TreeItem()
{
foreach (TreeItem *it, childItems)
const auto copy = childItems;
for (TreeItem* it : copy) {
delete it;
}
delete ellipsis_;
}
......
......@@ -336,7 +336,7 @@ QList<Variable*> Locals::updateLocals(const QStringList& locals)
existing << var->expression();
}
foreach (const QString& var, locals) {
for (const QString& var : locals) {
current << var;
// If we currently don't display this local var, add it.
if( !existing.contains( var ) ) {
......@@ -371,7 +371,7 @@ QList<Variable*> Locals::updateLocals(const QStringList& locals)
QList<Variable*> ret;
ret.reserve(childItems.size());
foreach (TreeItem *i, childItems) {
for (TreeItem* i : qAsConst(childItems)) {
Q_ASSERT(qobject_cast<Variable*>(i));
ret << static_cast<Variable*>(i);
}
......@@ -414,7 +414,7 @@ QHash<QString, Locals*> VariablesRoot::allLocals() const
void VariablesRoot::resetChanged()
{
m_watches->resetChanged();
foreach (Locals *l, m_locals) {
for (Locals* l : qAsConst(m_locals)) {
l->resetChanged();
}
}
......@@ -484,8 +484,10 @@ void VariableCollection::textDocumentCreated(IDocument* doc)
&KTextEditor::Document::viewCreated,
this, &VariableCollection::viewCreated );
foreach( KTextEditor::View* view, doc->textDocument()->views() )
const auto views = doc->textDocument()->views();
for (KTextEditor::View* view : views) {
viewCreated( doc->textDocument(), view );
}
}
void VariableCollection::viewCreated(KTextEditor::Document* doc,
......
......@@ -228,8 +228,8 @@ void VariableTree::setupActions()
act->setShortcut(Qt::Key_H);
m_formatMenu->addAction(act);
foreach(QAction* act, m_formatMenu->actions())
{
const auto formatMenuActions = m_formatMenu->actions();
for (QAction* act : formatMenuActions) {
act->setCheckable(true);
act->setShortcutContext(Qt::WidgetWithChildrenShortcut);
const int id = act->data().toInt();
......@@ -274,7 +274,8 @@ void VariableTree::contextMenuEvent(QContextMenuEvent* event)
if(selectedVariable()->canSetFormat())
contextMenu.addMenu(m_formatMenu);
foreach(QAction* act, m_formatMenu->actions()) {
const auto formatMenuActions = m_formatMenu->actions();
for (QAction* act : formatMenuActions) {
if(act->data().toInt()==selectedVariable()->format())
act->setChecked(true);
}
......
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