Commit d11d7fbf5b5eb8da1c7c0a1cbb70d3fc8e9f4e8e

  • avatar
  • swiesner <swiesner @283d02a7-25f6-0310…ecb5cbfe19da.>
  • Thu Aug 05 13:28:11 CEST 2010
Reduced number of productName DBus calls in MouseDevicesModel

git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/playground/utils/synaptiks@1159457 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
  
130130
131131QVariant MouseDevicesModel::data(const QModelIndex &index, int role) const {
132132 Q_D(const MouseDevicesModel);
133 if (index.isValid()) {
133 if (index.isValid() && index.column() == 0) {
134134 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;
150146 }
151 default:
152 return QVariant();
153147 }
154 } else {
155 return QVariant();
156148 }
149 return QVariant();
157150}
158151
159152bool MouseDevicesModel::setData(const QModelIndex &index,