| 143 | } |
| 144 | |
| 145 | QModelIndex AggregateModel::parent(const QModelIndex &index) const |
| 146 | { |
| 147 | Q_D(const AggregateModel); |
| 148 | |
| 149 | if (!index.isValid()) |
| 150 | return QModelIndex(); |
| 151 | |
| 152 | if (index.internalPointer() == d->internal) |
| 153 | { |
| 154 | //this is aggregator item, it has no parents |
| 155 | return QModelIndex(); |
| 156 | } |
| 157 | |
| 158 | //this is just an item from the model |
| 159 | auto *item = static_cast<QStandardItem*>(index.internalPointer()); |
| 160 | QModelIndex parent; |
| 161 | if (!item->parent()) |
| 162 | { |
| 163 | //we need to find the aggregator item that owns this index |
| 164 | //first find the model for this index |
| 165 | QStandardItemModel *model = item->model(); |
| 166 | //next find the row number of the aggregator item |
| 167 | int row = d->modelList.indexOf(model); |
| 168 | parent = createIndex(row, 0, d->internal); |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | //we have a standard item in the source model - just map it into our model |
| 173 | parent = createIndex(item->parent()->row(), 0, item->parent()); |
| 174 | } |
| 175 | return parent; |
| 176 | } |
| 177 | |
| 178 | QModelIndex AggregateModel::index(int row, int column, const QModelIndex &parent) const |
| 179 | { |
no test coverage detected