| 173 | } |
| 174 | |
| 175 | bool setData(const QModelIndex &index, const QVariant &val, int role) override |
| 176 | { |
| 177 | SDObject *o = NULL; |
| 178 | |
| 179 | if(role == Qt::UserRole) |
| 180 | { |
| 181 | // if we have setData for user role, that means we got reset. Just need to emit data changed |
| 182 | o = obj(index); |
| 183 | } |
| 184 | else if(index.column() == Column_Value) |
| 185 | { |
| 186 | o = obj(index); |
| 187 | |
| 188 | SDObject *value = o->FindChild("value"); |
| 189 | |
| 190 | if(role == Qt::CheckStateRole && value) |
| 191 | { |
| 192 | value->data.basic.b = (val.toInt() == Qt::CheckState::Checked); |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | // didn't change anything we care about |
| 197 | o = NULL; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | if(o) |
| 202 | { |
| 203 | // dataChanged this index and all parents (in case a section became non-customised, or |
| 204 | // customised, and it wasn't before) |
| 205 | QModelIndex idx = index; |
| 206 | while(idx.isValid()) |
| 207 | { |
| 208 | o = obj(idx); |
| 209 | emit dataChanged(createIndex(idx.row(), 0, o), createIndex(idx.row(), Column_Count, o), |
| 210 | {Qt::DisplayRole, Qt::CheckStateRole, Qt::FontRole}); |
| 211 | |
| 212 | idx = parents[o]; |
| 213 | } |
| 214 | |
| 215 | return true; |
| 216 | } |
| 217 | |
| 218 | return false; |
| 219 | } |
| 220 | |
| 221 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override |
| 222 | { |