MCPcopy Create free account
hub / github.com/KDAB/KDChart / mapToSource

Method mapToSource

src/KDChart/KDChartAbstractProxyModel.cpp:58–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58QModelIndex 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
77QModelIndex AbstractProxyModel::index(int row, int col, const QModelIndex &index) const
78{

Callers

nothing calls this directly

Calls 5

rowMethod · 0.80
QModelIndexClass · 0.50
isValidMethod · 0.45
modelMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected