Minor cleanup on RawSourceItemModel and TelemetryCustomScreen.
This commit is contained in:
@@ -50,7 +50,7 @@ RawSourceItemModel::RawSourceItemModel(const GeneralSettings * const generalSett
|
|||||||
addItems(SOURCE_TYPE_GVAR, RawSource::GVarsGroup, fw->getCapability(Gvars));
|
addItems(SOURCE_TYPE_GVAR, RawSource::GVarsGroup, fw->getCapability(Gvars));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawSourceItemModel::setDynamicItemData(QStandardItem * item, const RawSource & src)
|
void RawSourceItemModel::setDynamicItemData(QStandardItem * item, const RawSource & src) const
|
||||||
{
|
{
|
||||||
Board::Type board = getCurrentBoard();
|
Board::Type board = getCurrentBoard();
|
||||||
item->setText(src.toString(modelData, generalSettings, board));
|
item->setText(src.toString(modelData, generalSettings, board));
|
||||||
@@ -70,7 +70,7 @@ void RawSourceItemModel::addItems(const RawSourceType & type, const unsigned gro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawSourceItemModel::update()
|
void RawSourceItemModel::update() const
|
||||||
{
|
{
|
||||||
for (int i=0; i < rowCount(); ++i)
|
for (int i=0; i < rowCount(); ++i)
|
||||||
setDynamicItemData(item(i), RawSource(item(i)->data(ItemIdRole).toInt()));
|
setDynamicItemData(item(i), RawSource(item(i)->data(ItemIdRole).toInt()));
|
||||||
@@ -107,18 +107,19 @@ void RawSourceFilterItemModel::setFilterGroups(unsigned groups)
|
|||||||
|
|
||||||
bool RawSourceFilterItemModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
|
bool RawSourceFilterItemModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const
|
||||||
{
|
{
|
||||||
bool ok = true;
|
|
||||||
const QModelIndex & srcIdx = sourceModel()->index(sourceRow, 0, sourceParent);
|
const QModelIndex & srcIdx = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
if (!sourceModel()->data(srcIdx, filterRole()).toBool())
|
if (!srcIdx.isValid() || !sourceModel()->data(srcIdx, filterRole()).toBool())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (filterGroups && filterGroups != RawSource::AllSourceGroups) {
|
if (filterGroups && filterGroups != RawSource::AllSourceGroups) {
|
||||||
|
bool ok;
|
||||||
const unsigned group = sourceModel()->data(srcIdx, RawSourceItemModel::ItemGroupRole).toUInt(&ok);
|
const unsigned group = sourceModel()->data(srcIdx, RawSourceItemModel::ItemGroupRole).toUInt(&ok);
|
||||||
return (ok && (filterGroups & group));
|
return (ok && (filterGroups & group));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawSourceFilterItemModel::update()
|
void RawSourceFilterItemModel::update() const
|
||||||
{
|
{
|
||||||
RawSourceItemModel * model = qobject_cast<RawSourceItemModel *>(sourceModel());
|
RawSourceItemModel * model = qobject_cast<RawSourceItemModel *>(sourceModel());
|
||||||
if (model)
|
if (model)
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ class RawSourceItemModel: public QStandardItemModel
|
|||||||
RawSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr);
|
RawSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void update();
|
void update() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setDynamicItemData(QStandardItem * item, const RawSource & src);
|
void setDynamicItemData(QStandardItem * item, const RawSource & src) const;
|
||||||
void addItems(const RawSourceType & type, const unsigned group, const int count, const int start = 0);
|
void addItems(const RawSourceType & type, const unsigned group, const int count, const int start = 0);
|
||||||
|
|
||||||
const GeneralSettings * generalSettings;
|
const GeneralSettings * generalSettings;
|
||||||
@@ -66,7 +66,7 @@ class RawSourceFilterItemModel: public QSortFilterProxyModel
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setFilterGroups(unsigned groups);
|
void setFilterGroups(unsigned groups);
|
||||||
void update();
|
void update() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const override;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const override;
|
||||||
|
|||||||
@@ -320,8 +320,7 @@ TelemetryAnalog::~TelemetryAnalog()
|
|||||||
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware, RawSourceFilterItemModel * srcModel):
|
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware, RawSourceFilterItemModel * srcModel):
|
||||||
ModelPanel(parent, model, generalSettings, firmware),
|
ModelPanel(parent, model, generalSettings, firmware),
|
||||||
ui(new Ui::TelemetryCustomScreen),
|
ui(new Ui::TelemetryCustomScreen),
|
||||||
screen(screen),
|
screen(screen)
|
||||||
rawSourceItemModel(srcModel)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@@ -329,7 +328,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
|
|||||||
for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||||
fieldsCB[l][c] = new QComboBox(this);
|
fieldsCB[l][c] = new QComboBox(this);
|
||||||
fieldsCB[l][c]->setProperty("index", c + (l<<8));
|
fieldsCB[l][c]->setProperty("index", c + (l<<8));
|
||||||
fieldsCB[l][c]->setModel(rawSourceItemModel);
|
fieldsCB[l][c]->setModel(srcModel);
|
||||||
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
|
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
|
||||||
connect(fieldsCB[l][c], SIGNAL(activated(int)), this, SLOT(customFieldChanged(int)));
|
connect(fieldsCB[l][c], SIGNAL(activated(int)), this, SLOT(customFieldChanged(int)));
|
||||||
}
|
}
|
||||||
@@ -338,7 +337,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
|
|||||||
for (int l=0; l<4; l++) {
|
for (int l=0; l<4; l++) {
|
||||||
barsCB[l] = new QComboBox(this);
|
barsCB[l] = new QComboBox(this);
|
||||||
barsCB[l]->setProperty("index", l);
|
barsCB[l]->setProperty("index", l);
|
||||||
barsCB[l]->setModel(rawSourceItemModel);
|
barsCB[l]->setModel(srcModel);
|
||||||
connect(barsCB[l], SIGNAL(activated(int)), this, SLOT(barSourceChanged(int)));
|
connect(barsCB[l], SIGNAL(activated(int)), this, SLOT(barSourceChanged(int)));
|
||||||
ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);
|
ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ class TelemetryCustomScreen: public ModelPanel
|
|||||||
void updateBar(int line);
|
void updateBar(int line);
|
||||||
Ui::TelemetryCustomScreen * ui;
|
Ui::TelemetryCustomScreen * ui;
|
||||||
FrSkyScreenData & screen;
|
FrSkyScreenData & screen;
|
||||||
RawSourceFilterItemModel * rawSourceItemModel;
|
|
||||||
QComboBox * fieldsCB[4][3];
|
QComboBox * fieldsCB[4][3];
|
||||||
QComboBox * barsCB[4];
|
QComboBox * barsCB[4];
|
||||||
QDoubleSpinBox * minSB[4];
|
QDoubleSpinBox * minSB[4];
|
||||||
|
|||||||
Reference in New Issue
Block a user