| 123 | } |
| 124 | |
| 125 | QVariant AggregateModel::data(const QModelIndex &index, int role) const |
| 126 | { |
| 127 | Q_D(const AggregateModel); |
| 128 | |
| 129 | if (!index.isValid() || (role != Qt::DisplayRole)) |
| 130 | return QVariant(); |
| 131 | |
| 132 | if (!index.parent().isValid()) |
| 133 | { |
| 134 | //aggregator item |
| 135 | return d->modelNames[d->modelList[index.row()]]; |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | //we have a standard item in the source model - just map it into our model |
| 140 | auto *item = static_cast<QStandardItem*>(index.internalPointer()); |
| 141 | return item->data(role); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | QModelIndex AggregateModel::parent(const QModelIndex &index) const |
| 146 | { |