Index: sources/view/VAdjustmentResponseBase.cpp =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -rb794e2e09c4a06e6faaa722f2dc35f50e5f2e8e0 --- sources/view/VAdjustmentResponseBase.cpp (.../VAdjustmentResponseBase.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/view/VAdjustmentResponseBase.cpp (.../VAdjustmentResponseBase.cpp) (revision b794e2e09c4a06e6faaa722f2dc35f50e5f2e8e0) @@ -16,19 +16,65 @@ // Project #include "GuiController.h" +#include "Settings.h" VIEW_DEF_CLASS(VAdjustmentResponseBase) -void View::VAdjustmentResponseBase::initConnections() { } +void View::VAdjustmentResponseBase::initConnections() { + ACTION_VIEW_CONNECTION(SettingsData); +} /*! * \brief View::VAdjustmentResponseBase::text * \details The slot to get the Reason Description * \return Reason description as string + * \note thid method is kept to be consistent with the qml implementation. + * it returns the same value as title method. */ -QString View::VAdjustmentResponseBase::text() +QString View::VAdjustmentResponseBase::text() { return title(); } + +/*! + * \brief View::VAdjustmentResponseBase::title + * \details The slot to get the Rejection Title + * \return Rejection Title as string + */ +QString View::VAdjustmentResponseBase::title () { - QString text; - if (_adjustment_Reason != GuiRequestReasons::REQUEST_REJECT_REASON_NONE) - text = Gui::enumString(static_cast(_adjustment_Reason), "[%1] Unknown Error"); - return text; + if ( ! _adjustment_Reason ) return {}; + QString s = _rejects[_adjustment_Reason].title; + if ( ! s.isEmpty()) return s; + else return tr("[%1] Unknown Error").arg(_adjustment_Reason); } + +/*! + * \brief View::onActionReceive + * \details This function updates the reject 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 View::VAdjustmentResponseBase::onActionReceive(const SettingsData &) { + QString category = Storage::Settings_Category_Rejects; + QStringList groups = _Settings.groups(category); + + for (const auto &group : groups) { + bool ok = true; + quint32 id = group.toInt( &ok ); + if ( ! ok ) { LOG_DEBUG(QString("Invalid Reject ID [%1]").arg(group)); continue; } + + RejectData rejectData; + for (const QString &key : _Settings.keys(category, group)) { + if (Storage::Settings::isKeyTitle ( key ) ) { + rejectData.title = _Settings.value(category, group, key).toString(); + } + } + _rejects[id] = rejectData; + + /// 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() << "@TR: category:" << category << ":" << id << _rejects[id].title << _rejects[id].message << _rejects[id].instructions.keys() << _rejects[id].instructions.values(); + /// for (const auto &key : _rejects[id].instructions.keys()) { + /// qDebug() << "-" << key << _rejects[id].instructions.value(key); + /// } + } + + emit adjustment_ReasonTriggered (_adjustment_Reason); // to get the dialog content in sync with the Rejects.conf in case there is an early reject. +}