| 112 | } |
| 113 | |
| 114 | QVariant VersionProxyModel::data(const QModelIndex &index, int role) const |
| 115 | { |
| 116 | if(!index.isValid()) |
| 117 | { |
| 118 | return QVariant(); |
| 119 | } |
| 120 | auto column = m_columns[index.column()]; |
| 121 | auto parentIndex = mapToSource(index); |
| 122 | switch(role) |
| 123 | { |
| 124 | case Qt::DisplayRole: |
| 125 | { |
| 126 | switch(column) |
| 127 | { |
| 128 | case Name: |
| 129 | { |
| 130 | QString version = sourceModel()->data(parentIndex, BaseVersionList::VersionRole).toString(); |
| 131 | if(version == m_currentVersion) |
| 132 | { |
| 133 | return tr("%1 (installed)").arg(version); |
| 134 | } |
| 135 | return version; |
| 136 | } |
| 137 | case ParentVersion: |
| 138 | return sourceModel()->data(parentIndex, BaseVersionList::ParentVersionRole); |
| 139 | case Branch: |
| 140 | return sourceModel()->data(parentIndex, BaseVersionList::BranchRole); |
| 141 | case Type: |
| 142 | return sourceModel()->data(parentIndex, BaseVersionList::TypeRole); |
| 143 | case Architecture: |
| 144 | return sourceModel()->data(parentIndex, BaseVersionList::ArchitectureRole); |
| 145 | case Path: |
| 146 | return sourceModel()->data(parentIndex, BaseVersionList::PathRole); |
| 147 | case Time: |
| 148 | return sourceModel()->data(parentIndex, Meta::VersionList::TimeRole).toDate(); |
| 149 | default: |
| 150 | return QVariant(); |
| 151 | } |
| 152 | } |
| 153 | case Qt::ToolTipRole: |
| 154 | { |
| 155 | switch(column) |
| 156 | { |
| 157 | case Name: |
| 158 | { |
| 159 | if(hasRecommended) |
| 160 | { |
| 161 | auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole); |
| 162 | if(value.toBool()) |
| 163 | { |
| 164 | return tr("Recommended"); |
| 165 | } |
| 166 | else if(hasLatest) |
| 167 | { |
| 168 | auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole); |
| 169 | if(value.toBool()) |
| 170 | { |
| 171 | return tr("Latest"); |
no test coverage detected