Changeset View
Changeset View
Standalone View
Standalone View
kcms/solid_actions/ActionModel.cpp
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
99 | void ActionModel::buildActionList() | 99 | void ActionModel::buildActionList() | ||
100 | { | 100 | { | ||
101 | beginResetModel(); | 101 | beginResetModel(); | ||
102 | qDeleteAll( d->actions ); | 102 | qDeleteAll( d->actions ); | ||
103 | d->actions.clear(); | 103 | d->actions.clear(); | ||
104 | // Prepare to search for possible actions -> we only want solid types | 104 | // Prepare to search for possible actions -> we only want solid types | ||
105 | const QStringList actionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("solid/actions"), QStandardPaths::LocateDirectory); | 105 | const QStringList actionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("solid/actions"), QStandardPaths::LocateDirectory); | ||
106 | // Get service objects for those actions and add them to the display | 106 | // Get service objects for those actions and add them to the display | ||
107 | foreach (const QString & actionDir, actionDirs) { | 107 | for (const QString &actionDir : actionDirs) { | ||
108 | QDirIterator it(actionDir, QStringList() << QStringLiteral("*.desktop")); | 108 | QDirIterator it(actionDir, QStringList() << QStringLiteral("*.desktop")); | ||
109 | while (it.hasNext()) { | 109 | while (it.hasNext()) { | ||
110 | it.next(); | 110 | it.next(); | ||
111 | const QString desktop = it.filePath(); | 111 | const QString desktop = it.filePath(); | ||
112 | // Get contained services list | 112 | // Get contained services list | ||
113 | QList<KServiceAction> services = KDesktopFileActions::userDefinedServices(desktop, true); | 113 | const QList<KServiceAction> services = KDesktopFileActions::userDefinedServices(desktop, true); | ||
114 | foreach( const KServiceAction &deviceAction, services ) { | 114 | for (const KServiceAction &deviceAction : services) { | ||
115 | ActionItem * actionItem = new ActionItem( desktop, deviceAction.name(), this ); // Create an action | 115 | ActionItem * actionItem = new ActionItem( desktop, deviceAction.name(), this ); // Create an action | ||
116 | d->actions.append( actionItem ); | 116 | d->actions.append( actionItem ); | ||
117 | } | 117 | } | ||
118 | } | 118 | } | ||
119 | } | 119 | } | ||
120 | 120 | | |||
121 | std::sort(d->actions.begin(), d->actions.end(), sortAction); | 121 | std::sort(d->actions.begin(), d->actions.end(), sortAction); | ||
122 | endResetModel(); | 122 | endResetModel(); | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | QList<ActionItem*> ActionModel::actionList() const | 125 | QList<ActionItem*> ActionModel::actionList() const | ||
126 | { | 126 | { | ||
127 | return d->actions; | 127 | return d->actions; | ||
128 | } | 128 | } | ||
129 | 129 | |