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
Plasma
Plasma Workspace
Commits
d3f58b05
Commit
d3f58b05
authored
Dec 29, 2020
by
Alexander Lohnau
💬
Browse files
Port a bunch of foreach usages
parent
053b187c
Changes
31
Hide whitespace changes
Inline
Side-by-side
applets/digital-clock/plugin/timezonemodel.cpp
View file @
d3f58b05
...
...
@@ -178,7 +178,7 @@ void TimeZoneModel::update()
}
cities
.
sort
(
Qt
::
CaseInsensitive
);
Q_FOREACH
(
const
QString
&
key
,
cities
)
{
for
(
const
QString
&
key
:
qAsConst
(
cities
)
)
{
const
QTimeZone
timeZone
=
zonesByCity
.
value
(
key
);
QString
comment
=
timeZone
.
comment
();
...
...
applets/kicker/plugin/actionlist.cpp
View file @
d3f58b05
...
...
@@ -91,12 +91,12 @@ QVariantList createActionListForFileItem(const KFileItem &fileItem)
{
QVariantList
list
;
KService
::
List
services
=
KApplicationTrader
::
queryByMimeType
(
fileItem
.
mimetype
());
const
KService
::
List
services
=
KApplicationTrader
::
queryByMimeType
(
fileItem
.
mimetype
());
if
(
!
services
.
isEmpty
())
{
list
<<
createTitleActionItem
(
i18n
(
"Open with:"
));
for
each
(
const
KService
::
Ptr
service
,
services
)
{
for
(
const
KService
::
Ptr
service
:
services
)
{
const
QString
text
=
service
->
name
().
replace
(
QLatin1Char
(
'&'
),
QStringLiteral
(
"&&"
));
QVariantMap
item
=
createActionItem
(
text
,
service
->
icon
(),
QStringLiteral
(
"_kicker_fileItem_openWith"
),
service
->
entryPath
());
...
...
@@ -225,7 +225,7 @@ QVariantList jumpListActions(KService::Ptr service)
}
const
auto
&
actions
=
service
->
actions
();
for
each
(
const
KServiceAction
&
action
,
actions
)
{
for
(
const
KServiceAction
&
action
:
actions
)
{
if
(
action
.
text
().
isEmpty
()
||
action
.
exec
().
isEmpty
())
{
continue
;
}
...
...
applets/kicker/plugin/appsmodel.cpp
View file @
d3f58b05
...
...
@@ -77,7 +77,7 @@ AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesO
foreach
(
AbstractEntry
*
suggestedEntry
,
entryList
)
{
bool
found
=
false
;
for
each
(
const
AbstractEntry
*
entry
,
m_entryList
)
{
for
(
const
AbstractEntry
*
entry
:
qAsConst
(
m_entryList
)
)
{
if
(
entry
->
type
()
==
AbstractEntry
::
RunnableType
&&
static_cast
<
const
AppEntry
*>
(
entry
)
->
service
()
->
storageId
()
==
static_cast
<
const
AppEntry
*>
(
suggestedEntry
)
->
service
()
->
storageId
())
{
...
...
@@ -520,7 +520,7 @@ void AppsModel::refreshInternal()
bool
found
=
false
;
for
each
(
const
AbstractEntry
*
entry
,
m_entryList
)
{
for
(
const
AbstractEntry
*
entry
:
qAsConst
(
m_entryList
)
)
{
if
(
entry
->
type
()
==
AbstractEntry
::
RunnableType
&&
static_cast
<
const
AppEntry
*>
(
entry
)
->
service
()
->
storageId
()
==
service
->
storageId
())
{
found
=
true
;
...
...
@@ -658,7 +658,7 @@ void AppsModel::processServiceGroup(KServiceGroup::Ptr group)
bool
found
=
false
;
for
each
(
const
AbstractEntry
*
entry
,
m_entryList
)
{
for
(
const
AbstractEntry
*
entry
:
qAsConst
(
m_entryList
)
)
{
if
(
entry
->
type
()
==
AbstractEntry
::
RunnableType
&&
static_cast
<
const
AppEntry
*>
(
entry
)
->
service
()
->
storageId
()
==
service
->
storageId
())
{
found
=
true
;
...
...
applets/kicker/plugin/recentcontactsmodel.cpp
View file @
d3f58b05
...
...
@@ -114,7 +114,7 @@ bool RecentContactsModel::trigger(int row, const QString &actionId, const QVaria
if
(
!
actionList
.
isEmpty
())
{
QAction
*
chat
=
nullptr
;
for
each
(
QAction
*
action
,
actionList
)
{
for
(
QAction
*
action
:
actionList
)
{
const
QVariant
&
actionType
=
action
->
property
(
"actionType"
);
if
(
!
actionType
.
isNull
()
&&
actionType
.
toInt
()
==
KPeople
::
ActionType
::
TextChatAction
)
{
...
...
applets/kicker/plugin/runnermatchesmodel.cpp
View file @
d3f58b05
...
...
@@ -93,8 +93,8 @@ QVariant RunnerMatchesModel::data(const QModelIndex &index, int role) const
return
match
.
runner
()
->
id
()
==
QLatin1String
(
"services"
)
||
!
runner
->
actions
().
isEmpty
();
}
else
if
(
role
==
Kicker
::
ActionListRole
)
{
QVariantList
actionList
;
for
each
(
QAction
*
action
,
m_runnerManager
->
actionsForMatch
(
match
)
)
{
const
QList
<
QAction
*>
actions
=
m_runnerManager
->
actionsForMatch
(
match
);
for
(
QAction
*
action
:
actions
)
{
QVariantMap
item
=
Kicker
::
createActionItem
(
action
->
text
(),
action
->
icon
().
name
(),
QStringLiteral
(
"runnerAction"
),
QVariant
::
fromValue
<
QObject
*>
(
action
));
...
...
applets/kicker/plugin/runnermodel.cpp
View file @
d3f58b05
...
...
@@ -215,7 +215,7 @@ void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
// We do not use a QMultiHash here because it keeps values in LIFO order, while we want FIFO.
QHash
<
QString
,
QList
<
Plasma
::
QueryMatch
>
>
matchesForRunner
;
for
each
(
const
Plasma
::
QueryMatch
&
match
,
matches
)
{
for
(
const
Plasma
::
QueryMatch
&
match
:
matches
)
{
auto
it
=
matchesForRunner
.
find
(
match
.
runner
()
->
id
());
if
(
it
==
matchesForRunner
.
end
())
{
...
...
components/shellprivate/interactiveconsole/interactiveconsole.cpp
View file @
d3f58b05
...
...
@@ -129,7 +129,7 @@ InteractiveConsole::InteractiveConsole(QWidget *parent)
editorLayout
->
addWidget
(
toolBar
);
const
KService
::
List
offers
=
KServiceTypeTrader
::
self
()
->
query
(
QStringLiteral
(
"KTextEditor/Document"
));
for
each
(
const
KService
::
Ptr
&
service
,
offers
)
{
for
(
const
KService
::
Ptr
&
service
:
offers
)
{
m_editorPart
=
service
->
createInstance
<
KTextEditor
::
Document
>
(
widget
);
if
(
m_editorPart
)
{
m_editorPart
->
setHighlightingMode
(
QStringLiteral
(
"JavaScript/PlasmaDesktop"
));
...
...
components/shellprivate/widgetexplorer/plasmaappletitemmodel.cpp
View file @
d3f58b05
...
...
@@ -311,7 +311,7 @@ void PlasmaAppletItemModel::populateModel(const QStringList &whatChanged)
void
PlasmaAppletItemModel
::
setRunningApplets
(
const
QHash
<
QString
,
int
>
&
apps
)
{
//foreach item, find that string and set the count
//for
each item, find that string and set the count
for
(
int
r
=
0
;
r
<
rowCount
();
++
r
)
{
QStandardItem
*
i
=
item
(
r
);
PlasmaAppletItem
*
p
=
dynamic_cast
<
PlasmaAppletItem
*>
(
i
);
...
...
@@ -373,7 +373,7 @@ QMimeData *PlasmaAppletItemModel::mimeData(const QModelIndexList &indexes) const
QByteArray
appletNames
;
int
lastRow
=
-
1
;
for
each
(
const
QModelIndex
&
index
,
indexes
)
{
for
(
const
QModelIndex
&
index
:
indexes
)
{
if
(
index
.
row
()
==
lastRow
)
{
continue
;
}
...
...
components/shellprivate/widgetexplorer/widgetexplorer.cpp
View file @
d3f58b05
...
...
@@ -138,7 +138,6 @@ void WidgetExplorerPrivate::initFilters()
typedef
QPair
<
QString
,
QString
>
catPair
;
QMap
<
QString
,
catPair
>
categories
;
QSet
<
QString
>
existingCategories
=
itemModel
.
categories
();
//foreach (const QString &category, Plasma::Applet::listCategories(application)) {
QStringList
cats
;
const
QList
<
KPluginMetaData
>
list
=
PluginLoader
::
self
()
->
listAppletMetaData
(
QString
());
...
...
@@ -157,7 +156,7 @@ void WidgetExplorerPrivate::initFilters()
}
}
qWarning
()
<<
"TODO: port listCategories()"
;
for
each
(
const
QString
&
category
,
cats
)
{
for
(
const
QString
&
category
:
qAsConst
(
cats
)
)
{
const
QString
lowerCaseCat
=
category
.
toLower
();
if
(
existingCategories
.
contains
(
lowerCaseCat
))
{
const
QString
trans
=
i18nd
(
"libplasma5"
,
category
.
toLocal8Bit
());
...
...
@@ -165,7 +164,7 @@ void WidgetExplorerPrivate::initFilters()
}
}
for
each
(
const
catPair
&
category
,
categories
)
{
for
(
const
catPair
&
category
:
qAsConst
(
categories
)
)
{
filterModel
.
addFilter
(
category
.
first
,
KCategorizedItemsViewModels
::
Filter
(
QStringLiteral
(
"category"
),
category
.
second
));
}
...
...
@@ -525,10 +524,10 @@ void WidgetExplorer::uninstall(const QString &pluginName)
if
(
corona
())
{
const
auto
&
containments
=
corona
()
->
containments
();
for
each
(
Containment
*
c
,
containments
)
{
for
(
Containment
*
c
:
containments
)
{
const
auto
&
applets
=
c
->
applets
();
for
each
(
Applet
*
applet
,
applets
)
{
for
(
Applet
*
applet
:
applets
)
{
const
auto
&
appletInfo
=
applet
->
pluginMetaData
();
if
(
appletInfo
.
isValid
()
&&
appletInfo
.
pluginId
()
==
pluginName
)
{
...
...
containmentactions/applauncher/launch.cpp
View file @
d3f58b05
...
...
@@ -49,7 +49,8 @@ QList<QAction*> AppLauncher::contextualActions()
void
AppLauncher
::
makeMenu
(
QMenu
*
menu
,
const
KServiceGroup
::
Ptr
group
)
{
foreach
(
KSycocaEntry
::
Ptr
p
,
group
->
entries
(
true
,
true
,
true
))
{
const
auto
entries
=
group
->
entries
(
true
,
true
,
true
);
for
(
const
KSycocaEntry
::
Ptr
&
p
:
entries
)
{
if
(
p
->
isType
(
KST_KService
))
{
const
KService
::
Ptr
service
(
static_cast
<
KService
*>
(
p
.
data
()));
...
...
containmentactions/contextmenu/menu.cpp
View file @
d3f58b05
...
...
@@ -93,7 +93,7 @@ void ContextMenu::restore(const KConfigGroup &config)
disabled
.
insert
(
QStringLiteral
(
"configure shortcuts"
));
}
for
each
(
const
QString
&
name
,
m_actionOrder
)
{
for
(
const
QString
&
name
:
qAsConst
(
m_actionOrder
)
)
{
actions
.
insert
(
name
,
!
disabled
.
contains
(
name
));
}
...
...
dataengines/activities/activityengine.cpp
View file @
d3f58b05
...
...
@@ -44,9 +44,9 @@ void ActivityEngine::init()
}
else
{
m_activityController
=
new
KActivities
::
Controller
(
this
);
m_currentActivity
=
m_activityController
->
currentActivity
();
QStringList
activities
=
m_activityController
->
activities
();
const
QStringList
activities
=
m_activityController
->
activities
();
//setData("allActivities", activities);
for
each
(
const
QString
&
id
,
activities
)
{
for
(
const
QString
&
id
:
activities
)
{
insertActivity
(
id
);
}
...
...
@@ -160,7 +160,7 @@ void ActivityEngine::setActivityScores(const ActivityDataList &activities)
QSet
<
QString
>
presentActivities
;
m_activityScores
.
clear
();
for
each
(
const
ActivityData
&
activity
,
activities
)
{
for
(
const
ActivityData
&
activity
:
activities
)
{
if
(
m_activities
.
contains
(
activity
.
id
))
{
setData
(
activity
.
id
,
QStringLiteral
(
"Score"
),
activity
.
score
);
}
...
...
@@ -168,7 +168,8 @@ void ActivityEngine::setActivityScores(const ActivityDataList &activities)
m_activityScores
[
activity
.
id
]
=
activity
.
score
;
}
foreach
(
const
QString
&
activityId
,
m_activityController
->
activities
())
{
const
auto
controllerActivities
=
m_activityController
->
activities
();
for
(
const
QString
&
activityId
:
controllerActivities
)
{
if
(
!
presentActivities
.
contains
(
activityId
)
&&
m_activities
.
contains
(
activityId
))
{
setData
(
activityId
,
QStringLiteral
(
"Score"
),
0
);
}
...
...
dataengines/apps/appsource.cpp
View file @
d3f58b05
...
...
@@ -71,7 +71,8 @@ void AppSource::updateGroup()
setData
(
QStringLiteral
(
"display"
),
!
m_group
->
noDisplay
());
QStringList
entries
;
foreach
(
KSycocaEntry
::
Ptr
p
,
m_group
->
entries
(
true
,
false
,
true
))
{
const
auto
groupEntries
=
m_group
->
entries
(
true
,
false
,
true
);
for
(
const
KSycocaEntry
::
Ptr
&
p
:
groupEntries
)
{
if
(
p
->
isType
(
KST_KService
))
{
const
KService
::
Ptr
service
(
static_cast
<
KService
*>
(
p
.
data
()));
entries
<<
service
->
storageId
();
...
...
dataengines/devicenotifications/ksolidnotify.cpp
View file @
d3f58b05
...
...
@@ -189,7 +189,7 @@ void KSolidNotify::onSolidReply(SolidReplyType type, Solid::ErrorType error, con
if
(
type
==
SolidReplyType
::
Eject
)
{
QString
discUdi
;
for
each
(
Solid
::
Device
device
,
m_devices
)
{
for
(
Solid
::
Device
device
:
qAsConst
(
m_devices
)
)
{
if
(
device
.
parentUdi
()
==
udi
)
{
discUdi
=
device
.
udi
();
}
...
...
dataengines/geolocation/geolocation.cpp
View file @
d3f58b05
...
...
@@ -52,7 +52,7 @@ void Geolocation::init()
const
KService
::
List
offers
=
KServiceTypeTrader
::
self
()
->
query
(
QStringLiteral
(
"Plasma/GeolocationProvider"
));
QVariantList
args
;
Q_FOREACH
(
const
KService
::
Ptr
&
service
,
offers
)
{
for
(
const
KService
::
Ptr
&
service
:
offers
)
{
QString
error
;
GeolocationProvider
*
plugin
=
service
->
createInstance
<
GeolocationProvider
>
(
nullptr
,
args
,
&
error
);
if
(
plugin
)
{
...
...
@@ -91,7 +91,7 @@ bool Geolocation::updatePlugins(GeolocationProvider::UpdateTriggers triggers)
{
bool
changed
=
false
;
Q_FOREACH
(
GeolocationProvider
*
plugin
,
m_plugins
)
{
for
(
GeolocationProvider
*
plugin
:
qAsConst
(
m_plugins
)
)
{
changed
=
plugin
->
requestUpdate
(
triggers
)
||
changed
;
}
...
...
@@ -130,7 +130,7 @@ void Geolocation::pluginAvailabilityChanged(GeolocationProvider *provider)
provider
->
requestUpdate
(
GeolocationProvider
::
ForcedUpdate
);
bool
changed
=
false
;
Q_FOREACH
(
GeolocationProvider
*
plugin
,
m_plugins
)
{
for
(
GeolocationProvider
*
plugin
:
qAsConst
(
m_plugins
)
)
{
changed
=
plugin
->
populateSharedData
()
||
changed
;
}
...
...
dataengines/hotplug/hotplugengine.cpp
View file @
d3f58b05
...
...
@@ -48,7 +48,7 @@ HotplugEngine::HotplugEngine(QObject* parent, const QVariantList& args)
{
const
QStringList
folders
=
QStandardPaths
::
locateAll
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"solid/actions"
),
QStandardPaths
::
LocateDirectory
);
for
each
(
const
QString
&
folder
,
folders
)
{
for
(
const
QString
&
folder
:
folders
)
{
m_dirWatch
->
addDir
(
folder
,
KDirWatch
::
WatchFiles
);
}
connect
(
m_dirWatch
,
&
KDirWatch
::
created
,
this
,
&
HotplugEngine
::
updatePredicates
);
...
...
@@ -73,8 +73,8 @@ void HotplugEngine::init()
p
|=
Solid
::
Predicate
(
Solid
::
DeviceInterface
::
OpticalDisc
);
p
|=
Solid
::
Predicate
(
Solid
::
DeviceInterface
::
PortableMediaPlayer
);
p
|=
Solid
::
Predicate
(
Solid
::
DeviceInterface
::
Camera
);
QList
<
Solid
::
Device
>
devices
=
Solid
::
Device
::
listFromQuery
(
p
);
for
each
(
const
Solid
::
Device
&
dev
,
devices
)
{
const
QList
<
Solid
::
Device
>
devices
=
Solid
::
Device
::
listFromQuery
(
p
);
for
(
const
Solid
::
Device
&
dev
:
devices
)
{
m_startList
.
insert
(
dev
.
udi
(),
dev
);
}
...
...
@@ -114,14 +114,14 @@ void HotplugEngine::findPredicates()
m_predicates
.
clear
();
QStringList
files
;
const
QStringList
dirs
=
QStandardPaths
::
locateAll
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"solid/actions"
),
QStandardPaths
::
LocateDirectory
);
Q_FOREACH
(
const
QString
&
dir
,
dirs
)
{
for
(
const
QString
&
dir
:
dirs
)
{
QDirIterator
it
(
dir
,
QStringList
()
<<
QStringLiteral
(
"*.desktop"
));
while
(
it
.
hasNext
())
{
files
.
prepend
(
it
.
next
());
}
}
//qDebug() << files;
for
each
(
const
QString
&
path
,
files
)
{
for
(
const
QString
&
path
:
qAsConst
(
files
)
)
{
KDesktopFile
cfg
(
path
);
const
QString
string_predicate
=
cfg
.
desktopGroup
().
readEntry
(
"X-KDE-Solid-Predicate"
);
//qDebug() << path << string_predicate;
...
...
kcms/colors/editor/setpreviewwidget.cpp
View file @
d3f58b05
...
...
@@ -64,9 +64,8 @@ SetPreviewWidget::SetPreviewWidget(QWidget *parent) : QFrame(parent)
labelSelection7->setBackgroundRole(QPalette::Highlight);
*/
QList
<
QWidget
*>
widgets
=
findChildren
<
QWidget
*>
();
foreach
(
QWidget
*
widget
,
widgets
)
{
const
QList
<
QWidget
*>
widgets
=
findChildren
<
QWidget
*>
();
for
(
QWidget
*
widget
:
widgets
)
{
widget
->
installEventFilter
(
this
);
widget
->
setFocusPolicy
(
Qt
::
NoFocus
);
}
...
...
kcms/cursortheme/xcursor/thememodel.cpp
View file @
d3f58b05
...
...
@@ -274,8 +274,8 @@ bool CursorThemeModel::isCursorTheme(const QString &theme, const int depth)
// Recurse through the list of inherited themes, to check if one of them
// is a cursor theme.
QStringList
inherits
=
cg
.
readEntry
(
"Inherits"
,
QStringList
());
for
each
(
const
QString
&
inherit
,
inherits
)
const
QStringList
inherits
=
cg
.
readEntry
(
"Inherits"
,
QStringList
());
for
(
const
QString
&
inherit
:
inherits
)
{
// Avoid possible DoS
if
(
inherit
==
theme
)
...
...
kcms/lookandfeel/kcm.cpp
View file @
d3f58b05
...
...
@@ -581,8 +581,8 @@ QDir KCMLookandFeel::cursorThemeDir(const QString &theme, const int depth)
// Recurse through the list of inherited themes, to check if one of them
// is a cursor theme.
QStringList
inherits
=
cg
.
readEntry
(
"Inherits"
,
QStringList
());
for
each
(
const
QString
&
inherit
,
inherits
)
{
const
QStringList
inherits
=
cg
.
readEntry
(
"Inherits"
,
QStringList
());
for
(
const
QString
&
inherit
:
inherits
)
{
// Avoid possible DoS
if
(
inherit
==
theme
)
{
continue
;
...
...
klipper/configdialog.cpp
View file @
d3f58b05
...
...
@@ -88,7 +88,7 @@ void ActionsWidget::setActionList(const ActionList& list)
qDeleteAll
(
m_actionList
);
m_actionList
.
clear
();
for
each
(
ClipAction
*
action
,
list
)
{
for
(
ClipAction
*
action
:
list
)
{
if
(
!
action
)
{
qCDebug
(
KLIPPER_LOG
)
<<
"action is null!"
;
continue
;
...
...
Prev
1
2
Next
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