Changeset View
Changeset View
Standalone View
Standalone View
src/settings/services/servicessettingspage.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 102 | { | |||
---|---|---|---|---|---|
107 | KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals); | 107 | KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals); | ||
108 | KConfigGroup showGroup = config.group("Show"); | 108 | KConfigGroup showGroup = config.group("Show"); | ||
109 | 109 | | |||
110 | QStringList enabledPlugins; | 110 | QStringList enabledPlugins; | ||
111 | 111 | | |||
112 | const QAbstractItemModel* model = m_listView->model(); | 112 | const QAbstractItemModel* model = m_listView->model(); | ||
113 | for (int i = 0; i < model->rowCount(); ++i) { | 113 | for (int i = 0; i < model->rowCount(); ++i) { | ||
114 | const QModelIndex index = model->index(i, 0); | 114 | const QModelIndex index = model->index(i, 0); | ||
115 | const QString service = model->data(index, ServiceModel::DesktopEntryNameRole).toString(); | 115 | const QString service = model->data(index, static_cast<int>(ServiceModel::Role::DesktopEntryName)).toString(); | ||
116 | const bool checked = model->data(index, Qt::CheckStateRole).toBool(); | 116 | const bool checked = model->data(index, Qt::CheckStateRole).toBool(); | ||
117 | 117 | | |||
118 | if (service.startsWith(VersionControlServicePrefix)) { | 118 | if (service.startsWith(VersionControlServicePrefix)) { | ||
119 | if (checked) { | 119 | if (checked) { | ||
120 | enabledPlugins.append(model->data(index, Qt::DisplayRole).toString()); | 120 | enabledPlugins.append(model->data(index, Qt::DisplayRole).toString()); | ||
121 | } | 121 | } | ||
122 | } else if (service == QLatin1String(DeleteService)) { | 122 | } else if (service == QLatin1String(DeleteService)) { | ||
123 | KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); | 123 | KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); | ||
Show All 22 Lines | |||||
146 | } | 146 | } | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | void ServicesSettingsPage::restoreDefaults() | 149 | void ServicesSettingsPage::restoreDefaults() | ||
150 | { | 150 | { | ||
151 | QAbstractItemModel* model = m_listView->model(); | 151 | QAbstractItemModel* model = m_listView->model(); | ||
152 | for (int i = 0; i < model->rowCount(); ++i) { | 152 | for (int i = 0; i < model->rowCount(); ++i) { | ||
153 | const QModelIndex index = model->index(i, 0); | 153 | const QModelIndex index = model->index(i, 0); | ||
154 | const QString service = model->data(index, ServiceModel::DesktopEntryNameRole).toString(); | 154 | const QString service = model->data(index, static_cast<int>(ServiceModel::Role::DesktopEntryName)).toString(); | ||
155 | 155 | | |||
156 | const bool checked = !service.startsWith(VersionControlServicePrefix) | 156 | const bool checked = !service.startsWith(VersionControlServicePrefix) | ||
157 | && service != QLatin1String(DeleteService) | 157 | && service != QLatin1String(DeleteService) | ||
158 | && service != QLatin1String(CopyToMoveToService); | 158 | && service != QLatin1String(CopyToMoveToService); | ||
159 | model->setData(index, checked, Qt::CheckStateRole); | 159 | model->setData(index, checked, Qt::CheckStateRole); | ||
160 | } | 160 | } | ||
161 | } | 161 | } | ||
162 | 162 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 249 | { | |||
261 | 261 | | |||
262 | m_sortModel->sort(Qt::DisplayRole); | 262 | m_sortModel->sort(Qt::DisplayRole); | ||
263 | } | 263 | } | ||
264 | 264 | | |||
265 | bool ServicesSettingsPage::isInServicesList(const QString& service) const | 265 | bool ServicesSettingsPage::isInServicesList(const QString& service) const | ||
266 | { | 266 | { | ||
267 | for (int i = 0; i < m_serviceModel->rowCount(); ++i) { | 267 | for (int i = 0; i < m_serviceModel->rowCount(); ++i) { | ||
268 | const QModelIndex index = m_serviceModel->index(i, 0); | 268 | const QModelIndex index = m_serviceModel->index(i, 0); | ||
269 | if (m_serviceModel->data(index, ServiceModel::DesktopEntryNameRole).toString() == service) { | 269 | if (m_serviceModel->data(index, static_cast<int>(ServiceModel::Role::DesktopEntryName)).toString() == service) { | ||
270 | return true; | 270 | return true; | ||
271 | } | 271 | } | ||
272 | } | 272 | } | ||
273 | return false; | 273 | return false; | ||
274 | } | 274 | } | ||
275 | 275 | | |||
276 | void ServicesSettingsPage::addRow(const QString& icon, | 276 | void ServicesSettingsPage::addRow(const QString& icon, | ||
277 | const QString& text, | 277 | const QString& text, | ||
278 | const QString& value, | 278 | const QString& value, | ||
279 | bool checked) | 279 | bool checked) | ||
280 | { | 280 | { | ||
281 | m_serviceModel->insertRow(0); | 281 | m_serviceModel->insertRow(0); | ||
282 | 282 | | |||
283 | const QModelIndex index = m_serviceModel->index(0, 0); | 283 | const QModelIndex index = m_serviceModel->index(0, 0); | ||
284 | m_serviceModel->setData(index, icon, Qt::DecorationRole); | 284 | m_serviceModel->setData(index, icon, Qt::DecorationRole); | ||
285 | m_serviceModel->setData(index, text, Qt::DisplayRole); | 285 | m_serviceModel->setData(index, text, Qt::DisplayRole); | ||
286 | m_serviceModel->setData(index, value, ServiceModel::DesktopEntryNameRole); | 286 | m_serviceModel->setData(index, value, static_cast<int>(ServiceModel::Role::DesktopEntryName)); | ||
287 | m_serviceModel->setData(index, checked, Qt::CheckStateRole); | 287 | m_serviceModel->setData(index, checked, Qt::CheckStateRole); | ||
288 | } | 288 | } | ||
289 | 289 | |