MCPcopy Create free account
hub / github.com/KDE/kdevelop / mapFromSource

Method mapFromSource

kdevplatform/util/multilevellistview.cpp:219–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219QModelIndex MultiLevelListViewPrivate::mapFromSource(QModelIndex index, int level) const
220{
221 if (!index.isValid()) {
222 return index;
223 }
224
225 Q_ASSERT(index.model() == model);
226
227 auto* proxy = qobject_cast<QAbstractProxyModel*>(views.at(level)->model());
228 Q_ASSERT(proxy);
229
230 // find all proxies between the source and our view
231 QVector<QAbstractProxyModel*> proxies;
232 proxies << proxy;
233 while (true) {
234 auto* child = qobject_cast<QAbstractProxyModel*>(proxy->sourceModel());
235 if (child) {
236 proxy = child;
237 proxies << proxy;
238 } else {
239 Q_ASSERT(proxy->sourceModel() == model);
240 break;
241 }
242 }
243 // iterate in reverse order to find the view's index
244 for (int i = proxies.size() - 1; i >= 0; --i) {
245 proxy = proxies.at(i);
246 index = proxy->mapFromSource(index);
247 Q_ASSERT(index.isValid());
248 }
249
250 return index;
251}
252
253MultiLevelListView::MultiLevelListView(QWidget* parent, Qt::WindowFlags f)
254 : QWidget(parent, f)

Callers 7

editMethod · 0.45
breakpointHitMethod · 0.45
VariableTreeMethod · 0.45
testProjectProxyModelMethod · 0.45
BranchManagerMethod · 0.45
setCurrentIndexMethod · 0.45

Calls 4

isValidMethod · 0.45
modelMethod · 0.45
atMethod · 0.45
sizeMethod · 0.45

Tested by 1

testProjectProxyModelMethod · 0.36