@@ -416,6 +416,10 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
416416 addParams ();
417417 }
418418
419+ connect (this , &HardwarePanel::inputFlexTypeChanged, [=](AutoComboBox *cb, int index)
420+ { setFlexTypeModel (cb, index); }
421+ );
422+ connect (this , &HardwarePanel::refreshItemModels, [=]() { updateItemModels (); });
419423 addVSpring (grid, 0 , grid->rowCount ());
420424 addHSpring (grid, grid->columnCount (), 0 );
421425 disableMouseScrolling ();
@@ -497,6 +501,7 @@ void HardwarePanel::addFlex(int index)
497501 name->setValidator (new NameValidator (board, this ));
498502 name->setField (config.name , HARDWARE_NAME_LEN, this );
499503 params->append (name);
504+ connect (name, &AutoLineEdit::editingFinished, [=] () { emit refreshItemModels (); });
500505
501506 AutoComboBox *type = new AutoComboBox (this );
502507 setFlexTypeModel (type, index);
@@ -516,11 +521,10 @@ void HardwarePanel::addFlex(int index)
516521 } else {
517522 invertToggles[index - Boards::getCapability (board, Board::Sticks)]->show ();
518523 }
519- emit InputFlexTypeChanged ();
524+ emit inputFlexTypeChanged (type, index);
525+ emit refreshItemModels ();
520526 });
521527
522- connect (this , &HardwarePanel::InputFlexTypeChanged, [=]() { setFlexTypeModel (type, index); });
523-
524528 params->append (type);
525529
526530 AutoCheckBox *inverted = new AutoCheckBox (this );
@@ -559,6 +563,7 @@ void HardwarePanel::addSwitch(int index)
559563 name->setValidator (new NameValidator (board, this ));
560564 name->setField (config.name , HARDWARE_NAME_LEN, this );
561565 params->append (name);
566+ connect (name, &AutoLineEdit::editingFinished, [=] () { emit refreshItemModels (); });
562567
563568 AutoComboBox *input = nullptr ;
564569
@@ -589,6 +594,12 @@ void HardwarePanel::addSwitch(int index)
589594 type->setField (config.type , this );
590595 params->append (type);
591596
597+ if (!generalSettings.isSwitchFlex (index) && !generalSettings.isSwitchFunc (index)) {
598+ connect (type, &AutoComboBox::currentDataChanged, [=] (int val) {
599+ emit refreshItemModels ();
600+ });
601+ }
602+
592603 if (generalSettings.isSwitchFlex (index)) {
593604 connect (input, &AutoComboBox::currentDataChanged, [=] (int val) {
594605 if (val < 0 ) {
@@ -598,6 +609,8 @@ void HardwarePanel::addSwitch(int index)
598609 }
599610 else
600611 type->setModel (tabFilteredModels->getItemModel (FIM_SWITCHTYPE3POS));
612+
613+ emit refreshItemModels ();
601614 });
602615 }
603616
@@ -613,6 +626,7 @@ void HardwarePanel::addSwitch(int index)
613626
614627 connect (type, &AutoComboBox::currentDataChanged, [=] (int val) {
615628 start->setEnabled (val == Board::SWITCH_2POS);
629+ emit refreshItemModels ();
616630 });
617631
618632 if (Boards::getCapability (board, Board::FunctionSwitchColors)) {
@@ -728,3 +742,8 @@ void HardwarePanel::updateSerialPortUSBVCP()
728742 view->setRowHidden (i, false );
729743 }
730744}
745+
746+ void HardwarePanel::updateItemModels ()
747+ {
748+ editorItemModels->update (AbstractItemModel::IMUE_Hardware);
749+ }
0 commit comments