1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-17 05:15:18 +03:00

Merge pull request #3091 from opentx/projectkk2glider/issue_2861_header_always_visible

Use new TableLayout for Logical switches, Outputs and Special functions
This commit is contained in:
Bertrand Songis 2015-11-22 21:55:40 +01:00
commit 731faa82ad
6 changed files with 122 additions and 75 deletions

View file

@ -995,3 +995,38 @@ QStringList extractLatLon(const QString & position)
} }
return result; return result;
} }
TableLayout::TableLayout(QWidget * parent, int rowCount, const QStringList & headerLabels)
{
tableWidget = new QTableWidget(parent);
QVBoxLayout * layout = new QVBoxLayout();
layout->addWidget(tableWidget);
layout->setContentsMargins(0, 0, 0, 0);
parent->setLayout(layout);
tableWidget->setRowCount(rowCount);
tableWidget->setColumnCount(headerLabels.size());
tableWidget->setShowGrid(false);
tableWidget->verticalHeader()->setVisible(false);
tableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
tableWidget->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
tableWidget->setStyleSheet("QTableWidget {background-color: transparent;}");
tableWidget->setHorizontalHeaderLabels(headerLabels);
}
void TableLayout::addWidget(int row, int column, QWidget * widget)
{
QHBoxLayout * layout = new QHBoxLayout(tableWidget);
layout->addWidget(widget);
addLayout(row, column, layout);
}
void TableLayout::addLayout(int row, int column, QLayout * layout)
{
layout->setContentsMargins(1, 3, 1, 3);
QWidget * containerWidget = new QWidget(tableWidget);
containerWidget->setLayout(layout);
tableWidget->setCellWidget(row, column, containerWidget);
}

View file

@ -201,4 +201,18 @@ private:
double toDecimalCoordinate(const QString & value); double toDecimalCoordinate(const QString & value);
QStringList extractLatLon(const QString & position); QStringList extractLatLon(const QString & position);
class TableLayout
{
public:
TableLayout(QWidget * parent, int rowCount, const QStringList & headerLabels);
// ~TableLayout() ;
void addWidget(int row, int column, QWidget * widget);
void addLayout(int row, int column, QLayout * layout);
QTableWidget * getTableWidget() { return tableWidget; };
private:
QTableWidget * tableWidget;
};
#endif // HELPERS_H #endif // HELPERS_H

View file

