Index: denali.pro.user =================================================================== diff -u -r30d7e9993624feb138e7532ad2feaefc592f6a63 -raacab152859bb82a439a0a01e951e0ced2aac76e --- denali.pro.user (.../denali.pro.user) (revision 30d7e9993624feb138e7532ad2feaefc592f6a63) +++ denali.pro.user (.../denali.pro.user) (revision aacab152859bb82a439a0a01e951e0ced2aac76e) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/model/hd/alarm/MAlarmMapping.cpp =================================================================== diff -u -r30d7e9993624feb138e7532ad2feaefc592f6a63 -raacab152859bb82a439a0a01e951e0ced2aac76e --- sources/model/hd/alarm/MAlarmMapping.cpp (.../MAlarmMapping.cpp) (revision 30d7e9993624feb138e7532ad2feaefc592f6a63) +++ sources/model/hd/alarm/MAlarmMapping.cpp (.../MAlarmMapping.cpp) (revision aacab152859bb82a439a0a01e951e0ced2aac76e) @@ -7,7 +7,7 @@ * * \file MAlarmMapping.cpp * \author (last) Behrouz NematiPour - * \date (last) 27-Oct-2022 + * \date (last) 28-Oct-2022 * \author (original) Behrouz NematiPour * \date (original) 03-May-2021 * Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -r30d7e9993624feb138e7532ad2feaefc592f6a63 -raacab152859bb82a439a0a01e951e0ced2aac76e --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision 30d7e9993624feb138e7532ad2feaefc592f6a63) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision aacab152859bb82a439a0a01e951e0ced2aac76e) @@ -61,7 +61,9 @@ QStringList keys = _Settings.keys (category, group); QVariantList values = _Settings.values (category, group); if ( Storage::Settings::isCategoryInstructions( category ) ) { - updateInstructions(group, keys, values); + TKeysList keysList = updateReplacements(group, keys ); + updateInstructions(group, keysList, values ); + updateInstructions(group ); } else { //TODO: Since it is global system settings, move this to the settings controller so the C++ backend can also use it. like Date/Time formats. for (const auto &key : keys) { @@ -109,54 +111,65 @@ adjustment(true); } -void VSettings::updateReplacements(const QString &vGroup, QStringList &vKeys) +VSettings::TKeysList VSettings::updateReplacements(const QString &vGroup, const QStringList &vKeys) { + TKeysList keysList; for ( quint16 keyIndex = 0; keyIndex < vKeys.count(); keyIndex++ ) { - QRegExp regx("\\{\\w+:\\d+\\}"); + QRegExp regx("\\{\\s*\\d+\\s*:\\s*\\d+\\s*:\\s*\\w*\\s*:\\s*\\d*\\s*\\}"); QString key = vKeys[keyIndex]; int replacementCount = key.count(regx); - int oLen = 0; + QStringList keyList; for ( int j = 0; j < replacementCount; j++ ) { - int cLen = 0; int pos = key.indexOf(regx); - cLen = regx.matchedLength(); - QString blk = key.mid(pos+1, cLen-2); - key.remove(pos, regx.matchedLength()); + int len = regx.matchedLength(); + QString blk = key.mid(pos+1, len-2); + keyList += key.mid(0, pos); + keyList += ""; // value placeholder + key.remove(0, pos + regx.matchedLength()); QStringList lst = blk.split(":"); quint16 id = lst[0].toUInt(); - quint8 ix = lst[1].toUInt(); + quint16 ix = lst[1].toUInt(); + QString ex = lst[2] ; + quint16 rd = lst[3].toUInt(); TLocation loc; loc.group = vGroup ; loc.keyIndex = keyIndex ; - loc.locIndex = pos - oLen ; + loc.locIndex = j * 2 + 1 ; loc.prmIndex = ix ; - + loc.prmExtra = ex ; + loc.prmRound = rd ; _replacements[id] += loc; - qDebug() << "#" << replacementCount << id << ix << loc.group << loc.keyIndex << loc.locIndex << loc.prmIndex << oLen << cLen ; - oLen = cLen; + //DEBUG: qDebug() << "#" << replacementCount << id << loc.group << loc.keyIndex << loc.locIndex << loc.prmIndex; } - vKeys[keyIndex] = key; + keyList += key; + keysList += keyList; } + return keysList; } -void VSettings::updateInstructions(const QString &vGroup, QStringList &vKeys, const QVariantList &vValues) +void VSettings::updateInstructions(const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues) { - // DEBUG : - // qDebug() << " ##### " - // << group - // << keys - // << values - // << location ; - QVariantMap details; - QString location = QString(Storage::Settings_Category_InstructionsImagesLoc).arg(Storage::Settings_Path_Name); + TInstruction mInstruction; + mInstruction.location = _location; + mInstruction.keys = vKeysList; + mInstruction.values = vValues ; + _instructionMap[vGroup] = mInstruction; +} - updateReplacements(vGroup, vKeys); - - details["location"] = location ; - details["keys" ] = vKeys ; - details["values" ] = vValues ; - - _instructions[vGroup] = details; +void VSettings::updateInstructions(const QString &vGroup) +{ + //TODO: this function or even the structure may need to update to send less data to qml and only the updated part. + TKeysList keysList = _instructionMap[vGroup].keys ; + QVariantList values = _instructionMap[vGroup].values; + QStringList keyList; + for ( const auto &keys : keysList) { + keyList += keys.join(""); + } + QVariantMap details; + details["location"] = _location ; + details["keys" ] = keyList ; + details["values" ] = values ; + _instructions[vGroup] = details ; } /*! @@ -166,22 +179,33 @@ * \param vAction - the action * \param vData - the action data */ -void VSettings::onActionReceive (GuiActionType vAction, const QVariantList &) +void VSettings::onActionReceive (GuiActionType vAction, const QVariantList &vData) { bool isChanged = false; - QVariantMap mInstructions = _instructions; // the original should be kept unchanged since all the posIndexes will change if values added. quint16 id = qFromBigEndian((quint16)vAction); if (_replacements.contains(id)) { isChanged = true; - qDebug() << _replacements[id].count(); + //DEBUG: qDebug() << _replacements[id].count(); for ( auto item : _replacements[id]) { - qDebug() << id << item.group << item.keyIndex << item.locIndex << item.prmIndex; - QVariantMap details = mInstructions[item.group].toMap(); - // QStringList keys = details["keys" ].toStringList(); - // qDebug() << keys.at(item.keyIndex).insert(); - + //DEBUG: qDebug() << id << item.group << item.keyIndex << item.locIndex << item.prmIndex; + QString value; + quint16 len = vData.length(); + if ( 0 < item.prmIndex && item.prmIndex <= len ) { + if ( item.prmRound > 0 ) { + value = QString::number(vData[item.prmIndex - 1].toFloat(), 'f', item.prmRound) + item.prmExtra; + } + else { + value = vData[item.prmIndex - 1].toString() + item.prmExtra; + } + } + else { + LOG_DEBUG(QString("Given prmIndex %1 is out of message %2 parameters count %3 on instruction group '%4' and key index %5") + .arg(item.prmIndex).arg(id).arg(len).arg(item.group).arg(item.keyIndex)); + continue; + } + _instructionMap[item.group].keys[item.keyIndex][item.locIndex] = value; + updateInstructions(item.group); } - qDebug() << "\n"; } - if ( isChanged ) emit instructionsChanged(mInstructions); + if ( isChanged ) emit instructionsChanged(_instructions); } Index: sources/view/settings/VSettings.h =================================================================== diff -u -r30d7e9993624feb138e7532ad2feaefc592f6a63 -raacab152859bb82a439a0a01e951e0ced2aac76e --- sources/view/settings/VSettings.h (.../VSettings.h) (revision 30d7e9993624feb138e7532ad2feaefc592f6a63) +++ sources/view/settings/VSettings.h (.../VSettings.h) (revision aacab152859bb82a439a0a01e951e0ced2aac76e) @@ -31,6 +31,29 @@ { Q_OBJECT + QString _location = QString(Storage::Settings_Category_InstructionsImagesLoc).arg(Storage::Settings_Path_Name); + typedef QList TKeysList; + typedef struct { + QString location; + TKeysList keys ; + QVariantList values ; + } TInstruction ; + QMap _instructionMap; + + typedef qint16 TID ; + typedef qint16 TParamIndex ; + typedef struct { + QString group ; + quint16 keyIndex; + quint16 locIndex; + quint16 prmIndex; + QString prmExtra; + quint16 prmRound; + } TLocation; + typedef QList TLocationList; + typedef QMap TReplacements; + TReplacements _replacements; + TRIGGER ( bool , adjustment , 0 ) // TODO: This view needs modification and it needs to isolate the settings and have its own specific properties, not the complete settings exposed to QML and let QML access it. @@ -45,22 +68,11 @@ SETTINGS(bool , noCANBus , false , Storage::Settings_Category_NoCANBus , "Navigation" , "Create Treatment To Patient ID" ) VIEW_DEC(VSettings, SettingsData) -private: - typedef qint16 TID ; - typedef qint16 TParamIndex ; - typedef struct { - QString group ; - quint16 keyIndex; - quint16 locIndex; - quint16 prmIndex; - } TLocation; - typedef QList TLocationList; - typedef QMap TReplacements; - TReplacements _replacements; private: - void updateInstructions (const QString &vGroup, QStringList &vKeys, const QVariantList &vValues); - void updateReplacements (const QString &vGroup, QStringList &vKeys); + TKeysList updateReplacements ( const QString &vGroup, const QStringList &vKeys ); + void updateInstructions ( const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues ); + void updateInstructions ( const QString &vGroup ); private slots: void onActionReceive (GuiActionType vAction, const QVariantList &vData);