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
(cherry picked from commit ef59e42c40
)
This commit is contained in:
parent
1d0c42b8ac
commit
4202fbdeca
|
@ -173,15 +173,14 @@ void ContextMenuSettingsPage::applySettings()
|
|||
|
||||
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).toBool();
|
||||
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).toBool();
|
||||
|
||||
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);
|
||||
|
@ -235,14 +234,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::CheckStateRole);
|
||||
m_serviceModel->setData(index, checked, Qt::CheckStateRole);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue