| 56 | } |
| 57 | |
| 58 | QModelIndex AbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const |
| 59 | { |
| 60 | if (!sourceModel() || !proxyIndex.isValid()) |
| 61 | return QModelIndex(); |
| 62 | if (proxyIndex.model() != this) |
| 63 | qDebug() << proxyIndex.model() << this; |
| 64 | Q_ASSERT(proxyIndex.model() == this); |
| 65 | // So here we need to create a source index which holds that internal pointer. |
| 66 | // No way to pass it to sourceModel()->index... so we have to do the ugly way: |
| 67 | QModelIndex sourceIndex; |
| 68 | auto *hack = reinterpret_cast<KDPrivateModelIndex *>(&sourceIndex); |
| 69 | hack->r = proxyIndex.row(); |
| 70 | hack->c = proxyIndex.column(); |
| 71 | hack->p = proxyIndex.internalPointer(); |
| 72 | hack->m = sourceModel(); |
| 73 | Q_ASSERT(sourceIndex.isValid()); |
| 74 | return sourceIndex; |
| 75 | } |
| 76 | |
| 77 | QModelIndex AbstractProxyModel::index(int row, int col, const QModelIndex &index) const |
| 78 | { |
nothing calls this directly
no test coverage detected