Limit sensors available as possible RSSI source
This commit is contained in:
@@ -488,7 +488,7 @@ TelemetrySourceItemModel::TelemetrySourceItemModel(const GeneralSettings * const
|
||||
if (!modelData)
|
||||
return;
|
||||
|
||||
setUpdateMask(IMUE_TeleSensors);
|
||||
setUpdateMask(IMUE_TeleSensors | IMUE_Modules);
|
||||
const int count = firmware->getCapability(Sensors);
|
||||
|
||||
for (int i = -count; i <= count; ++i) {
|
||||
@@ -519,6 +519,49 @@ void TelemetrySourceItemModel::update(const int event)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// RssiSourceItemModel
|
||||
//
|
||||
|
||||
RssiSourceItemModel::RssiSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData,
|
||||
Firmware * firmware, const Boards * const board, const Board::Type boardType) :
|
||||
AbstractDynamicItemModel(generalSettings, modelData, firmware, board, boardType)
|
||||
{
|
||||
setId(IMID_RssiSource);
|
||||
|
||||
if (!modelData)
|
||||
return;
|
||||
|
||||
setUpdateMask(IMUE_TeleSensors | IMUE_Modules);
|
||||
|
||||
for (int i = 0; i <= firmware->getCapability(Sensors); ++i) {
|
||||
QStandardItem * modelItem = new QStandardItem();
|
||||
modelItem->setData(i, IMDR_Id);
|
||||
modelItem->setData(i < 0 ? IMDG_Negative : i > 0 ? IMDG_Positive : IMDG_None, IMDR_Flags);
|
||||
setDynamicItemData(modelItem, i);
|
||||
appendRow(modelItem);
|
||||
}
|
||||
}
|
||||
|
||||
void RssiSourceItemModel::setDynamicItemData(QStandardItem * item, const int value) const
|
||||
{
|
||||
item->setText(SensorData::rssiSensorToString(modelData, value));
|
||||
item->setData(SensorData::isRssiSensorAvailable(modelData, value), IMDR_Available);
|
||||
}
|
||||
|
||||
void RssiSourceItemModel::update(const int event)
|
||||
{
|
||||
if (doUpdate(event)) {
|
||||
emit aboutToBeUpdated();
|
||||
|
||||
for (int i = 0; i < rowCount(); ++i) {
|
||||
setDynamicItemData(item(i), item(i)->data(IMDR_Id).toInt());
|
||||
}
|
||||
|
||||
emit updateComplete();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CurveRefTypeItemModel
|
||||
//
|
||||
@@ -624,6 +667,9 @@ void CompoundItemModelFactory::addItemModel(const int id)
|
||||
case AbstractItemModel::IMID_TeleSource:
|
||||
registerItemModel(new TelemetrySourceItemModel(generalSettings, modelData, firmware, board, boardType));
|
||||
break;
|
||||
case AbstractItemModel::IMID_RssiSource:
|
||||
registerItemModel(new RssiSourceItemModel(generalSettings, modelData, firmware, board, boardType));
|
||||
break;
|
||||
case AbstractItemModel::IMID_CurveRefType:
|
||||
registerItemModel(new CurveRefTypeItemModel(generalSettings, modelData, firmware, board, boardType));
|
||||
break;
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef COMPOUNDITEMMODELS_H
|
||||
#define COMPOUNDITEMMODELS_H
|
||||
#pragma once
|
||||
|
||||
#include "rawsource.h"
|
||||
#include "rawswitch.h"
|
||||
@@ -44,6 +43,7 @@ class AbstractItemModel: public QStandardItemModel
|
||||
IMID_CustomFuncAction,
|
||||
IMID_CustomFuncResetParam,
|
||||
IMID_TeleSource,
|
||||
IMID_RssiSource,
|
||||
IMID_CurveRefType,
|
||||
IMID_CurveRefFunc,
|
||||
IMID_ReservedCount,
|
||||
@@ -78,8 +78,9 @@ class AbstractItemModel: public QStandardItemModel
|
||||
IMUE_Scripts = 1 << 7,
|
||||
IMUE_TeleSensors = 1 << 8,
|
||||
IMUE_Timers = 1 << 9,
|
||||
IMUE_Modules = 1 << 10,
|
||||
IMUE_All = IMUE_SystemRefresh | IMUE_Channels | IMUE_Curves | IMUE_FlightModes | IMUE_GVars | IMUE_Inputs |
|
||||
IMUE_LogicalSwitches | IMUE_Scripts | IMUE_TeleSensors | IMUE_Timers
|
||||
IMUE_LogicalSwitches | IMUE_Scripts | IMUE_TeleSensors | IMUE_Timers | IMUE_Modules
|
||||
};
|
||||
Q_ENUM(ItemModelUpdateEvent)
|
||||
|
||||
@@ -305,6 +306,21 @@ class TelemetrySourceItemModel: public AbstractDynamicItemModel
|
||||
virtual void setDynamicItemData(QStandardItem * item, const int value) const;
|
||||
};
|
||||
|
||||
class RssiSourceItemModel: public AbstractDynamicItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RssiSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData,
|
||||
Firmware * firmware, const Boards * const board, const Board::Type boardType);
|
||||
virtual ~RssiSourceItemModel() {};
|
||||
|
||||
public slots:
|
||||
virtual void update(const int event = IMUE_SystemRefresh) override;
|
||||
|
||||
protected:
|
||||
virtual void setDynamicItemData(QStandardItem * item, const int value) const;
|
||||
};
|
||||
|
||||
class CurveRefTypeItemModel : public AbstractStaticItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -361,5 +377,3 @@ class CompoundItemModelFactory
|
||||
private:
|
||||
void setSourceId(AbstractItemModel * itemModel);
|
||||
};
|
||||
|
||||
#endif // COMPOUNDITEMMODELS_H
|
||||
|
||||
Reference in New Issue
Block a user