MCPcopy Create free account
hub / github.com/KDAB/GammaRay / indexForNode

Method indexForNode

plugins/quickinspector/quickscenegraphmodel.cpp:380–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380QModelIndex QuickSceneGraphModel::indexForNode(QSGNode *node) const
381{
382 if (!node)
383 return {};
384
385 auto cit = m_childParentMap.find(node);
386 QSGNode *parent = nullptr;
387 if (cit != m_childParentMap.end()) {
388 parent = cit->second;
389 }
390
391 auto pit = m_parentChildMap.find(parent);
392 if (pit == m_parentChildMap.end()) {
393 return {};
394 }
395
396 const QVector<QSGNode *> &siblings = pit->second;
397 auto it = std::lower_bound(siblings.constBegin(), siblings.constEnd(), node);
398 if (it == siblings.constEnd() || *it != node)
399 return QModelIndex();
400
401 const int row = std::distance(siblings.constBegin(), it);
402 return createIndex(row, 0, node);
403}
404
405QSGNode *QuickSceneGraphModel::sgNodeForItem(QQuickItem *item) const
406{

Callers 1

itemSelectionChangedMethod · 0.45

Calls 4

endMethod · 0.80
QModelIndexClass · 0.50
constBeginMethod · 0.45
constEndMethod · 0.45

Tested by 1

itemSelectionChangedMethod · 0.36