| 53 | } |
| 54 | |
| 55 | QVariant EnvironmentProfileModel::data(const QModelIndex& index, int role) const |
| 56 | { |
| 57 | if (!index.isValid() || |
| 58 | index.row() < 0 || index.row() >= rowCount() || |
| 59 | index.column() < 0 || index.column() >= columnCount(QModelIndex()) || |
| 60 | m_currentProfileName.isEmpty()) { |
| 61 | return {}; |
| 62 | } |
| 63 | |
| 64 | const auto variable = m_varsByIndex[index.row()]; |
| 65 | if (role == VariableRole) { |
| 66 | return variable; |
| 67 | } |
| 68 | if (role == ValueRole) { |
| 69 | const auto& variables = m_profileListModel->variables(m_currentProfileName); |
| 70 | return variables.value(variable); |
| 71 | } |
| 72 | if (role == Qt::DisplayRole || role == Qt::EditRole) { |
| 73 | if (index.column() == VariableColumn) { |
| 74 | return variable; |
| 75 | } |
| 76 | const auto& variables = m_profileListModel->variables(m_currentProfileName); |
| 77 | return variables.value(variable); |
| 78 | } |
| 79 | return {}; |
| 80 | } |
| 81 | |
| 82 | QVariant EnvironmentProfileModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 83 | { |