| 76 | } |
| 77 | |
| 78 | QVariant QmlContextModel::data(const QModelIndex &index, int role) const |
| 79 | { |
| 80 | if (m_contexts.isEmpty() || !index.isValid()) |
| 81 | return QVariant(); |
| 82 | |
| 83 | if (role == Qt::DisplayRole) { |
| 84 | auto context = m_contexts.at(index.row()); |
| 85 | switch (index.column()) { |
| 86 | case 0: |
| 87 | return Util::shortDisplayString(context); |
| 88 | case 1: |
| 89 | if (context->baseUrl().scheme() == QLatin1String("file")) // ### use SourceLocation for this! |
| 90 | return context->baseUrl().path(); |
| 91 | return context->baseUrl().toString(); |
| 92 | } |
| 93 | } else if (role == ObjectModel::ObjectRole) { |
| 94 | return QVariant::fromValue(m_contexts.at(index.row())); |
| 95 | } |
| 96 | |
| 97 | return QVariant(); |
| 98 | } |
| 99 | |
| 100 | QVariant QmlContextModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 101 | { |
no test coverage detected