Index: sources/view/hd/alarm/VAlarmStatus.cpp =================================================================== diff -u -r465a935949a85d3d1bebd11979737ff38ef96122 -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision 465a935949a85d3d1bebd11979737ff38ef96122) +++ sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,13 +1,13 @@ /*! * - * Copyright (c) 2020-2022 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file VAlarmStatus.cpp * \author (last) Behrouz NematiPour - * \date (last) 18-Apr-2022 + * \date (last) 17-Jan-2024 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * @@ -117,6 +117,16 @@ } // disabled coco end + //// ------ HIDE THE DIALOG - if has NO the alarm ------ + // DENBUG-182: Phantom Alarm Screen Appears After Clearing Last Alarm + if (vData.mTop == GuiAlarmID::ALARM_ID_NO_ALARM) { + hasAlarm(false); + _alarm_AlarmID = 0; + emit didAlarmEmpty(); + return; + } + + //// ----- SET PROPERTY VALUES ------ // Look for this tag: #First_Time_Message_Sent_With_Silenced // this has to be first to make sure in the Notification dialog when we decided to show the dialog, // we should also consider checking the alarms Silenced and if it is already silenced, @@ -150,28 +160,24 @@ } alarm_Flag_alarmsCondition (vData.mFlags.at(GuiAlarmFlags::ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION )); - if (vData.mTop == GuiAlarmID::ALARM_ID_NO_ALARM) { - emit didAlarmEmpty(); + hasAlarm(true); + + if ( + // alarm id properties + _alarm_AlarmIDChanged + || _alarm_PriorityChanged + // alarm buttons + || _alarm_Flag_noResumeChanged + || _alarm_Flag_noRinsebackChanged + || _alarm_Flag_noEndTreatmentChanged + || _alarm_Flag_UserMustAckChanged + // alarm cannot be minimized + || ( _alarm_Flag_noMinimizeChanged && _alarm_Flag_noMinimize ) + // alarm is out of silence + || ( _alarm_Flag_alarmsSilencedChanged && ! _alarm_Flag_alarmsSilenced ) + ){ + emit didAlarmRaise(); } - else { - hasAlarm(true); - if ( - // alarm id properties - _alarm_AlarmIDChanged - || _alarm_PriorityChanged - // alarm buttons - || _alarm_Flag_noResumeChanged - || _alarm_Flag_noRinsebackChanged - || _alarm_Flag_noEndTreatmentChanged - || _alarm_Flag_UserMustAckChanged - // alarm cannot be minimized - || ( _alarm_Flag_noMinimizeChanged && _alarm_Flag_noMinimize ) - // alarm is out of silence - || ( _alarm_Flag_alarmsSilencedChanged && ! _alarm_Flag_alarmsSilenced ) - ){ - emit didAlarmRaise(); - } - } } /*! @@ -194,43 +200,45 @@ return alarmIDText(static_cast(alarm_AlarmID())); } -QString VAlarmStatus::title () { QString s = _alarms[_alarm_AlarmID].title ; if ( ! s.isEmpty()) return s; else return tr("Alarm") ; } -QString VAlarmStatus::message () { QString s = _alarms[_alarm_AlarmID].message; if ( ! s.isEmpty()) return s; else return text() ; } -QStringList VAlarmStatus::instructionKeys () { return _alarms[_alarm_AlarmID].instructions.keys () ; } -QStringList VAlarmStatus::instructionValues () { return _alarms[_alarm_AlarmID].instructions.values () ; } +QString VAlarmStatus::title () { if ( ! _alarm_AlarmID ) return {}; QString s = _alarms[_alarm_AlarmID].title ; if ( ! s.isEmpty()) return s; else return tr("Alarm") ; } +QString VAlarmStatus::message () { if ( ! _alarm_AlarmID ) return {}; QString s = _alarms[_alarm_AlarmID].message; if ( ! s.isEmpty()) return s; else return text() ; } +QStringList VAlarmStatus::instructionKeys () { if ( ! _alarm_AlarmID ) return {}; return _alarms[_alarm_AlarmID].instructions.keys () ; } +QStringList VAlarmStatus::instructionValues () { if ( ! _alarm_AlarmID ) return {}; return _alarms[_alarm_AlarmID].instructions.values () ; } +/*! + * \brief View::VAlarmStatus::onActionReceive + * \details This function updates the alarm structure defined here to be used on the AlarmDialogs, + * when the settings controller is done reading the Alarms.conf and signaling this class. + * \todo This function with the same one in VActiveAlarmList needs to be moved to a Controller Model structure, for a better performance and memory management. + */ void VAlarmStatus::onActionReceive(const SettingsData &) { - QStringList mCategorys = _Settings.categorys(); - for (const QString &category : mCategorys) { - QStringList groups = _Settings.groups(category); - if ( ! Storage::Settings::isCategoryAlarms( category ) ) continue; + QString category = Storage::Settings_Category_Alarms; + QStringList groups = _Settings.groups(category); + for (const auto &group : groups) { + bool ok = true; + quint32 id = group.toInt( &ok ); + if ( ! ok ) { LOG_DEBUG(QString("Invalid Alarm ID [%1]").arg(group)); continue; } - for (const auto &group : groups) { - bool ok = true; - quint32 id = group.toInt( &ok ); - if ( ! ok ) { LOG_DEBUG(QString("Not an alarm ID number [%1]").arg(group)); continue; } - - AlarmData alarmData; - InstructionData instructionData; - for (const QString &key : _Settings.keys(group)) { - if (isTitle ( key ) ) { - alarmData.title = _Settings.value(group, key).toString(); - } else if (isMessage ( key ) ) { - alarmData.message = _Settings.value(group, key).toString(); - } else { - instructionData[key] = _Settings.value(group, key).toString(); - alarmData.instructions = instructionData; - } + AlarmData alarmData; + InstructionData instructionData; + for (const QString &key : _Settings.keys(category, group)) { + if (Storage::Settings::isKeyTitle ( key ) ) { + alarmData.title = _Settings.value(category, group, key).toString(); + } else if (Storage::Settings::isKeyMessage ( key ) ) { + alarmData.message = _Settings.value(category, group, key).toString(); + } else { + instructionData[key] = _Settings.value(category, group, key).toString(); + alarmData.instructions = instructionData; } - _alarms[id] = alarmData; - - /// DEBUG: - /// TODO: the MSettings model should do the same has been done here and use map instead of separate structure to iterate vertically, while map supports, keys, values. - // qDebug() << "@" << id << _alarms[id].title << _alarms[id].message << _alarms[id].instructions.keys() << _alarms[id].instructions.values(); - // for (const auto &key : _alarms[id].instructions.keys()) { - // qDebug() << "-" << key << _alarms[id].instructions.value(key); - // } } + _alarms[id] = alarmData; + + /// DEBUG: + /// TODO: the MSettings model should do the same has been done here and use map instead of separate structure to iterate vertically, while map supports, keys, values. + // qDebug() << "@" << id << _alarms[id].title << _alarms[id].message << _alarms[id].instructions.keys() << _alarms[id].instructions.values(); + // for (const auto &key : _alarms[id].instructions.keys()) { + // qDebug() << "-" << key << _alarms[id].instructions.value(key); + // } } emit alarm_AlarmIDChanged(_alarm_AlarmID); // to get the dialog content in sync with the Alarm.conf in case there is an early alarm. }