Commit 5bb3ebc9 authored by Méven Car's avatar Méven Car

KCM/solid-actions convert foreach

Reviewers: ervin, #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27154
parent 96e4fed8
......@@ -88,9 +88,9 @@ Solid::Predicate ActionItem::predicate() const
QString ActionItem::involvedTypes() const
{
SolidActionData * actData = SolidActionData::instance();
QSet<Solid::DeviceInterface::Type> devTypeList = predicateItem.usedTypes();
const QSet<Solid::DeviceInterface::Type> devTypeList = predicateItem.usedTypes();
QStringList deviceTypes;
foreach( Solid::DeviceInterface::Type devType, devTypeList ) {
for (Solid::DeviceInterface::Type devType : devTypeList) {
deviceTypes << actData->nameFromInterface( devType );
}
......@@ -140,10 +140,10 @@ KConfigGroup * ActionItem::configItem(DesktopAction actionType, GroupType keyGro
int countAccess = 0;
if (actionType == ActionItem::DesktopRead) {
foreach(KConfigGroup * possibleGroup, actionGroups.values(keyGroup)) {
const auto values = actionGroups.values(keyGroup);
for (KConfigGroup *possibleGroup : values) {
if (possibleGroup->hasKey(keyName)) {
return possibleGroup;
break;
}
}
} else if (actionType == ActionItem::DesktopWrite) {
......
......@@ -104,14 +104,14 @@ void ActionModel::buildActionList()
// Prepare to search for possible actions -> we only want solid types
const QStringList actionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("solid/actions"), QStandardPaths::LocateDirectory);
// Get service objects for those actions and add them to the display
foreach (const QString & actionDir, actionDirs) {
for (const QString &actionDir : actionDirs) {
QDirIterator it(actionDir, QStringList() << QStringLiteral("*.desktop"));
while (it.hasNext()) {
it.next();
const QString desktop = it.filePath();
// Get contained services list
QList<KServiceAction> services = KDesktopFileActions::userDefinedServices(desktop, true);
foreach( const KServiceAction &deviceAction, services ) {
const QList<KServiceAction> services = KDesktopFileActions::userDefinedServices(desktop, true);
for (const KServiceAction &deviceAction : services) {
ActionItem * actionItem = new ActionItem( desktop, deviceAction.name(), this ); // Create an action
d->actions.append( actionItem );
}
......
......@@ -17,7 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
***************************************************************************/
#include <QDebug>
#include <QCoreApplication>
#include <QCommandLineParser>
......@@ -46,8 +45,9 @@ int main( int argc, char *argv[] )
parser.process(application);
aboutData.processCommandLine(&parser);
SolidActionData * availActions = SolidActionData::instance();
foreach( Solid::DeviceInterface::Type internalType, availActions->interfaceTypeList() ) {
SolidActionData *availActions = SolidActionData::instance();
const auto interfaceTypes = availActions->interfaceTypeList();
for (Solid::DeviceInterface::Type internalType : interfaceTypes) {
const QString typeName = Solid::DeviceInterface::typeToString( internalType );
KDesktopFile typeFile(QStandardPaths::GenericDataLocation, "solid/devices/solid-device-" + typeName + ".desktop" );
KConfigGroup tConfig = typeFile.desktopGroup();
......@@ -64,8 +64,7 @@ int main( int argc, char *argv[] )
const QString actionText = typeValues.join(QLatin1Char(';')).append(";");
tConfig.writeEntry( "Actions", actionText );
qWarning() << "Desktop file created: " + typeFile.fileName();
foreach( const QString &tValue, typeValues ) {
for (const QString &tValue : typeValues) {
KConfigGroup vConfig = typeFile.actionGroup( tValue );
if( !vConfig.hasKey("Name") ) {
vConfig.writeEntry( "Name", availActions->propertyName( internalType, tValue ) );
......@@ -76,6 +75,5 @@ int main( int argc, char *argv[] )
typeFile.sync();
}
qWarning() << "Generation now completed";
return 0;
}
......@@ -46,8 +46,8 @@ SolidActionData::SolidActionData(bool includeFiles)
{
const int propertyOffset = Solid::DeviceInterface::staticMetaObject.propertyOffset();
QList<QMetaObject> interfaceList = fillInterfaceList();
foreach( const QMetaObject &interface, interfaceList ) {
const QList<QMetaObject> interfaceList = fillInterfaceList();
for (const QMetaObject &interface : interfaceList) {
QString ifaceName = interface.className();
ifaceName.remove(0, ifaceName.lastIndexOf(':') + 1);
Solid::DeviceInterface::Type ifaceDev = Solid::DeviceInterface::stringToType( ifaceName );
......@@ -80,7 +80,8 @@ SolidActionData::SolidActionData(bool includeFiles)
types.insert( ifaceDev, cleanName ); // Read the user friendly name
QMap<QString,QString> deviceValues = values.value( ifaceDev );
foreach( const QString &text, deviceFile.readActions() ) { // We want every single action
const auto actions = deviceFile.readActions();
for (const QString &text : actions) { // We want every single action
KConfigGroup actionType = deviceFile.actionGroup( text );
deviceValues.insert( text, actionType.readEntry("Name") ); // Add to the type - actions map
}
......
......@@ -136,9 +136,9 @@ void SolidActions::addAction()
// Prepare to open the editDialog
fillActionsList();
QList<ActionItem*> actionList = actionModel->actionList();
const QList<ActionItem*> actionList = actionModel->actionList();
QModelIndex newAction;
foreach( ActionItem * newItem, actionList ) { // Lets find our new action
for (ActionItem *newItem : actionList) { // Lets find our new action
if( newItem->desktopMasterPath == filePath ) {
const int position = actionList.indexOf( newItem );
newAction = actionModel->index( position, 0 ); // Grab it
......
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