@ -7,7 +7,7 @@
#include <QCheckBox> #include <QCheckBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
LimitsGroup::LimitsGroup(Firmware * firmware, QGridLayout *gridLayout, int row, int col, int & value, int min, int max, int deflt): LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, int min, int max, int deflt):
firmware(firmware), firmware(firmware),
spinbox(new QDoubleSpinBox()), spinbox(new QDoubleSpinBox()),
value(value), value(value),
@ -45,8 +45,10 @@ LimitsGroup::LimitsGroup(Firmware * firmware, QGridLayout *gridLayout, int row,
horizontalLayout->addWidget(gv); horizontalLayout->addWidget(gv);
QComboBox * cb = new QComboBox(); QComboBox * cb = new QComboBox();
horizontalLayout->addWidget(cb); horizontalLayout->addWidget(cb);
cb->setSizeAdjustPolicy(QComboBox::AdjustToContents);
horizontalLayout->addWidget(spinbox); horizontalLayout->addWidget(spinbox);
gridLayout->addLayout(horizontalLayout, row, col, 1, 1); spinbox->setMinimumWidth(80);
tableLayout->addLayout(row, col, horizontalLayout);
gvarGroup = new GVarGroup(gv, spinbox, cb, value, deflt, min, max, displayStep, allowGVars); gvarGroup = new GVarGroup(gv, spinbox, cb, value, deflt, min, max, displayStep, allowGVars);
} }
@ -74,55 +76,51 @@ void LimitsGroup::updateMinMax(int max)
Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware) ModelPanel(parent, model, generalSettings, firmware)
{ {
QGridLayout * gridLayout = new QGridLayout(this); int channelNameMaxLen = firmware->getCapability(ChannelsName);
bool minimize = false;
int col = 1; QStringList headerLabels;
if (firmware->getCapability(ChannelsName)) { headerLabels << "#";
minimize=true; if (channelNameMaxLen > 0) {
addLabel(gridLayout, tr("Name"), col++); headerLabels << tr("Name");
} }
addLabel(gridLayout, tr("Subtrim"), col++, minimize); headerLabels << tr("Subtrim") << tr("Min") << tr("Max") << tr("Direction");
addLabel(gridLayout, tr("Min"), col++, minimize);
addLabel(gridLayout, tr("Max"), col++, minimize);
addLabel(gridLayout, tr("Direction"), col++, minimize);
if (IS_TARANIS(GetEepromInterface()->getBoard())) if (IS_TARANIS(GetEepromInterface()->getBoard()))
addLabel(gridLayout, tr("Curve"), col++, minimize); headerLabels << tr("Curve");
if (firmware->getCapability(PPMCenter)) if (firmware->getCapability(PPMCenter))
addLabel(gridLayout, tr("PPM Center"), col++, minimize); headerLabels << tr("PPM Center");
if (firmware->getCapability(SYMLimits)) if (firmware->getCapability(SYMLimits))
addLabel(gridLayout, tr("Linear Subtrim"), col++, true); headerLabels << tr("Linear Subtrim");
TableLayout * tableLayout = new TableLayout(this, firmware->getCapability(LogicalSwitches), headerLabels);
for (int i=0; i<firmware->getCapability(Outputs); i++) { for (int i=0; i<firmware->getCapability(Outputs); i++) {
col = 0; int col = 0;
// Channel label // Channel label
QLabel *label = new QLabel(this); QLabel *label = new QLabel(this);
label->setText(tr("Channel %1").arg(i+1)); label->setText(tr("CH%1").arg(i+1));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout->addWidget(label, i+1, col++, 1, 1); tableLayout->addWidget(i, col++, label);
// Channel name // Channel name
int nameLen = firmware->getCapability(ChannelsName); if (channelNameMaxLen > 0) {
if (nameLen > 0) {
QLineEdit * name = new QLineEdit(this); QLineEdit * name = new QLineEdit(this);
name->setProperty("index", i); name->setProperty("index", i);
name->setMaxLength(nameLen); name->setMaxLength(channelNameMaxLen);
QRegExp rx(CHAR_FOR_NAMES_REGEX); QRegExp rx(CHAR_FOR_NAMES_REGEX);
name->setValidator(new QRegExpValidator(rx, this)); name->setValidator(new QRegExpValidator(rx, this));
name->setText(model.limitData[i].name); name->setText(model.limitData[i].name);
connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited())); connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited()));
gridLayout->addWidget(name, i+1, col++, 1, 1); tableLayout->addWidget(i, col++, name);
} }
// Channel offset // Channel offset
limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].offset, -1000, 1000, 0); limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, -1000, 1000, 0);
// Channel min // Channel min
limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].min, -model.getChannelsMax()*10, 0, -1000); limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, -model.getChannelsMax()*10, 0, -1000);
// Channel max // Channel max
limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].max, 0, model.getChannelsMax()*10, 1000); limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, 0, model.getChannelsMax()*10, 1000);
// Channel inversion // Channel inversion
QComboBox * invCB = new QComboBox(this); QComboBox * invCB = new QComboBox(this);
@ -130,7 +128,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
invCB->setProperty("index", i); invCB->setProperty("index", i);
invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0); invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0);
connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited())); connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited()));
gridLayout->addWidget(invCB, i+1, col++, 1, 1); tableLayout->addWidget(i, col++, invCB);
// Curve // Curve
if (IS_TARANIS(GetEepromInterface()->getBoard())) { if (IS_TARANIS(GetEepromInterface()->getBoard())) {
@ -142,7 +140,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
} }
curveCB->setCurrentIndex(model.limitData[i].curve.value+numcurves); curveCB->setCurrentIndex(model.limitData[i].curve.value+numcurves);
connect(curveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited())); connect(curveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited()));
gridLayout->addWidget(curveCB, i+1, col++, 1, 1); tableLayout->addWidget(i, col++, curveCB);
} }
// PPM center // PPM center
@ -157,7 +155,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
center->setValue(1500); center->setValue(1500);
center->setValue(model.limitData[i].ppmCenter + 1500); center->setValue(model.limitData[i].ppmCenter + 1500);
connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited())); connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited()));
gridLayout->addWidget(center, i+1, col++, 1, 1); tableLayout->addWidget(i, col++, center);
} }
// Symetrical limits // Symetrical limits
@ -166,14 +164,12 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
symlimits->setProperty("index", i); symlimits->setProperty("index", i);
symlimits->setChecked(model.limitData[i].symetrical); symlimits->setChecked(model.limitData[i].symetrical);
connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited())); connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited()));
gridLayout->addWidget(symlimits, i+1, col++, 1, 1); tableLayout->addWidget(i, col++, symlimits);
} }
} }
// Push the rows up
addVSpring(gridLayout, 0,firmware->getCapability(Outputs)+1);
disableMouseScrolling(); disableMouseScrolling();
tableLayout->getTableWidget()->resizeColumnsToContents();
} }
Channels::~Channels() Channels::~Channels()

