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
63a220b0
Commit
63a220b0
authored
Jun 27, 2019
by
Friedrich W. H. Kossebau
Browse files
grepview: port foreach -> range-based for
parent
500eeea9
Changes
5
Hide whitespace changes
Inline
Side-by-side
plugins/grepview/grepdialog.cpp
View file @
63a220b0
...
...
@@ -160,14 +160,11 @@ QList<QUrl> getDirectoryChoice(const QString& text)
///Check if all directories are part of a project
bool
directoriesInProject
(
const
QString
&
dir
)
{
foreach
(
const
QUrl
&
url
,
getDirectoryChoice
(
dir
))
{
const
auto
urls
=
getDirectoryChoice
(
dir
);
return
std
::
all_of
(
urls
.
begin
(),
urls
.
end
(),
[
&
](
const
QUrl
&
url
)
{
IProject
*
proj
=
ICore
::
self
()
->
projectController
()
->
findProjectForUrl
(
url
);
if
(
!
proj
||
!
proj
->
path
().
toUrl
().
isLocalFile
())
{
return
false
;
}
}
return
true
;
return
(
proj
&&
proj
->
path
().
toUrl
().
isLocalFile
());
});
}
///Max number of items in paths combo box.
...
...
@@ -314,8 +311,8 @@ QMenu* GrepDialog::createSyncButtonMenu()
}
QVector
<
QUrl
>
otherProjectUrls
;
foreach
(
IProject
*
project
,
m_plugin
->
core
()
->
projectController
()
->
projects
()
)
{
const
auto
project
s
=
m_plugin
->
core
()
->
projectController
()
->
projects
()
;
for
(
IProject
*
project
:
projects
)
{
if
(
!
hadUrls
.
contains
(
project
->
path
()))
{
otherProjectUrls
.
append
(
project
->
path
().
toUrl
());
}
...
...
@@ -323,8 +320,7 @@ QMenu* GrepDialog::createSyncButtonMenu()
// sort the remaining project URLs alphabetically
std
::
sort
(
otherProjectUrls
.
begin
(),
otherProjectUrls
.
end
());
foreach
(
const
QUrl
&
url
,
otherProjectUrls
)
{
for
(
const
QUrl
&
url
:
qAsConst
(
otherProjectUrls
))
{
addUrlToMenu
(
ret
,
url
);
}
...
...
@@ -442,7 +438,8 @@ bool GrepDialog::checkProjectsOpened()
KDevelop
::
ICore
::
self
()
->
projectController
()
->
projects
().
count
())
return
false
;
foreach
(
IProject
*
p
,
KDevelop
::
ICore
::
self
()
->
projectController
()
->
projects
())
{
const
auto
projects
=
KDevelop
::
ICore
::
self
()
->
projectController
()
->
projects
();
for
(
IProject
*
p
:
projects
)
{
if
(
!
p
->
isReady
())
return
false
;
}
...
...
@@ -466,7 +463,8 @@ void GrepDialog::nextHistory(bool next)
bool
GrepDialog
::
isPartOfChoice
(
const
QUrl
&
url
)
const
{
foreach
(
const
QUrl
&
choice
,
getDirectoryChoice
(
m_settings
.
searchPaths
))
{
const
auto
choices
=
getDirectoryChoice
(
m_settings
.
searchPaths
);
for
(
const
QUrl
&
choice
:
choices
)
{
if
(
choice
.
isParentOf
(
url
)
||
choice
==
url
)
return
true
;
}
...
...
@@ -484,8 +482,8 @@ void GrepDialog::startSearch()
// search for unsaved documents
QList
<
IDocument
*>
unsavedFiles
;
foreach
(
ID
ocument
*
doc
,
ICore
::
self
()
->
documentController
()
->
openDocuments
()
)
{
const
auto
d
ocument
s
=
ICore
::
self
()
->
documentController
()
->
openDocuments
()
;
for
(
IDocument
*
doc
:
documents
)
{
QUrl
docUrl
=
doc
->
url
();
if
(
doc
->
state
()
!=
IDocument
::
Clean
&&
isPartOfChoice
(
docUrl
)
&&
...
...
plugins/grepview/grepfindthread.cpp
View file @
63a220b0
...
...
@@ -82,8 +82,7 @@ static QList<QUrl> thread_findFiles(const QDir& dir, int depth, const QStringLis
infos
<<
QFileInfo
(
dir
.
path
());
QList
<
QUrl
>
dirFiles
;
foreach
(
const
QFileInfo
&
currFile
,
infos
)
{
for
(
const
QFileInfo
&
currFile
:
qAsConst
(
infos
))
{
QString
currName
=
currFile
.
canonicalFilePath
();
if
(
!
QDir
::
match
(
exclude
,
currName
))
dirFiles
<<
QUrl
::
fromLocalFile
(
currName
);
...
...
@@ -91,8 +90,8 @@ static QList<QUrl> thread_findFiles(const QDir& dir, int depth, const QStringLis
if
(
depth
!=
0
)
{
static
const
QDir
::
Filters
dirFilter
=
QDir
::
NoDotAndDotDot
|
QDir
::
AllDirs
|
QDir
::
Readable
|
QDir
::
NoSymLinks
;
foreach
(
const
QFileInfo
&
currDir
,
dir
.
entryInfoList
(
QStringList
(),
dirFilter
)
)
{
const
auto
dirs
=
dir
.
entryInfoList
(
QStringList
(),
dirFilter
)
;
for
(
const
QFileInfo
&
currDir
:
dirs
)
{
if
(
abort
)
break
;
QString
canonical
=
currDir
.
canonicalFilePath
();
...
...
@@ -142,8 +141,7 @@ void GrepFindFilesThread::run()
qCDebug
(
PLUGIN_GREPVIEW
)
<<
"running with start dir"
<<
m_startDirs
;
foreach
(
const
QUrl
&
directory
,
m_startDirs
)
{
for
(
const
QUrl
&
directory
:
qAsConst
(
m_startDirs
))
{
if
(
m_project
)
m_files
+=
thread_getProjectFiles
(
directory
,
m_depth
,
include
,
exclude
,
m_tryAbort
);
else
...
...
plugins/grepview/grepoutputview.cpp
View file @
63a220b0
...
...
@@ -188,7 +188,7 @@ GrepOutputView::~GrepOutputView()
cg
.
writeEntry
(
"LastReplacementItems"
,
qCombo2StringList
(
replacementCombo
,
true
));
QStringList
settingsStrings
;
settingsStrings
.
reserve
(
m_settingsHistory
.
size
()
*
GrepSettingsStorageItemCount
);
for
each
(
const
GrepJobSettings
&
s
,
m_settingsHistory
)
{
for
(
const
GrepJobSettings
&
s
:
qAsConst
(
m_settingsHistory
)
)
{
settingsStrings
<<
QString
::
number
(
s
.
projectFilesOnly
?
1
:
0
)
<<
QString
::
number
(
s
.
caseSensitive
?
1
:
0
)
...
...
plugins/grepview/grepviewplugin.cpp
View file @
63a220b0
...
...
@@ -105,7 +105,7 @@ GrepViewPlugin::~GrepViewPlugin()
void
GrepViewPlugin
::
unload
()
{
for
each
(
const
QPointer
<
GrepDialog
>
&
p
,
m_currentDialogs
)
{
for
(
const
QPointer
<
GrepDialog
>
&
p
:
qAsConst
(
m_currentDialogs
)
)
{
if
(
p
)
{
p
->
reject
();
p
->
deleteLater
();
...
...
plugins/grepview/tests/test_findreplace.cpp
View file @
63a220b0
...
...
@@ -153,8 +153,7 @@ void FindReplaceTest::testReplace()
QTemporaryDir
tempDir
;
QDir
dir
(
tempDir
.
path
());
// we need some convenience functions that are not in QTemporaryDir
foreach
(
const
File
&
fileData
,
subject
)
{
for
(
const
File
&
fileData
:
qAsConst
(
subject
))
{
QFile
file
(
dir
.
filePath
(
fileData
.
first
));
QVERIFY
(
file
.
open
(
QIODevice
::
WriteOnly
));
QVERIFY
(
file
.
write
(
fileData
.
second
.
toUtf8
())
!=
-
1
);
...
...
@@ -187,8 +186,7 @@ void FindReplaceTest::testReplace()
model
->
makeItemsCheckable
(
true
);
model
->
doReplacements
();
foreach
(
const
File
&
fileData
,
result
)
{
for
(
const
File
&
fileData
:
qAsConst
(
result
))
{
QFile
file
(
dir
.
filePath
(
fileData
.
first
));
QVERIFY
(
file
.
open
(
QIODevice
::
ReadOnly
));
QCOMPARE
(
QString
(
file
.
readAll
()),
fileData
.
second
);
...
...
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