| 84 | } |
| 85 | |
| 86 | QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const { |
| 87 | auto row = index.row(); |
| 88 | auto mod = m_mods.at(row); |
| 89 | |
| 90 | if (role == Qt::DisplayRole) { |
| 91 | if (index.column() == NameColumn) { |
| 92 | return mod.name; |
| 93 | } |
| 94 | if (index.column() == DescriptionColumn) { |
| 95 | return mod.description; |
| 96 | } |
| 97 | } |
| 98 | else if (role == Qt::ToolTipRole) { |
| 99 | if (index.column() == DescriptionColumn) { |
| 100 | return mod.description; |
| 101 | } |
| 102 | } |
| 103 | else if (role == Qt::ForegroundRole) { |
| 104 | if (!mod.colour.isEmpty() && m_version.colours.contains(mod.colour)) { |
| 105 | return QColor(QString("#%1").arg(m_version.colours[mod.colour])); |
| 106 | } |
| 107 | } |
| 108 | else if (role == Qt::CheckStateRole) { |
| 109 | if (index.column() == EnabledColumn) { |
| 110 | return m_selection[mod.name] ? Qt::Checked : Qt::Unchecked; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | return {}; |
| 115 | } |
| 116 | |
| 117 | bool AtlOptionalModListModel::setData(const QModelIndex &index, const QVariant &value, int role) { |
| 118 | if (role == Qt::CheckStateRole) { |