View file

@ -1,6 +1,7 @@
#ifndef CHANNELS_H #ifndef CHANNELS_H
#define CHANNELS_H #define CHANNELS_H
#include "helpers.h"
#include "modeledit.h" #include "modeledit.h"
#include <QSpinBox> #include <QSpinBox>
@ -9,7 +10,7 @@ class GVarGroup;
class LimitsGroup class LimitsGroup
{ {
public: public:
LimitsGroup(Firmware * firmware, QGridLayout *gridLayout, int row, int col, int & value, int min, int max, int deflt); LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, int min, int max, int deflt);
~LimitsGroup(); ~LimitsGroup();
void updateMinMax(int max); void updateMinMax(int max);

View file

@ -52,14 +52,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
clickOutput(NULL) clickOutput(NULL)
#endif #endif
{ {
QGridLayout * gridLayout = new QGridLayout(this);
addLabel(gridLayout, tr("Switch"), 1);
addLabel(gridLayout, tr("Action"), 2);
addLabel(gridLayout, tr("Parameters"), 3);
addLabel(gridLayout, tr("Enable"), 4, true );
addEmptyLabel(gridLayout, 5 );
lock = true; lock = true;
int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
@ -89,6 +81,10 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
CompanionIcon playIcon("play.png"); CompanionIcon playIcon("play.png");
QStringList headerLabels;
headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << tr("Enable");
TableLayout * tableLayout = new TableLayout(this, num_fsw, headerLabels);
for (int i=0; i<num_fsw; i++) { for (int i=0; i<num_fsw; i++) {
// The label // The label
QLabel * label = new QLabel(this); QLabel * label = new QLabel(this);
@ -101,35 +97,36 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
label->setText(tr("GF%1").arg(i+1)); label->setText(tr("GF%1").arg(i+1));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0); tableLayout->addWidget(i, 0, label);
// The switch // The switch
fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setProperty("index", i);
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); fswtchSwtch[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
fswtchSwtch[i]->setMaxVisibleItems(10); fswtchSwtch[i]->setMaxVisibleItems(10);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1); tableLayout->addWidget(i, 1, fswtchSwtch[i]);
// The function // The function
fswtchFunc[i] = new QComboBox(this); fswtchFunc[i] = new QComboBox(this);
fswtchFunc[i]->setProperty("index", i); fswtchFunc[i]->setProperty("index", i);
fswtchFunc[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited())); connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited()));
gridLayout->addWidget(fswtchFunc[i], i+1, 2); tableLayout->addWidget(i, 2, fswtchFunc[i]);
// The parameters // The parameters
QHBoxLayout *paramLayout = new QHBoxLayout(); QHBoxLayout * paramLayout = new QHBoxLayout();
gridLayout->addLayout(paramLayout, i+1, 3); tableLayout->addLayout(i, 3, paramLayout);
fswtchGVmode[i] = new QComboBox(this); fswtchGVmode[i] = new QComboBox(this);
fswtchGVmode[i]->setProperty("index", i); fswtchGVmode[i]->setProperty("index", i);
fswtchGVmode[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
paramLayout->addWidget(fswtchGVmode[i]); paramLayout->addWidget(fswtchGVmode[i]);
fswtchParamGV[i] = new QCheckBox(this); fswtchParamGV[i] = new QCheckBox(this);
fswtchParamGV[i]->setProperty("index", i); fswtchParamGV[i]->setProperty("index", i);
fswtchParamGV[i]->setText("GV"); fswtchParamGV[i]->setText("GV");
fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
paramLayout->addWidget(fswtchParamGV[i]); paramLayout->addWidget(fswtchParamGV[i]);
@ -150,11 +147,13 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
fswtchParamT[i] = new QComboBox(this); fswtchParamT[i] = new QComboBox(this);
fswtchParamT[i]->setProperty("index", i); fswtchParamT[i]->setProperty("index", i);
paramLayout->addWidget(fswtchParamT[i]); paramLayout->addWidget(fswtchParamT[i]);
fswtchParamT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
fswtchParamArmT[i] = new QComboBox(this); fswtchParamArmT[i] = new QComboBox(this);
fswtchParamArmT[i]->setProperty("index", i); fswtchParamArmT[i]->setProperty("index", i);
fswtchParamArmT[i]->setEditable(true); fswtchParamArmT[i]->setEditable(true);
fswtchParamArmT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
paramLayout->addWidget(fswtchParamArmT[i]); paramLayout->addWidget(fswtchParamArmT[i]);
connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
@ -177,28 +176,31 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic())); connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
#endif #endif
QHBoxLayout *repeatLayout = new QHBoxLayout(); QHBoxLayout * repeatLayout = new QHBoxLayout();
gridLayout->addLayout(repeatLayout, i+1, 4); tableLayout->addLayout(i, 4, repeatLayout);
fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam); fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam);
fswtchRepeat[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
repeatLayout->addWidget(fswtchRepeat[i], i+1); repeatLayout->addWidget(fswtchRepeat[i], i+1);
connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified())); connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));
fswtchEnable[i] = new QCheckBox(this); fswtchEnable[i] = new QCheckBox(this);
fswtchEnable[i]->setProperty("index", i); fswtchEnable[i]->setProperty("index", i);
fswtchEnable[i]->setText(tr("ON")); fswtchEnable[i]->setText(tr("ON"));
fswtchEnable[i]->setFixedWidth( 80 ); fswtchEnable[i]->setFixedWidth(200);
repeatLayout->addWidget(fswtchEnable[i], i+1); repeatLayout->addWidget(fswtchEnable[i], i+1);
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
} }
// Push rows upward
addDoubleSpring(gridLayout, 5, num_fsw+1);
disableMouseScrolling(); disableMouseScrolling();
lock = false; lock = false;
update();
tableLayout->getTableWidget()->resizeColumnsToContents();
tableLayout->getTableWidget()->setColumnWidth(3, 300);
} }
CustomFunctionsPanel::~CustomFunctionsPanel() CustomFunctionsPanel::~CustomFunctionsPanel()
{ {
} }

