| 378 | } |
| 379 | |
| 380 | QModelIndex 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 | |
| 405 | QSGNode *QuickSceneGraphModel::sgNodeForItem(QQuickItem *item) const |
| 406 | { |