Input and mix source list use filter to remove none entry

This commit is contained in:
elecpower
2020-09-20 07:43:54 +10:00
parent 4feee9c665
commit 1b40c69593
4 changed files with 17 additions and 19 deletions
+14 -15
View File
@@ -38,9 +38,9 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
{
ui->setupUi(this);
QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0, ui->lb_FP1, ui->lb_FP2, ui->lb_FP3, ui->lb_FP4, ui->lb_FP5, ui->lb_FP6, ui->lb_FP7, ui->lb_FP8 };
QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0, ui->cb_FP1, ui->cb_FP2, ui->cb_FP3, ui->cb_FP4, ui->cb_FP5, ui->cb_FP6, ui->cb_FP7, ui->cb_FP8 };
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
cb_fp[i] = tmp[i];
}
@@ -57,11 +57,11 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
ui->switchesCB->setModel(rawSwitchModel);
ui->switchesCB->setCurrentIndex(ui->switchesCB->findData(ed->swtch.toValue()));
ui->sideCB->setCurrentIndex(ed->mode-1);
ui->sideCB->setCurrentIndex(ed->mode - 1);
if (!firmware->getCapability(FlightModes)) {
ui->label_phases->hide();
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
@@ -71,13 +71,13 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
ui->label_phases->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->label_phases, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(label_phases_customContextMenuRequested(const QPoint &)));
int mask = 1;
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
if ((ed->flightModes & mask) == 0) {
cb_fp[i]->setChecked(true);
}
mask <<= 1;
}
for (int i=firmware->getCapability(FlightModes); i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = firmware->getCapability(FlightModes); i < CPN_MAX_FLIGHT_MODES; i++) {
lb_fp[i]->hide();
cb_fp[i]->hide();
}
@@ -87,7 +87,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
ui->inputName->setMaxLength(firmware->getCapability(InputsLength));
ui->sourceCB->setModel(rawSourceModel);
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(ed->srcRaw.toValue()));
ui->sourceCB->removeItem(0);
ui->inputName->setValidator(new QRegExpValidator(rx, this));
ui->inputName->setText(inputName);
}
@@ -100,8 +99,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
ui->trimCB->hide();
}
for(int i=0; i < getBoardCapability(getCurrentBoard(), Board::NumTrims); i++) {
ui->trimCB->addItem(RawSource(SOURCE_TYPE_TRIM, i).toString(), i+1);
for(int i = 0; i < getBoardCapability(getCurrentBoard(), Board::NumTrims); i++) {
ui->trimCB->addItem(RawSource(SOURCE_TYPE_TRIM, i).toString(), i + 1);
}
ui->trimCB->setCurrentIndex(1 - ed->carryTrim);
@@ -126,7 +125,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
connect(ui->trimCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
connect(ui->switchesCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
connect(ui->sideCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
connect(cb_fp[i], SIGNAL(toggled(bool)), this, SLOT(valuesChanged()));
}
if (firmware->getCapability(VirtualInputs)) {
@@ -183,7 +182,7 @@ void ExpoDialog::valuesChanged()
}
ed->flightModes = 0;
for (int i=CPN_MAX_FLIGHT_MODES-1; i>=0 ; i--) {
for (int i = CPN_MAX_FLIGHT_MODES - 1; i >= 0 ; i--) {
if (!cb_fp[i]->checkState()) {
ed->flightModes++;
}
@@ -214,7 +213,7 @@ void ExpoDialog::label_phases_customContextMenuRequested(const QPoint & pos)
void ExpoDialog::fmClearAll()
{
lock = true;
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
cb_fp[i]->setChecked(false);
}
lock = false;
@@ -224,7 +223,7 @@ void ExpoDialog::fmClearAll()
void ExpoDialog::fmSetAll()
{
lock = true;
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
cb_fp[i]->setChecked(true);
}
lock = false;
@@ -234,7 +233,7 @@ void ExpoDialog::fmSetAll()
void ExpoDialog::fmInvertAll()
{
lock = true;
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
cb_fp[i]->setChecked(!cb_fp[i]->isChecked());
}
lock = false;
+1 -1
View File
@@ -29,7 +29,7 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g
expoInserted(false),
modelPrinter(firmware, generalSettings, model)
{
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup), this);
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);
+1 -2
View File
@@ -47,7 +47,6 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata,
ui->sourceCB->setModel(rawSourceModel);
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(md->srcRaw.toValue()));
ui->sourceCB->removeItem(0);
int limit = firmware->getCapability(OffsetWeight);
@@ -191,7 +190,7 @@ void MixerDialog::valuesChanged()
strcpy(md->name, ui->mixerName->text().toLatin1());
md->flightModes = 0;
for (int i = CPN_MAX_FLIGHT_MODES-1; i >= 0 ; i--) {
for (int i = CPN_MAX_FLIGHT_MODES - 1; i >= 0 ; i--) {
if (!cb_fp[i]->checkState()) {
md->flightModes++;
}
+1 -1
View File
@@ -29,7 +29,7 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
highlightedSource(0),
modelPrinter(firmware, generalSettings, model)
{
rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups | RawSource::ScriptsGroup, this);
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);