Index: sources/device/DeviceView.cpp =================================================================== diff -u -r71cd3700a59ff4b0e363aae8e3487c559c0a0eec -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 71cd3700a59ff4b0e363aae8e3487c559c0a0eec) +++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -498,12 +498,6 @@ return true; } -QModelIndex View::VDevice::index(int vRow, int vColumn, const QModelIndex &vParent) const { - return hasIndex(vRow, vColumn, vParent) - ? createIndex(vRow, vColumn) - : QModelIndex(); -} - // ================================================= WifiInfo void VDevice::doInitWifiInfo() { wifiInfoRequest({}); Index: sources/device/DeviceView.h =================================================================== diff -u -rbabe585dd9603621275742b07135c0fd4181802f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/device/DeviceView.h (.../DeviceView.h) (revision babe585dd9603621275742b07135c0fd4181802f) +++ sources/device/DeviceView.h (.../DeviceView.h) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -89,7 +89,6 @@ void dataAppend (const DataModel &vData , bool vFirst , bool vSecond); void dataClear ( ); bool setData (const QModelIndex &vIndex, const QVariant& vValue, int vRole = Qt::EditRole) override; - QModelIndex index (int vRow, int vColumn, const QModelIndex &vParent = QModelIndex()) const override; private: Index: sources/gui/qml/AlarmItem.qml =================================================================== diff -u -rf7d7e8b10c7626f3c6b8450876721a452ebd730f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/gui/qml/AlarmItem.qml (.../AlarmItem.qml) (revision f7d7e8b10c7626f3c6b8450876721a452ebd730f) +++ sources/gui/qml/AlarmItem.qml (.../AlarmItem.qml) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -117,7 +117,6 @@ titlePixelSize : Fonts.fontPixelAlarmTitle description : vAlarmStatus.message instructionModel : vAlarmStatus.instructionModel -// images : vAlarmStatus.instructionValues alarmID : vAlarmStatus.alarm_AlarmID isSilenced : vAlarmStatus.alarm_Flag_alarmsSilenced timeout : vAlarmStatus.alarm_MuteTimeout Index: sources/gui/qml/dialogs/NotificationDialog.qml =================================================================== diff -u -rf7d7e8b10c7626f3c6b8450876721a452ebd730f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/gui/qml/dialogs/NotificationDialog.qml (.../NotificationDialog.qml) (revision f7d7e8b10c7626f3c6b8450876721a452ebd730f) +++ sources/gui/qml/dialogs/NotificationDialog.qml (.../NotificationDialog.qml) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -61,21 +61,6 @@ visible : description && ! isSilenced radius : Variables.alarmDialogRadius -// onInstructionsChanged: { -// _model.clear() - -// for (var step in instructions) { -// _model.append({ text: instructions[step], image: "file:" + images[step] }) -// } - -// if ( _model.count > 0) { -// _listView.currentIndex = 0 -// figureImageSource = _model.get(_listView.currentIndex).image -// } -// } - -// ListModel { id: _model } - signal muteClicked() signal minimizeClicked() signal listClicked() @@ -178,7 +163,6 @@ width : _descriptionRect.width ListView {id: _listView -// model : _model height : _alarmContentRow.height width : parent.width * 0.65 currentIndex: 0 @@ -249,10 +233,10 @@ MouseArea { anchors.fill: parent onClicked: { - if (_listView.currentIndex !== index) { +// if (_listView.currentIndex !== index) { _listView.currentIndex = index _root.figureImageSource = model.image - } +// } } } } @@ -416,4 +400,14 @@ color : Colors.alarmDialogGreyText font.pixelSize : Fonts.fontPixelAlarmID } + + Connections { target: vAlarmStatus + function onDidAlarmRaise ( ) { + // on new alarm reset to selection and image to step 1 + if ( _root.instructionModel.rowCount() > 0) { + _listView.currentIndex = 0 + figureImageSource = _root.instructionModel.get(_listView.currentIndex).image + } + } + } } Index: sources/view/hd/alarm/VAlarmInstructionsModel.cpp =================================================================== diff -u -rf7d7e8b10c7626f3c6b8450876721a452ebd730f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/view/hd/alarm/VAlarmInstructionsModel.cpp (.../VAlarmInstructionsModel.cpp) (revision f7d7e8b10c7626f3c6b8450876721a452ebd730f) +++ sources/view/hd/alarm/VAlarmInstructionsModel.cpp (.../VAlarmInstructionsModel.cpp) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -14,12 +14,6 @@ */ QHash View::VAlarmInstructionsModel::roleNames() const { -// static const QHash roles { -// { eRole_Instruction, "instruction" }, -// { eRole_Image, "image" }, -// }; -// return roles; - return _dataRoles; } @@ -33,27 +27,45 @@ } /*! - * \brief Set the role names for the data in this list model. - * \param[in] roleNames New role names for this list model. - * \note This will clear the list model of any data. + * \brief Retrieve the data stored at the given index for the specified role. + * \param[in] index Index of the data in the list model. + * \param[in] role Role of the data to fetch. + * \return Data at index for role or Invalid if index or role are not valid. */ QVariant View::VAlarmInstructionsModel::data(const QModelIndex &vIndex, int vRole) const { // check for invalid or out of bounds index - if (vIndex.isValid() == false || vIndex.row() >= rowCount() || vIndex.column() > 0) - { + if ( ! vIndex.isValid() || vIndex.row() >= rowCount()) { return QVariant(); } - else - { - // ensure the role is in the data and return it, otherwise return invalid - return (_data[vIndex.row()].find(vRole) != _data[vIndex.row()].end()) - ? _data[vIndex.row()][vRole] - : QVariant(); + + switch (vRole) { + case eRole_Instruction : return _data[vIndex.row()].value(eRole_Instruction) ; + case eRole_Image : return _data[vIndex.row()].value(eRole_Image) ; } + + return QString("Alarm %1").arg(vIndex.row()); } /*! + * \brief Retrieve the data stored at the given index for the specified role and expose to QML + * \param[in] vRow Index of the data in the list model. + */ +QVariantMap View::VAlarmInstructionsModel::get(int vRow) const +{ + if (vRow < 0 || vRow >= rowCount()) { + return {}; + } + + QHash roles = roleNames(); + QVariantMap map; + for (auto it = roles.begin(); it != roles.end(); ++it) { + map[it.value()] = data(index(vRow, 0), it.key()); + } + return map; +} + +/*! * \brief Clear any data contained in this list model. */ void View::VAlarmInstructionsModel::clear() { @@ -63,20 +75,6 @@ } /*! - * \brief Get an index for this list model from the given row, column, and parent. - * \param[in] row Index row - * \param[in] column Index column - * \param[in] parent Index parent - * \return An index for the given row, column, and parent, or an invalid index if row, column, - * or parent are not valid. - */ -QModelIndex View::VAlarmInstructionsModel::index(int vRow, int vColumn, const QModelIndex &vParent) const { - return hasIndex(vRow, vColumn, vParent) - ? createIndex(vRow, vColumn) - : QModelIndex(); -} - -/*! * \brief Sets the value of the data in this list model at the given index and for the given role. * \param[in] index Location of data to update. * \param[in] value Value to set. @@ -92,7 +90,7 @@ { _data[vIndex.row()][vRole] = vValue; // explicitly emit a dataChanged signal to notify anybody bound to this property (vRole) - Q_EMIT dataChanged(vIndex, vIndex, QVector(1, vRole)); + emit dataChanged(vIndex, vIndex, QVector(1, vRole)); } return true; Index: sources/view/hd/alarm/VAlarmInstructionsModel.h =================================================================== diff -u -rf7d7e8b10c7626f3c6b8450876721a452ebd730f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/view/hd/alarm/VAlarmInstructionsModel.h (.../VAlarmInstructionsModel.h) (revision f7d7e8b10c7626f3c6b8450876721a452ebd730f) +++ sources/view/hd/alarm/VAlarmInstructionsModel.h (.../VAlarmInstructionsModel.h) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -32,15 +32,15 @@ int rowCount (const QModelIndex & = QModelIndex() ) const override; QVariant data (const QModelIndex &vIndex, int vRole = Qt::DisplayRole ) const override; bool setData (const QModelIndex &vIndex, const QVariant& vValue, int vRole = Qt::EditRole) override; - QModelIndex index (int vRow, int vColumn, const QModelIndex &vParent = QModelIndex() ) const override; void clear ( ); void appendData (const QHash &vData ); + Q_INVOKABLE QVariantMap get (int vRow ) const; // Exposed to QML + VIEW_DEC_CLASS_EX(VAlarmInstructionsModel, QAbstractListModel) private: QList> _data; }; - } Index: sources/view/hd/alarm/VAlarmStatus.cpp =================================================================== diff -u -rf7d7e8b10c7626f3c6b8450876721a452ebd730f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision f7d7e8b10c7626f3c6b8450876721a452ebd730f) +++ sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -159,11 +159,10 @@ it != _alarms[_alarm_AlarmID].instructions.constEnd(); ++it) { _alarmInstructionsList.appendData( {{VAlarmInstructionsModel::eRole_Instruction, it.key() }, - {VAlarmInstructionsModel::eRole_Image, it.value()}}); + {VAlarmInstructionsModel::eRole_Image, "file:" + it.value()}}); } emit didAlarmRaise(); - } } @@ -189,8 +188,6 @@ 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 Index: sources/view/hd/alarm/VAlarmStatus.h =================================================================== diff -u -rf7d7e8b10c7626f3c6b8450876721a452ebd730f -rac9c658e925728918ccf010670d67f00fc0a8c08 --- sources/view/hd/alarm/VAlarmStatus.h (.../VAlarmStatus.h) (revision f7d7e8b10c7626f3c6b8450876721a452ebd730f) +++ sources/view/hd/alarm/VAlarmStatus.h (.../VAlarmStatus.h) (revision ac9c658e925728918ccf010670d67f00fc0a8c08) @@ -84,8 +84,6 @@ // ********** STATIC PROPERTIES: The properties which need to be updated by each alarm message received. ********** // Q_PROPERTY(QString title READ title NOTIFY alarm_AlarmIDChanged ) Q_PROPERTY(QString message READ message NOTIFY alarm_AlarmIDChanged ) -// Q_PROPERTY(QStringList instructionKeys READ instructionKeys NOTIFY alarm_AlarmIDChanged ) -// Q_PROPERTY(QStringList instructionValues READ instructionValues NOTIFY alarm_AlarmIDChanged ) Q_PROPERTY(QString text READ text NOTIFY alarm_AlarmIDChanged ) Q_PROPERTY(VAlarmInstructionsModel* instructionModel READ instructionModel NOTIFY alarm_AlarmIDChanged)