Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/plugins/folder/previewpluginsmodel.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 57 | switch (role) { | |||
---|---|---|---|---|---|
60 | 60 | | |||
61 | case Qt::CheckStateRole: | 61 | case Qt::CheckStateRole: | ||
62 | return m_checkedRows.at(index.row()) ? Qt::Checked : Qt::Unchecked; | 62 | return m_checkedRows.at(index.row()) ? Qt::Checked : Qt::Unchecked; | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | return QVariant(); | 65 | return QVariant(); | ||
66 | } | 66 | } | ||
67 | 67 | | |||
68 | void PreviewPluginsModel::setRowChecked(int row, bool checked) | 68 | bool PreviewPluginsModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||
69 | { | 69 | { | ||
70 | m_checkedRows[row] = checked; | 70 | if (index.row() < 0 || index.row() >= m_plugins.size()) { | ||
71 | return false; | ||||
72 | } | ||||
71 | 73 | | |||
72 | QModelIndex idx = index(row, 0); | 74 | if (role == Qt::CheckStateRole) { | ||
75 | m_checkedRows[index.row()] = value.toBool(); | ||||
76 | emit dataChanged(index, index, {role}); | ||||
77 | return true; | ||||
78 | } | ||||
73 | 79 | | |||
74 | emit dataChanged(idx, idx); | 80 | return false; | ||
75 | } | 81 | } | ||
76 | 82 | | |||
77 | int PreviewPluginsModel::indexOfPlugin(const QString &name) const | 83 | int PreviewPluginsModel::indexOfPlugin(const QString &name) const | ||
78 | { | 84 | { | ||
79 | for (int i = 0; i < m_plugins.size(); i++) { | 85 | for (int i = 0; i < m_plugins.size(); i++) { | ||
80 | if (m_plugins.at(i)->desktopEntryName() == name) { | 86 | if (m_plugins.at(i)->desktopEntryName() == name) { | ||
81 | return i; | 87 | return i; | ||
82 | } | 88 | } | ||
Show All 30 Lines |