X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/30a807e44afb334dd153c8bcbdbde4f36942bee0..d1b06ab94f6936eee7f32f113f44f17b7477ac22:/src/settings/contextmenu/contextmenusettingspage.cpp diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp index 1c83e477e..c401c2d6b 100644 --- a/src/settings/contextmenu/contextmenusettingspage.cpp +++ b/src/settings/contextmenu/contextmenusettingspage.cpp @@ -12,7 +12,6 @@ #include "settings/servicemodel.h" #include -#include #include #include #include @@ -167,23 +166,22 @@ void ContextMenuSettingsPage::applySettings() } KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals); - KConfigGroup showGroup = config.group("Show"); + KConfigGroup showGroup = config.group(QStringLiteral("Show")); QStringList enabledPlugins; - const QAbstractItemModel *model = m_listView->model(); - for (int i = 0; i < model->rowCount(); ++i) { - const QModelIndex index = model->index(i, 0); - const QString service = model->data(index, ServiceModel::DesktopEntryNameRole).toString(); - const bool checked = model->data(index, Qt::CheckStateRole).value() == Qt::Checked; + for (int i = 0; i < m_serviceModel->rowCount(); ++i) { + const QModelIndex index = m_serviceModel->index(i, 0); + const QString service = m_serviceModel->data(index, ServiceModel::DesktopEntryNameRole).toString(); + const bool checked = m_serviceModel->data(index, Qt::CheckStateRole).value() == Qt::Checked; if (service.startsWith(VersionControlServicePrefix)) { if (checked) { - enabledPlugins.append(model->data(index, Qt::DisplayRole).toString()); + enabledPlugins.append(m_serviceModel->data(index, Qt::DisplayRole).toString()); } } else if (service == QLatin1String(DeleteService)) { KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); - KConfigGroup configGroup(globalConfig, "KDE"); + KConfigGroup configGroup(globalConfig, QStringLiteral("KDE")); configGroup.writeEntry("ShowDeleteCommand", checked); configGroup.sync(); } else if (service == QLatin1String(CopyToMoveToService)) { @@ -224,14 +222,13 @@ void ContextMenuSettingsPage::applySettings() void ContextMenuSettingsPage::restoreDefaults() { - QAbstractItemModel *model = m_listView->model(); - for (int i = 0; i < model->rowCount(); ++i) { - const QModelIndex index = model->index(i, 0); - const QString service = model->data(index, ServiceModel::DesktopEntryNameRole).toString(); + for (int i = 0; i < m_serviceModel->rowCount(); ++i) { + const QModelIndex index = m_serviceModel->index(i, 0); + const QString service = m_serviceModel->data(index, ServiceModel::DesktopEntryNameRole).toString(); const bool checked = !service.startsWith(VersionControlServicePrefix) && service != QLatin1String(DeleteService) && service != QLatin1String(CopyToMoveToService); - model->setData(index, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); + m_serviceModel->setData(index, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); } } @@ -244,7 +241,7 @@ void ContextMenuSettingsPage::showEvent(QShowEvent *event) // Add "Show 'Delete' command" as service KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::IncludeGlobals); - KConfigGroup configGroup(globalConfig, "KDE"); + KConfigGroup configGroup(globalConfig, QStringLiteral("KDE")); addRow(QStringLiteral("edit-delete"), i18nc("@option:check", "Delete"), DeleteService, configGroup.readEntry("ShowDeleteCommand", ShowDeleteDefault)); // Add "Show 'Copy To' and 'Move To' commands" as service @@ -273,14 +270,14 @@ void ContextMenuSettingsPage::showEvent(QShowEvent *event) void ContextMenuSettingsPage::loadServices() { const KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals); - const KConfigGroup showGroup = config.group("Show"); + const KConfigGroup showGroup = config.group(QStringLiteral("Show")); // Load generic services const auto locations = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kio/servicemenus"), QStandardPaths::LocateDirectory); QStringList files = KFileUtils::findAllUniqueFiles(locations); for (const auto &file : std::as_const(files)) { - const QList serviceActions = KDesktopFileActions::userDefinedServices(KService(file), true); + const QList serviceActions = KService(file).actions(); const KDesktopFile desktopFile(file); const QString subMenuName = desktopFile.desktopGroup().readEntry("X-KDE-Submenu");