From 31a8866ac0aa3966cd77e87e14974f0a6a66f940 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 8 Jul 2023 22:34:08 +0200 Subject: Fix usage of Qt::CheckStateRole in preview model Qt::CheckStateRole expects an enum, not a bool Also set the flag that the item it user checkable, otherwise it can't be changed BUG: 471999 --- src/settings/serviceitemdelegate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/settings/serviceitemdelegate.cpp') diff --git a/src/settings/serviceitemdelegate.cpp b/src/settings/serviceitemdelegate.cpp index 97fafc631..929e699d8 100644 --- a/src/settings/serviceitemdelegate.cpp +++ b/src/settings/serviceitemdelegate.cpp @@ -74,7 +74,7 @@ void ServiceItemDelegate::updateItemWidgets(const QList &widgets, con if (!iconName.isEmpty()) { checkBox->setIcon(QIcon::fromTheme(iconName)); } - checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool()); + checkBox->setChecked(model->data(index, Qt::CheckStateRole).value() == Qt::Checked); const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool(); @@ -98,7 +98,7 @@ void ServiceItemDelegate::updateItemWidgets(const QList &widgets, con void ServiceItemDelegate::slotCheckBoxClicked(bool checked) { QAbstractItemModel *model = const_cast(focusedIndex().model()); - model->setData(focusedIndex(), checked, Qt::CheckStateRole); + model->setData(focusedIndex(), checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); } void ServiceItemDelegate::slotConfigureButtonClicked() -- cgit v1.3