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();
+ const bool checked = model->data(index, Qt::CheckStateRole).value<Qt::CheckState>() == Qt::Checked;
if (service.startsWith(VersionControlServicePrefix)) {
if (checked) {
const bool checked =
!service.startsWith(VersionControlServicePrefix) && service != QLatin1String(DeleteService) && service != QLatin1String(CopyToMoveToService);
- model->setData(index, checked, Qt::CheckStateRole);
+ model->setData(index, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
}
}
m_serviceModel->setData(index, icon, Qt::DecorationRole);
m_serviceModel->setData(index, text, Qt::DisplayRole);
m_serviceModel->setData(index, value, ServiceModel::DesktopEntryNameRole);
- m_serviceModel->setData(index, checked, Qt::CheckStateRole);
+ m_serviceModel->setData(index, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
}
#include "moc_contextmenusettingspage.cpp"
m_enabledPreviewPlugins.clear();
for (int i = 0; i < rowCount; ++i) {
const QModelIndex index = model->index(i, 0);
- const bool checked = model->data(index, Qt::CheckStateRole).toBool();
+ const bool checked = model->data(index, Qt::CheckStateRole).value<Qt::CheckState>() == Qt::Checked;
if (checked) {
const QString enabledPlugin = model->data(index, Qt::UserRole).toString();
m_enabledPreviewPlugins.append(enabledPlugin);
model->insertRow(0);
const QModelIndex index = model->index(0, 0);
- model->setData(index, show, Qt::CheckStateRole);
+ model->setData(index, show ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
model->setData(index, plugin.name(), Qt::DisplayRole);
model->setData(index, plugin.pluginId(), ServiceModel::DesktopEntryNameRole);
}
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::CheckState>() == Qt::Checked);
const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool();
void ServiceItemDelegate::slotCheckBoxClicked(bool checked)
{
QAbstractItemModel *model = const_cast<QAbstractItemModel *>(focusedIndex().model());
- model->setData(focusedIndex(), checked, Qt::CheckStateRole);
+ model->setData(focusedIndex(), checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
}
void ServiceItemDelegate::slotConfigureButtonClicked()
beginInsertRows(parent, row, row + count - 1);
for (int i = 0; i < count; ++i) {
ServiceItem item;
- item.checked = false;
+ item.checked = Qt::Unchecked;
item.configurable = false;
m_items.insert(row, item);
}
switch (role) {
case Qt::CheckStateRole:
- m_items[row].checked = value.toBool();
+ m_items[row].checked = value.value<Qt::CheckState>();
break;
case ConfigurableRole:
m_items[row].configurable = value.toBool();
endRemoveRows();
}
+Qt::ItemFlags ServiceModel::flags(const QModelIndex &index) const
+{
+ return QAbstractListModel::flags(index) | Qt::ItemIsUserCheckable;
+}
+
#include "moc_servicemodel.cpp"
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
void clear();
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
private:
struct ServiceItem {
- bool checked;
+ Qt::CheckState checked;
bool configurable;
QString icon;
QString text;