* @brief Handles edits to the action form model. */
| 4294 | * @brief Handles edits to the action form model. |
| 4295 | */ |
| 4296 | void DataModel::ProjectEditor::onActionItemChanged(QStandardItem* item) |
| 4297 | { |
| 4298 | if (!item) |
| 4299 | return; |
| 4300 | |
| 4301 | static QStringList eolKeys; |
| 4302 | if (eolKeys.isEmpty()) |
| 4303 | for (auto i = m_eolSequences.begin(); i != m_eolSequences.end(); ++i) |
| 4304 | eolKeys.append(i.key()); |
| 4305 | |
| 4306 | const auto id = item->data(ParameterType); |
| 4307 | const auto value = item->data(EditableValue); |
| 4308 | |
| 4309 | switch (static_cast<ActionItem>(id.toInt())) { |
| 4310 | case kActionView_Title: |
| 4311 | m_selectedAction.title = value.toString(); |
| 4312 | break; |
| 4313 | case kActionView_Data: |
| 4314 | m_selectedAction.txData = value.toString(); |
| 4315 | break; |
| 4316 | case kActionView_EOL: { |
| 4317 | const int eolIdx = value.toInt(); |
| 4318 | if (eolIdx < 0 || eolIdx >= eolKeys.size()) |
| 4319 | return; |
| 4320 | |
| 4321 | m_selectedAction.eolSequence = eolKeys.at(eolIdx); |
| 4322 | break; |
| 4323 | } |
| 4324 | case kActionView_Icon: |
| 4325 | m_selectedAction.icon = value.toString(); |
| 4326 | Q_EMIT actionModelChanged(); |
| 4327 | break; |
| 4328 | case kActionView_Binary: |
| 4329 | m_selectedAction.binaryData = value.toBool(); |
| 4330 | buildActionModel(m_selectedAction); |
| 4331 | break; |
| 4332 | case kActionView_TxEncoding: |
| 4333 | m_selectedAction.txEncoding = value.toInt(); |
| 4334 | break; |
| 4335 | case kActionView_SourceId: { |
| 4336 | const auto& sources = DataModel::ProjectModel::instance().sources(); |
| 4337 | const int srcIdx = value.toInt(); |
| 4338 | if (srcIdx >= 0 && srcIdx < static_cast<int>(sources.size())) |
| 4339 | m_selectedAction.sourceId = sources[srcIdx].sourceId; |
| 4340 | |
| 4341 | break; |
| 4342 | } |
| 4343 | case kActionView_AutoExecute: |
| 4344 | m_selectedAction.autoExecuteOnConnect = value.toBool(); |
| 4345 | break; |
| 4346 | case kActionView_TimerMode: |
| 4347 | m_selectedAction.timerMode = static_cast<DataModel::TimerMode>(value.toInt()); |
| 4348 | buildActionModel(m_selectedAction); |
| 4349 | break; |
| 4350 | case kActionView_TimerInterval: |
| 4351 | m_selectedAction.timerIntervalMs = value.toInt(); |
| 4352 | break; |
| 4353 | case kActionView_RepeatCount: |
nothing calls this directly
no test coverage detected