| 59 | } |
| 60 | |
| 61 | void TextDocumentInspector::objectSelected(QObject *obj) |
| 62 | { |
| 63 | if (auto doc = qobject_cast<QTextDocument *>(obj)) { |
| 64 | const auto indexList = m_documentsModel->match(m_documentsModel->index(0, 0), |
| 65 | ObjectModel::ObjectRole, |
| 66 | QVariant::fromValue<QObject *>(doc), 1, |
| 67 | Qt::MatchExactly | Qt::MatchRecursive | Qt::MatchWrap); |
| 68 | if (indexList.isEmpty()) |
| 69 | return; |
| 70 | |
| 71 | const auto &index = indexList.first(); |
| 72 | m_documentSelectionModel->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); |
| 73 | } else if (auto docObj = qobject_cast<QTextObject *>(obj)) { |
| 74 | objectSelected(docObj->document()); |
| 75 | } else if (auto layout = qobject_cast<QAbstractTextDocumentLayout *>(obj)) { |
| 76 | objectSelected(layout->document()); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | void TextDocumentInspector::documentSelected(const QItemSelection &selected, |
| 81 | const QItemSelection &deselected) |