From 365c2f9e34b0f322e0d53e658ed085facb36f7c8 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Mon, 7 Jul 2014 21:38:55 +0200 Subject: [PATCH] Re #1457 - cleanup --- companion/src/simulation/simulatordialog.cpp | 42 ++++++++++---------- companion/src/simulation/simulatordialog.h | 3 -- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 7b6faf948..005c8cc55 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -282,9 +282,6 @@ void SimulatorDialog::initUi(T * ui) trimHRight = ui->trimHRight; trimVRight = ui->trimVRight; tabWidget = ui->tabWidget; - logicalSwitchesLayout = ui->logicalSwitchesLayout; - channelsLayout = ui->channelsLayout; - gvarsLayout = ui->gvarsLayout; leftXPerc = ui->leftXPerc; leftYPerc = ui->leftYPerc; rightXPerc = ui->rightXPerc; @@ -358,26 +355,26 @@ void SimulatorDialog::initUi(T * ui) int outputs = std::min(32,GetCurrentFirmware()->getCapability(Outputs)); if (outputs <= 16) { - int idx = tabWidget->indexOf(ui->outputs2); - tabWidget->removeTab(idx); + // hide second Outputs tab + tabWidget->removeTab(tabWidget->indexOf(ui->outputs2)); } else { tabWidget->setTabText(tabWidget->indexOf(ui->outputs), tr("Outputs") + QString(" 1-%1").arg(16)); tabWidget->setTabText(tabWidget->indexOf(ui->outputs2), tr("Outputs") + QString(" 17-%1").arg(outputs)); } for (int i=0; ichannelsLayout; + QGridLayout * outputTab = ui->channelsLayout; int column = i / (std::min(16,outputs)/2); - int line = i % (std::min(16,outputs)/2); + int line = i % (std::min(16,outputs)/2); if (i >= 16 ) { - dest = ui->channelsLayout2; - column = (i-16) / (8); - line = (i-16) % (8); + outputTab = ui->channelsLayout2; + column = (i-16) / (std::min(16,outputs-16)/2); + line = (i-16) % (std::min(16,outputs-16)/2); } QLabel * label = new QLabel(tabWidget); ModelData model; label->setText(RawSource(SOURCE_TYPE_CH, i).toString(model)); - dest->addWidget(label, line, column == 0 ? 0 : 5, 1, 1); + outputTab->addWidget(label, line, column == 0 ? 0 : 5, 1, 1); QSlider * slider = new QSlider(tabWidget); slider->setEnabled(false); @@ -403,23 +400,23 @@ void SimulatorDialog::initUi(T * ui) slider->setInvertedAppearance(false); slider->setTickPosition(QSlider::TicksBelow); channelSliders << slider; - dest->addWidget(slider, line, column == 0 ? 1 : 4, 1, 1); + outputTab->addWidget(slider, line, column == 0 ? 1 : 4, 1, 1); QLabel * value = new QLabel(tabWidget); value->setMinimumSize(QSize(50, 0)); value->setAlignment(Qt::AlignCenter); channelValues << value; - dest->addWidget(value, line, column == 0 ? 2 : 3, 1, 1); + outputTab->addWidget(value, line, column == 0 ? 2 : 3, 1, 1); } int switches = GetCurrentFirmware()->getCapability(LogicalSwitches); for (int i=0; iaddWidget(swtch1, i / (switches/2), i % (switches/2), 1, 1); + QFrame * swtch = createLogicalSwitch(tabWidget, i, logicalSwitchLabels); + ui->logicalSwitchesLayout->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1); if (outputs > 16) { // repeat logical switches on second outputs tab - QFrame * swtch2 = createLogicalSwitch(tabWidget, i, logicalSwitchLabels2); - ui->logicalSwitchesLayout2->addWidget(swtch2, i / (switches/2), i % (switches/2), 1, 1); + swtch = createLogicalSwitch(tabWidget, i, logicalSwitchLabels2); + ui->logicalSwitchesLayout2->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1); } } @@ -429,16 +426,16 @@ void SimulatorDialog::initUi(T * ui) for (int fm=0; fmsetText(QString("FM%1").arg(fm)); - gvarsLayout->addWidget(label, 0, fm+1); + ui->gvarsLayout->addWidget(label, 0, fm+1); } for (int i=0; isetText(QString("GV%1").arg(i+1)); - gvarsLayout->addWidget(label, i+1, 0); + ui->gvarsLayout->addWidget(label, i+1, 0); for (int fm=0; fmaddWidget(value, i+1, fm+1); + ui->gvarsLayout->addWidget(value, i+1, fm+1); } } } @@ -453,7 +450,7 @@ void SimulatorDialog::initUi(T * ui) QFrame * SimulatorDialog::createLogicalSwitch(QWidget * parent, int switchNo, QVector & labels) { - QFrame * swtch = new QFrame(tabWidget); + QFrame * swtch = new QFrame(parent); swtch->setAutoFillBackground(true); swtch->setFrameShape(QFrame::Panel); swtch->setFrameShadow(QFrame::Raised); @@ -857,8 +854,9 @@ void SimulatorDialog::setValues() for (int i=0; igetCapability(LogicalSwitches); i++) { logicalSwitchLabels[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF); - if (!logicalSwitchLabels2.isEmpty()) + if (!logicalSwitchLabels2.isEmpty()) { logicalSwitchLabels2[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF); + } } for (unsigned int gv=0; gv logicalSwitchLabels; QVector logicalSwitchLabels2; QVector channelSliders;