Commit d11d7fbf5b5eb8da1c7c0a1cbb70d3fc8e9f4e8e
- Diff rendering mode:
- inline
- side by side
kcmodule/mousedevicesmodel.cpp
(13 / 20)
|   | |||
| 130 | 130 | ||
| 131 | 131 | QVariant MouseDevicesModel::data(const QModelIndex &index, int role) const { | |
| 132 | 132 | Q_D(const MouseDevicesModel); | |
| 133 | if (index.isValid()) { | ||
| 133 | if (index.isValid() && index.column() == 0) { | ||
| 134 | 134 | QString id = d->deviceIndex.at(index.row()); | |
| 135 | QDBusReply<QString> productName = | ||
| 136 | d->devices->call("productName", id); | ||
| 137 | switch (role) { | ||
| 138 | case Qt::DisplayRole: | ||
| 139 | if (productName.isValid()) | ||
| 140 | return productName.value(); | ||
| 141 | else | ||
| 142 | return QString(); | ||
| 143 | case Qt::ToolTipRole: | ||
| 144 | return id; | ||
| 145 | case Qt::CheckStateRole: | ||
| 146 | if (d->checkedDevices.contains(id)) { | ||
| 147 | return Qt::Checked; | ||
| 148 | } else { | ||
| 149 | return Qt::Unchecked; | ||
| 135 | if (role == Qt::DisplayRole) { | ||
| 136 | QDBusReply<QString> productName = | ||
| 137 | d->devices->call("productName", id); | ||
| 138 | return productName.isValid() ? productName.value() : QString(); | ||
| 139 | } else { | ||
| 140 | switch(role) { | ||
| 141 | case Qt::ToolTipRole: | ||
| 142 | return id; | ||
| 143 | case Qt::CheckStateRole: | ||
| 144 | return d->checkedDevices.contains(id) ? | ||
| 145 | Qt::Checked : Qt::Unchecked; | ||
| 150 | 146 | } | |
| 151 | default: | ||
| 152 | return QVariant(); | ||
| 153 | 147 | } | |
| 154 | } else { | ||
| 155 | return QVariant(); | ||
| 156 | 148 | } | |
| 149 | return QVariant(); | ||
| 157 | 150 | } | |
| 158 | 151 | ||
| 159 | 152 | bool MouseDevicesModel::setData(const QModelIndex &index, |