View file

@ -13,17 +13,13 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
{ {
int channelsMax = model.getChannelsMax(true); int channelsMax = model.getChannelsMax(true);
QGridLayout * gridLayout = new QGridLayout(this); QStringList headerLabels;
headerLabels << "#" << tr("Function") << tr("V1") << tr("V2") << tr("AND Switch");
int col = 1;
addLabel(gridLayout, tr("Function"), col++);
addLabel(gridLayout, tr("V1"), col++);
addLabel(gridLayout, tr("V2"), col++);
addLabel(gridLayout, tr("AND Switch"), col++);
if (firmware->getCapability(LogicalSwitchesExt)) { if (firmware->getCapability(LogicalSwitchesExt)) {
addLabel(gridLayout, tr("Duration"), col++); headerLabels << tr("Duration") << tr("Delay");
addLabel(gridLayout, tr("Delay"), col++);
} }
TableLayout * tableLayout = new TableLayout(this, firmware->getCapability(LogicalSwitches), headerLabels);
lock = true; lock = true;
for (int i=0; i<firmware->getCapability(LogicalSwitches); i++) { for (int i=0; i<firmware->getCapability(LogicalSwitches); i++) {
@ -35,20 +31,21 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
label->setMouseTracking(true); label->setMouseTracking(true);
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint))); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0); tableLayout->addWidget(i, 0, label);
// The function // The function
csw[i] = new QComboBox(this); csw[i] = new QComboBox(this);
csw[i]->setProperty("index", i); csw[i]->setProperty("index", i);
connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
gridLayout->addWidget(csw[i], i+1, 1); tableLayout->addWidget(i, 1, csw[i]);
// V1 // V1
QHBoxLayout *v1Layout = new QHBoxLayout();
cswitchSource1[i] = new QComboBox(this); cswitchSource1[i] = new QComboBox(this);
cswitchSource1[i]->setProperty("index",i); cswitchSource1[i]->setProperty("index",i);
cswitchSource1[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int))); connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int)));
gridLayout->addWidget(cswitchSource1[i], i+1, 2); v1Layout->addWidget(cswitchSource1[i]);
cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this); cswitchValue[i] = new QDoubleSpinBox(this);
cswitchValue[i]->setMaximum(channelsMax); cswitchValue[i]->setMaximum(channelsMax);
cswitchValue[i]->setMinimum(-channelsMax); cswitchValue[i]->setMinimum(-channelsMax);
@ -56,13 +53,15 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
cswitchValue[i]->setDecimals(0); cswitchValue[i]->setDecimals(0);
cswitchValue[i]->setProperty("index", i); cswitchValue[i]->setProperty("index", i);
connect(cswitchValue[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); connect(cswitchValue[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
gridLayout->addWidget(cswitchValue[i], i+1, 2); v1Layout->addWidget(cswitchValue[i]);
cswitchValue[i]->setVisible(false); cswitchValue[i]->setVisible(false);
tableLayout->addLayout(i, 2, v1Layout);
// V2 // V2
QHBoxLayout *v2Layout = new QHBoxLayout(); QHBoxLayout *v2Layout = new QHBoxLayout();
cswitchSource2[i] = new QComboBox(this); cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i); cswitchSource2[i]->setProperty("index", i);
cswitchSource2[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int))); connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
v2Layout->addWidget(cswitchSource2[i]); v2Layout->addWidget(cswitchSource2[i]);
cswitchSource2[i]->setVisible(false); cswitchSource2[i]->setVisible(false);
@ -90,13 +89,14 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
connect(cswitchTOffset[i],SIGNAL(editingFinished()),this,SLOT(edited())); connect(cswitchTOffset[i],SIGNAL(editingFinished()),this,SLOT(edited()));
v2Layout->addWidget(cswitchTOffset[i]); v2Layout->addWidget(cswitchTOffset[i]);
cswitchTOffset[i]->setVisible(false); cswitchTOffset[i]->setVisible(false);
gridLayout->addLayout(v2Layout, i+1, 3); tableLayout->addLayout(i, 3, v2Layout);
// AND // AND
cswitchAnd[i] = new QComboBox(this); cswitchAnd[i] = new QComboBox(this);
cswitchAnd[i]->setProperty("index", i); cswitchAnd[i]->setProperty("index", i);
cswitchAnd[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
gridLayout->addWidget(cswitchAnd[i], i+1, 4); tableLayout->addWidget(i, 4, cswitchAnd[i]);
if (firmware->getCapability(LogicalSwitchesExt)) { if (firmware->getCapability(LogicalSwitchesExt)) {
// Duration // Duration
@ -108,7 +108,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setAccelerated(true);
cswitchDuration[i]->setDecimals(1); cswitchDuration[i]->setDecimals(1);
connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double))); connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
gridLayout->addWidget(cswitchDuration[i], i+1, 5); tableLayout->addWidget(i, 5, cswitchDuration[i]);
// Delay // Delay
cswitchDelay[i] = new QDoubleSpinBox(this); cswitchDelay[i] = new QDoubleSpinBox(this);
@ -119,15 +119,14 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setAccelerated(true);
cswitchDelay[i]->setDecimals(1); cswitchDelay[i]->setDecimals(1);
connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double))); connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
gridLayout->addWidget(cswitchDelay[i], i+1, 6); tableLayout->addWidget(i, 6, cswitchDelay[i]);
} }
} }
// Push rows upward
addVSpring(gridLayout,0,firmware->getCapability(LogicalSwitches)+1);
disableMouseScrolling(); disableMouseScrolling();
lock = false; lock = false;
update();
tableLayout->getTableWidget()->resizeColumnsToContents();
} }
LogicalSwitchesPanel::~LogicalSwitchesPanel() LogicalSwitchesPanel::~LogicalSwitchesPanel()