X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ed2d352c42a6d517d4f29b3582c0e00aa34fe647..e1b325a867ede95c5815ca11998017c67fc78ea9:/src/settings/servicemodel.cpp diff --git a/src/settings/servicemodel.cpp b/src/settings/servicemodel.cpp index 07a804e33..c2ebda7c1 100644 --- a/src/settings/servicemodel.cpp +++ b/src/settings/servicemodel.cpp @@ -6,6 +6,8 @@ #include "servicemodel.h" +#include + ServiceModel::ServiceModel(QObject *parent) : QAbstractListModel(parent) , m_items() @@ -29,8 +31,7 @@ bool ServiceModel::insertRows(int row, int count, const QModelIndex &parent) beginInsertRows(parent, row, row + count - 1); for (int i = 0; i < count; ++i) { ServiceItem item; - item.checked = false; - item.configurable = false; + item.checked = Qt::Unchecked; m_items.insert(row, item); } endInsertRows(); @@ -47,10 +48,7 @@ bool ServiceModel::setData(const QModelIndex &index, const QVariant &value, int switch (role) { case Qt::CheckStateRole: - m_items[row].checked = value.toBool(); - break; - case ConfigurableRole: - m_items[row].configurable = value.toBool(); + m_items[row].checked = value.value(); break; case Qt::DecorationRole: m_items[row].icon = value.toString(); @@ -74,12 +72,10 @@ QVariant ServiceModel::data(const QModelIndex &index, int role) const const int row = index.row(); if (row < rowCount()) { switch (role) { - case ConfigurableRole: - return m_items[row].configurable; case Qt::CheckStateRole: return m_items[row].checked; case Qt::DecorationRole: - return m_items[row].icon; + return QIcon::fromTheme(m_items[row].icon); case Qt::DisplayRole: return m_items[row].text; case DesktopEntryNameRole: @@ -105,4 +101,9 @@ void ServiceModel::clear() endRemoveRows(); } +Qt::ItemFlags ServiceModel::flags(const QModelIndex &index) const +{ + return QAbstractListModel::flags(index) | Qt::ItemIsUserCheckable; +} + #include "moc_servicemodel.cpp"