* @brief Reads project-wide scalar fields (title, delimiters, decoder, lock state) from JSON. */
| 2573 | * @brief Reads project-wide scalar fields (title, delimiters, decoder, lock state) from JSON. |
| 2574 | */ |
| 2575 | void DataModel::ProjectModel::loadProjectRootScalars(const QJsonObject& json) |
| 2576 | { |
| 2577 | m_title = json.value(Keys::Title).toString(); |
| 2578 | m_frameEndSequence = json.value(Keys::FrameEnd).toString(); |
| 2579 | m_frameStartSequence = json.value(Keys::FrameStart).toString(); |
| 2580 | m_hexadecimalDelimiters = json.value(Keys::HexadecimalDelimiters).toBool(); |
| 2581 | m_frameDetection = |
| 2582 | static_cast<SerialStudio::FrameDetection>(json.value(Keys::FrameDetection).toInt()); |
| 2583 | |
| 2584 | if (json.contains(Keys::ChecksumAlgorithm)) |
| 2585 | m_checksumAlgorithm = json.value(Keys::ChecksumAlgorithm).toString(); |
| 2586 | else |
| 2587 | m_checksumAlgorithm = json.value(Keys::Checksum).toString(); |
| 2588 | |
| 2589 | if (json.contains(Keys::DecoderMethod)) |
| 2590 | m_frameDecoder = |
| 2591 | static_cast<SerialStudio::DecoderMethod>(json.value(Keys::DecoderMethod).toInt()); |
| 2592 | else |
| 2593 | m_frameDecoder = static_cast<SerialStudio::DecoderMethod>(json.value(Keys::Decoder).toInt()); |
| 2594 | |
| 2595 | m_writerVersionAtCreation = json.value(Keys::WriterVersionAtCreation).toString(); |
| 2596 | |
| 2597 | m_nextUniqueId = ss_jsr(json, Keys::NextUniqueId, 1).toInt(); |
| 2598 | |
| 2599 | m_passwordHash = json.value(Keys::PasswordHash).toString(); |
| 2600 | const bool wasLocked = m_locked; |
| 2601 | m_locked = !m_passwordHash.isEmpty(); |
| 2602 | if (m_locked != wasLocked) |
| 2603 | Q_EMIT lockedChanged(); |
| 2604 | |
| 2605 | if (!json.contains(Keys::FrameDetection)) |
| 2606 | m_frameDetection = SerialStudio::StartAndEndDelimiter; |
| 2607 | } |
| 2608 | |
| 2609 | /** |
| 2610 | * @brief Deserializes groups, actions and sources arrays into m_groups/m_actions/m_sources. |