PrintDialog / CompareDialog refactoring
This commit is contained in:
@@ -11,7 +11,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
firmware(firmware),
|
||||
ed(expoData),
|
||||
inputName(inputName),
|
||||
modelPrinter(firmware, &generalSettings, &model)
|
||||
modelPrinter(firmware, generalSettings, model)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QLabel * lb_fp[] = {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 };
|
||||
@@ -49,7 +49,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
else {
|
||||
int mask=1;
|
||||
for (int i=0; i<9 ; i++) {
|
||||
if ((ed->phases & mask)==0) {
|
||||
if ((ed->flightModes & mask)==0) {
|
||||
cb_fp[i]->setChecked(true);
|
||||
}
|
||||
mask <<= 1;
|
||||
@@ -157,18 +157,18 @@ void ExpoDialog::valuesChanged()
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
inputName = ui->inputName->text();
|
||||
|
||||
ed->phases=0;
|
||||
ed->flightModes=0;
|
||||
for (int i=8; i>=0 ; i--) {
|
||||
if (!cb_fp[i]->checkState()) {
|
||||
ed->phases+=1;
|
||||
ed->flightModes+=1;
|
||||
}
|
||||
ed->phases<<=1;
|
||||
ed->flightModes<<=1;
|
||||
}
|
||||
ed->phases>>=1;
|
||||
ed->flightModes>>=1;
|
||||
if (firmware->getCapability(FlightModes)) {
|
||||
int zeros=0;
|
||||
int ones=0;
|
||||
int phtemp=ed->phases;
|
||||
int phtemp=ed->flightModes;
|
||||
for (int i=0; i<firmware->getCapability(FlightModes); i++) {
|
||||
if (phtemp & 1) {
|
||||
ones++;
|
||||
@@ -179,7 +179,7 @@ void ExpoDialog::valuesChanged()
|
||||
phtemp >>=1;
|
||||
}
|
||||
if (zeros==1) {
|
||||
phtemp=ed->phases;
|
||||
phtemp=ed->flightModes;
|
||||
for (int i=0; i<firmware->getCapability(FlightModes); i++) {
|
||||
if ((phtemp & 1)==0) {
|
||||
break;
|
||||
@@ -188,7 +188,7 @@ void ExpoDialog::valuesChanged()
|
||||
}
|
||||
}
|
||||
else if (ones==1) {
|
||||
phtemp=ed->phases;
|
||||
phtemp=ed->flightModes;
|
||||
for (int i=0; i<firmware->getCapability(FlightModes); i++) {
|
||||
if (phtemp & 1) {
|
||||
break;
|
||||
@@ -198,7 +198,7 @@ void ExpoDialog::valuesChanged()
|
||||
}
|
||||
}
|
||||
else {
|
||||
ed->phases=0;
|
||||
ed->flightModes=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
expoInserted(false),
|
||||
modelPrinter(firmware, &generalSettings, &model)
|
||||
modelPrinter(firmware, generalSettings, model)
|
||||
{
|
||||
inputsCount = firmware->getCapability(VirtualInputs);
|
||||
if (inputsCount == 0)
|
||||
@@ -140,14 +140,14 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
||||
if (new_ch) *new_ch = 1;
|
||||
}
|
||||
else {
|
||||
ExpoData *md = &model->expoData[dest];
|
||||
ExpoData & input = model->expoData[dest];
|
||||
|
||||
if ((dest == 0) || (model->expoData[dest-1].chn != md->chn)) {
|
||||
if ((dest == 0) || (model->expoData[dest-1].chn != input.chn)) {
|
||||
if (new_ch) *new_ch = 1;
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
str += QString("%1").arg(modelPrinter.printInputName(md->chn), -10, ' ');
|
||||
str += QString("%1").arg(modelPrinter.printInputName(input.chn), -10, ' ');
|
||||
else
|
||||
str = modelPrinter.printInputName(md->chn);
|
||||
str = modelPrinter.printInputName(input.chn);
|
||||
}
|
||||
else {
|
||||
if (firmware->getCapability(VirtualInputs))
|
||||
@@ -156,7 +156,7 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
||||
str = " ";
|
||||
}
|
||||
str.replace(" ", " ");
|
||||
str += modelPrinter.printInputLine(md);
|
||||
str += modelPrinter.printInputLine(input);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
|
||||
else {
|
||||
int mask=1;
|
||||
for (int i=0; i<9 ; i++) {
|
||||
if ((md->phases & mask)==0) {
|
||||
if ((md->flightModes & mask)==0) {
|
||||
cb_fp[i]->setChecked(true);
|
||||
}
|
||||
mask <<= 1;
|
||||
@@ -164,14 +164,14 @@ void MixerDialog::valuesChanged()
|
||||
md->name[i]=ui->mixerName->text().toAscii().at(i);
|
||||
}
|
||||
md->name[i]=0;
|
||||
md->phases=0;
|
||||
md->flightModes=0;
|
||||
for (int i=8; i>=0 ; i--) {
|
||||
if (!cb_fp[i]->checkState()) {
|
||||
md->phases+=1;
|
||||
md->flightModes+=1;
|
||||
}
|
||||
md->phases<<=1;
|
||||
md->flightModes<<=1;
|
||||
}
|
||||
md->phases>>=1;
|
||||
md->flightModes>>=1;
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
mixInserted(false),
|
||||
highlightedSource(0),
|
||||
modelPrinter(firmware, &generalSettings, &model)
|
||||
modelPrinter(firmware, generalSettings, model)
|
||||
{
|
||||
QGridLayout * mixesLayout = new QGridLayout(this);
|
||||
|
||||
@@ -56,11 +56,11 @@ void MixesPanel::update()
|
||||
unsigned int outputs = firmware->getCapability(Outputs);
|
||||
|
||||
for (i=0; i<firmware->getCapability(Mixes); i++) {
|
||||
MixData *md = &model->mixData[i];
|
||||
// qDebug() << "md->destCh: " << md->destCh;
|
||||
if (md->destCh==0 || md->destCh>outputs) continue;
|
||||
MixData & mix = model->mixData[i];
|
||||
// qDebug() << "mix.destCh: " << mix.destCh;
|
||||
if (mix.destCh==0 || mix.destCh>outputs) continue;
|
||||
QString str = "";
|
||||
while (curDest < md->destCh-1) {
|
||||
while (curDest < mix.destCh-1) {
|
||||
curDest++;
|
||||
AddMixerLine(-curDest);
|
||||
}
|
||||
@@ -133,14 +133,14 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
||||
if (new_ch) *new_ch = 1;
|
||||
}
|
||||
else {
|
||||
MixData *md = &model->mixData[dest];
|
||||
//md->destCh from 1 to 32
|
||||
str = modelPrinter.printMixerName(md->destCh);
|
||||
MixData & mix = model->mixData[dest];
|
||||
//mix->destCh from 1 to 32
|
||||
str = modelPrinter.printMixerName(mix.destCh);
|
||||
|
||||
if ((dest == 0) || (model->mixData[dest-1].destCh != md->destCh)) {
|
||||
if ((dest == 0) || (model->mixData[dest-1].destCh != mix.destCh)) {
|
||||
if (new_ch) *new_ch = 1;
|
||||
//highlight channel if needed
|
||||
if (md->destCh == highlightedSource) {
|
||||
if (mix.destCh == highlightedSource) {
|
||||
str = "<b>" + str + "</b>";
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
||||
str.fill(' ');
|
||||
}
|
||||
|
||||
str += modelPrinter.printMixerLine(md, highlightedSource);
|
||||
str += modelPrinter.printMixerLine(mix, highlightedSource);
|
||||
}
|
||||
return str.replace(" ", " ");
|
||||
}
|
||||
@@ -303,10 +303,11 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||
int idx; // mixer index
|
||||
int dch;
|
||||
|
||||
if(destIdx<0) {
|
||||
if (destIdx < 0) {
|
||||
dch = -destIdx;
|
||||
idx = getMixerIndex(dch) - 1; //get mixer index to insert
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
idx = destIdx;
|
||||
dch = model->mixData[idx].destCh;
|
||||
}
|
||||
@@ -314,14 +315,14 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||
QByteArray mxData = mimeData->data("application/x-companion-mix");
|
||||
|
||||
int i = 0;
|
||||
while(i<mxData.size()) {
|
||||
while (i < mxData.size()) {
|
||||
idx++;
|
||||
if(idx==firmware->getCapability(Mixes)) break;
|
||||
if (idx == firmware->getCapability(Mixes)) break;
|
||||
|
||||
if (!gm_insertMix(idx))
|
||||
break;
|
||||
MixData *md = &model->mixData[idx];
|
||||
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
|
||||
MixData * md = &model->mixData[idx];
|
||||
memcpy(md, mxData.mid(i, sizeof(MixData)).constData(), sizeof(MixData));
|
||||
md->destCh = dch;
|
||||
i += sizeof(MixData);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "ui_setup_module.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget *prevFocus):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
@@ -35,10 +36,11 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
||||
}
|
||||
|
||||
ui->countdownBeep->setField(timer.countdownBeep, this);
|
||||
ui->countdownBeep->addItem(tr("Silent"), 0);
|
||||
ui->countdownBeep->addItem(tr("Beeps"), 1);
|
||||
ui->countdownBeep->addItem(tr("Silent"), TimerData::COUNTDOWN_SILENT);
|
||||
ui->countdownBeep->addItem(tr("Beeps"), TimerData::COUNTDOWN_BEEPS);
|
||||
if (IS_ARM(board) || IS_2560(board)) {
|
||||
ui->countdownBeep->addItem(tr("Voice"), 2);
|
||||
ui->countdownBeep->addItem(tr("Voice"), TimerData::COUNTDOWN_VOICE);
|
||||
ui->countdownBeep->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC);
|
||||
}
|
||||
|
||||
ui->persistent->setField(timer.persistent, this);
|
||||
@@ -167,7 +169,7 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
|
||||
// The protocols available on this board
|
||||
for (int i=0; i<PROTO_LAST; i++) {
|
||||
if (GetEepromInterface()->isAvailable((Protocol)i, moduleIdx)) {
|
||||
ui->protocol->addItem(getProtocolStr(i), (QVariant)i);
|
||||
ui->protocol->addItem(ModelPrinter::printModuleProtocol(i), (QVariant)i);
|
||||
if (i == module.protocol) ui->protocol->setCurrentIndex(ui->protocol->count()-1);
|
||||
}
|
||||
}
|
||||
@@ -756,7 +758,7 @@ void SetupPanel::populateThrottleSourceCB()
|
||||
|
||||
int channels = (IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16);
|
||||
for (int i=0; i<channels; i++) {
|
||||
ui->throttleSource->addItem(QObject::tr("CH%1").arg(i+1, 2, 10, QChar('0')), THROTTLE_SOURCE_FIRST_CHANNEL+i);
|
||||
ui->throttleSource->addItem(ModelPrinter::printChannelName(i), THROTTLE_SOURCE_FIRST_CHANNEL+i);
|
||||
if (model->thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i))
|
||||
ui->throttleSource->setCurrentIndex(ui->throttleSource->count()-1);
|
||||
}
|
||||
|
||||
@@ -29,20 +29,10 @@ TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog, Mod
|
||||
update();
|
||||
|
||||
ui->UnitCB->setCurrentIndex(analog.type);
|
||||
if (!IS_TARANIS(firmware->getBoard())) {
|
||||
ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level);
|
||||
ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater);
|
||||
ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level);
|
||||
ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater);
|
||||
}
|
||||
else {
|
||||
ui->alarm1LevelCB->hide();
|
||||
ui->alarm2LevelCB->hide();
|
||||
ui->alarm1GreaterCB->hide();
|
||||
ui->alarm2GreaterCB->hide();
|
||||
ui->alarm1Label->setText(tr("Low Alarm"));
|
||||
ui->alarm2Label->setText(tr("Critical Alarm"));
|
||||
}
|
||||
ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level);
|
||||
ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater);
|
||||
ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level);
|
||||
ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater);
|
||||
|
||||
if (!(firmware->getCapability(Telemetry) & TM_HASOFFSET)) {
|
||||
ui->CalibSB->hide();
|
||||
|
||||
Reference in New Issue
Block a user