| 37 | } |
| 38 | |
| 39 | void QmlContextModel::setContext(QQmlContext *leafContext) |
| 40 | { |
| 41 | if (!m_contexts.isEmpty()) { |
| 42 | if (m_contexts.last() != leafContext) |
| 43 | clear(); |
| 44 | else |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | if (!leafContext) |
| 49 | return; |
| 50 | |
| 51 | Q_ASSERT(m_contexts.isEmpty()); |
| 52 | QVector<QQmlContext *> tmp; |
| 53 | auto context = leafContext; |
| 54 | do { |
| 55 | tmp.push_back(context); |
| 56 | context = context->parentContext(); |
| 57 | } while (context); |
| 58 | std::reverse(tmp.begin(), tmp.end()); |
| 59 | |
| 60 | beginInsertRows(QModelIndex(), 0, tmp.size() - 1); |
| 61 | m_contexts = std::move(tmp); |
| 62 | endInsertRows(); |
| 63 | } |
| 64 | |
| 65 | int QmlContextModel::columnCount(const QModelIndex &parent) const |
| 66 | { |
no test coverage detected