mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Process correct model when applying service menu changes
The listview's model is a filter model, we must iterate through the source, otherwise we get incorrect results BUG: 475547
This commit is contained in:
parent
8ef3c7bc42
commit
ef59e42c40
|
@ -176,15 +176,14 @@ void ContextMenuSettingsPage::applySettings()
|
||||||
|
|
||||||
QStringList enabledPlugins;
|
QStringList enabledPlugins;
|
||||||
|
|
||||||
const QAbstractItemModel *model = m_listView->model();
|
for (int i = 0; i < m_serviceModel->rowCount(); ++i) {
|
||||||
for (int i = 0; i < model->rowCount(); ++i) {
|
const QModelIndex index = m_serviceModel->index(i, 0);
|
||||||
const QModelIndex index = model->index(i, 0);
|
const QString service = m_serviceModel->data(index, ServiceModel::DesktopEntryNameRole).toString();
|
||||||
const QString service = model->data(index, ServiceModel::DesktopEntryNameRole).toString();
|
const bool checked = m_serviceModel->data(index, Qt::CheckStateRole).toBool();
|
||||||
const bool checked = model->data(index, Qt::CheckStateRole).toBool();
|
|
||||||
|
|
||||||
if (service.startsWith(VersionControlServicePrefix)) {
|
if (service.startsWith(VersionControlServicePrefix)) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
enabledPlugins.append(model->data(index, Qt::DisplayRole).toString());
|
enabledPlugins.append(m_serviceModel->data(index, Qt::DisplayRole).toString());
|
||||||
}
|
}
|
||||||
} else if (service == QLatin1String(DeleteService)) {
|
} else if (service == QLatin1String(DeleteService)) {
|
||||||
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals);
|
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals);
|
||||||
|
@ -229,14 +228,13 @@ void ContextMenuSettingsPage::applySettings()
|
||||||
|
|
||||||
void ContextMenuSettingsPage::restoreDefaults()
|
void ContextMenuSettingsPage::restoreDefaults()
|
||||||
{
|
{
|
||||||
QAbstractItemModel *model = m_listView->model();
|
for (int i = 0; i < m_serviceModel->rowCount(); ++i) {
|
||||||
for (int i = 0; i < model->rowCount(); ++i) {
|
const QModelIndex index = m_serviceModel->index(i, 0);
|
||||||
const QModelIndex index = model->index(i, 0);
|
const QString service = m_serviceModel->data(index, ServiceModel::DesktopEntryNameRole).toString();
|
||||||
const QString service = model->data(index, ServiceModel::DesktopEntryNameRole).toString();
|
|
||||||
|
|
||||||
const bool checked =
|
const bool checked =
|
||||||
!service.startsWith(VersionControlServicePrefix) && service != QLatin1String(DeleteService) && service != QLatin1String(CopyToMoveToService);
|
!service.startsWith(VersionControlServicePrefix) && service != QLatin1String(DeleteService) && service != QLatin1String(CopyToMoveToService);
|
||||||
model->setData(index, checked, Qt::CheckStateRole);
|
m_serviceModel->setData(index, checked, Qt::CheckStateRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue