Changeset View
Changeset View
Standalone View
Standalone View
soliduiserver/deviceactionsdialog.cpp
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | |||||
86 | { | 86 | { | ||
87 | return m_actions; | 87 | return m_actions; | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | void DeviceActionsDialog::updateActionsListBox() | 90 | void DeviceActionsDialog::updateActionsListBox() | ||
91 | { | 91 | { | ||
92 | m_view.actionsList->clear(); | 92 | m_view.actionsList->clear(); | ||
93 | 93 | | |||
94 | foreach (DeviceAction *action, m_actions) { | 94 | for (DeviceAction *action : qAsConst(m_actions)) { | ||
95 | QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(action->iconName()), | 95 | QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(action->iconName()), | ||
96 | action->label()); | 96 | action->label()); | ||
97 | item->setData(Qt::UserRole, action->id()); | 97 | item->setData(Qt::UserRole, action->id()); | ||
98 | m_view.actionsList->addItem(item); | 98 | m_view.actionsList->addItem(item); | ||
99 | } | 99 | } | ||
100 | 100 | | |||
101 | if (m_view.actionsList->count()>0) | 101 | if (m_view.actionsList->count()>0) | ||
102 | m_view.actionsList->item(0)->setSelected(true); | 102 | m_view.actionsList->item(0)->setSelected(true); | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | void DeviceActionsDialog::slotOk() | 105 | void DeviceActionsDialog::slotOk() | ||
106 | { | 106 | { | ||
107 | QListWidgetItem *item = m_view.actionsList->selectedItems().value(0); | 107 | QListWidgetItem *item = m_view.actionsList->selectedItems().value(0); | ||
108 | 108 | | |||
109 | if (item) { | 109 | if (item) { | ||
110 | const QString id = item->data(Qt::UserRole).toString(); | 110 | const QString id = item->data(Qt::UserRole).toString(); | ||
111 | 111 | | |||
112 | foreach (DeviceAction *action, m_actions) { | 112 | for (DeviceAction *action : qAsConst(m_actions)) { | ||
113 | if (action->id()==id) { | 113 | if (action->id()==id) { | ||
114 | launchAction(action); | 114 | launchAction(action); | ||
115 | return; | 115 | return; | ||
116 | } | 116 | } | ||
117 | } | 117 | } | ||
118 | } | 118 | } | ||
119 | } | 119 | } | ||
120 | 120 | | |||
121 | void DeviceActionsDialog::launchAction(DeviceAction *action) | 121 | void DeviceActionsDialog::launchAction(DeviceAction *action) | ||
122 | { | 122 | { | ||
123 | action->execute(m_device); | 123 | action->execute(m_device); | ||
124 | accept(); | 124 | accept(); | ||
125 | } | 125 | } |