diff --git a/companion/src/datamodels/compounditemmodels.cpp b/companion/src/datamodels/compounditemmodels.cpp index f47741341..24aac5aa9 100644 --- a/companion/src/datamodels/compounditemmodels.cpp +++ b/companion/src/datamodels/compounditemmodels.cpp @@ -457,9 +457,7 @@ CustomFuncResetParamItemModel::CustomFuncResetParamItemModel(const GeneralSettin void CustomFuncResetParamItemModel::setDynamicItemData(QStandardItem * item, const int value) const { - CustomFunctionData cfd = CustomFunctionData(AssignFunc::FuncReset); - cfd.param = value; - item->setText(CustomFunctionData::resetToString(modelData)); + item->setText(CustomFunctionData::resetToString(modelData, value)); item->setData(CustomFunctionData::isResetParamAvailable(modelData, value), IMDR_Available); } diff --git a/companion/src/datamodels/compounditemmodels.h b/companion/src/datamodels/compounditemmodels.h index de32fc902..c6d204cb3 100644 --- a/companion/src/datamodels/compounditemmodels.h +++ b/companion/src/datamodels/compounditemmodels.h @@ -18,8 +18,7 @@ * GNU General Public License for more details. */ -#ifndef COMPOUNDITEMMODELS_H -#define COMPOUNDITEMMODELS_H +#pragma once #include "rawsource.h" #include "rawswitch.h" @@ -361,5 +360,3 @@ class CompoundItemModelFactory private: void setSourceId(AbstractItemModel * itemModel); }; - -#endif // COMPOUNDITEMMODELS_H diff --git a/companion/src/firmwares/customfunctiondata.cpp b/companion/src/firmwares/customfunctiondata.cpp index aa2f64bbd..b5bece769 100644 --- a/companion/src/firmwares/customfunctiondata.cpp +++ b/companion/src/firmwares/customfunctiondata.cpp @@ -262,6 +262,7 @@ QString CustomFunctionData::resetToString(const ModelData * model, int value) else return QString(CPN_STR_UNKNOWN_ITEM); } + step += reCount; if (value < step + firmware->getCapability(Sensors)) @@ -291,8 +292,8 @@ bool CustomFunctionData::isResetParamAvailable(const ModelData * model, int inde } else if (index < CPN_MAX_TIMERS + firmware->getCapability(RotaryEncoders)) return true; - else if (model && index < CPN_MAX_TIMERS + firmware->getCapability(RotaryEncoders) + firmware->getCapability(Sensors)) - return model->sensorData[index - CPN_MAX_TIMERS - firmware->getCapability(RotaryEncoders)].isAvailable(); + else if (model && index < resetParamCount()) + return model->sensorData[index - (CPN_MAX_TIMERS + 2 + firmware->getCapability(RotaryEncoders))].isAvailable(); return false; } diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 05eefb96b..7f3e8ee19 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -99,7 +99,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, playIcon.addImage("stop.png", QIcon::Normal, QIcon::On); QStringList headerLabels; - headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << tr("Enable"); + headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << ""; TableLayout * tableLayout = new TableLayout(this, fswCapability, headerLabels); for (int i = 0; i < fswCapability; i++) { @@ -119,19 +119,21 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, // The switch fswtchSwtch[i] = new QComboBox(this); + fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setModel(tabFilterFactory->getItemModel(rawSwitchId)); fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue())); - fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); + fswtchSwtch[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); fswtchSwtch[i]->setMaxVisibleItems(10); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); tableLayout->addWidget(i, 1, fswtchSwtch[i]); // The function fswtchFunc[i] = new QComboBox(this); + fswtchFunc[i]->setProperty("index", i); fswtchFunc[i]->setModel(tabFilterFactory->getItemModel(funcActionsId)); fswtchFunc[i]->setCurrentIndex(fswtchFunc[i]->findData(functions[i].func)); - fswtchFunc[i]->setProperty("index", i); + fswtchFunc[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited())); tableLayout->addWidget(i, 2, fswtchFunc[i]); @@ -148,8 +150,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, fswtchParamGV[i] = new QCheckBox(this); fswtchParamGV[i]->setProperty("index", i); - fswtchParamGV[i]->setText("GV"); - fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + fswtchParamGV[i]->setText(tr("GV")); + fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchParamGV[i]); @@ -202,6 +204,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, fswtchRepeat[i]->setProperty("index", i); fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId)); fswtchRepeat[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); + fswtchRepeat[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); repeatLayout->addWidget(fswtchRepeat[i], i + 1); connect(fswtchRepeat[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));