* @brief Propagates group form edits to ProjectModel and the tree. */
| 4114 | * @brief Propagates group form edits to ProjectModel and the tree. |
| 4115 | */ |
| 4116 | void DataModel::ProjectEditor::onGroupItemChanged(QStandardItem* item) |
| 4117 | { |
| 4118 | if (!item) |
| 4119 | return; |
| 4120 | |
| 4121 | const auto id = static_cast<GroupItem>(item->data(ParameterType).toInt()); |
| 4122 | const auto value = item->data(EditableValue); |
| 4123 | auto& pm = DataModel::ProjectModel::instance(); |
| 4124 | const auto groupId = m_selectedGroup.groupId; |
| 4125 | |
| 4126 | if (id == kGroupView_Title) { |
| 4127 | if (!applyGroupTitleEdit(value.toString(), groupId)) |
| 4128 | return; |
| 4129 | |
| 4130 | Q_EMIT editableOptionsChanged(); |
| 4131 | return; |
| 4132 | } |
| 4133 | |
| 4134 | if (id == kGroupView_Source) { |
| 4135 | applyGroupSourceEdit(value.toInt(), groupId); |
| 4136 | Q_EMIT editableOptionsChanged(); |
| 4137 | return; |
| 4138 | } |
| 4139 | |
| 4140 | if (id == kGroupView_Widget) { |
| 4141 | if (!applyGroupWidgetEdit(value.toInt(), groupId)) |
| 4142 | return; |
| 4143 | |
| 4144 | Q_EMIT editableOptionsChanged(); |
| 4145 | return; |
| 4146 | } |
| 4147 | |
| 4148 | if (id == kGroupView_xAxis) { |
| 4149 | const int xAxisId = (value.toInt() == 1) ? kXAxisSamples : kXAxisTime; |
| 4150 | for (auto& dataset : m_selectedGroup.datasets) |
| 4151 | dataset.xAxisId = xAxisId; |
| 4152 | |
| 4153 | pm.updateGroup(groupId, m_selectedGroup); |
| 4154 | Q_EMIT editableOptionsChanged(); |
| 4155 | return; |
| 4156 | } |
| 4157 | |
| 4158 | if (id == kGroupView_WebUrl) { |
| 4159 | m_selectedGroup.webViewUrl = value.toString(); |
| 4160 | pm.updateGroup(groupId, m_selectedGroup, false); |
| 4161 | Q_EMIT editableOptionsChanged(); |
| 4162 | return; |
| 4163 | } |
| 4164 | |
| 4165 | #ifdef BUILD_COMMERCIAL |
| 4166 | if (id == kGroupView_ImgMode) { |
| 4167 | if (applyGroupImgModeEdit(value.toInt(), groupId)) |
| 4168 | return; |
| 4169 | |
| 4170 | Q_EMIT editableOptionsChanged(); |
| 4171 | return; |
| 4172 | } |
| 4173 |
nothing calls this directly
no test coverage detected