MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / indexModelToView

Function indexModelToView

src/modelutils.cpp:40–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40QModelIndex indexModelToView(const QModelIndex& index, const QAbstractItemView* view)
41{
42 // we need to stack the proxy
43 std::vector<QAbstractProxyModel*> proxies;
44 {
45 auto* currentModel = view->model();
46 while (auto* proxy = qobject_cast<QAbstractProxyModel*>(currentModel)) {
47 proxies.push_back(proxy);
48 currentModel = proxy->sourceModel();
49 }
50 }
51
52 if (proxies.empty() || proxies.back()->sourceModel() != index.model()) {
53 return QModelIndex();
54 }
55
56 auto qindex = index;
57 for (auto rit = proxies.rbegin(); rit != proxies.rend(); ++rit) {
58 qindex = (*rit)->mapFromSource(qindex);
59 }
60
61 return qindex;
62}
63
64QModelIndexList indexModelToView(const QModelIndexList& index,
65 const QAbstractItemView* view)

Callers 9

indexModelToViewMethod · 0.85
setSelectedMethod · 0.85
nextModMethod · 0.85
prevModMethod · 0.85
indexModelToViewMethod · 0.85
setSelectedMethod · 0.85
onModInstalledMethod · 0.85

Calls 5

QModelIndexClass · 0.85
modelMethod · 0.80
backMethod · 0.80
emptyMethod · 0.45
mapFromSourceMethod · 0.45

Tested by

no test coverage detected