| 131 | } |
| 132 | |
| 133 | QModelIndex Model::parent(const QModelIndex& index) const |
| 134 | { |
| 135 | // if (!index.isValid()) |
| 136 | // return QModelIndex(); |
| 137 | // TreeItem* childItem = static_cast<TreeItem*>(index.internalPointer()); |
| 138 | // TreeItem* parentItem = childItem->parent(); |
| 139 | // if (parentItem == rootItem) |
| 140 | // return QModelIndex(); |
| 141 | // return createIndex(parentItem->row(), 0, parentItem); |
| 142 | |
| 143 | if (!index.isValid()) |
| 144 | return QModelIndex(); |
| 145 | Node* parentItem = getItem(index)->parent(); |
| 146 | if (parentItem == rootItem) |
| 147 | return QModelIndex(); |
| 148 | return createIndex(parentItem->row(), /*index.column()*/ 0, parentItem); |
| 149 | } |
| 150 | |
| 151 | QVariant Model::data(const QModelIndex& index, int role) const |
| 152 | { |