| 58 | } |
| 59 | |
| 60 | QModelIndex T_TreeViewModel::index(int row, int column, const QModelIndex& parent) const |
| 61 | { |
| 62 | if (!hasIndex(row, column, parent)) |
| 63 | { |
| 64 | return QModelIndex(); |
| 65 | } |
| 66 | T_TreeItem* parentItem; |
| 67 | if (!parent.isValid()) |
| 68 | { |
| 69 | parentItem = _rootItem; |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | parentItem = static_cast<T_TreeItem*>(parent.internalPointer()); |
| 74 | } |
| 75 | T_TreeItem* childItem = nullptr; |
| 76 | if (parentItem->getChildrenItems().count() > row) |
| 77 | { |
| 78 | childItem = parentItem->getChildrenItems().at(row); |
| 79 | } |
| 80 | if (childItem) |
| 81 | { |
| 82 | return createIndex(row, column, childItem); |
| 83 | } |
| 84 | return QModelIndex(); |
| 85 | } |
| 86 | |
| 87 | int T_TreeViewModel::rowCount(const QModelIndex& parent) const |
| 88 | { |
no test coverage detected