Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Schöps
kdevelop
Commits
3abee5e5
Commit
3abee5e5
authored
Jun 26, 2019
by
Friedrich W. H. Kossebau
Browse files
contextbrowser: port foreach -> range-based for
parent
7896f4e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
plugins/contextbrowser/browsemanager.cpp
View file @
3abee5e5
...
...
@@ -57,8 +57,10 @@ EditorViewWatcher::EditorViewWatcher(QObject* parent)
connect
(
ICore
::
self
()
->
documentController
(),
&
IDocumentController
::
textDocumentCreated
,
this
,
&
EditorViewWatcher
::
documentCreated
);
foreach
(
KDevelop
::
IDocument
*
document
,
ICore
::
self
()
->
documentController
()
->
openDocuments
())
const
auto
documents
=
ICore
::
self
()
->
documentController
()
->
openDocuments
();
for
(
KDevelop
::
IDocument
*
document
:
documents
)
{
documentCreated
(
document
);
}
}
void
EditorViewWatcher
::
documentCreated
(
KDevelop
::
IDocument
*
document
)
...
...
@@ -66,7 +68,8 @@ void EditorViewWatcher::documentCreated(KDevelop::IDocument* document)
KTextEditor
::
Document
*
textDocument
=
document
->
textDocument
();
if
(
textDocument
)
{
connect
(
textDocument
,
&
Document
::
viewCreated
,
this
,
&
EditorViewWatcher
::
viewCreated
);
foreach
(
KTextEditor
::
View
*
view
,
textDocument
->
views
())
{
const
auto
views
=
textDocument
->
views
();
for
(
KTextEditor
::
View
*
view
:
views
)
{
Q_ASSERT
(
view
->
parentWidget
());
addViewInternal
(
view
);
}
...
...
@@ -121,8 +124,10 @@ BrowseManager::BrowseManager(ContextBrowserPlugin* controller)
connect
(
m_delayedBrowsingTimer
,
&
QTimer
::
timeout
,
this
,
&
BrowseManager
::
eventuallyStartDelayedBrowsing
);
foreach
(
KTextEditor
::
View
*
view
,
m_watcher
.
allViews
())
const
auto
views
=
m_watcher
.
allViews
();
for
(
KTextEditor
::
View
*
view
:
views
)
{
viewAdded
(
view
);
}
}
KTextEditor
::
View
*
viewFromWidget
(
QWidget
*
widget
)
...
...
@@ -144,7 +149,8 @@ BrowseManager::JumpLocation BrowseManager::determineJumpLoc(KTextEditor::Cursor
}
// Step 1: Look for a special language object(Macro, included header, etc.)
foreach
(
const
auto
&
language
,
ICore
::
self
()
->
languageController
()
->
languagesForUrl
(
viewUrl
))
{
const
auto
languages
=
ICore
::
self
()
->
languageController
()
->
languagesForUrl
(
viewUrl
);
for
(
const
auto
&
language
:
languages
)
{
auto
jumpTo
=
language
->
specialLanguageObjectJumpCursor
(
viewUrl
,
textCursor
);
if
(
jumpTo
.
first
.
isValid
()
&&
jumpTo
.
second
.
isValid
())
{
return
{
...
...
@@ -322,9 +328,11 @@ void BrowseManager::applyEventFilter(QWidget* object, bool install)
else
object
->
removeEventFilter
(
this
);
foreach
(
QObject
*
child
,
object
->
children
())
const
auto
children
=
object
->
children
();
for
(
QObject
*
child
:
children
)
{
if
(
qobject_cast
<
QWidget
*>
(
child
))
applyEventFilter
(
qobject_cast
<
QWidget
*>
(
child
),
install
);
}
}
void
BrowseManager
::
viewAdded
(
KTextEditor
::
View
*
view
)
...
...
@@ -367,6 +375,8 @@ Watcher::Watcher(BrowseManager* manager)
:
EditorViewWatcher
(
manager
)
,
m_manager
(
manager
)
{
foreach
(
KTextEditor
::
View
*
view
,
allViews
())
const
auto
views
=
allViews
();
for
(
KTextEditor
::
View
*
view
:
views
)
{
m_manager
->
applyEventFilter
(
view
,
true
);
}
}
plugins/contextbrowser/contextbrowser.cpp
View file @
3abee5e5
...
...
@@ -468,7 +468,8 @@ static QVector<KDevelop::IProblem::Ptr> findProblemsUnderCursor(TopDUContext* to
const
auto
modelsData
=
ICore
::
self
()
->
languageController
()
->
problemModelSet
()
->
models
();
for
(
const
auto
&
modelData
:
modelsData
)
{
foreach
(
const
auto
&
problem
,
modelData
.
model
->
problems
(
topContext
->
url
()))
{
const
auto
modelProblems
=
modelData
.
model
->
problems
(
topContext
->
url
());
for
(
const
auto
&
problem
:
modelProblems
)
{
DocumentRange
problemRange
=
problem
->
finalLocation
();
if
(
problemRange
.
contains
(
position
)
||
(
problemRange
.
isEmpty
()
&&
problemRange
.
boundaryAtCursor
(
position
)))
{
...
...
@@ -530,7 +531,7 @@ static QVector<KDevelop::IProblem::Ptr> findProblemsCloseToCursor(const TopDUCon
QVector
<
KDevelop
::
IProblem
::
Ptr
>
closestProblems
;
// Show problems, located on the same line
for
each
(
auto
problem
,
allProblems
)
{
for
(
auto
&
problem
:
qAsConst
(
allProblems
)
)
{
auto
r
=
problem
->
finalLocation
();
if
(
r
.
onSingleLine
()
&&
r
.
start
().
line
()
==
position
.
line
())
closestProblems
+=
problem
;
...
...
@@ -541,7 +542,7 @@ static QVector<KDevelop::IProblem::Ptr> findProblemsCloseToCursor(const TopDUCon
// If not, only show it in case there's only whitespace
// between the current cursor position and the problem line
if
(
closestProblems
.
isEmpty
())
{
for
each
(
auto
problem
,
allProblems
)
{
for
(
auto
&
problem
:
qAsConst
(
allProblems
)
)
{
auto
r
=
problem
->
finalLocation
();
KTextEditor
::
Range
dist
;
...
...
@@ -808,15 +809,14 @@ Declaration* ContextBrowserPlugin::findDeclaration(View* view, const KTextEditor
return
foundDeclaration
;
}
ContextBrowserView
*
ContextBrowserPlugin
::
browserViewForWidget
(
QWidget
*
widget
)
ContextBrowserView
*
ContextBrowserPlugin
::
browserViewForWidget
(
QWidget
*
widget
)
const
{
foreach
(
ContextBrowserView
*
contextView
,
m_views
)
{
if
(
masterWidget
(
contextView
)
==
masterWidget
(
widget
))
{
return
contextView
;
}
}
const
auto
masterWidgetOfWidget
=
masterWidget
(
widget
);
auto
it
=
std
::
find_if
(
m_views
.
begin
(),
m_views
.
end
(),
[
&
](
ContextBrowserView
*
contextView
)
{
return
(
masterWidget
(
contextView
)
==
masterWidgetOfWidget
);
});
return
nullptr
;
return
(
it
!=
m_views
.
end
())
?
*
it
:
nullptr
;
}
void
ContextBrowserPlugin
::
updateForView
(
View
*
view
)
...
...
@@ -920,7 +920,7 @@ void ContextBrowserPlugin::updateForView(View* view)
void
ContextBrowserPlugin
::
updateViews
()
{
for
each
(
View
*
view
,
m_updateViews
)
{
for
(
View
*
view
:
qAsConst
(
m_updateViews
)
)
{
updateForView
(
view
);
}
...
...
@@ -965,8 +965,10 @@ void ContextBrowserPlugin::textDocumentCreated(KDevelop::IDocument* document)
connect
(
document
->
textDocument
(),
&
KTextEditor
::
Document
::
viewCreated
,
this
,
&
ContextBrowserPlugin
::
viewCreated
);
foreach
(
View
*
view
,
document
->
textDocument
()
->
views
())
const
auto
views
=
document
->
textDocument
()
->
views
();
for
(
View
*
view
:
views
)
{
viewCreated
(
document
->
textDocument
(),
view
);
}
}
void
ContextBrowserPlugin
::
documentActivated
(
IDocument
*
doc
)
...
...
@@ -1069,7 +1071,7 @@ void ContextBrowserPlugin::switchUse(bool forward)
Declaration
*
decl
=
nullptr
;
//If we have a locked declaration, use that for jumping
for
each
(
ContextBrowserView
*
view
,
m_views
)
{
for
(
ContextBrowserView
*
view
:
qAsConst
(
m_views
)
)
{
decl
=
view
->
lockedDeclaration
().
data
();
///@todo Somehow match the correct context-browser view if there is multiple
if
(
decl
)
break
;
...
...
plugins/contextbrowser/contextbrowser.h
View file @
3abee5e5
...
...
@@ -216,7 +216,7 @@ private:
// Returns the currently active and visible context browser view that belongs
// to the same context (mainwindow and area) as the given widget
ContextBrowserView
*
browserViewForWidget
(
QWidget
*
widget
);
ContextBrowserView
*
browserViewForWidget
(
QWidget
*
widget
)
const
;
void
showToolTip
(
KTextEditor
::
View
*
view
,
KTextEditor
::
Cursor
position
);
QTimer
*
m_updateTimer
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment