| 266 | } |
| 267 | |
| 268 | QModelIndex ViewTreeModel::index(int row, int column, const QModelIndex& parent) const |
| 269 | { |
| 270 | if (!hasIndex(row, column, parent)) |
| 271 | { |
| 272 | return QModelIndex(); |
| 273 | } |
| 274 | |
| 275 | ViewTreeItem* parentItem = nullptr; |
| 276 | if (!parent.isValid()) |
| 277 | { |
| 278 | parentItem = d->rootItem.data(); |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | parentItem = static_cast<ViewTreeItem*>(parent.internalPointer()); |
| 283 | } |
| 284 | |
| 285 | ViewTreeItem* childItem = parentItem->childItem(row); |
| 286 | if (childItem) |
| 287 | { |
| 288 | return createIndex(row, column, childItem); |
| 289 | } |
| 290 | return QModelIndex(); |
| 291 | } |
| 292 | |
| 293 | QModelIndex ViewTreeModel::parent(const QModelIndex& child) const |
| 294 | { |