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

patchreview: port foreach -> range-based for

parent 896df055
......@@ -272,19 +272,23 @@ bool PatchHighlighter::isRemoval( Diff2::Difference* diff ) {
void PatchHighlighter::performContentChange( KTextEditor::Document* doc, const QStringList& oldLines, const QStringList& newLines, int editLineNumber ) {
QPair<QList<Diff2::Difference*>, QList<Diff2::Difference*> > diffChange = m_model->linesChanged( oldLines, newLines, editLineNumber );
QList<Diff2::Difference*> inserted = diffChange.first;
QList<Diff2::Difference*> removed = diffChange.second;
const QList<Diff2::Difference*>& inserted = diffChange.first;
const QList<Diff2::Difference*>& removed = diffChange.second;
foreach(Diff2::Difference* d, removed) {
foreach(Diff2::DifferenceString* s, d->sourceLines())
for (Diff2::Difference* d : removed) {
const auto sourceLines = d->sourceLines();
for (Diff2::DifferenceString* s : sourceLines)
qCDebug(PLUGIN_PATCHREVIEW) << "removed source" << s->string();
foreach(Diff2::DifferenceString* s, d->destinationLines())
const auto destinationLines = d->destinationLines();
for (Diff2::DifferenceString* s : destinationLines)
qCDebug(PLUGIN_PATCHREVIEW) << "removed destination" << s->string();
}
foreach(Diff2::Difference* d, inserted) {
foreach(Diff2::DifferenceString* s, d->sourceLines())
for (Diff2::Difference* d : inserted) {
const auto sourceLines = d->sourceLines();
for (Diff2::DifferenceString* s : sourceLines)
qCDebug(PLUGIN_PATCHREVIEW) << "inserted source" << s->string();
foreach(Diff2::DifferenceString* s, d->destinationLines())
const auto destinationLines = d->destinationLines();
for (Diff2::DifferenceString* s : destinationLines)
qCDebug(PLUGIN_PATCHREVIEW) << "inserted destination" << s->string();
}
......@@ -306,7 +310,7 @@ void PatchHighlighter::performContentChange( KTextEditor::Document* doc, const Q
if ( !moving )
return;
foreach( Diff2::Difference* diff, inserted ) {
for (Diff2::Difference* diff : inserted) {
int lineStart = diff->destinationLineNumber();
if ( lineStart > 0 ) {
--lineStart;
......@@ -658,7 +662,8 @@ void PatchHighlighter::clear() {
if( !markIface )
return;
foreach( int line, markIface->marks().keys() ) {
for (auto it = markIface->marks().begin(), end = markIface->marks().end(); it != end; ++it) {
int line = it.key();
markIface->removeMark( line, m_allmarks );
}
......
......@@ -410,7 +410,8 @@ void PatchReviewPlugin::startReview( IPatchSource* patch, IPatchReview::ReviewMo
void PatchReviewPlugin::switchToEmptyReviewArea()
{
foreach(Sublime::Area* area, ICore::self()->uiController()->allAreas()) {
const auto allAreas = ICore::self()->uiController()->allAreas();
for (Sublime::Area* area : allAreas) {
if (area->objectName() == QLatin1String("review")) {
area->clearDocuments();
}
......@@ -427,7 +428,7 @@ QUrl PatchReviewPlugin::urlForFileModel( const Diff2::DiffModel* model )
if (destPath.size() >= (int)m_depth) {
destPath.remove(0, m_depth);
}
foreach(const QString& segment, destPath) {
for (const QString& segment : qAsConst(destPath)) {
path.addPath(segment);
}
path.addPath(model->destinationFile());
......@@ -536,7 +537,8 @@ PatchReviewPlugin::PatchReviewPlugin( QObject *parent, const QVariantList & )
actionCollection()->setDefaultShortcut( m_finishReview, Qt::CTRL|Qt::Key_Return );
actionCollection()->addAction(QStringLiteral("commit_or_finish_review"), m_finishReview);
foreach(Sublime::Area* area, ICore::self()->uiController()->allAreas()) {
const auto allAreas = ICore::self()->uiController()->allAreas();
for (Sublime::Area* area : allAreas) {
if (area->objectName() == QLatin1String("review"))
area->addAction(m_finishReview);
}
......@@ -592,7 +594,8 @@ KDevelop::ContextMenuExtension PatchReviewPlugin::contextMenuExtension(KDevelop:
urls = filectx->urls();
} else if ( context->type() == KDevelop::Context::ProjectItemContext ) {
auto* projctx = static_cast<KDevelop::ProjectItemContext*>(context);
foreach( KDevelop::ProjectBaseItem* item, projctx->items() ) {
const auto items = projctx->items();
for (KDevelop::ProjectBaseItem* item : items) {
if ( item->file() ) {
urls << item->file()->path().toUrl();
}
......
......@@ -278,8 +278,7 @@ void PatchReviewToolView::customContextMenuRequested(const QPoint& pos)
}
QList<QAction*> vcsActions;
foreach( const ContextMenuExtension& ext, extensions )
{
for (const ContextMenuExtension& ext : qAsConst(extensions)) {
vcsActions += ext.actions(ContextMenuExtension::VcsGroup);
}
......@@ -365,8 +364,8 @@ void PatchReviewToolView::open( const QUrl& url, bool activate ) const
qCDebug(PLUGIN_PATCHREVIEW) << "activating url" << url;
// If the document is already open in this area, just re-activate it
if(KDevelop::IDocument* doc = ICore::self()->documentController()->documentForUrl(url)) {
foreach(Sublime::View* view, ICore::self()->uiController()->activeArea()->views())
{
const auto views = ICore::self()->uiController()->activeArea()->views();
for (Sublime::View* view : views) {
if(view->document() == dynamic_cast<Sublime::Document*>(doc))
{
if (activate) {
......@@ -426,8 +425,8 @@ void PatchReviewToolView::fileItemChanged( QStandardItem* item )
{ // The file was deselected, so eventually close it
if(doc && doc->state() == IDocument::Clean)
{
foreach(Sublime::View* view, ICore::self()->uiController()->activeArea()->views())
{
const auto views = ICore::self()->uiController()->activeArea()->views();
for (Sublime::View* view : views) {
if(view->document() == dynamic_cast<Sublime::Document*>(doc))
{
ICore::self()->uiController()->activeArea()->closeView(view);
......
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