Changeset View
Changeset View
Standalone View
Standalone View
src/kactioncollection.cpp
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Line(s) | |||||
219 | QList<QAction *> KActionCollection::actions() const | 219 | QList<QAction *> KActionCollection::actions() const | ||
220 | { | 220 | { | ||
221 | return d->actions; | 221 | return d->actions; | ||
222 | } | 222 | } | ||
223 | 223 | | |||
224 | const QList< QAction * > KActionCollection::actionsWithoutGroup() const | 224 | const QList< QAction * > KActionCollection::actionsWithoutGroup() const | ||
225 | { | 225 | { | ||
226 | QList<QAction *> ret; | 226 | QList<QAction *> ret; | ||
227 | Q_FOREACH (QAction *action, d->actions) | 227 | for (QAction *action : qAsConst(d->actions)) { | ||
228 | if (!action->actionGroup()) { | 228 | if (!action->actionGroup()) { | ||
229 | ret.append(action); | 229 | ret.append(action); | ||
230 | } | 230 | } | ||
231 | } | ||||
231 | return ret; | 232 | return ret; | ||
232 | } | 233 | } | ||
233 | 234 | | |||
234 | const QList< QActionGroup * > KActionCollection::actionGroups() const | 235 | const QList< QActionGroup * > KActionCollection::actionGroups() const | ||
235 | { | 236 | { | ||
236 | QSet<QActionGroup *> set; | 237 | QSet<QActionGroup *> set; | ||
237 | Q_FOREACH (QAction *action, d->actions) | 238 | for (QAction *action : qAsConst(d->actions)) { | ||
238 | if (action->actionGroup()) { | 239 | if (action->actionGroup()) { | ||
239 | set.insert(action->actionGroup()); | 240 | set.insert(action->actionGroup()); | ||
240 | } | 241 | } | ||
242 | } | ||||
241 | return set.toList(); | 243 | return set.toList(); | ||
242 | } | 244 | } | ||
243 | 245 | | |||
244 | QAction *KActionCollection::addAction(const QString &name, QAction *action) | 246 | QAction *KActionCollection::addAction(const QString &name, QAction *action) | ||
245 | { | 247 | { | ||
246 | if (!action) { | 248 | if (!action) { | ||
247 | return action; | 249 | return action; | ||
248 | } | 250 | } | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 317 | if (oldIndex != -1) { | |||
316 | d->actionByName.remove(d->actionByName.key(action)); | 318 | d->actionByName.remove(d->actionByName.key(action)); | ||
317 | d->actions.removeAt(oldIndex); | 319 | d->actions.removeAt(oldIndex); | ||
318 | } | 320 | } | ||
319 | 321 | | |||
320 | // Add action to our lists. | 322 | // Add action to our lists. | ||
321 | d->actionByName.insert(indexName, action); | 323 | d->actionByName.insert(indexName, action); | ||
322 | d->actions.append(action); | 324 | d->actions.append(action); | ||
323 | 325 | | |||
324 | Q_FOREACH (QWidget *widget, d->associatedWidgets) { | 326 | for (QWidget *widget : qAsConst(d->associatedWidgets)) { | ||
325 | widget->addAction(action); | 327 | widget->addAction(action); | ||
326 | } | 328 | } | ||
327 | 329 | | |||
328 | connect(action, SIGNAL(destroyed(QObject*)), SLOT(_k_actionDestroyed(QObject*))); | 330 | connect(action, SIGNAL(destroyed(QObject*)), SLOT(_k_actionDestroyed(QObject*))); | ||
329 | 331 | | |||
330 | d->setComponentForAction(action); | 332 | d->setComponentForAction(action); | ||
331 | 333 | | |||
332 | if (d->connectHovered) { | 334 | if (d->connectHovered) { | ||
Show All 24 Lines | |||||
357 | 359 | | |||
358 | QAction *KActionCollection::takeAction(QAction *action) | 360 | QAction *KActionCollection::takeAction(QAction *action) | ||
359 | { | 361 | { | ||
360 | if (!d->unlistAction(action)) { | 362 | if (!d->unlistAction(action)) { | ||
361 | return nullptr; | 363 | return nullptr; | ||
362 | } | 364 | } | ||
363 | 365 | | |||
364 | // Remove the action from all widgets | 366 | // Remove the action from all widgets | ||
365 | Q_FOREACH (QWidget *widget, d->associatedWidgets) { | 367 | for (QWidget *widget : qAsConst(d->associatedWidgets)) { | ||
366 | widget->removeAction(action); | 368 | widget->removeAction(action); | ||
367 | } | 369 | } | ||
368 | 370 | | |||
369 | action->disconnect(this); | 371 | action->disconnect(this); | ||
370 | 372 | | |||
371 | emit removed(action); //deprecated | 373 | emit removed(action); //deprecated | ||
372 | return action; | 374 | return action; | ||
373 | } | 375 | } | ||
▲ Show 20 Lines • Show All 480 Lines • ▼ Show 20 Line(s) | |||||
854 | 856 | | |||
855 | QList< QWidget * > KActionCollection::associatedWidgets() const | 857 | QList< QWidget * > KActionCollection::associatedWidgets() const | ||
856 | { | 858 | { | ||
857 | return d->associatedWidgets; | 859 | return d->associatedWidgets; | ||
858 | } | 860 | } | ||
859 | 861 | | |||
860 | void KActionCollection::clearAssociatedWidgets() | 862 | void KActionCollection::clearAssociatedWidgets() | ||
861 | { | 863 | { | ||
862 | Q_FOREACH (QWidget *widget, d->associatedWidgets) | 864 | for (QWidget *widget : qAsConst(d->associatedWidgets)) { | ||
863 | Q_FOREACH (QAction *action, actions()) { | 865 | const auto actions = this->actions(); | ||
866 | for (QAction *action : actions) { | ||||
864 | widget->removeAction(action); | 867 | widget->removeAction(action); | ||
865 | } | 868 | } | ||
869 | } | ||||
866 | 870 | | |||
867 | d->associatedWidgets.clear(); | 871 | d->associatedWidgets.clear(); | ||
868 | } | 872 | } | ||
869 | 873 | | |||
870 | void KActionCollectionPrivate::_k_associatedWidgetDestroyed(QObject *obj) | 874 | void KActionCollectionPrivate::_k_associatedWidgetDestroyed(QObject *obj) | ||
871 | { | 875 | { | ||
872 | associatedWidgets.removeAll(static_cast<QWidget *>(obj)); | 876 | associatedWidgets.removeAll(static_cast<QWidget *>(obj)); | ||
873 | } | 877 | } | ||
874 | 878 | | |||
875 | #include "moc_kactioncollection.cpp" | 879 | #include "moc_kactioncollection.cpp" |