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
198a279f
Commit
198a279f
authored
Jun 26, 2019
by
Friedrich W. H. Kossebau
Browse files
testview: port foreach -> range-based for
parent
2fe1ffa9
Changes
2
Hide whitespace changes
Inline
Side-by-side
plugins/testview/testview.cpp
View file @
198a279f
...
...
@@ -121,8 +121,8 @@ TestView::TestView(TestViewPlugin* plugin, QWidget* parent)
connect
(
tc
,
&
ITestController
::
testRunStarted
,
this
,
&
TestView
::
notifyTestCaseStarted
);
foreach
(
ITestSuite
*
suite
,
tc
->
testSuites
()
)
{
const
auto
suite
s
=
tc
->
testSuites
()
;
for
(
ITestSuite
*
suite
:
suites
)
{
addTestSuite
(
suite
);
}
}
...
...
@@ -222,15 +222,12 @@ QIcon TestView::iconForTestResult(TestResult::TestCaseResult result)
QStandardItem
*
TestView
::
itemForSuite
(
ITestSuite
*
suite
)
{
foreach
(
QStandardItem
*
item
,
m_model
->
findItems
(
suite
->
name
(),
Qt
::
MatchRecursive
))
{
if
(
item
->
parent
()
&&
item
->
parent
()
->
text
()
==
suite
->
project
()
->
name
()
&&
!
item
->
parent
()
->
parent
())
{
return
item
;
}
}
return
nullptr
;
const
auto
items
=
m_model
->
findItems
(
suite
->
name
(),
Qt
::
MatchRecursive
);
auto
it
=
std
::
find_if
(
items
.
begin
(),
items
.
end
(),
[
&
](
QStandardItem
*
item
)
{
return
(
item
->
parent
()
&&
item
->
parent
()
->
text
()
==
suite
->
project
()
->
name
()
&&
!
item
->
parent
()
->
parent
());
});
return
(
it
!=
items
.
end
())
?
*
it
:
nullptr
;
}
QStandardItem
*
TestView
::
itemForProject
(
IProject
*
project
)
...
...
@@ -268,8 +265,7 @@ void TestView::runSelectedTests()
* This is the somewhat-intuitive approach. Maybe a configuration should be offered.
*/
foreach
(
const
QModelIndex
&
idx
,
indexes
)
{
for
(
const
QModelIndex
&
idx
:
qAsConst
(
indexes
))
{
QModelIndex
index
=
m_filter
->
mapToSource
(
idx
);
if
(
index
.
parent
().
isValid
()
&&
indexes
.
contains
(
index
.
parent
()))
{
...
...
@@ -280,8 +276,8 @@ void TestView::runSelectedTests()
{
// A project was selected
IProject
*
project
=
ICore
::
self
()
->
projectController
()
->
findProjectByName
(
item
->
data
(
ProjectRole
).
toString
());
foreach
(
ITestSuite
*
suite
,
tc
->
testSuitesForProject
(
project
)
)
{
const
auto
suite
s
=
tc
->
testSuitesForProject
(
project
)
;
for
(
ITestSuite
*
suite
:
suites
)
{
jobs
<<
suite
->
launchAllCases
(
ITestSuite
::
Silent
);
}
}
...
...
@@ -366,8 +362,8 @@ void TestView::addTestSuite(ITestSuite* suite)
QStandardItem
*
suiteItem
=
new
QStandardItem
(
QIcon
::
fromTheme
(
QStringLiteral
(
"view-list-tree"
)),
suite
->
name
());
suiteItem
->
setData
(
suite
->
name
(),
SuiteRole
);
foreach
(
const
QString
&
caseName
,
suite
->
cases
()
)
{
const
auto
caseName
s
=
suite
->
cases
()
;
for
(
const
QString
&
caseName
:
caseNames
)
{
QStandardItem
*
caseItem
=
new
QStandardItem
(
iconForTestResult
(
TestResult
::
NotRun
),
caseName
);
caseItem
->
setData
(
caseName
,
CaseRole
);
suiteItem
->
appendRow
(
caseItem
);
...
...
plugins/testview/testviewplugin.cpp
View file @
198a279f
...
...
@@ -101,11 +101,11 @@ void TestViewPlugin::unload()
void
TestViewPlugin
::
runAllTests
()
{
ITestController
*
tc
=
core
()
->
testController
();
foreach
(
IProject
*
project
,
core
()
->
projectController
()
->
projects
()
)
{
const
auto
project
s
=
core
()
->
projectController
()
->
projects
()
;
for
(
IProject
*
project
:
projects
)
{
QList
<
KJob
*>
jobs
;
foreach
(
ITestSuite
*
suite
,
tc
->
testSuitesForProject
(
project
)
)
{
const
auto
suite
s
=
tc
->
testSuitesForProject
(
project
)
;
for
(
ITestSuite
*
suite
:
suites
)
{
if
(
KJob
*
job
=
suite
->
launchAllCases
(
ITestSuite
::
Silent
))
{
jobs
<<
job
;
...
...
@@ -124,8 +124,8 @@ void TestViewPlugin::runAllTests()
void
TestViewPlugin
::
stopRunningTests
()
{
foreach
(
KJob
*
job
,
core
()
->
runController
()
->
currentJobs
()
)
{
const
auto
job
s
=
core
()
->
runController
()
->
currentJobs
()
;
for
(
KJob
*
job
:
jobs
)
{
if
(
job
->
property
(
"test_job"
).
toBool
())
{
job
->
kill
();
...
...
@@ -135,15 +135,11 @@ void TestViewPlugin::stopRunningTests()
void
TestViewPlugin
::
jobStateChanged
()
{
bool
found
=
false
;
foreach
(
KJob
*
job
,
core
()
->
runController
()
->
currentJobs
())
{
if
(
job
->
property
(
"test_job"
).
toBool
())
{
found
=
true
;
break
;
}
}
const
auto
jobs
=
core
()
->
runController
()
->
currentJobs
();
const
bool
found
=
std
::
any_of
(
jobs
.
begin
(),
jobs
.
end
(),
[](
KJob
*
job
)
{
return
(
job
->
property
(
"test_job"
).
toBool
());
});
actionCollection
()
->
action
(
QStringLiteral
(
"run_all_tests"
))
->
setEnabled
(
!
found
);
actionCollection
()
->
action
(
QStringLiteral
(
"stop_running_tests"
))
->
setEnabled
(
found
);
}
...
...
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