Refactor to directly call updates to data models
This commit is contained in:
@@ -43,7 +43,7 @@ RawSourceItemModel::RawSourceItemModel(const GeneralSettings * const generalSett
|
||||
addItems(SOURCE_TYPE_PPM, RawSource::SourcesGroup, fw->getCapability(TrainerInputs));
|
||||
addItems(SOURCE_TYPE_CH, RawSource::SourcesGroup, fw->getCapability(Outputs));
|
||||
addItems(SOURCE_TYPE_SPECIAL, RawSource::TelemGroup, 5);
|
||||
addItems(SOURCE_TYPE_TELEMETRY, RawSource::TelemGroup, CPN_MAX_SENSORS * 3);
|
||||
addItems(SOURCE_TYPE_TELEMETRY, RawSource::TelemGroup, fw->getCapability(Sensors) * 3);
|
||||
addItems(SOURCE_TYPE_GVAR, RawSource::GVarsGroup, fw->getCapability(Gvars));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett
|
||||
|
||||
// Descending switch direction: NOT (!) switches
|
||||
addItems(SWITCH_TYPE_ACT, -1);
|
||||
addItems(SWITCH_TYPE_SENSOR, -CPN_MAX_SENSORS);
|
||||
addItems(SWITCH_TYPE_SENSOR, -fw->getCapability(Sensors));
|
||||
addItems(SWITCH_TYPE_TELEMETRY, -1);
|
||||
addItems(SWITCH_TYPE_FLIGHT_MODE, -fw->getCapability(FlightModes));
|
||||
addItems(SWITCH_TYPE_VIRTUAL, -fw->getCapability(LogicalSwitches));
|
||||
@@ -109,7 +109,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett
|
||||
addItems(SWITCH_TYPE_VIRTUAL, fw->getCapability(LogicalSwitches));
|
||||
addItems(SWITCH_TYPE_FLIGHT_MODE, fw->getCapability(FlightModes));
|
||||
addItems(SWITCH_TYPE_TELEMETRY, 1);
|
||||
addItems(SWITCH_TYPE_SENSOR, CPN_MAX_SENSORS);
|
||||
addItems(SWITCH_TYPE_SENSOR, fw->getCapability(Sensors));
|
||||
addItems(SWITCH_TYPE_ON, 1);
|
||||
addItems(SWITCH_TYPE_ONE, 1);
|
||||
addItems(SWITCH_TYPE_ACT, 1);
|
||||
@@ -220,3 +220,44 @@ void CurveItemModel::update()
|
||||
|
||||
emit dataUpdateComplete();
|
||||
}
|
||||
|
||||
//
|
||||
// CommonItemModels
|
||||
//
|
||||
|
||||
CommonItemModels::CommonItemModels(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent)
|
||||
{
|
||||
m_rawSourceItemModel = new RawSourceItemModel(generalSettings, modelData, parent);
|
||||
m_rawSwitchItemModel = new RawSwitchItemModel(generalSettings, modelData, parent);
|
||||
m_curveItemModel = new CurveItemModel(generalSettings, modelData, parent);
|
||||
}
|
||||
|
||||
CommonItemModels::~CommonItemModels()
|
||||
{
|
||||
}
|
||||
|
||||
void CommonItemModels::update(const RadioModelObjects radioModelObjects)
|
||||
{
|
||||
switch (radioModelObjects) {
|
||||
case RMO_CHANNELS:
|
||||
case RMO_INPUTS:
|
||||
case RMO_TELEMETRY_SENSORS:
|
||||
case RMO_TIMERS:
|
||||
m_rawSourceItemModel->update();
|
||||
break;
|
||||
case RMO_FLIGHT_MODES:
|
||||
case RMO_GLOBAL_VARIABLES:
|
||||
case RMO_LOGICAL_SWITCHES:
|
||||
m_rawSourceItemModel->update();
|
||||
m_rawSwitchItemModel->update();
|
||||
break;
|
||||
case RMO_CURVES:
|
||||
m_curveItemModel->update();
|
||||
break;
|
||||
case RMO_SCRIPTS:
|
||||
// no need to refresh
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Unknown RadioModelObject:" << radioModelObjects;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,4 +105,36 @@ class CurveItemModel: public AbstractRawItemDataModel
|
||||
void setDynamicItemData(QStandardItem * item, int index) const;
|
||||
};
|
||||
|
||||
|
||||
class CommonItemModels: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum RadioModelObjects {
|
||||
RMO_CHANNELS,
|
||||
RMO_CURVES,
|
||||
RMO_FLIGHT_MODES,
|
||||
RMO_GLOBAL_VARIABLES,
|
||||
RMO_INPUTS,
|
||||
RMO_LOGICAL_SWITCHES,
|
||||
RMO_SCRIPTS,
|
||||
RMO_TELEMETRY_SENSORS,
|
||||
RMO_TIMERS
|
||||
};
|
||||
Q_ENUM(RadioModelObjects)
|
||||
|
||||
explicit CommonItemModels(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr);
|
||||
~CommonItemModels();
|
||||
|
||||
void update(const RadioModelObjects radioModelObjects);
|
||||
RawSourceItemModel * rawSourceItemModel() const { return m_rawSourceItemModel; }
|
||||
RawSwitchItemModel * rawSwitchItemModel() const { return m_rawSwitchItemModel; }
|
||||
CurveItemModel * curveItemModel() const { return m_curveItemModel; }
|
||||
|
||||
private:
|
||||
RawSourceItemModel *m_rawSourceItemModel;
|
||||
RawSwitchItemModel *m_rawSwitchItemModel;
|
||||
CurveItemModel *m_curveItemModel;
|
||||
};
|
||||
|
||||
#endif // RAWITEMDATAMODELS_H
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "rawitemfilteredmodel.h"
|
||||
#include "rawitemdatamodels.h"
|
||||
|
||||
RawItemFilteredModel::RawItemFilteredModel(QAbstractItemModel * sourceModel, int flags, QObject * parent) :
|
||||
QSortFilterProxyModel(parent),
|
||||
@@ -31,10 +30,10 @@ RawItemFilteredModel::RawItemFilteredModel(QAbstractItemModel * sourceModel, int
|
||||
setDynamicSortFilter(true);
|
||||
setSourceModel(sourceModel);
|
||||
|
||||
AbstractRawItemDataModel * model = qobject_cast<AbstractRawItemDataModel *>(sourceModel);
|
||||
if (model) {
|
||||
connect(model, &AbstractRawItemDataModel::dataAboutToBeUpdated, this, &RawItemFilteredModel::onDataAboutToBeUpdated);
|
||||
connect(model, &AbstractRawItemDataModel::dataUpdateComplete, this, &RawItemFilteredModel::onDataUpdateComplete);
|
||||
AbstractRawItemDataModel * itemModel = qobject_cast<AbstractRawItemDataModel *>(sourceModel);
|
||||
if (itemModel) {
|
||||
connect(itemModel, &AbstractRawItemDataModel::dataAboutToBeUpdated, this, &RawItemFilteredModel::onDataAboutToBeUpdated);
|
||||
connect(itemModel, &AbstractRawItemDataModel::dataUpdateComplete, this, &RawItemFilteredModel::onDataUpdateComplete);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +61,9 @@ bool RawItemFilteredModel::filterAcceptsRow(int sourceRow, const QModelIndex & s
|
||||
|
||||
void RawItemFilteredModel::update() const
|
||||
{
|
||||
AbstractRawItemDataModel * model = qobject_cast<AbstractRawItemDataModel *>(sourceModel());
|
||||
if (model)
|
||||
model->update();
|
||||
AbstractRawItemDataModel * itemModel = qobject_cast<AbstractRawItemDataModel *>(sourceModel());
|
||||
if (itemModel)
|
||||
itemModel->update();
|
||||
}
|
||||
|
||||
void RawItemFilteredModel::onDataAboutToBeUpdated()
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
class GeneralSettings;
|
||||
class ModelData;
|
||||
class RawSourceItemModel;
|
||||
class RawSwitchItemModel;
|
||||
|
||||
class RawItemFilteredModel: public QSortFilterProxyModel
|
||||
{
|
||||
@@ -36,9 +34,11 @@ class RawItemFilteredModel: public QSortFilterProxyModel
|
||||
public:
|
||||
enum DataFilters {
|
||||
AllFilter = AbstractRawItemDataModel::NegativeGroup | AbstractRawItemDataModel::NoneGroup | AbstractRawItemDataModel::PositiveGroup,
|
||||
HideNegativeFilter = AllFilter &~ AbstractRawItemDataModel::NegativeGroup,
|
||||
NonePositiveFilter = AbstractRawItemDataModel::NoneGroup | AbstractRawItemDataModel::PositiveGroup,
|
||||
PositiveFilter = AbstractRawItemDataModel::PositiveGroup
|
||||
AllExcludeNoneFilter = AllFilter &~ AbstractRawItemDataModel::NoneGroup,
|
||||
NegativeFilter = AbstractRawItemDataModel::NegativeGroup | AbstractRawItemDataModel::NoneGroup,
|
||||
NegativeExcludeNoneFilter = AbstractRawItemDataModel::NegativeGroup,
|
||||
PositiveFilter = AbstractRawItemDataModel::PositiveGroup | AbstractRawItemDataModel::NoneGroup,
|
||||
PositiveExcludeNoneFilter = AbstractRawItemDataModel::PositiveGroup
|
||||
};
|
||||
Q_ENUM(DataFilters)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
|
||||
tr("THs"), tr("TH%"), tr("THt")
|
||||
};
|
||||
|
||||
const QStringList directionIndicators = QStringList()
|
||||
static const QStringList directionIndicators = QStringList()
|
||||
<< CPN_STR_SW_INDICATOR_UP
|
||||
<< CPN_STR_SW_INDICATOR_NEUT
|
||||
<< CPN_STR_SW_INDICATOR_DN;
|
||||
|
||||
@@ -56,11 +56,10 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
|
||||
}
|
||||
}
|
||||
|
||||
RawSourceItemModel *rawSourceModel = new RawSourceItemModel(&generalSettings, nullptr, this);
|
||||
RawSwitchItemModel *rawSwitchModel = new RawSwitchItemModel(&generalSettings, nullptr, this);
|
||||
commonItemModels = new CommonItemModels(&generalSettings, nullptr, this);
|
||||
|
||||
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
|
||||
addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, rawSourceModel, rawSwitchModel), tr("Global Functions"));
|
||||
addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, commonItemModels), tr("Global Functions"));
|
||||
addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
|
||||
addTab(new HardwarePanel(this, generalSettings, firmware), tr("Hardware"));
|
||||
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "eeprominterface.h"
|
||||
#include "genericpanel.h"
|
||||
|
||||
class CommonItemModels;
|
||||
|
||||
namespace Ui {
|
||||
class GeneralEdit;
|
||||
}
|
||||
@@ -56,7 +58,7 @@ class GeneralEdit : public QDialog
|
||||
void getGeneralSwitchDefPos(int i, bool val);
|
||||
void setSwitchDefPos();
|
||||
void updateVarioPitchRange();
|
||||
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
@@ -71,7 +73,7 @@ class GeneralEdit : public QDialog
|
||||
QVector<GenericPanel *> panels;
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
CommonItemModels *commonItemModels;
|
||||
};
|
||||
|
||||
#endif // _GENERALEDIT_H_
|
||||
|
||||
@@ -96,15 +96,16 @@ void LimitsGroup::updateMinMax(int max)
|
||||
}
|
||||
}
|
||||
}
|
||||
ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CurveItemModel * curveItemModel):
|
||||
ModelPanel(parent, model, generalSettings, firmware)
|
||||
ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
chnCapability = firmware->getCapability(Outputs);
|
||||
int channelNameMaxLen = firmware->getCapability(ChannelsName);
|
||||
|
||||
curveModel = new RawItemFilteredModel(curveItemModel, RawItemFilteredModel::AllFilter, this);
|
||||
connect(curveModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &ChannelsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(curveModel, &RawItemFilteredModel::dataUpdateComplete, this, &ChannelsPanel::onModelDataUpdateComplete);
|
||||
curveFilteredModel = new RawItemFilteredModel(commonItemModels->curveItemModel(), RawItemFilteredModel::AllFilter, this);
|
||||
connect(curveFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &ChannelsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(curveFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &ChannelsPanel::onModelDataUpdateComplete);
|
||||
|
||||
QStringList headerLabels;
|
||||
headerLabels << "#";
|
||||
@@ -165,7 +166,7 @@ ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSetting
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard())) {
|
||||
curveCB[i] = new QComboBox(this);
|
||||
curveCB[i]->setProperty("index", i);
|
||||
curveCB[i]->setModel(curveModel);
|
||||
curveCB[i]->setModel(curveFilteredModel);
|
||||
connect(curveCB[i], SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited()));
|
||||
tableLayout->addWidget(i, col++, curveCB[i]);
|
||||
}
|
||||
@@ -213,7 +214,6 @@ ChannelsPanel::~ChannelsPanel()
|
||||
delete centerSB[i];
|
||||
delete symlimitsChk[i];
|
||||
}
|
||||
delete curveModel;
|
||||
}
|
||||
|
||||
void ChannelsPanel::symlimitsEdited()
|
||||
@@ -233,7 +233,7 @@ void ChannelsPanel::nameEdited()
|
||||
int index = le->property("index").toInt();
|
||||
if (model->limitData[index].name != le->text()) {
|
||||
strcpy(model->limitData[index].name, le->text().toLatin1());
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ void ChannelsPanel::cmPaste()
|
||||
if (hasClipboardData(&data)) {
|
||||
memcpy(&model->limitData[selectedIndex], data.constData(), sizeof(LimitData));
|
||||
updateLine(selectedIndex);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ void ChannelsPanel::cmDelete()
|
||||
updateLine(i);
|
||||
}
|
||||
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ void ChannelsPanel::cmClear(bool prompt)
|
||||
model->limitData[selectedIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_CLEAR, selectedIndex);
|
||||
updateLine(selectedIndex);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ void ChannelsPanel::cmClearAll()
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_CLEAR, i);
|
||||
updateLine(i);
|
||||
}
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ void ChannelsPanel::cmInsert()
|
||||
model->limitData[selectedIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ void ChannelsPanel::swapData(int idx1, int idx2)
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_SWAP, idx1, idx2);
|
||||
updateLine(idx1);
|
||||
updateLine(idx2);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -482,4 +482,10 @@ void ChannelsPanel::onModelDataAboutToBeUpdated()
|
||||
void ChannelsPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void ChannelsPanel::updateItemModels()
|
||||
{
|
||||
commonItemModels->update(CommonItemModels::RMO_CHANNELS);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class CurveItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
|
||||
constexpr char MIMETYPE_CHANNEL[] = "application/x-companion-channel";
|
||||
@@ -57,7 +57,7 @@ class ChannelsPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CurveItemModel * curveItemModel);
|
||||
ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
~ChannelsPanel();
|
||||
|
||||
public slots:
|
||||
@@ -84,9 +84,6 @@ class ChannelsPanel : public ModelPanel
|
||||
void onModelDataAboutToBeUpdated();
|
||||
void onModelDataUpdateComplete();
|
||||
|
||||
signals:
|
||||
void updateDataModels();
|
||||
|
||||
private:
|
||||
bool hasClipboardData(QByteArray * data = nullptr) const;
|
||||
bool insertAllowed() const;
|
||||
@@ -103,7 +100,9 @@ class ChannelsPanel : public ModelPanel
|
||||
QCheckBox *symlimitsChk[CPN_MAX_CHNOUT];
|
||||
int selectedIndex;
|
||||
int chnCapability;
|
||||
RawItemFilteredModel *curveModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel *curveFilteredModel;
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _CHANNELS_H_
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "node.h"
|
||||
#include "edge.h"
|
||||
#include "helpers.h"
|
||||
#include "rawitemfilteredmodel.h"
|
||||
|
||||
#define GFX_MARGIN 16
|
||||
|
||||
@@ -108,10 +109,11 @@ float curveSymmetricalX(float x, float coeff, float yMin, float yMid, float yMax
|
||||
return y;
|
||||
}
|
||||
|
||||
CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::Curves),
|
||||
currentCurve(0)
|
||||
currentCurve(0),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -523,7 +525,7 @@ void CurvesPanel::on_curveName_editingFinished()
|
||||
if (ui->curveName->text() != model->curves[currentCurve].name) {
|
||||
memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name));
|
||||
strcpy(model->curves[currentCurve].name, ui->curveName->text().toLatin1());
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -712,7 +714,7 @@ void CurvesPanel::cmClear(bool prompt)
|
||||
model->curves[selectedIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_CLEAR, selectedIndex);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -726,7 +728,7 @@ void CurvesPanel::cmClearAll()
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_CLEAR, i);
|
||||
}
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -756,7 +758,7 @@ void CurvesPanel::cmDelete()
|
||||
model->curves[maxCurves - 1].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -766,7 +768,7 @@ void CurvesPanel::cmInsert()
|
||||
model->curves[selectedIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -787,7 +789,7 @@ void CurvesPanel::cmPaste()
|
||||
CurveData *cd = &model->curves[selectedIndex];
|
||||
memcpy(cd, data.constData(), sizeof(CurveData));
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -802,11 +804,16 @@ void CurvesPanel::swapData(int idx1, int idx2)
|
||||
memcpy(cd1, &cdtmp, sizeof(CurveData));
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SWAP, idx1, idx2);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CurvesPanel::updateItemModels()
|
||||
{
|
||||
commonItemModels->update(CommonItemModels::RMO_CURVES);
|
||||
}
|
||||
|
||||
CustomScene::CustomScene(QGraphicsView * view) :
|
||||
QGraphicsScene(view)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
|
||||
class CommonItemModels;
|
||||
|
||||
constexpr char MIMETYPE_CURVE[] = "application/x-companion-curve";
|
||||
|
||||
namespace Ui {
|
||||
@@ -59,7 +61,7 @@ class CurvesPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CurvesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
CurvesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~CurvesPanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -91,9 +93,6 @@ class CurvesPanel : public ModelPanel
|
||||
void cmMoveDown();
|
||||
void cmMoveUp();
|
||||
|
||||
signals:
|
||||
void updateDataModels();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
void addTemplate(QString name, unsigned int flags, curveFunction function);
|
||||
@@ -122,6 +121,8 @@ class CurvesPanel : public ModelPanel
|
||||
bool moveDownAllowed() const;
|
||||
bool moveUpAllowed() const;
|
||||
void swapData(int idx1, int idx2);
|
||||
CommonItemModels * commonItemModels;
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _CURVES_H_
|
||||
|
||||
@@ -66,10 +66,10 @@ void RepeatComboBox::update()
|
||||
setCurrentIndex(value);
|
||||
}
|
||||
|
||||
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel):
|
||||
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
GenericPanel(parent, model, generalSettings, firmware),
|
||||
functions(model ? model->customFn : generalSettings.customFn),
|
||||
commonItemModels(commonItemModels),
|
||||
mediaPlayerCurrent(-1),
|
||||
mediaPlayer(nullptr),
|
||||
modelsUpdateCnt(0)
|
||||
@@ -77,21 +77,21 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
|
||||
lock = true;
|
||||
fswCapability = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
|
||||
|
||||
rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, model ? RawSwitch::SpecialFunctionsContext : RawSwitch::GlobalFunctionsContext);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), model ? RawSwitch::SpecialFunctionsContext : RawSwitch::GlobalFunctionsContext, this);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
|
||||
rawSrcAllModel = new RawItemFilteredModel(rawSourceItemModel);
|
||||
connect(rawSrcAllModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSrcAllModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
rawSourceAllModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), this);
|
||||
connect(rawSourceAllModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceAllModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
|
||||
rawSrcInputsModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups);
|
||||
connect(rawSrcInputsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSrcInputsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
rawSourceInputsModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), RawSource::InputSourceGroups, this);
|
||||
connect(rawSourceInputsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceInputsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
|
||||
rawSrcGVarsModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::GVarsGroup);
|
||||
connect(rawSrcGVarsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSrcGVarsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
rawSourceGVarsModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), RawSource::GVarsGroup, this);
|
||||
connect(rawSourceGVarsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceGVarsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete);
|
||||
|
||||
if (!firmware->getCapability(VoicesAsNumbers)) {
|
||||
tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength));
|
||||
@@ -142,7 +142,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
|
||||
|
||||
// The switch
|
||||
fswtchSwtch[i] = new QComboBox(this);
|
||||
fswtchSwtch[i]->setModel(rawSwitchModel);
|
||||
fswtchSwtch[i]->setModel(rawSwitchFilteredModel);
|
||||
fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue()));
|
||||
fswtchSwtch[i]->setProperty("index", i);
|
||||
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||
@@ -253,10 +253,6 @@ CustomFunctionsPanel::~CustomFunctionsPanel()
|
||||
{
|
||||
if (mediaPlayer)
|
||||
stopSound(mediaPlayerCurrent);
|
||||
delete rawSwitchModel;
|
||||
delete rawSrcAllModel;
|
||||
delete rawSrcInputsModel;
|
||||
delete rawSrcGVarsModel;
|
||||
}
|
||||
|
||||
void CustomFunctionsPanel::onMediaPlayerStateChanged(QMediaPlayer::State state)
|
||||
@@ -707,21 +703,21 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi
|
||||
CustomFunctionData::populateResetParams(model, b, value);
|
||||
}
|
||||
else if (function == FuncVolume || function == FuncBacklight) {
|
||||
b->setModel(rawSrcInputsModel);
|
||||
b->setModel(rawSourceInputsModel);
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
}
|
||||
else if (function == FuncPlayValue) {
|
||||
b->setModel(rawSrcAllModel);
|
||||
b->setModel(rawSourceAllModel);
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
}
|
||||
else if (function >= FuncAdjustGV1 && function <= FuncAdjustGVLast) {
|
||||
switch (adjustmode) {
|
||||
case 1:
|
||||
b->setModel(rawSrcInputsModel);
|
||||
b->setModel(rawSourceInputsModel);
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
break;
|
||||
case 2:
|
||||
b->setModel(rawSrcGVarsModel);
|
||||
b->setModel(rawSourceGVarsModel);
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
break;
|
||||
}
|
||||
@@ -836,11 +832,13 @@ void CustomFunctionsPanel::onModelDataAboutToBeUpdated()
|
||||
void CustomFunctionsPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
if (modelsUpdateCnt < 1)
|
||||
if (modelsUpdateCnt < 1) {
|
||||
lock = true;
|
||||
for (int i = 0; i < fswCapability; i++) {
|
||||
fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue()));
|
||||
fswtchFunc[i]->setCurrentIndex(fswtchFunc[i]->findData(functions[i].func));
|
||||
}
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
|
||||
#include <QMediaPlayer>
|
||||
|
||||
class RawSourceItemModel;
|
||||
class RawSwitchItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
class TimerEdit;
|
||||
|
||||
@@ -56,8 +55,7 @@ class CustomFunctionsPanel : public GenericPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomFunctionsPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel);
|
||||
CustomFunctionsPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
~CustomFunctionsPanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -98,10 +96,11 @@ class CustomFunctionsPanel : public GenericPanel
|
||||
bool moveUpAllowed() const;
|
||||
void swapData(int idx1, int idx2);
|
||||
void resetCBsAndRefresh(int idx);
|
||||
RawItemFilteredModel * rawSwitchModel;
|
||||
RawItemFilteredModel * rawSrcAllModel;
|
||||
RawItemFilteredModel * rawSrcInputsModel;
|
||||
RawItemFilteredModel * rawSrcGVarsModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel * rawSwitchFilteredModel;
|
||||
RawItemFilteredModel * rawSourceAllModel;
|
||||
RawItemFilteredModel * rawSourceInputsModel;
|
||||
RawItemFilteredModel * rawSourceGVarsModel;
|
||||
|
||||
QSet<QString> tracksSet;
|
||||
QSet<QString> scriptsSet;
|
||||
|
||||
@@ -24,15 +24,15 @@
|
||||
#include "helpers.h"
|
||||
#include "customdebug.h"
|
||||
|
||||
FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * switchModel):
|
||||
FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * rawSwitchFilteredModel):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::FlightMode),
|
||||
phaseIdx(phaseIdx),
|
||||
phase(model.flightModeData[phaseIdx])
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(switchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &FlightModePanel::onModelDataAboutToBeUpdated);
|
||||
connect(switchModel, &RawItemFilteredModel::dataUpdateComplete, this, &FlightModePanel::onModelDataUpdateComplete);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &FlightModePanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &FlightModePanel::onModelDataUpdateComplete);
|
||||
|
||||
ui->labelName->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->labelName->setToolTip(tr("Popup menu available"));
|
||||
@@ -57,7 +57,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
|
||||
|
||||
// Flight mode switch
|
||||
if (phaseIdx > 0) {
|
||||
ui->swtch->setModel(switchModel);
|
||||
ui->swtch->setModel(rawSwitchFilteredModel);
|
||||
connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int)));
|
||||
}
|
||||
else {
|
||||
@@ -1374,10 +1374,11 @@ void FlightModePanel::onModelDataUpdateComplete()
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel):
|
||||
ModelPanel(parent, model, generalSettings, firmware)
|
||||
FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this);
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::MixesContext, this);
|
||||
modesCount = firmware->getCapability(FlightModes);
|
||||
|
||||
QGridLayout * gridLayout = new QGridLayout(this);
|
||||
@@ -1388,8 +1389,8 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS
|
||||
connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified);
|
||||
connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged);
|
||||
connect(tab, &FlightModePanel::phaseNameChanged, this, &FlightModesPanel::onPhaseNameChanged);
|
||||
connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::refreshDataModels);
|
||||
connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::refreshDataModels);
|
||||
connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::updateItemModels);
|
||||
connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::updateItemModels);
|
||||
|
||||
connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update);
|
||||
tabWidget->addTab(tab, getTabName(i));
|
||||
@@ -1402,7 +1403,6 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS
|
||||
|
||||
FlightModesPanel::~FlightModesPanel()
|
||||
{
|
||||
delete rawSwitchFilteredModel;
|
||||
}
|
||||
|
||||
QString FlightModesPanel::getTabName(int index)
|
||||
@@ -1423,7 +1423,7 @@ void FlightModesPanel::onPhaseNameChanged()
|
||||
{
|
||||
int index = sender()->property("index").toInt();
|
||||
tabWidget->setTabText(index, getTabName(index));
|
||||
refreshDataModels();
|
||||
updateItemModels();
|
||||
}
|
||||
|
||||
void FlightModesPanel::update()
|
||||
@@ -1431,9 +1431,10 @@ void FlightModesPanel::update()
|
||||
emit updated();
|
||||
}
|
||||
|
||||
void FlightModesPanel::refreshDataModels()
|
||||
void FlightModesPanel::updateItemModels()
|
||||
{
|
||||
emit updateDataModels();
|
||||
commonItemModels->update(CommonItemModels::RMO_FLIGHT_MODES);
|
||||
commonItemModels->update(CommonItemModels::RMO_GLOBAL_VARIABLES);
|
||||
}
|
||||
|
||||
void FlightModesPanel::onTabIndexChanged(int index)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class RawSwitchItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
|
||||
constexpr char MIMETYPE_FLIGHTMODE[] = "application/x-companion-flightmode";
|
||||
@@ -41,7 +41,7 @@ class FlightModePanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * switchModel);
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * rawSwitchFilteredModel);
|
||||
virtual ~FlightModePanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -145,19 +145,17 @@ class FlightModesPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel);
|
||||
FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~FlightModesPanel();
|
||||
|
||||
public slots:
|
||||
virtual void update() override;
|
||||
|
||||
signals:
|
||||
void updateDataModels();
|
||||
void updated();
|
||||
|
||||
private slots:
|
||||
void onPhaseNameChanged();
|
||||
void refreshDataModels();
|
||||
void onTabIndexChanged(int index);
|
||||
|
||||
private:
|
||||
@@ -165,8 +163,10 @@ class FlightModesPanel : public ModelPanel
|
||||
|
||||
int modesCount;
|
||||
QTabWidget *tabWidget;
|
||||
CommonItemModels *commonItemModels;
|
||||
RawItemFilteredModel *rawSwitchFilteredModel;
|
||||
QVector<GenericPanel *> panels;
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _FLIGHTMODES_H_
|
||||
|
||||
@@ -23,22 +23,26 @@
|
||||
#include "helpers.h"
|
||||
#include "rawitemfilteredmodel.h"
|
||||
|
||||
HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel):
|
||||
HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::Heli)
|
||||
ui(new Ui::Heli),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups, this);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &HeliPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &HeliPanel::onModelDataUpdateComplete);
|
||||
rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), RawSource::InputSourceGroups, this);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &HeliPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &HeliPanel::onModelDataUpdateComplete);
|
||||
|
||||
connect(ui->swashType, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
|
||||
connect(ui->swashRingVal, SIGNAL(editingFinished()), this, SLOT(edited()));
|
||||
ui->swashCollectiveSource->setModel(rawSourceFilteredModel);
|
||||
connect(ui->swashCollectiveSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
|
||||
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
ui->swashAileronSource->setModel(rawSourceFilteredModel);
|
||||
connect(ui->swashAileronSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
|
||||
ui->swashElevatorSource->setModel(rawSourceFilteredModel);
|
||||
connect(ui->swashElevatorSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
|
||||
connect(ui->swashAileronWeight, SIGNAL(editingFinished()), this, SLOT(edited()));
|
||||
connect(ui->swashElevatorWeight, SIGNAL(editingFinished()), this, SLOT(edited()));
|
||||
@@ -66,7 +70,6 @@ HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & gener
|
||||
|
||||
HeliPanel::~HeliPanel()
|
||||
{
|
||||
delete rawSourceModel;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -75,13 +78,10 @@ void HeliPanel::update()
|
||||
lock = true;
|
||||
|
||||
ui->swashType->setCurrentIndex(model->swashRingData.type);
|
||||
ui->swashCollectiveSource->setModel(rawSourceModel);
|
||||
ui->swashCollectiveSource->setCurrentIndex(ui->swashCollectiveSource->findData(model->swashRingData.collectiveSource.toValue()));
|
||||
ui->swashRingVal->setValue(model->swashRingData.value);
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
ui->swashElevatorSource->setModel(rawSourceModel);
|
||||
ui->swashElevatorSource->setCurrentIndex(ui->swashElevatorSource->findData(model->swashRingData.elevatorSource.toValue()));
|
||||
ui->swashAileronSource->setModel(rawSourceModel);
|
||||
ui->swashAileronSource->setCurrentIndex(ui->swashAileronSource->findData(model->swashRingData.aileronSource.toValue()));
|
||||
ui->swashElevatorWeight->setValue(model->swashRingData.elevatorWeight);
|
||||
ui->swashAileronWeight->setValue(model->swashRingData.aileronWeight);
|
||||
@@ -126,4 +126,5 @@ void HeliPanel::onModelDataAboutToBeUpdated()
|
||||
void HeliPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "modeledit.h"
|
||||
|
||||
class RawSourceItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
|
||||
namespace Ui {
|
||||
@@ -35,7 +35,7 @@ class HeliPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel);
|
||||
HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
~HeliPanel();
|
||||
void update();
|
||||
|
||||
@@ -46,7 +46,8 @@ class HeliPanel : public ModelPanel
|
||||
|
||||
private:
|
||||
Ui::Heli *ui;
|
||||
RawItemFilteredModel * rawSourceModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel * rawSourceFilteredModel;
|
||||
};
|
||||
|
||||
#endif // _HELI_H_
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
#include "helpers.h"
|
||||
#include "rawitemfilteredmodel.h"
|
||||
|
||||
InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel):
|
||||
InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
expoInserted(false),
|
||||
modelPrinter(firmware, generalSettings, model)
|
||||
modelPrinter(firmware, generalSettings, model),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~ RawSource::NoneGroup & ~RawSource::InputsGroup), this);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete);
|
||||
rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), (RawSource::InputSourceGroups & ~ RawSource::NoneGroup & ~RawSource::InputsGroup), this);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete);
|
||||
|
||||
rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete);
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::MixesContext, this);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete);
|
||||
|
||||
inputsCount = firmware->getCapability(VirtualInputs);
|
||||
if (inputsCount == 0)
|
||||
@@ -75,8 +75,6 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g
|
||||
|
||||
InputsPanel::~InputsPanel()
|
||||
{
|
||||
delete rawSourceModel;
|
||||
delete rawSwitchModel;
|
||||
}
|
||||
|
||||
void InputsPanel::update()
|
||||
@@ -192,13 +190,13 @@ void InputsPanel::gm_openExpo(int index)
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
inputName = model->inputNames[ed.chn];
|
||||
|
||||
ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceModel, rawSwitchModel);
|
||||
ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceFilteredModel, rawSwitchFilteredModel);
|
||||
if (g->exec()) {
|
||||
model->expoData[index] = ed;
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
strncpy(model->inputNames[ed.chn], inputName.toLatin1().data(), INPUT_NAME_LEN);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
else {
|
||||
@@ -253,7 +251,7 @@ void InputsPanel::exposDelete(bool prompt)
|
||||
|
||||
exposDeleteList(list, prompt);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -328,7 +326,7 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
|
||||
}
|
||||
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -497,7 +495,7 @@ void InputsPanel::moveExpoList(bool down)
|
||||
}
|
||||
if (mod) {
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
setSelectedByExpoList(highlightList);
|
||||
@@ -537,7 +535,7 @@ void InputsPanel::clearExpos()
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, i);
|
||||
}
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -586,7 +584,7 @@ void InputsPanel::cmInputClear()
|
||||
}
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -610,7 +608,7 @@ void InputsPanel::cmInputDelete()
|
||||
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, -1);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -629,7 +627,7 @@ void InputsPanel::cmInputInsert()
|
||||
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, 1);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -691,7 +689,7 @@ void InputsPanel::cmInputSwapData(int idx1, int idx2)
|
||||
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SWAP, idx1, idx2);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -735,4 +733,10 @@ void InputsPanel::onModelDataAboutToBeUpdated()
|
||||
void InputsPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void InputsPanel::updateItemModels()
|
||||
{
|
||||
commonItemModels->update(CommonItemModels::RMO_INPUTS);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
#include "mixerslistwidget.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class RawSourceItemModel;
|
||||
class RawSwitchItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
|
||||
constexpr char MIMETYPE_EXPO[] = "application/x-companion-expo";
|
||||
@@ -36,8 +35,7 @@ class InputsPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel);
|
||||
InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~InputsPanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -67,9 +65,6 @@ class InputsPanel : public ModelPanel
|
||||
void onModelDataAboutToBeUpdated();
|
||||
void onModelDataUpdateComplete();
|
||||
|
||||
signals:
|
||||
void updateDataModels();
|
||||
|
||||
private:
|
||||
bool expoInserted;
|
||||
MixersListWidget *ExposlistWidget;
|
||||
@@ -77,8 +72,9 @@ class InputsPanel : public ModelPanel
|
||||
ModelPrinter modelPrinter;
|
||||
int selectedIdx;
|
||||
int inputIdx;
|
||||
RawItemFilteredModel *rawSourceModel;
|
||||
RawItemFilteredModel *rawSwitchModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel *rawSourceFilteredModel;
|
||||
RawItemFilteredModel *rawSwitchFilteredModel;
|
||||
|
||||
int getExpoIndex(unsigned int dch);
|
||||
bool gm_insertExpo(int idx);
|
||||
@@ -99,6 +95,7 @@ class InputsPanel : public ModelPanel
|
||||
bool isExpoIndex(const int index);
|
||||
int getIndexFromSelected();
|
||||
int getInputIndexFromSelected();
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _INPUTS_H_
|
||||
|
||||
@@ -24,20 +24,20 @@
|
||||
|
||||
#include <TimerEdit>
|
||||
|
||||
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel):
|
||||
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
commonItemModels(commonItemModels),
|
||||
selectedIndex(0),
|
||||
modelsUpdateCnt(0)
|
||||
{
|
||||
rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::LogicalSwitchesContext);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete);
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::LogicalSwitchesContext, this);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete);
|
||||
|
||||
const int srcGroups = firmware->getCapability(GvarsInCS) ? 0 : (RawSource::AllSourceGroups & ~RawSource::GVarsGroup);
|
||||
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, srcGroups, this);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete);
|
||||
rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), srcGroups, this);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete);
|
||||
|
||||
lsCapability = firmware->getCapability(LogicalSwitches);
|
||||
lsCapabilityExt = firmware->getCapability(LogicalSwitchesExt);
|
||||
@@ -124,7 +124,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
|
||||
// AND
|
||||
cbAndSwitch[i] = new QComboBox(this);
|
||||
cbAndSwitch[i]->setProperty("index", i);
|
||||
cbAndSwitch[i]->setModel(rawSwitchModel);
|
||||
cbAndSwitch[i]->setModel(rawSwitchFilteredModel);
|
||||
cbAndSwitch[i]->setVisible(true);
|
||||
connect(cbAndSwitch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(onAndSwitchChanged(int)));
|
||||
tableLayout->addWidget(i, 4, cbAndSwitch[i]);
|
||||
@@ -161,8 +161,6 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
|
||||
|
||||
LogicalSwitchesPanel::~LogicalSwitchesPanel()
|
||||
{
|
||||
delete rawSourceModel;
|
||||
delete rawSwitchModel;
|
||||
}
|
||||
|
||||
void LogicalSwitchesPanel::onFunctionChanged()
|
||||
@@ -174,7 +172,6 @@ void LogicalSwitchesPanel::onFunctionChanged()
|
||||
if (model->logicalSw[i].func == newFunc)
|
||||
return;
|
||||
|
||||
unsigned oldFunc = model->logicalSw[i].func;
|
||||
CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily();
|
||||
model->logicalSw[i].func = newFunc;
|
||||
CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily();
|
||||
@@ -191,10 +188,7 @@ void LogicalSwitchesPanel::onFunctionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
if (oldFunc == LS_FN_OFF || newFunc == LS_FN_OFF)
|
||||
updateCBLists();
|
||||
else
|
||||
updateLine(i);
|
||||
updateLine(i);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -345,6 +339,7 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, doubl
|
||||
|
||||
void LogicalSwitchesPanel::updateLine(int i)
|
||||
{
|
||||
const bool savelock = lock;
|
||||
lock = true;
|
||||
unsigned int mask = 0;
|
||||
|
||||
@@ -362,7 +357,7 @@ void LogicalSwitchesPanel::updateLine(int i)
|
||||
RawSource source = RawSource(model->logicalSw[i].val1);
|
||||
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
|
||||
double value = range.step * model->logicalSw[i].val2 + range.offset; /* TODO+source.getRawOffset(model)*/
|
||||
cbSource1[i]->setModel(rawSourceModel);
|
||||
cbSource1[i]->setModel(rawSourceFilteredModel);
|
||||
cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(source.toValue()));
|
||||
if (source.isTimeBased()) {
|
||||
mask |= VALUE_TO_VISIBLE;
|
||||
@@ -391,16 +386,16 @@ void LogicalSwitchesPanel::updateLine(int i)
|
||||
case LS_FAMILY_STICKY: // no break
|
||||
case LS_FAMILY_VBOOL:
|
||||
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
||||
cbSource1[i]->setModel(rawSwitchModel);
|
||||
cbSource1[i]->setModel(rawSwitchFilteredModel);
|
||||
cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1));
|
||||
cbSource2[i]->setModel(rawSwitchModel);
|
||||
cbSource2[i]->setModel(rawSwitchFilteredModel);
|
||||
cbSource2[i]->setCurrentIndex(cbSource2[i]->findData(model->logicalSw[i].val2));
|
||||
break;
|
||||
|
||||
case LS_FAMILY_EDGE:
|
||||
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
|
||||
mask &= ~DELAY_ENABLED;
|
||||
cbSource1[i]->setModel(rawSwitchModel);
|
||||
cbSource1[i]->setModel(rawSwitchFilteredModel);
|
||||
cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1));
|
||||
updateTimerParam(dsbOffset[i], model->logicalSw[i].val2, 0.0);
|
||||
updateTimerParam(dsbOffset2[i], model->logicalSw[i].val2 + model->logicalSw[i].val3, ValToTim(TimToVal(dsbOffset[i]->value()) - 1));
|
||||
@@ -409,9 +404,9 @@ void LogicalSwitchesPanel::updateLine(int i)
|
||||
|
||||
case LS_FAMILY_VCOMP:
|
||||
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
||||
cbSource1[i]->setModel(rawSourceModel);
|
||||
cbSource1[i]->setModel(rawSourceFilteredModel);
|
||||
cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1));
|
||||
cbSource2[i]->setModel(rawSourceModel);
|
||||
cbSource2[i]->setModel(rawSourceFilteredModel);
|
||||
cbSource2[i]->setCurrentIndex(cbSource2[i]->findData(model->logicalSw[i].val2));
|
||||
break;
|
||||
|
||||
@@ -439,7 +434,7 @@ void LogicalSwitchesPanel::updateLine(int i)
|
||||
dsbDelay[i]->setValue(model->logicalSw[i].delay / 10.0);
|
||||
}
|
||||
|
||||
lock = false;
|
||||
lock = savelock;
|
||||
}
|
||||
|
||||
void LogicalSwitchesPanel::populateFunctionCB(QComboBox *b)
|
||||
@@ -491,6 +486,7 @@ void LogicalSwitchesPanel::cmPaste()
|
||||
QByteArray data;
|
||||
if (hasClipboardData(&data)) {
|
||||
memcpy(&model->logicalSw[selectedIndex], data.constData(), sizeof(LogicalSwitchData));
|
||||
updateLine(selectedIndex);
|
||||
updateCBLists();
|
||||
emit modified();
|
||||
}
|
||||
@@ -505,6 +501,7 @@ void LogicalSwitchesPanel::cmDelete()
|
||||
model->logicalSw[lsCapability - 1].clear();
|
||||
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1);
|
||||
update();
|
||||
updateCBLists();
|
||||
emit modified();
|
||||
}
|
||||
@@ -515,7 +512,7 @@ void LogicalSwitchesPanel::cmCopy()
|
||||
data.append((char*)&model->logicalSw[selectedIndex], sizeof(LogicalSwitchData));
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
mimeData->setData(MIMETYPE_LOGICAL_SWITCH, data);
|
||||
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
|
||||
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
void LogicalSwitchesPanel::cmCut()
|
||||
@@ -526,7 +523,6 @@ void LogicalSwitchesPanel::cmCut()
|
||||
cmClear(false);
|
||||
}
|
||||
|
||||
// TODO make something generic here!
|
||||
void LogicalSwitchesPanel::onCustomContextMenuRequested(QPoint pos)
|
||||
{
|
||||
QLabel *label = (QLabel *)sender();
|
||||
@@ -595,6 +591,7 @@ void LogicalSwitchesPanel::cmClear(bool prompt)
|
||||
|
||||
model->logicalSw[selectedIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, selectedIndex);
|
||||
updateLine(selectedIndex);
|
||||
updateCBLists();
|
||||
emit modified();
|
||||
}
|
||||
@@ -608,6 +605,7 @@ void LogicalSwitchesPanel::cmClearAll()
|
||||
model->logicalSw[i].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, i);
|
||||
}
|
||||
update();
|
||||
updateCBLists();
|
||||
emit modified();
|
||||
}
|
||||
@@ -617,6 +615,7 @@ void LogicalSwitchesPanel::cmInsert()
|
||||
memmove(&model->logicalSw[selectedIndex + 1], &model->logicalSw[selectedIndex], (CPN_MAX_LOGICAL_SWITCHES - (selectedIndex + 1)) * sizeof(LogicalSwitchData));
|
||||
model->logicalSw[selectedIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1);
|
||||
update();
|
||||
updateCBLists();
|
||||
emit modified();
|
||||
}
|
||||
@@ -630,6 +629,8 @@ void LogicalSwitchesPanel::swapData(int idx1, int idx2)
|
||||
memcpy(lsw2, lsw1, sizeof(LogicalSwitchData));
|
||||
memcpy(lsw1, &lstmp, sizeof(LogicalSwitchData));
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SWAP, idx1, idx2);
|
||||
updateLine(idx1);
|
||||
updateLine(idx2);
|
||||
updateCBLists();
|
||||
emit modified();
|
||||
}
|
||||
@@ -642,15 +643,14 @@ void LogicalSwitchesPanel::updateCBLists()
|
||||
// So this workaround gives time for other events to be processed before refreshing
|
||||
// Not sure if this an OS related issue or a QT bug in QT 5.7 (and higher?)
|
||||
// The delay is abitary
|
||||
QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateDataModels);
|
||||
//QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateItemModels);
|
||||
updateItemModels();
|
||||
}
|
||||
|
||||
void LogicalSwitchesPanel::updateDataModels()
|
||||
void LogicalSwitchesPanel::updateItemModels()
|
||||
{
|
||||
// This is inconsistent but needed as part of the workaround
|
||||
//emit updateCBLists(); adds to the event stack so call direct
|
||||
rawSourceModel->update();
|
||||
rawSwitchModel->update();
|
||||
lock = true;
|
||||
commonItemModels->update(CommonItemModels::RMO_LOGICAL_SWITCHES);
|
||||
}
|
||||
|
||||
void LogicalSwitchesPanel::onModelDataAboutToBeUpdated()
|
||||
@@ -662,6 +662,8 @@ void LogicalSwitchesPanel::onModelDataAboutToBeUpdated()
|
||||
void LogicalSwitchesPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
if (modelsUpdateCnt < 1)
|
||||
if (modelsUpdateCnt < 1) {
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#include "modeledit.h"
|
||||
#include "radiodata.h"
|
||||
|
||||
class RawSourceItemModel;
|
||||
class RawSwitchItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
class TimerEdit;
|
||||
|
||||
@@ -36,8 +35,7 @@ class LogicalSwitchesPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel);
|
||||
LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~LogicalSwitchesPanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -76,8 +74,9 @@ class LogicalSwitchesPanel : public ModelPanel
|
||||
QDoubleSpinBox * dsbDelay[CPN_MAX_LOGICAL_SWITCHES];
|
||||
QComboBox * cbSource1[CPN_MAX_LOGICAL_SWITCHES];
|
||||
QComboBox * cbSource2[CPN_MAX_LOGICAL_SWITCHES];
|
||||
RawItemFilteredModel * rawSwitchModel;
|
||||
RawItemFilteredModel * rawSourceModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel * rawSwitchFilteredModel;
|
||||
RawItemFilteredModel * rawSourceFilteredModel;
|
||||
int selectedIndex;
|
||||
void populateFunctionCB(QComboBox *b);
|
||||
void updateTimerParam(QDoubleSpinBox *sb, int timer, double minimum=0);
|
||||
@@ -90,7 +89,7 @@ class LogicalSwitchesPanel : public ModelPanel
|
||||
bool moveUpAllowed() const;
|
||||
int modelsUpdateCnt;
|
||||
void updateCBLists();
|
||||
void updateDataModels();
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _LOGICALSWITCHES_H_
|
||||
|
||||
@@ -148,10 +148,10 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata,
|
||||
|
||||
MixerDialog::~MixerDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete gvWeightGroup;
|
||||
delete gvOffsetGroup;
|
||||
delete curveGroup;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MixerDialog::changeEvent(QEvent *e)
|
||||
|
||||
@@ -22,20 +22,20 @@
|
||||
#include "helpers.h"
|
||||
#include "rawitemfilteredmodel.h"
|
||||
|
||||
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel):
|
||||
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
mixInserted(false),
|
||||
highlightedSource(0),
|
||||
modelPrinter(firmware, generalSettings, model)
|
||||
modelPrinter(firmware, generalSettings, model),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, ((RawSource::InputSourceGroups | RawSource::ScriptsGroup) & ~ RawSource::NoneGroup), this);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete);
|
||||
rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), ((RawSource::InputSourceGroups | RawSource::ScriptsGroup) & ~ RawSource::NoneGroup), this);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete);
|
||||
|
||||
rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete);
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::MixesContext, this);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete);
|
||||
|
||||
QGridLayout * mixesLayout = new QGridLayout(this);
|
||||
|
||||
@@ -70,8 +70,6 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
|
||||
|
||||
MixesPanel::~MixesPanel()
|
||||
{
|
||||
delete rawSourceModel;
|
||||
delete rawSwitchModel;
|
||||
}
|
||||
|
||||
void MixesPanel::update()
|
||||
@@ -187,7 +185,7 @@ void MixesPanel::gm_openMix(int index)
|
||||
|
||||
MixData mixd(model->mixData[index]);
|
||||
|
||||
MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceModel, rawSwitchModel);
|
||||
MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceFilteredModel, rawSwitchFilteredModel);
|
||||
if(g->exec()) {
|
||||
model->mixData[index] = mixd;
|
||||
emit modified();
|
||||
@@ -550,4 +548,5 @@ void MixesPanel::onModelDataAboutToBeUpdated()
|
||||
void MixesPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
#include "mixerdialog.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class RawSourceItemModel;
|
||||
class RawSwitchItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
|
||||
class MixesPanel : public ModelPanel
|
||||
@@ -35,8 +34,7 @@ class MixesPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel);
|
||||
MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~MixesPanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -70,8 +68,9 @@ class MixesPanel : public ModelPanel
|
||||
bool mixInserted;
|
||||
unsigned int highlightedSource;
|
||||
ModelPrinter modelPrinter;
|
||||
RawItemFilteredModel *rawSourceModel;
|
||||
RawItemFilteredModel *rawSwitchModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel *rawSourceFilteredModel;
|
||||
RawItemFilteredModel *rawSwitchFilteredModel;
|
||||
|
||||
int getMixerIndex(unsigned int dch);
|
||||
bool gm_insertMix(int idx);
|
||||
|
||||
@@ -53,89 +53,65 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
GeneralSettings &generalSettings = radioData.generalSettings;
|
||||
ModelData &model = radioData.models[modelId];
|
||||
|
||||
/*
|
||||
Create reusable model specific ui datamodels here and pass pointers as needed
|
||||
They should be referenced through filters in each use case
|
||||
Code that updates the source for one or more ui datamodels should emit a SIGNAL that can be trapped (see below) and the datamodels refreshed
|
||||
WARNING: beware of looping signals and slots and unnecessary data field updates from refreshing datamodels
|
||||
where practical make signals granular to only those fields that affect datamodels thus needing to be refreshed
|
||||
*/
|
||||
rawSourceModel = new RawSourceItemModel(&generalSettings, &model, this);
|
||||
rawSwitchModel = new RawSwitchItemModel(&generalSettings, &model, this);
|
||||
curveModel = new CurveItemModel(&generalSettings, &model, this);
|
||||
commonItemModels = new CommonItemModels(&generalSettings, &model, this);
|
||||
s1.report("Init");
|
||||
|
||||
SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, rawSwitchModel);
|
||||
SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(setupPanel, tr("Setup"));
|
||||
s1.report("Setup");
|
||||
|
||||
if (firmware->getCapability(Heli)) {
|
||||
HeliPanel * heliPanel = new HeliPanel(this, model, generalSettings, firmware, rawSourceModel);
|
||||
HeliPanel * heliPanel = new HeliPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(heliPanel, tr("Heli"));
|
||||
s1.report("Heli");
|
||||
}
|
||||
|
||||
FlightModesPanel * flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, rawSwitchModel);
|
||||
FlightModesPanel * flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(flightModesPanel, tr("Flight Modes"));
|
||||
s1.report("Flight Modes");
|
||||
|
||||
InputsPanel * inputsPanel = new InputsPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel);
|
||||
InputsPanel * inputsPanel = new InputsPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(inputsPanel, tr("Inputs"));
|
||||
s1.report("Inputs");
|
||||
|
||||
MixesPanel * mixesPanel = new MixesPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel);
|
||||
MixesPanel * mixesPanel = new MixesPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(mixesPanel, tr("Mixes"));
|
||||
s1.report("Mixes");
|
||||
|
||||
ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, curveModel);
|
||||
ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(channelsPanel, tr("Outputs"));
|
||||
s1.report("Outputs");
|
||||
|
||||
CurvesPanel * curvesPanel = new CurvesPanel(this, model, generalSettings, firmware);
|
||||
CurvesPanel * curvesPanel = new CurvesPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(curvesPanel, tr("Curves"));
|
||||
s1.report("Curves");
|
||||
|
||||
LogicalSwitchesPanel * logicalSwitchesPanel = new LogicalSwitchesPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel);
|
||||
LogicalSwitchesPanel * logicalSwitchesPanel = new LogicalSwitchesPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(logicalSwitchesPanel, tr("Logical Switches"));
|
||||
s1.report("Logical Switches");
|
||||
|
||||
CustomFunctionsPanel * customFunctionsPanel = new CustomFunctionsPanel(this, &model, generalSettings, firmware, rawSourceModel, rawSwitchModel);
|
||||
CustomFunctionsPanel * customFunctionsPanel = new CustomFunctionsPanel(this, &model, generalSettings, firmware, commonItemModels);
|
||||
addTab(customFunctionsPanel, tr("Special Functions"));
|
||||
s1.report("Special Functions");
|
||||
|
||||
if (firmware->getCapability(Telemetry)) {
|
||||
TelemetryPanel * telemetryPanel = new TelemetryPanel(this, model, generalSettings, firmware, rawSourceModel);
|
||||
TelemetryPanel * telemetryPanel = new TelemetryPanel(this, model, generalSettings, firmware, commonItemModels);
|
||||
addTab(telemetryPanel, tr("Telemetry"));
|
||||
connect(telemetryPanel, &TelemetryPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update);
|
||||
s1.report("Telemetry");
|
||||
}
|
||||
|
||||
connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits);
|
||||
connect(setupPanel, &SetupPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update);
|
||||
|
||||
connect(flightModesPanel, &FlightModesPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update);
|
||||
connect(flightModesPanel, &FlightModesPanel::updateDataModels, rawSwitchModel, &RawSwitchItemModel::update);
|
||||
|
||||
connect(inputsPanel, &InputsPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update);
|
||||
|
||||
connect(channelsPanel, &ChannelsPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update);
|
||||
|
||||
connect(curvesPanel, &CurvesPanel::updateDataModels, curveModel, &CurveItemModel::update);
|
||||
|
||||
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation);
|
||||
|
||||
onTabIndexChanged(ui->tabWidget->currentIndex()); // make sure to trigger update on default tab panel
|
||||
|
||||
s1.report("Signals and Slots");
|
||||
gStopwatch.report("ModelEdit end constructor");
|
||||
}
|
||||
|
||||
ModelEdit::~ModelEdit()
|
||||
{
|
||||
delete rawSourceModel;
|
||||
delete rawSwitchModel;
|
||||
delete curveModel;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
#include "genericpanel.h"
|
||||
|
||||
class RadioData;
|
||||
class RawSourceItemModel;
|
||||
class RawSwitchItemModel;
|
||||
class CurveItemModel;
|
||||
class CommonItemModels;
|
||||
|
||||
namespace Ui {
|
||||
class ModelEdit;
|
||||
@@ -65,9 +63,7 @@ class ModelEdit : public QDialog
|
||||
RadioData & radioData;
|
||||
Firmware * firmware;
|
||||
QVector<GenericPanel *> panels;
|
||||
RawSourceItemModel *rawSourceModel;
|
||||
RawSwitchItemModel *rawSwitchModel;
|
||||
CurveItemModel *curveModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void launchSimulation();
|
||||
|
||||
@@ -31,15 +31,14 @@
|
||||
|
||||
#include <QDir>
|
||||
|
||||
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, RawItemFilteredModel * rawSwitchModel):
|
||||
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, RawItemFilteredModel * rawSwitchFilteredModel):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
timer(timer),
|
||||
ui(new Ui::Timer)
|
||||
{
|
||||
|
||||
ui->setupUi(this);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &TimerPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &TimerPanel::onModelDataUpdateComplete);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &TimerPanel::onModelDataAboutToBeUpdated);
|
||||
connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &TimerPanel::onModelDataUpdateComplete);
|
||||
|
||||
lock = true;
|
||||
|
||||
@@ -50,11 +49,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
||||
}
|
||||
else {
|
||||
ui->name->setMaxLength(length);
|
||||
//ui->name->setText(timer.name);
|
||||
}
|
||||
|
||||
// Mode
|
||||
ui->mode->setModel(rawSwitchModel);
|
||||
ui->mode->setModel(rawSwitchFilteredModel);
|
||||
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
||||
connect(ui->mode, SIGNAL(activated(int)), this, SLOT(onModeChanged(int)));
|
||||
|
||||
@@ -96,6 +94,7 @@ TimerPanel::~TimerPanel()
|
||||
void TimerPanel::update()
|
||||
{
|
||||
lock = true;
|
||||
|
||||
ui->name->setText(timer.name);
|
||||
|
||||
int hour = timer.val / 3600;
|
||||
@@ -116,7 +115,7 @@ void TimerPanel::update()
|
||||
pvalue -= hours * 3600;
|
||||
int minutes = pvalue / 60;
|
||||
int seconds = pvalue % 60;
|
||||
ui->persistentValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours, 2, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
|
||||
ui->persistentValue->setText(QString(" %1(%2:%3:%4)").arg(sign < 0 ? "-" :" ").arg(hours, 2, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
|
||||
}
|
||||
|
||||
ui->countdownBeep->updateValue();
|
||||
@@ -133,7 +132,7 @@ QWidget * TimerPanel::getLastFocus()
|
||||
void TimerPanel::on_value_editingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
unsigned val = ui->value->time().hour()*3600 + ui->value->time().minute()*60 + ui->value->time().second();
|
||||
unsigned val = ui->value->time().hour() * 3600 + ui->value->time().minute() * 60 + ui->value->time().second();
|
||||
if (timer.val != val) {
|
||||
timer.val = val;
|
||||
emit modified();
|
||||
@@ -181,6 +180,7 @@ void TimerPanel::onModelDataAboutToBeUpdated()
|
||||
void TimerPanel::onModelDataUpdateComplete()
|
||||
{
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -250,19 +250,19 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
|
||||
}
|
||||
|
||||
// The protocols available on this board
|
||||
for (unsigned int i=0; i<PULSES_PROTOCOL_LAST; i++) {
|
||||
for (unsigned int i = 0; i < PULSES_PROTOCOL_LAST; i++) {
|
||||
if (firmware->isAvailable((PulsesProtocol) i, moduleIdx)) {
|
||||
ui->protocol->addItem(ModuleData::protocolToString(i), i);
|
||||
if (i == module.protocol)
|
||||
ui->protocol->setCurrentIndex(ui->protocol->count()-1);
|
||||
ui->protocol->setCurrentIndex(ui->protocol->count() - 1);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<=MODULE_SUBTYPE_MULTI_LAST; i++) {
|
||||
for (int i = 0; i <= MODULE_SUBTYPE_MULTI_LAST; i++) {
|
||||
if (i == MODULE_SUBTYPE_MULTI_SCANNER)
|
||||
continue;
|
||||
ui->multiProtocol->addItem(Multiprotocols::protocolToString(i), i);
|
||||
}
|
||||
for (int i=MODULE_SUBTYPE_MULTI_LAST + 1; i <= 124; i++) {
|
||||
for (int i = MODULE_SUBTYPE_MULTI_LAST + 1; i <= 124; i++) {
|
||||
ui->multiProtocol->addItem(QString::number(i + 3), i);
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ void ModulePanel::setupFailsafes()
|
||||
else {
|
||||
QLabel * label = new QLabel(this);
|
||||
label->setProperty("index", i);
|
||||
label->setText(QString::number(i+1));
|
||||
label->setText(QString::number(i + 1));
|
||||
|
||||
QComboBox * combo = new QComboBox(this);
|
||||
combo->setProperty("index", i);
|
||||
@@ -519,7 +519,7 @@ void ModulePanel::update()
|
||||
ui->ppmFrameLength->setVisible(mask & MASK_SBUSPPM_FIELDS);
|
||||
ui->ppmFrameLength->setMinimum(module.channelsCount * (model->extendedLimits ? 2.250 : 2)+3.5);
|
||||
ui->ppmFrameLength->setMaximum(firmware->getCapability(PPMFrameLength));
|
||||
ui->ppmFrameLength->setValue(22.5+((double)module.ppm.frameLength)*0.5);
|
||||
ui->ppmFrameLength->setValue(22.5 + ((double)module.ppm.frameLength) * 0.5);
|
||||
|
||||
// Antenna mode on Horus and XLite
|
||||
if (mask & MASK_ANTENNA) {
|
||||
@@ -613,17 +613,17 @@ void ModulePanel::update()
|
||||
ui->registrationIdLabel->setVisible(mask & MASK_ACCESS);
|
||||
ui->registrationId->setVisible(mask & MASK_ACCESS);
|
||||
|
||||
ui->rx1Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0)));
|
||||
ui->clearRx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0)));
|
||||
ui->rx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0)));
|
||||
ui->rx1Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 0)));
|
||||
ui->clearRx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 0)));
|
||||
ui->rx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 0)));
|
||||
|
||||
ui->rx2Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1)));
|
||||
ui->clearRx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1)));
|
||||
ui->rx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1)));
|
||||
ui->rx2Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 1)));
|
||||
ui->clearRx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 1)));
|
||||
ui->rx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 1)));
|
||||
|
||||
ui->rx3Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2)));
|
||||
ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2)));
|
||||
ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2)));
|
||||
ui->rx3Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2)));
|
||||
ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2)));
|
||||
ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2)));
|
||||
|
||||
// Failsafes
|
||||
ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES);
|
||||
@@ -751,7 +751,7 @@ void ModulePanel::on_rxNumber_editingFinished()
|
||||
|
||||
void ModulePanel::on_ppmFrameLength_editingFinished()
|
||||
{
|
||||
int val = (ui->ppmFrameLength->value()-22.5) / 0.5;
|
||||
int val = (ui->ppmFrameLength->value() - 22.5) / 0.5;
|
||||
if (module.ppm.frameLength != val) {
|
||||
module.ppm.frameLength = val;
|
||||
emit modified();
|
||||
@@ -775,8 +775,8 @@ void ModulePanel::onMultiProtocolChanged(int index)
|
||||
module.multi.rfProtocol = (unsigned int)rfProtocol;
|
||||
unsigned int maxSubTypes = multiProtocols.getProtocol(index).numSubTypes();
|
||||
if (rfProtocol > MODULE_SUBTYPE_MULTI_LAST)
|
||||
maxSubTypes=8;
|
||||
module.subType = std::min(module.subType, maxSubTypes -1);
|
||||
maxSubTypes = 8;
|
||||
module.subType = std::min(module.subType, maxSubTypes - 1);
|
||||
module.channelsCount = module.getMaxChannelCount();
|
||||
update();
|
||||
emit modified();
|
||||
@@ -970,19 +970,19 @@ void ModulePanel::onClearAccessRxClicked()
|
||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||
|
||||
if (button == ui->clearRx1) {
|
||||
module.access.receivers &= ~(1<<0);
|
||||
module.access.receivers &= ~(1 << 0);
|
||||
ui->rx1->clear();
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
else if (button == ui->clearRx2) {
|
||||
module.access.receivers &= ~(1<<1);
|
||||
module.access.receivers &= ~(1 << 1);
|
||||
ui->rx2->clear();
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
else if (button == ui->clearRx3) {
|
||||
module.access.receivers &= ~(1<<2);
|
||||
module.access.receivers &= ~(1 << 2);
|
||||
ui->rx3->clear();
|
||||
update();
|
||||
emit modified();
|
||||
@@ -991,18 +991,20 @@ void ModulePanel::onClearAccessRxClicked()
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel):
|
||||
SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::Setup)
|
||||
ui(new Ui::Setup),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::TimersContext, this);
|
||||
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
lock = true;
|
||||
|
||||
memset(modules, 0, sizeof(modules));
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
ui->name->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->name->setMaxLength(firmware->getCapability(ModelName));
|
||||
@@ -1020,7 +1022,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
|
||||
QFileInfo fi(file);
|
||||
QString temp = fi.fileName();
|
||||
if (!items.contains(temp) && temp.length() <= 6+4) {
|
||||
if (!items.contains(temp) && temp.length() <= 6 + 4) {
|
||||
items.append(temp);
|
||||
}
|
||||
}
|
||||
@@ -1030,7 +1032,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
foreach (QString file, qd.entryList(filters, QDir::Files)) {
|
||||
QFileInfo fi(file);
|
||||
QString temp = fi.completeBaseName();
|
||||
if (!items.contains(temp) && temp.length() <= 10+4) {
|
||||
if (!items.contains(temp) && temp.length() <= 10 + 4) {
|
||||
items.append(temp);
|
||||
}
|
||||
}
|
||||
@@ -1043,7 +1045,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
foreach (QString file, items) {
|
||||
ui->image->addItem(file);
|
||||
if (file == model.bitmap) {
|
||||
ui->image->setCurrentIndex(ui->image->count()-1);
|
||||
ui->image->setCurrentIndex(ui->image->count() - 1);
|
||||
QString fileName = path;
|
||||
fileName.append(model.bitmap);
|
||||
if (!IS_FAMILY_HORUS_OR_T16(board))
|
||||
@@ -1075,7 +1077,6 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
}
|
||||
|
||||
QWidget * prevFocus = ui->image;
|
||||
rawSwitchFilteredModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::TimersContext, this);
|
||||
|
||||
timersCount = firmware->getCapability(Timers);
|
||||
|
||||
@@ -1107,7 +1108,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
if (firmware->getCapability(HasTopLcd)) {
|
||||
ui->toplcdTimer->setField(model.toplcdTimer, this);
|
||||
for (int i = 0; i < CPN_MAX_TIMERS; i++) {
|
||||
if (i<timersCount) {
|
||||
if (i < timersCount) {
|
||||
ui->toplcdTimer->addItem(tr("Timer %1").arg(i + 1), i);
|
||||
}
|
||||
}
|
||||
@@ -1130,12 +1131,12 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
prevFocus = ui->trimsDisplay;
|
||||
int analogs = CPN_MAX_STICKS + getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders);
|
||||
int genAryIdx = 0;
|
||||
for (int i=0; i < analogs + firmware->getCapability(RotaryEncoders); i++) {
|
||||
for (int i = 0; i < analogs + firmware->getCapability(RotaryEncoders); i++) {
|
||||
RawSource src((i < analogs) ? SOURCE_TYPE_STICK : SOURCE_TYPE_ROTARY_ENCODER, (i < analogs) ? i : analogs - i);
|
||||
QCheckBox * checkbox = new QCheckBox(this);
|
||||
checkbox->setProperty("index", i);
|
||||
checkbox->setText(src.toString(&model, &generalSettings));
|
||||
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
|
||||
ui->centerBeepLayout->addWidget(checkbox, 0, i + 1);
|
||||
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
|
||||
centerBeepCheckboxes << checkbox;
|
||||
if (IS_HORUS_OR_TARANIS(board)) {
|
||||
@@ -1151,7 +1152,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
}
|
||||
|
||||
// Startup switches warnings
|
||||
for (int i=0; i<getBoardCapability(board, Board::Switches); i++) {
|
||||
for (int i = 0; i < getBoardCapability(board, Board::Switches); i++) {
|
||||
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, i);
|
||||
switchInfo.config = Board::SwitchType(generalSettings.switchConfig[i]);
|
||||
if (switchInfo.config == Board::SWITCH_NOT_AVAILABLE || switchInfo.config == Board::SWITCH_TOGGLE) {
|
||||
@@ -1175,11 +1176,11 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
label->setText(src.toString(&model, &generalSettings));
|
||||
slider->setMaximum(switchInfo.config == Board::SWITCH_3POS ? 2 : 1);
|
||||
cb->setProperty("index", i);
|
||||
ui->switchesStartupLayout->addWidget(label, 0, i+1);
|
||||
ui->switchesStartupLayout->addWidget(label, 0, i + 1);
|
||||
ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter);
|
||||
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
|
||||
ui->switchesStartupLayout->addWidget(slider, 1, i + 1);
|
||||
ui->switchesStartupLayout->setAlignment(slider, Qt::AlignCenter);
|
||||
ui->switchesStartupLayout->addWidget(cb, 2, i+1);
|
||||
ui->switchesStartupLayout->addWidget(cb, 2, i + 1);
|
||||
ui->switchesStartupLayout->setAlignment(cb, Qt::AlignCenter);
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool)));
|
||||
@@ -1193,12 +1194,12 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
// Pot warnings
|
||||
prevFocus = ui->potWarningMode;
|
||||
if (IS_HORUS_OR_TARANIS(board)) {
|
||||
for (int i=0; i<getBoardCapability(board, Board::Pots)+getBoardCapability(board, Board::Sliders); i++) {
|
||||
for (int i = 0; i < getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders); i++) {
|
||||
RawSource src(SOURCE_TYPE_STICK, CPN_MAX_STICKS + i);
|
||||
QCheckBox * cb = new QCheckBox(this);
|
||||
cb->setProperty("index", i);
|
||||
cb->setText(src.toString(&model, &generalSettings));
|
||||
ui->potWarningLayout->addWidget(cb, 0, i+1);
|
||||
ui->potWarningLayout->addWidget(cb, 0, i + 1);
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
|
||||
potWarningCheckboxes << cb;
|
||||
if (src.isPot(&genAryIdx) && !generalSettings.isPotAvailable(genAryIdx)) {
|
||||
@@ -1246,7 +1247,6 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
|
||||
SetupPanel::~SetupPanel()
|
||||
{
|
||||
delete rawSwitchFilteredModel;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -1277,7 +1277,7 @@ void SetupPanel::on_extendedTrims_toggled(bool checked)
|
||||
|
||||
void SetupPanel::on_trimIncrement_currentIndexChanged(int index)
|
||||
{
|
||||
model->trimInc = index-2;
|
||||
model->trimInc = index - 2;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1346,13 +1346,13 @@ void SetupPanel::populateThrottleSourceCB()
|
||||
ui->throttleSource->clear();
|
||||
ui->throttleSource->addItem(tr("THR"), 0);
|
||||
|
||||
int idx=1;
|
||||
for (int i=0; i<getBoardCapability(board, Board::Pots)+getBoardCapability(board, Board::Sliders); i++, idx++) {
|
||||
if (RawSource(SOURCE_TYPE_STICK,4+i).isAvailable(model,&generalSettings,board)) {
|
||||
ui->throttleSource->addItem(firmware->getAnalogInputName(4+i), idx);
|
||||
int idx = 1;
|
||||
for (int i = 0; i < getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders); i++, idx++) {
|
||||
if (RawSource(SOURCE_TYPE_STICK, 4 + i).isAvailable(model, &generalSettings, board)) {
|
||||
ui->throttleSource->addItem(firmware->getAnalogInputName(4 + i), idx);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<firmware->getCapability(Outputs); i++, idx++) {
|
||||
for (int i = 0; i < firmware->getCapability(Outputs); i++, idx++) {
|
||||
ui->throttleSource->addItem(RawSource(SOURCE_TYPE_CH, i).toString(model, &generalSettings), idx);
|
||||
}
|
||||
|
||||
@@ -1381,7 +1381,7 @@ void SetupPanel::update()
|
||||
updatePotWarnings();
|
||||
}
|
||||
|
||||
for (int i=0; i<CPN_MAX_MODULES+1; i++) {
|
||||
for (int i = 0; i < CPN_MAX_MODULES + 1; i++) {
|
||||
if (modules[i]) {
|
||||
modules[i]->update();
|
||||
}
|
||||
@@ -1392,7 +1392,7 @@ void SetupPanel::update()
|
||||
|
||||
void SetupPanel::updateBeepCenter()
|
||||
{
|
||||
for (int i=0; i<centerBeepCheckboxes.size(); i++) {
|
||||
for (int i = 0; i < centerBeepCheckboxes.size(); i++) {
|
||||
centerBeepCheckboxes[i]->setChecked(model->beepANACenter & (0x01 << i));
|
||||
}
|
||||
}
|
||||
@@ -1404,20 +1404,20 @@ void SetupPanel::updateStartupSwitches()
|
||||
uint64_t switchStates = model->switchWarningStates;
|
||||
uint64_t value;
|
||||
|
||||
for (int i=0; i<startupSwitchesSliders.size(); i++) {
|
||||
for (int i = 0; i < startupSwitchesSliders.size(); i++) {
|
||||
QSlider * slider = startupSwitchesSliders[i];
|
||||
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
||||
int index = slider->property("index").toInt();
|
||||
bool enabled = !(model->switchWarningEnable & (1 << index));
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard())) {
|
||||
value = (switchStates >> (2*index)) & 0x03;
|
||||
value = (switchStates >> (2 * index)) & 0x03;
|
||||
if (generalSettings.switchConfig[index] != Board::SWITCH_3POS && value == 2) {
|
||||
value = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = (i==0 ? switchStates & 0x3 : switchStates & 0x1);
|
||||
switchStates >>= (i==0 ? 2 : 1);
|
||||
value = (i == 0 ? switchStates & 0x3 : switchStates & 0x1);
|
||||
switchStates >>= (i == 0 ? 2 : 1);
|
||||
}
|
||||
slider->setValue(value);
|
||||
slider->setEnabled(enabled);
|
||||
@@ -1443,7 +1443,7 @@ void SetupPanel::startupSwitchEdited(int value)
|
||||
mask = 0x03;
|
||||
}
|
||||
else {
|
||||
shift = index+1;
|
||||
shift = index + 1;
|
||||
mask = 0x01ull << shift;
|
||||
}
|
||||
}
|
||||
@@ -1484,7 +1484,7 @@ void SetupPanel::updatePotWarnings()
|
||||
{
|
||||
lock = true;
|
||||
ui->potWarningMode->setCurrentIndex(model->potsWarningMode);
|
||||
for (int i=0; i<potWarningCheckboxes.size(); i++) {
|
||||
for (int i = 0; i < potWarningCheckboxes.size(); i++) {
|
||||
QCheckBox *checkbox = potWarningCheckboxes[i];
|
||||
int index = checkbox->property("index").toInt();
|
||||
checkbox->setChecked(!model->potsWarnEnabled[index]);
|
||||
@@ -1614,7 +1614,7 @@ void SetupPanel::cmTimerClear(bool prompt)
|
||||
|
||||
model->timers[selectedTimerIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_CLEAR, selectedTimerIndex);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1627,7 +1627,7 @@ void SetupPanel::cmTimerClearAll()
|
||||
model->timers[i].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_CLEAR, i);
|
||||
}
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1661,7 +1661,7 @@ void SetupPanel::cmTimerDelete()
|
||||
}
|
||||
model->timers[maxidx].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SHIFT, selectedTimerIndex, 0, -1);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1674,7 +1674,7 @@ void SetupPanel::cmTimerInsert()
|
||||
}
|
||||
model->timers[selectedTimerIndex].clear();
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SHIFT, selectedTimerIndex, 0, 1);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1694,7 +1694,7 @@ void SetupPanel::cmTimerPaste()
|
||||
if (hasTimerClipboardData(&data)) {
|
||||
TimerData *td = &model->timers[selectedTimerIndex];
|
||||
memcpy(td, data.constData(), sizeof(TimerData));
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
@@ -1708,12 +1708,17 @@ void SetupPanel::swapTimerData(int idx1, int idx2)
|
||||
memcpy(td2, td1, sizeof(TimerData));
|
||||
memcpy(td1, &tdtmp, sizeof(TimerData));
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SWAP, idx1, idx2);
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void SetupPanel::onTimerNameChanged()
|
||||
{
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
}
|
||||
|
||||
void SetupPanel::updateItemModels()
|
||||
{
|
||||
commonItemModels->update(CommonItemModels::RMO_TIMERS);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
constexpr char MIMETYPE_TIMER[] = "application/x-companion-timer";
|
||||
|
||||
class RawSwitchItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
|
||||
namespace Ui {
|
||||
@@ -131,7 +131,7 @@ class SetupPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel);
|
||||
SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~SetupPanel();
|
||||
|
||||
virtual void update();
|
||||
@@ -139,7 +139,6 @@ class SetupPanel : public ModelPanel
|
||||
signals:
|
||||
void extendedLimitsToggled();
|
||||
void updated();
|
||||
void updateDataModels();
|
||||
|
||||
private slots:
|
||||
void on_name_editingFinished();
|
||||
@@ -190,7 +189,9 @@ class SetupPanel : public ModelPanel
|
||||
bool moveTimerDownAllowed() const;
|
||||
bool moveTimerUpAllowed() const;
|
||||
void swapTimerData(int idx1, int idx2);
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel * rawSwitchFilteredModel;
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _SETUP_H_
|
||||
|
||||
@@ -297,6 +297,7 @@ void TelemetryCustomScreen::onModelDataAboutToBeUpdated()
|
||||
void TelemetryCustomScreen::onModelDataUpdateComplete()
|
||||
{
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
@@ -690,12 +691,13 @@ void TelemetrySensorPanel::cmMoveDown()
|
||||
|
||||
/******************************************************/
|
||||
|
||||
TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel):
|
||||
TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::Telemetry)
|
||||
ui(new Ui::Telemetry),
|
||||
commonItemModels(commonItemModels)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, this);
|
||||
rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), this);
|
||||
|
||||
sensorCapability = firmware->getCapability(Sensors);
|
||||
if (sensorCapability > CPN_MAX_SENSORS) // TODO should be role of getCapability
|
||||
@@ -732,7 +734,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
||||
}
|
||||
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) {
|
||||
TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, rawSourceModel);
|
||||
TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, rawSourceFilteredModel);
|
||||
ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i + 1));
|
||||
telemetryCustomScreens[i] = tab;
|
||||
connect(tab, &TelemetryCustomScreen::modified, this, &TelemetryPanel::onModified);
|
||||
@@ -745,7 +747,6 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
||||
|
||||
TelemetryPanel::~TelemetryPanel()
|
||||
{
|
||||
delete rawSourceModel;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -983,7 +984,7 @@ void TelemetryPanel::on_clearAllSensors()
|
||||
}
|
||||
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -994,7 +995,7 @@ void TelemetryPanel::on_insertSensor(int selectedIndex)
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1);
|
||||
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1008,7 +1009,7 @@ void TelemetryPanel::on_deleteSensor(int selectedIndex)
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1);
|
||||
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
@@ -1032,7 +1033,12 @@ void TelemetryPanel::swapData(int idx1, int idx2)
|
||||
memcpy(sd1, &sdtmp, sizeof(SensorData));
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SWAP, idx1, idx2);
|
||||
update();
|
||||
emit updateDataModels();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::updateItemModels()
|
||||
{
|
||||
commonItemModels->update(CommonItemModels::RMO_TELEMETRY_SENSORS);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
constexpr char MIMETYPE_TELE_SENSOR[] = "application/x-companion-tele-sensor";
|
||||
|
||||
class AutoComboBox;
|
||||
class RawSourceItemModel;
|
||||
class CommonItemModels;
|
||||
class RawItemFilteredModel;
|
||||
class TimerEdit;
|
||||
|
||||
@@ -125,14 +125,12 @@ class TelemetryPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel);
|
||||
TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels);
|
||||
virtual ~TelemetryPanel();
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void updated();
|
||||
void updateDataModels();
|
||||
|
||||
|
||||
private slots:
|
||||
void on_telemetryProtocol_currentIndexChanged(int index);
|
||||
@@ -159,7 +157,8 @@ class TelemetryPanel : public ModelPanel
|
||||
TelemetryCustomScreen * telemetryCustomScreens[4];
|
||||
TelemetrySensorPanel * sensorPanels[CPN_MAX_SENSORS];
|
||||
int sensorCapability;
|
||||
RawItemFilteredModel * rawSourceModel;
|
||||
CommonItemModels * commonItemModels;
|
||||
RawItemFilteredModel * rawSourceFilteredModel;
|
||||
|
||||
void setup();
|
||||
void telBarUpdate();
|
||||
@@ -167,6 +166,7 @@ class TelemetryPanel : public ModelPanel
|
||||
void populateCurrentSource();
|
||||
void populateVarioSource();
|
||||
void swapData(int idx1, int idx2);
|
||||
void updateItemModels();
|
||||
};
|
||||
|
||||
#endif // _TELEMETRY_H_
|
||||
|
||||
Reference in New Issue
Block a user