Global Functions now integrated inside Companion - Fixes #502

This commit is contained in:
bsongis
2014-09-18 15:32:55 +02:00
parent 343e395652
commit ef7bbea285
45 changed files with 685 additions and 687 deletions
-2
View File
@@ -11,7 +11,6 @@ set(modeledit_NAMES
)
set(modeledit_SRCS
modelpanel.cpp
flightmodes.cpp
inputs.cpp
mixes.cpp
@@ -25,7 +24,6 @@ set(modeledit_SRCS
)
set(modeledit_HDRS
modelpanel.h
flightmodes.h
inputs.h
mixes.h
+6 -6
View File
@@ -187,7 +187,7 @@ void Channels::symlimitsEdited()
{
QCheckBox * ckb = qobject_cast<QCheckBox*>(sender());
int index = ckb->property("index").toInt();
model.limitData[index].symetrical = (ckb->checkState() ? 1 : 0);
model->limitData[index].symetrical = (ckb->checkState() ? 1 : 0);
emit modified();
}
@@ -197,7 +197,7 @@ void Channels::nameEdited()
lock = true;
QLineEdit *le = qobject_cast<QLineEdit*>(sender());
int index = le->property("index").toInt();
strcpy(model.limitData[index].name, le->text().toAscii());
strcpy(model->limitData[index].name, le->text().toAscii());
lock = false;
emit modified();
}
@@ -205,7 +205,7 @@ void Channels::nameEdited()
void Channels::refreshExtendedLimits()
{
int channelMax = model.getChannelsMax();
int channelMax = model->getChannelsMax();
foreach(LimitsGroup *group, limitsGroups) {
group->updateMinMax(10*channelMax);
@@ -218,7 +218,7 @@ void Channels::invEdited()
{
QComboBox *cb = qobject_cast<QComboBox*>(sender());
int index = cb->property("index").toInt();
model.limitData[index].revert = cb->currentIndex();
model->limitData[index].revert = cb->currentIndex();
emit modified();
}
@@ -226,7 +226,7 @@ void Channels::curveEdited()
{
QComboBox *cb = qobject_cast<QComboBox*>(sender());
int index = cb->property("index").toInt();
model.limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt());
model->limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt());
emit modified();
}
@@ -234,7 +234,7 @@ void Channels::ppmcenterEdited()
{
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
int index = sb->property("index").toInt();
model.limitData[index].ppmCenter = sb->value() - 1500;
model->limitData[index].ppmCenter = sb->value() - 1500;
emit modified();
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CHANNELS_H
#define CHANNELS_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QSpinBox>
class GVarGroup;
+52 -52
View File
@@ -204,7 +204,7 @@ void Curves::resetCurve()
int index = button->property("index").toInt();
int res = QMessageBox::question(this, "companion", tr("Are you sure you want to reset curve %1 ?").arg(index+1), QMessageBox::Yes | QMessageBox::No);
if (res == QMessageBox::Yes) {
model.curves[index].clear(5);
model->curves[index].clear(5);
update();
emit modified();
}
@@ -223,7 +223,7 @@ void Curves::update()
lock = true;
if (firmware->getCapability(HasCvNames)) {
ui->curveName->setText(model.curves[currentCurve].name);
ui->curveName->setText(model->curves[currentCurve].name);
}
updateCurveType();
@@ -245,21 +245,21 @@ void Curves::updateCurveType()
int index = 0;
if (firmware->getCapability(EnhancedCurves)) {
index = model.curves[currentCurve].count - 2;
index = model->curves[currentCurve].count - 2;
}
else {
ui->curveSmooth->hide();
if (model.curves[currentCurve].count == 5)
if (model->curves[currentCurve].count == 5)
index = 1;
else if (model.curves[currentCurve].count == 9)
else if (model->curves[currentCurve].count == 9)
index = 2;
else if (model.curves[currentCurve].count == 17)
else if (model->curves[currentCurve].count == 17)
index = 3;
}
ui->curvePoints->setCurrentIndex(index);
ui->curveCustom->setCurrentIndex(model.curves[currentCurve].type);
ui->curveSmooth->setCurrentIndex(model.curves[currentCurve].smooth);
ui->curveCustom->setCurrentIndex(model->curves[currentCurve].type);
ui->curveSmooth->setCurrentIndex(model->curves[currentCurve].smooth);
lock = false;
}
@@ -295,36 +295,36 @@ void Curves::updateCurve()
for (int k=0; k<numcurves; k++) {
pen.setColor(colors[k]);
if (currentCurve!=k && visibleCurves[k]) {
int numpoints = model.curves[k].count;
int numpoints = model->curves[k].count;
for (int i=0; i<numpoints-1; i++) {
if (model.curves[k].type == CurveData::CURVE_TYPE_CUSTOM)
scene->addLine(centerX + (qreal)model.curves[k].points[i].x*width/200,centerY - (qreal)model.curves[k].points[i].y*height/200,centerX + (qreal)model.curves[k].points[i+1].x*width/200,centerY - (qreal)model.curves[k].points[i+1].y*height/200, pen);
if (model->curves[k].type == CurveData::CURVE_TYPE_CUSTOM)
scene->addLine(centerX + (qreal)model->curves[k].points[i].x*width/200,centerY - (qreal)model->curves[k].points[i].y*height/200,centerX + (qreal)model->curves[k].points[i+1].x*width/200,centerY - (qreal)model->curves[k].points[i+1].y*height/200, pen);
else
scene->addLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i+1].y*height/200, pen);
scene->addLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)model->curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)model->curves[k].points[i+1].y*height/200, pen);
}
}
}
int numpoints = model.curves[currentCurve].count;
int numpoints = model->curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
nodel = nodex;
nodex = new Node();
nodex->setProperty("index", i);
nodex->setColor(colors[currentCurve]);
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
if (model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
if (i>0 && i<numpoints-1) {
nodex->setFixedX(false);
nodex->setMinX(model.curves[currentCurve].points[i-1].x);
nodex->setMaxX(model.curves[currentCurve].points[i+1].x);
nodex->setMinX(model->curves[currentCurve].points[i-1].x);
nodex->setMaxX(model->curves[currentCurve].points[i+1].x);
}
else {
nodex->setFixedX(true);
}
nodex->setPos(centerX + (qreal)model.curves[currentCurve].points[i].x*width/200,centerY - (qreal)model.curves[currentCurve].points[i].y*height/200);
nodex->setPos(centerX + (qreal)model->curves[currentCurve].points[i].x*width/200,centerY - (qreal)model->curves[currentCurve].points[i].y*height/200);
}
else {
nodex->setFixedX(true);
nodex->setPos(GFX_MARGIN + i*width/(numpoints-1), centerY - (qreal)model.curves[currentCurve].points[i].y*height/200);
nodex->setPos(GFX_MARGIN + i*width/(numpoints-1), centerY - (qreal)model->curves[currentCurve].points[i].y*height/200);
}
connect(nodex, SIGNAL(moved(int, int)), this, SLOT(onNodeMoved(int, int)));
connect(nodex, SIGNAL(focus()), this, SLOT(onNodeFocus()));
@@ -340,23 +340,23 @@ void Curves::updateCurvePoints()
{
lock = true;
int count = model.curves[currentCurve].count;
int count = model->curves[currentCurve].count;
for (int i=0; i<count; i++) {
spny[i]->show();
spny[i]->setValue(model.curves[currentCurve].points[i].y);
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
spny[i]->setValue(model->curves[currentCurve].points[i].y);
if (model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
spnx[i]->show();
if (i==0 || i==model.curves[currentCurve].count-1) {
if (i==0 || i==model->curves[currentCurve].count-1) {
spnx[i]->setDisabled(true);
spnx[i]->setMaximum(+100);
spnx[i]->setMinimum(-100);
}
else {
spnx[i]->setDisabled(false);
spnx[i]->setMaximum(model.curves[currentCurve].points[i+1].x);
spnx[i]->setMinimum(model.curves[currentCurve].points[i-1].x);
spnx[i]->setMaximum(model->curves[currentCurve].points[i+1].x);
spnx[i]->setMinimum(model->curves[currentCurve].points[i-1].x);
}
spnx[i]->setValue(model.curves[currentCurve].points[i].x);
spnx[i]->setValue(model->curves[currentCurve].points[i].x);
}
else {
spnx[i]->hide();
@@ -374,8 +374,8 @@ void Curves::onPointEdited()
{
if (!lock) {
int index = sender()->property("index").toInt();
model.curves[currentCurve].points[index].x = spnx[index]->value();
model.curves[currentCurve].points[index].y = spny[index]->value();
model->curves[currentCurve].points[index].x = spnx[index]->value();
model->curves[currentCurve].points[index].y = spny[index]->value();
updateCurve();
emit modified();
}
@@ -386,13 +386,13 @@ void Curves::onNodeMoved(int x, int y)
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
model.curves[currentCurve].points[index].x = x;
model.curves[currentCurve].points[index].y = y;
model->curves[currentCurve].points[index].x = x;
model->curves[currentCurve].points[index].y = y;
spnx[index]->setValue(x);
spny[index]->setValue(y);
if (index > 0)
spnx[index-1]->setMaximum(x);
if (index < model.curves[currentCurve].count-1)
if (index < model->curves[currentCurve].count-1)
spnx[index+1]->setMinimum(x);
emit modified();
lock = false;
@@ -418,8 +418,8 @@ bool Curves::allowCurveType(int points, CurveData::CurveType type)
int totalpoints = 0;
for (int i=0; i<numcurves; i++) {
int cvPoints = (i==currentCurve ? points : model.curves[i].count);
CurveData::CurveType cvType = (i==currentCurve ? type : model.curves[i].type);
int cvPoints = (i==currentCurve ? points : model->curves[i].count);
CurveData::CurveType cvType = (i==currentCurve ? type : model->curves[i].type);
totalpoints += cvPoints + (cvType==CurveData::CURVE_TYPE_CUSTOM ? cvPoints-2 : 0);
}
@@ -438,13 +438,13 @@ void Curves::on_curvePoints_currentIndexChanged(int index)
if (!lock) {
int numpoints = ((QComboBox *)sender())->itemData(index).toInt();
if (allowCurveType(numpoints, model.curves[currentCurve].type)) {
model.curves[currentCurve].count = numpoints;
if (allowCurveType(numpoints, model->curves[currentCurve].type)) {
model->curves[currentCurve].count = numpoints;
// TODO something better + reuse!
for (int i=0; i<C9X_MAX_POINTS; i++) {
model.curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
model.curves[currentCurve].points[i].y = 0;
model->curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
model->curves[currentCurve].points[i].y = 0;
}
update();
@@ -461,13 +461,13 @@ void Curves::on_curveCustom_currentIndexChanged(int index)
if (!lock) {
CurveData::CurveType type = (CurveData::CurveType)index;
int numpoints = ui->curvePoints->itemData(ui->curvePoints->currentIndex()).toInt();
if (allowCurveType(model.curves[currentCurve].count, type)) {
model.curves[currentCurve].type = type;
if (allowCurveType(model->curves[currentCurve].count, type)) {
model->curves[currentCurve].type = type;
// TODO something better + reuse!
for (int i=0; i<C9X_MAX_POINTS; i++) {
model.curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
model.curves[currentCurve].points[i].y = 0;
model->curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
model->curves[currentCurve].points[i].y = 0;
}
update();
@@ -481,14 +481,14 @@ void Curves::on_curveCustom_currentIndexChanged(int index)
void Curves::on_curveSmooth_currentIndexChanged(int index)
{
model.curves[currentCurve].smooth = index;
model->curves[currentCurve].smooth = index;
update();
}
void Curves::on_curveName_editingFinished()
{
memset(model.curves[currentCurve].name, 0, sizeof(model.curves[currentCurve].name));
strcpy(model.curves[currentCurve].name, ui->curveName->text().toAscii());
memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name));
strcpy(model->curves[currentCurve].name, ui->curveName->text().toAscii());
emit modified();
}
@@ -528,12 +528,12 @@ void Curves::addTemplate(QString name, unsigned int flags, curveFunction functio
void Curves::on_curveApply_clicked()
{
int index = ui->curveType->currentIndex();
int numpoints = model.curves[currentCurve].count;
int numpoints = model->curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
float x;
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM)
x = model.curves[currentCurve].points[i].x;
if (model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM)
x = model->curves[currentCurve].points[i].x;
else
x = -100.0 + (200.0/(numpoints-1))*i;
@@ -553,7 +553,7 @@ void Curves::on_curveApply_clicked()
}
if (apply) {
model.curves[currentCurve].points[i].y = templates[index].function(x, ui->curveCoeff->value(), ui->yMin->value(), ui->yMid->value(), ui->yMax->value());
model->curves[currentCurve].points[i].y = templates[index].function(x, ui->curveCoeff->value(), ui->yMin->value(), ui->yMid->value(), ui->yMax->value());
}
}
@@ -571,12 +571,12 @@ void ModelEdit::clearCurves(bool ask)
}
curvesLock=true;
for (int j=0; j<16; j++) {
model.curves[j].count = 5;
model.curves[j].custom = false;
memset(model.curves[j].name, 0, sizeof(model.curves[j].name));
model->curves[j].count = 5;
model->curves[j].custom = false;
memset(model->curves[j].name, 0, sizeof(model->curves[j].name));
for (int i=0; i<17; i++) {
model.curves[j].points[i].x = 0;
model.curves[j].points[i].y = 0;
model->curves[j].points[i].x = 0;
model->curves[j].points[i].y = 0;
}
}
for (int i=0; i<17; i++) {
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CURVES_H
#define CURVES_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QSpinBox>
namespace Ui {
+73 -65
View File
@@ -47,8 +47,9 @@ void RepeatComboBox::update()
setCurrentIndex(value);
}
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
ModelPanel(parent, model, generalSettings, firmware),
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GenericPanel(parent, model, generalSettings, firmware),
functions(model ? model->customFn : generalSettings.customFn),
initialized(false)
#if defined(PHONON)
,
@@ -70,8 +71,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
if (!firmware->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) {
if (model.customFn[i].func==FuncPlayPrompt || model.customFn[i].func==FuncBackgroundMusic) {
QString temp = model.customFn[i].paramarm;
if (functions[i].func==FuncPlayPrompt || functions[i].func==FuncBackgroundMusic) {
QString temp = functions[i].paramarm;
if (!temp.isEmpty()) {
if (!paramarmList.contains(temp)) {
paramarmList.append(temp);
@@ -118,6 +119,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i);
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
fswtchSwtch[i]->setMaxVisibleItems(10);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
@@ -181,7 +183,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
QHBoxLayout *repeatLayout = new QHBoxLayout();
gridLayout->addLayout(repeatLayout, i+1, 4);
fswtchRepeat[i] = new RepeatComboBox(this, model.customFn[i].repeatParam);
fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam);
repeatLayout->addWidget(fswtchRepeat[i], i+1);
connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));
@@ -308,31 +310,32 @@ void CustomFunctionsPanel::onChildModified()
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
{
CustomFunctionData & cfn = model.customFn[i];
CustomFunctionData & cfn = functions[i];
AssignFunc func = (AssignFunc)fswtchFunc[i]->itemData(fswtchFunc[i]->currentIndex()).toInt();
unsigned int widgetsMask = 0;
if (modified) {
cfn.swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt());
cfn.func = (AssignFunc)fswtchFunc[i]->currentIndex();
cfn.func = func;
cfn.enabled = fswtchEnable[i]->isChecked();
cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex();
}
int index = fswtchFunc[i]->currentIndex();
if (index>=FuncOverrideCH1 && index<=FuncOverrideCH32) {
int channelsMax = model.getChannelsMax(true);
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-channelsMax);
fswtchParam[i]->setMaximum(channelsMax);
if (modified) {
cfn.param = fswtchParam[i]->value();
if (func>=FuncOverrideCH1 && func<=FuncOverrideCH32) {
if (model) {
int channelsMax = model->getChannelsMax(true);
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-channelsMax);
fswtchParam[i]->setMaximum(channelsMax);
if (modified) {
cfn.param = fswtchParam[i]->value();
}
fswtchParam[i]->setValue(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
}
fswtchParam[i]->setValue(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index==FuncLogs) {
else if (func==FuncLogs) {
fswtchParam[i]->setDecimals(1);
fswtchParam[i]->setMinimum(0);
fswtchParam[i]->setMaximum(25.5);
@@ -341,7 +344,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParam[i]->setValue(cfn.param/10.0);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
}
else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) {
else if (func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) {
if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex();
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
if (cfn.adjustMode==0) {
@@ -361,16 +364,16 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
}
else {
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param, cfn.adjustMode);
populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
}
else if (index==FuncReset) {
else if (func==FuncReset) {
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
}
else if (index>=FuncSetTimer1 && index<=FuncSetTimer2) {
else if (func>=FuncSetTimer1 && func<=FuncSetTimer2) {
if (modified) cfn.param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
@@ -379,34 +382,34 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParam[i]->setValue(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index==FuncVolume) {
else if (func==FuncVolume) {
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (index != FuncBackgroundMusic) {
else if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) {
if (func != FuncBackgroundMusic) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->update();
}
if (index==FuncPlayValue) {
if (func==FuncPlayValue) {
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT;
}
else if (index==FuncPlayPrompt || index==FuncPlayBoth) {
else if (func==FuncPlayPrompt || func==FuncPlayBoth) {
if (firmware->getCapability(VoicesAsNumbers)) {
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(0);
if (index==FuncPlayPrompt) {
if (func==FuncPlayPrompt) {
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE;
}
else {
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT;
fswtchParamGV[i]->setChecked(false);
}
fswtchParam[i]->setMaximum(index==FuncPlayBoth ? 254 : 255);
fswtchParam[i]->setMaximum(func==FuncPlayBoth ? 254 : 255);
if (modified) {
if (fswtchParamGV[i]->isChecked()) {
fswtchParam[i]->setMinimum(1);
@@ -416,7 +419,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
cfn.param = fswtchParam[i]->value();
}
}
if (cfn.param>250 && (index!=FuncPlayBoth)) {
if (cfn.param>250 && (func!=FuncPlayBoth)) {
fswtchParamGV[i]->setChecked(true);
fswtchParam[i]->setValue(cfn.param-250);
fswtchParam[i]->setMaximum(5);
@@ -448,7 +451,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
}
}
}
else if (index==FuncBackgroundMusic) {
else if (func==FuncBackgroundMusic) {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(cfn.paramarm, 0, sizeof(cfn.paramarm));
@@ -461,18 +464,18 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
}
}
}
else if (index==FuncPlaySound) {
else if (func==FuncPlaySound) {
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
else if (index==FuncPlayHaptic) {
else if (func==FuncPlayHaptic) {
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
}
else if (index==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) {
else if (func==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) {
if (modified) cfn.param = (uint8_t)fswtchBLcolor[i]->value();
fswtchBLcolor[i]->setValue(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_BL_COLOR;
@@ -482,7 +485,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setValue(cfn.param);
if (index <= FuncInstantTrim) {
if (func <= FuncInstantTrim) {
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
}
}
@@ -509,11 +512,11 @@ void CustomFunctionsPanel::update()
lock = true;
for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
if (!initialized) {
populateSwitchCB(fswtchSwtch[i], model.customFn[i].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[i], model.customFn[i].func);
populateGVmodeCB(fswtchGVmode[i], model.customFn[i].adjustMode);
populateFuncParamCB(fswtchParamT[i], model, model.customFn[i].func, model.customFn[i].param, model.customFn[i].adjustMode);
populateFuncParamArmTCB(fswtchParamArmT[i], model.customFn[i].paramarm, paramarmList);
populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[i], functions[i].func);
populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode);
populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode);
populateFuncParamArmTCB(fswtchParamArmT[i], functions[i].paramarm, paramarmList);
}
refreshCustomFunction(i);
}
@@ -527,14 +530,14 @@ void CustomFunctionsPanel::fswPaste()
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-fsw")) {
QByteArray fswData = mimeData->data("application/x-companion-fsw");
CustomFunctionData *fsw = &model.customFn[selectedFunction];
CustomFunctionData *fsw = &functions[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(CustomFunctionData)).constData(), sizeof(CustomFunctionData));
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.customFn[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[selectedFunction], model.customFn[selectedFunction].func);
populateGVmodeCB(fswtchGVmode[selectedFunction], model.customFn[selectedFunction].adjustMode);
populateFuncParamCB(fswtchParamT[selectedFunction], model, model.customFn[selectedFunction].func, model.customFn[selectedFunction].param, model.customFn[selectedFunction].adjustMode);
populateFuncParamArmTCB(fswtchParamArmT[selectedFunction], model.customFn[selectedFunction].paramarm, paramarmList);
populateSwitchCB(fswtchSwtch[selectedFunction], functions[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[selectedFunction], functions[selectedFunction].func);
populateGVmodeCB(fswtchGVmode[selectedFunction], functions[selectedFunction].adjustMode);
populateFuncParamCB(fswtchParamT[selectedFunction], functions[selectedFunction].func, functions[selectedFunction].param, functions[selectedFunction].adjustMode);
populateFuncParamArmTCB(fswtchParamArmT[selectedFunction], functions[selectedFunction].paramarm, paramarmList);
refreshCustomFunction(selectedFunction);
lock = false;
emit modified();
@@ -543,11 +546,11 @@ void CustomFunctionsPanel::fswPaste()
void CustomFunctionsPanel::fswDelete()
{
model.customFn[selectedFunction].clear();
functions[selectedFunction].clear();
// TODO update switch and func
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.customFn[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[selectedFunction], model.customFn[selectedFunction].func);
populateSwitchCB(fswtchSwtch[selectedFunction], functions[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
populateFuncCB(fswtchFunc[selectedFunction], functions[selectedFunction].func);
refreshCustomFunction(selectedFunction);
lock = false;
emit modified();
@@ -556,7 +559,7 @@ void CustomFunctionsPanel::fswDelete()
void CustomFunctionsPanel::fswCopy()
{
QByteArray fswData;
fswData.append((char*)&model.customFn[selectedFunction], sizeof(CustomFunctionData));
fswData.append((char*)&functions[selectedFunction], sizeof(CustomFunctionData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
@@ -592,21 +595,26 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
{
b->clear();
for (unsigned int i=0; i<FuncCount; i++) {
b->addItem(CustomFunctionData(AssignFunc(i)).funcToString());
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && (!model || !firmware->getCapability(SafetyChannelCustomFunction))) ||
((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && !firmware->getCapability(Gvars))
) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
// skipped
// b->addItem(CustomFunctionData(AssignFunc(i)).funcToString(), i);
// QModelIndex index = b->model()->index(i, 0);
// QVariant v(0);
// b->model()->setData(index, v, Qt::UserRole - 1);
}
else {
b->addItem(CustomFunctionData(AssignFunc(i)).funcToString(), i);
if (i == value) {
b->setCurrentIndex(b->count()-1);
}
}
}
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
}
void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
@@ -640,7 +648,7 @@ void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, Q
}
}
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
+7 -4
View File
@@ -1,7 +1,7 @@
#ifndef CUSTOMFUNCTIONS_H
#define CUSTOMFUNCTIONS_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
@@ -31,16 +31,19 @@ class RepeatComboBox: public QComboBox
int & repeatParam;
};
class CustomFunctionsPanel : public ModelPanel
class CustomFunctionsPanel : public GenericPanel
{
Q_OBJECT
public:
CustomFunctionsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
CustomFunctionsPanel(QWidget *parent, ModelData * mode, GeneralSettings & generalSettings, FirmwareInterface * firmware);
~CustomFunctionsPanel();
virtual void update();
protected:
CustomFunctionData * functions;
private slots:
void customFunctionEdited();
void fsw_customContextMenuRequested(QPoint pos);
@@ -58,7 +61,7 @@ class CustomFunctionsPanel : public ModelPanel
private:
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
bool initialized;
+4 -4
View File
@@ -15,7 +15,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
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 };
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
setWindowTitle(tr("Edit %1").arg(getInputStr(model, ed->chn)));
setWindowTitle(tr("Edit %1").arg(getInputStr(&model, ed->chn)));
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
@@ -60,7 +60,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
if (firmware->getCapability(VirtualInputs)) {
ui->inputName->setMaxLength(4);
populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
populateSourceCB(ui->sourceCB, ed->srcRaw, &model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
ui->sourceCB->removeItem(0);
}
else {
@@ -122,7 +122,7 @@ ExpoDialog::~ExpoDialog()
void ExpoDialog::updateScale()
{
if (firmware->getCapability(VirtualInputs) && ed->srcRaw.type == SOURCE_TYPE_TELEMETRY) {
RawSourceRange range = ed->srcRaw.getRange(model, generalSettings);
RawSourceRange range = ed->srcRaw.getRange(&model, generalSettings);
ui->scaleLabel->show();
ui->scale->show();
ui->scale->setDecimals(range.decimals);
@@ -146,7 +146,7 @@ void ExpoDialog::valuesChanged()
updateScale();
}
RawSourceRange range = srcRaw.getRange(model, generalSettings);
RawSourceRange range = srcRaw.getRange(&model, generalSettings);
ed->scale = round(float(ui->scale->value()) / range.step);
ed->carryTrim = 1 - ui->trimCB->currentIndex();
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
+14 -14
View File
@@ -196,24 +196,24 @@ void FlightModePanel::update()
for (int i=0; i<4; i++) {
int trimsMax = firmware->getCapability(ExtendedTrims);
if (trimsMax == 0 || !model.extendedTrims) {
if (trimsMax == 0 || !model->extendedTrims) {
trimsMax = 125;
}
trimsSlider[i]->setRange(-trimsMax, +trimsMax);
trimsValue[i]->setRange(-trimsMax, +trimsMax);
int chn = CONVERT_MODE(i+1)-1;
if (chn == 2/*TODO constant*/ && model.throttleReversed)
if (chn == 2/*TODO constant*/ && model->throttleReversed)
trimsSlider[i]->setInvertedAppearance(true);
trimUpdate(i);
}
if (ui->gvGB->isVisible()) {
for (int i=0; i<gvCount; i++) {
gvNames[i]->setText(model.gvars_names[i]);
gvValues[i]->setDisabled(model.isGVarLinked(phaseIdx, i));
gvValues[i]->setValue(model.getGVarValue(phaseIdx, i));
gvNames[i]->setText(model->gvars_names[i]);
gvValues[i]->setDisabled(model->isGVarLinked(phaseIdx, i));
gvValues[i]->setValue(model->getGVarValue(phaseIdx, i));
if (IS_TARANIS(GetEepromInterface()->getBoard()) && phaseIdx == 0) {
gvPopups[i]->setChecked(model.gvars_popups[i]);
gvPopups[i]->setChecked(model->gvars_popups[i]);
}
}
}
@@ -224,7 +224,7 @@ void FlightModePanel::update()
FlightModeData *phasere = &phase;
while (idx > 1024) {
idx -= 1025;
phasere = &model.flightModeData[idx];
phasere = &model->flightModeData[idx];
idx = phasere->rotaryEncoders[i];
reValues[i]->setDisabled(true);
}
@@ -267,7 +267,7 @@ void FlightModePanel::trimUpdate(unsigned int trim)
{
lock = true;
int chn = CONVERT_MODE(trim+1)-1;
int value = model.getTrimValue(phaseIdx, chn);
int value = model->getTrimValue(phaseIdx, chn);
trimsSlider[trim]->setValue(value);
trimsValue[trim]->setValue(value);
if (phase.trimMode[chn] < 0) {
@@ -302,8 +302,8 @@ void FlightModePanel::GVName_editingFinished()
if (!lock) {
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
int gvar = lineedit->property("index").toInt();
memset(&model.gvars_names[gvar], 0, sizeof(model.gvars_names[gvar]));
strcpy(model.gvars_names[gvar], lineedit->text().toAscii());
memset(&model->gvars_names[gvar], 0, sizeof(model->gvars_names[gvar]));
strcpy(model->gvars_names[gvar], lineedit->text().toAscii());
emit modified();
}
}
@@ -330,7 +330,7 @@ void FlightModePanel::phaseGVPopupToggled(bool checked)
{
QCheckBox *cb = qobject_cast<QCheckBox*>(sender());
int gvar = cb->property("index").toInt();
model.gvars_popups[gvar] = checked;
model->gvars_popups[gvar] = checked;
}
void FlightModePanel::phaseREValue_editingFinished()
@@ -397,7 +397,7 @@ void FlightModePanel::phaseTrim_valueChanged()
int trim = spinBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
int value = spinBox->value();
model.setTrimValue(phaseIdx, chn, value);
model->setTrimValue(phaseIdx, chn, value);
lock = true;
trimsSlider[trim]->setValue(value);
lock = false;
@@ -412,7 +412,7 @@ void FlightModePanel::phaseTrimSlider_valueChanged()
int trim = slider->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
int value = slider->value();
model.setTrimValue(phaseIdx, chn, value);
model->setTrimValue(phaseIdx, chn, value);
lock = true;
trimsValue[trim]->setValue(value);
lock = false;
@@ -452,7 +452,7 @@ void FlightModesPanel::onPhaseModified()
QString FlightModesPanel::getTabName(int index)
{
QString result = tr("Flight Mode %1").arg(index);
const char *name = model.flightModeData[index].name;
const char *name = model->flightModeData[index].name;
if (firmware->getCapability(FlightModesName) && strlen(name) > 0) {
result += tr(" (%1)").arg(name);
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef FLIGHTMODES_H
#define FLIGHTMODES_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QVector>
#include <QLabel>
#include <QTabWidget>
+12 -12
View File
@@ -27,12 +27,12 @@ void HeliPanel::update()
{
lock = true;
ui->swashTypeCB->setCurrentIndex(model.swashRingData.type);
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->swashRingValSB->setValue(model.swashRingData.value);
ui->swashInvertELE->setChecked(model.swashRingData.invertELE);
ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL);
ui->swashInvertCOL->setChecked(model.swashRingData.invertCOL);
ui->swashTypeCB->setCurrentIndex(model->swashRingData.type);
populateSourceCB(ui->swashCollectiveCB, model->swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->swashRingValSB->setValue(model->swashRingData.value);
ui->swashInvertELE->setChecked(model->swashRingData.invertELE);
ui->swashInvertAIL->setChecked(model->swashRingData.invertAIL);
ui->swashInvertCOL->setChecked(model->swashRingData.invertCOL);
lock = false;
}
@@ -40,12 +40,12 @@ void HeliPanel::update()
void HeliPanel::edited()
{
if (!lock) {
model.swashRingData.type = ui->swashTypeCB->currentIndex();
model.swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt();
model.swashRingData.value = ui->swashRingValSB->value();
model.swashRingData.invertELE = ui->swashInvertELE->isChecked();
model.swashRingData.invertAIL = ui->swashInvertAIL->isChecked();
model.swashRingData.invertCOL = ui->swashInvertCOL->isChecked();
model->swashRingData.type = ui->swashTypeCB->currentIndex();
model->swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt();
model->swashRingData.value = ui->swashRingValSB->value();
model->swashRingData.invertELE = ui->swashInvertELE->isChecked();
model->swashRingData.invertAIL = ui->swashInvertAIL->isChecked();
model->swashRingData.invertCOL = ui->swashInvertCOL->isChecked();
emit modified();
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef HELI_H
#define HELI_H
#include "modelpanel.h"
#include "modeledit.h"
namespace Ui {
class Heli;
+24 -23
View File
@@ -59,7 +59,7 @@ void InputsPanel::update()
int curDest = -1;
for (int i=0; i<C9X_MAX_EXPOS; i++) {
ExpoData *md = &model.expoData[i];
ExpoData *md = &model->expoData[i];
if (md->mode==0) break;
@@ -104,7 +104,7 @@ bool InputsPanel::AddInputLine(int dest)
QByteArray qba(1, (quint8)dest);
if (dest >= 0) {
//add input data
ExpoData *md = &model.expoData[dest];
ExpoData *md = &model->expoData[dest];
qba.append((const char*)md, sizeof(ExpoData));
}
itm->setData(Qt::UserRole, qba);
@@ -139,9 +139,9 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
if (new_ch) *new_ch = 1;
}
else {
ExpoData *md = &model.expoData[dest];
ExpoData *md = &model->expoData[dest];
if ((dest == 0) || (model.expoData[dest-1].chn != md->chn)) {
if ((dest == 0) || (model->expoData[dest-1].chn != md->chn)) {
if (new_ch) *new_ch = 1;
if (firmware->getCapability(VirtualInputs))
str = QString("%1").arg(getInputStr(model, md->chn), -10, ' ');
@@ -191,14 +191,14 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
bool InputsPanel::gm_insertExpo(int idx)
{
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
if (idx<0 || idx>=C9X_MAX_EXPOS || model->expoData[C9X_MAX_EXPOS-1].mode > 0) {
QMessageBox::information(this, "Companion", tr("Not enough available inputs!"));
return false;
}
int chn = model.expoData[idx].chn;
int chn = model->expoData[idx].chn;
ExpoData * newExpo = model.insertInput(idx);
ExpoData * newExpo = model->insertInput(idx);
newExpo->chn = chn;
newExpo->weight = 100;
newExpo->mode = INPUT_MODE_BOTH;
@@ -208,26 +208,27 @@ bool InputsPanel::gm_insertExpo(int idx)
void InputsPanel::gm_deleteExpo(int index)
{
model.removeInput(index);
model->removeInput(index);
}
void InputsPanel::gm_openExpo(int index)
{
if(index<0 || index>=C9X_MAX_EXPOS) return;
ExpoData mixd(model.expoData[index]);
ExpoData mixd(model->expoData[index]);
char inputName[4+1];
emit modified();
update();
if (firmware->getCapability(VirtualInputs))
strcpy(inputName, model.inputNames[mixd.chn]);
if (firmware->getCapability(VirtualInputs)) {
strcpy(inputName, model->inputNames[mixd.chn]);
}
ExpoDialog *g = new ExpoDialog(this, model, &mixd, generalSettings, firmware, inputName);
ExpoDialog *g = new ExpoDialog(this, *model, &mixd, generalSettings, firmware, inputName);
if (g->exec()) {
model.expoData[index] = mixd;
model->expoData[index] = mixd;
if (firmware->getCapability(VirtualInputs))
strcpy(model.inputNames[mixd.chn], inputName);
strcpy(model->inputNames[mixd.chn], inputName);
emit modified();
update();
}
@@ -244,7 +245,7 @@ void InputsPanel::gm_openExpo(int index)
int InputsPanel::getExpoIndex(unsigned int dch)
{
unsigned int i = 0;
while (model.expoData[i].chn<=dch && model.expoData[i].mode && i<C9X_MAX_EXPOS) i++;
while (model->expoData[i].chn<=dch && model->expoData[i].mode && i<C9X_MAX_EXPOS) i++;
if(i==C9X_MAX_EXPOS) return -1;
return i;
}
@@ -302,7 +303,7 @@ void InputsPanel::exposCopy()
QByteArray mxData;
foreach(int idx, list) {
mxData.append((char*)&model.expoData[idx],sizeof(ExpoData));
mxData.append((char*)&model->expoData[idx], sizeof(ExpoData));
}
QMimeData *mimeData = new QMimeData;
@@ -329,7 +330,7 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
idx = getExpoIndex(dch) - 1; //get expo index to insert
} else {
idx = destIdx;
dch = model.expoData[idx].chn;
dch = model->expoData[idx].chn;
}
QByteArray mxData = mimeData->data("application/x-companion-expo");
@@ -339,7 +340,7 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
idx++;
if (!gm_insertExpo(idx))
break;
ExpoData *md = &model.expoData[idx];
ExpoData *md = &model->expoData[idx];
memcpy(md, mxData.mid(i, sizeof(ExpoData)).constData(), sizeof(ExpoData));
md->chn = dch;
i += sizeof(ExpoData);
@@ -378,7 +379,7 @@ void InputsPanel::expoOpen(QListWidgetItem *item)
idx = getExpoIndex(ch); // get expo index to insert
if (!gm_insertExpo(idx))
return;
model.expoData[idx].chn = ch;
model->expoData[idx].chn = ch;
expoInserted=true;
} else {
expoInserted=false;
@@ -396,7 +397,7 @@ void InputsPanel::expoAdd()
index++;
if (!gm_insertExpo(index))
return;
model.expoData[index].chn = model.expoData[index-1].chn;
model->expoData[index].chn = model->expoData[index-1].chn;
}
gm_openExpo(index);
}
@@ -452,8 +453,8 @@ int InputsPanel::gm_moveExpo(int idx, bool dir) //true=inc=down false=dec=up
int tdx = dir ? idx+1 : idx-1;
ExpoData temp;
temp.clear();
ExpoData &src=model.expoData[idx];
ExpoData &tgt=model.expoData[tdx];
ExpoData &src=model->expoData[idx];
ExpoData &tgt=model->expoData[tdx];
if (!dir && tdx<0 && src.chn>0) {
src.chn--;
return idx;
@@ -524,7 +525,7 @@ void InputsPanel::exposDeleteList(QList<int> list)
void InputsPanel::clearExpos()
{
if (QMessageBox::question(this, tr("Clear Inputs?"), tr("Really clear all the inputs?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
model.clearInputs();
model->clearInputs();
emit modified();
update();
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef INPUTS_H
#define INPUTS_H
#include "modelpanel.h"
#include "modeledit.h"
#include "mixerslist.h"
class InputsPanel : public ModelPanel
+58 -59
View File
@@ -138,11 +138,11 @@ void LogicalSwitchesPanel::v1Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.logicalSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
if (model.logicalSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
RawSource source = RawSource(model.logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model.logicalSw[i].getRangeFlags());
model.logicalSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step;
model->logicalSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
if (model->logicalSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
RawSource source = RawSource(model->logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
model->logicalSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step;
setSwitchWidgetVisibility(i);
}
emit modified();
@@ -153,7 +153,7 @@ void LogicalSwitchesPanel::v2Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.logicalSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
model->logicalSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
emit modified();
}
}
@@ -162,7 +162,7 @@ void LogicalSwitchesPanel::andEdited(int value)
{
if (!lock) {
int index = sender()->property("index").toInt();
model.logicalSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
model->logicalSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
emit modified();
}
}
@@ -171,7 +171,7 @@ void LogicalSwitchesPanel::durationEdited(double duration)
{
if (!lock) {
int index = sender()->property("index").toInt();
model.logicalSw[index].duration = (uint8_t)round(duration*10);
model->logicalSw[index].duration = (uint8_t)round(duration*10);
emit modified();
}
}
@@ -180,7 +180,7 @@ void LogicalSwitchesPanel::delayEdited(double delay)
{
if (!lock) {
int index = sender()->property("index").toInt();
model.logicalSw[index].delay = (uint8_t)round(delay*10);
model->logicalSw[index].delay = (uint8_t)round(delay*10);
emit modified();
}
}
@@ -190,30 +190,30 @@ void LogicalSwitchesPanel::edited()
if (!lock) {
lock = true;
int i = sender()->property("index").toInt();
CSFunctionFamily oldFuncFamily = model.logicalSw[i].getFunctionFamily();
model.logicalSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
CSFunctionFamily newFuncFamily = model.logicalSw[i].getFunctionFamily();
CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily();
model->logicalSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily();
if (oldFuncFamily != newFuncFamily) {
if (newFuncFamily == LS_FAMILY_TIMER) {
model.logicalSw[i].val1 = -119;
model.logicalSw[i].val2 = -119;
model->logicalSw[i].val1 = -119;
model->logicalSw[i].val2 = -119;
}
else if (newFuncFamily == LS_FAMILY_EDGE) {
model.logicalSw[i].val1 = 0;
model.logicalSw[i].val2 = -129;
model.logicalSw[i].val3 = 0;
model->logicalSw[i].val1 = 0;
model->logicalSw[i].val2 = -129;
model->logicalSw[i].val3 = 0;
}
else if (newFuncFamily == LS_FAMILY_STICKY) {
model.logicalSw[i].val1 = 0;
model.logicalSw[i].val2 = 0;
model.logicalSw[i].delay = 0;
model->logicalSw[i].val1 = 0;
model->logicalSw[i].val2 = 0;
model->logicalSw[i].delay = 0;
}
else {
model.logicalSw[i].val1 = 0;
model.logicalSw[i].val2 = 0;
model->logicalSw[i].val1 = 0;
model->logicalSw[i].val2 = 0;
}
model.logicalSw[i].andsw = 0;
model->logicalSw[i].andsw = 0;
setSwitchWidgetVisibility(i);
}
@@ -223,11 +223,11 @@ void LogicalSwitchesPanel::edited()
{
case LS_FAMILY_VOFS:
{
source = RawSource(model.logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model.logicalSw[i].getRangeFlags());
source = RawSource(model->logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
double value = source.isTimeBased() ? QTimeS(cswitchTOffset[i]->time()).seconds() : cswitchOffset[i]->value();
model.logicalSw[i].val2 = round((value-range.offset)/range.step);;
value = model.logicalSw[i].val2*range.step + range.offset;
model->logicalSw[i].val2 = round((value-range.offset)/range.step);;
value = model->logicalSw[i].val2*range.step + range.offset;
if (source.isTimeBased())
cswitchTOffset[i]->setTime(QTimeS(round(value)));
else
@@ -235,22 +235,22 @@ void LogicalSwitchesPanel::edited()
break;
}
case LS_FAMILY_TIMER:
model.logicalSw[i].val1 = TimToVal(cswitchValue[i]->value());
model.logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchValue[i], model.logicalSw[i].val1, 0.1);
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.1);
model->logicalSw[i].val1 = TimToVal(cswitchValue[i]->value());
model->logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchValue[i], model->logicalSw[i].val1, 0.1);
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.1);
break;
case LS_FAMILY_EDGE:
cswitchOffset2[i]->setSpecialValueText(tr("(no release)"));
if (sender() == cswitchOffset[i]) {
model.logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.0);
model->logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.0);
}
else {
model.logicalSw[i].val3 = TimToVal(cswitchOffset2[i]->value()) - model.logicalSw[i].val2;
model->logicalSw[i].val3 = TimToVal(cswitchOffset2[i]->value()) - model->logicalSw[i].val2;
}
updateTimerParam(cswitchOffset2[i], model.logicalSw[i].val2+model.logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
if (model.logicalSw[i].val3 == 0) {
updateTimerParam(cswitchOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
if (model->logicalSw[i].val3 == 0) {
cswitchOffset2[i]->setSuffix("(infinite)");
}
else {
@@ -294,10 +294,10 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
lock = true;
unsigned int mask = DELAY_ENABLED;
RawSource source = RawSource(model.logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model.logicalSw[i].getRangeFlags());
RawSource source = RawSource(model->logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
switch (model.logicalSw[i].getFunctionFamily())
switch (model->logicalSw[i].getFunctionFamily())
{
case LS_FAMILY_VOFS:
mask |= SOURCE1_VISIBLE;
@@ -307,7 +307,7 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
if (source.isTimeBased()) {
mask |= VALUE_TO_VISIBLE;
int maxTime = round(range.max);
int value = round(range.step*model.logicalSw[i].val2 + range.offset);
int value = round(range.step*model->logicalSw[i].val2 + range.offset);
cswitchTOffset[i]->setMaximumTime(QTimeS(maxTime));
cswitchTOffset[i]->setDisplayFormat((maxTime>=3600)?"hh:mm:ss":"mm:ss");
cswitchTOffset[i]->setTime(QTimeS(value));
@@ -320,24 +320,24 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchOffset[i]->setSuffix(" " + range.unit);
cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.logicalSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
cswitchOffset[i]->setValue(range.step*(model->logicalSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
case LS_FAMILY_STICKY:
// no break
case LS_FAMILY_VBOOL:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
populateSwitchCB(cswitchSource2[i], RawSwitch(model.logicalSw[i].val2), generalSettings, LogicalSwitchesContext);
populateSwitchCB(cswitchSource1[i], RawSwitch(model->logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
populateSwitchCB(cswitchSource2[i], RawSwitch(model->logicalSw[i].val2), generalSettings, LogicalSwitchesContext);
break;
case LS_FAMILY_EDGE:
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
mask &= ~DELAY_ENABLED;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.0);
updateTimerParam(cswitchOffset2[i], model.logicalSw[i].val2+model.logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
populateSwitchCB(cswitchSource1[i], RawSwitch(model->logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.0);
updateTimerParam(cswitchOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
cswitchOffset2[i]->setSpecialValueText(tr("(no release)"));
if (model.logicalSw[i].val3 == 0) {
if (model->logicalSw[i].val3 == 0) {
cswitchOffset2[i]->setSuffix(tr("(infinite)"));
}
else {
@@ -346,14 +346,13 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
break;
case LS_FAMILY_VCOMP:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
populateSourceCB(cswitchSource1[i], RawSource(model.logicalSw[i].val1), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.logicalSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[i].val1), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model->logicalSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
break;
case LS_FAMILY_TIMER:
mask |= VALUE1_VISIBLE | VALUE2_VISIBLE;
updateTimerParam(cswitchValue[i], model.logicalSw[i].val1, 0.1);
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.1);
break;
updateTimerParam(cswitchValue[i], model->logicalSw[i].val1, 0.1);
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.1);
}
cswitchSource1[i]->setVisible(mask & SOURCE1_VISIBLE);
@@ -364,8 +363,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchTOffset[i]->setVisible(mask & VALUE_TO_VISIBLE);
if (firmware->getCapability(LogicalSwitchesExt)) {
cswitchDelay[i]->setEnabled(mask & DELAY_ENABLED);
cswitchDuration[i]->setValue(model.logicalSw[i].duration/10.0);
cswitchDelay[i]->setValue(model.logicalSw[i].delay/10.0);
cswitchDuration[i]->setValue(model->logicalSw[i].duration/10.0);
cswitchDelay[i]->setValue(model->logicalSw[i].delay/10.0);
}
lock = false;
}
@@ -445,11 +444,11 @@ void LogicalSwitchesPanel::populateAndSwitchCB(QComboBox *b, const RawSwitch & v
void LogicalSwitchesPanel::updateLine(int i)
{
lock = true;
populateCSWCB(csw[i], model.logicalSw[i].func);
populateCSWCB(csw[i], model->logicalSw[i].func);
lock = true;
setSwitchWidgetVisibility(i);
lock = true;
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.logicalSw[i].andsw));
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model->logicalSw[i].andsw));
lock = false;
}
@@ -466,7 +465,7 @@ void LogicalSwitchesPanel::cswPaste()
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-csw")) {
QByteArray cswData = mimeData->data("application/x-companion-csw");
LogicalSwitchData *csw = &model.logicalSw[selectedSwitch];
LogicalSwitchData *csw = &model->logicalSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
emit modified();
updateLine(selectedSwitch);
@@ -475,7 +474,7 @@ void LogicalSwitchesPanel::cswPaste()
void LogicalSwitchesPanel::cswDelete()
{
model.logicalSw[selectedSwitch].clear();
model->logicalSw[selectedSwitch].clear();
emit modified();
updateLine(selectedSwitch);
}
@@ -483,7 +482,7 @@ void LogicalSwitchesPanel::cswDelete()
void LogicalSwitchesPanel::cswCopy()
{
QByteArray cswData;
cswData.append((char*)&model.logicalSw[selectedSwitch],sizeof(LogicalSwitchData));
cswData.append((char*)&model->logicalSw[selectedSwitch],sizeof(LogicalSwitchData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CUSTOMSWITCHES_H
#define CUSTOMSWITCHES_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QTimeEdit>
+1 -1
View File
@@ -19,7 +19,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh));
populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
populateSourceCB(ui->sourceCB, md->srcRaw, &model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->sourceCB->removeItem(0);
int limit = firmware->getCapability(OffsetWeight);
+33 -31
View File
@@ -50,7 +50,7 @@ QString MixesPanel::getChannelLabel(int curDest)
// TODO not nice, Qt brings a function for that, I don't remember right now
(str.length() < 4) ? str.append(" ") : str.append(" ");
if (firmware->getCapability(HasChNames)) {
QString name = model.limitData[curDest-1].name;
QString name = model->limitData[curDest-1].name;
if (!name.isEmpty()) {
name = QString("(") + name + QString(")");
}
@@ -72,7 +72,7 @@ void MixesPanel::update()
unsigned int outputs = firmware->getCapability(Outputs);
for (i=0; i<firmware->getCapability(Mixes); i++) {
MixData *md = &model.mixData[i];
MixData *md = &model->mixData[i];
// qDebug() << "md->destCh: " << md->destCh;
if (md->destCh==0 || md->destCh>outputs) continue;
QString str = "";
@@ -111,7 +111,7 @@ bool MixesPanel::AddMixerLine(int dest)
QByteArray qba(1, (quint8)dest);
if (dest >= 0) {
//add mix data
MixData *md = &model.mixData[dest];
MixData *md = &model->mixData[dest];
qba.append((const char*)md, sizeof(MixData));
}
itm->setData(Qt::UserRole, qba);
@@ -149,11 +149,11 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
if (new_ch) *new_ch = 1;
}
else {
MixData *md = &model.mixData[dest];
MixData *md = &model->mixData[dest];
//md->destCh from 1 to 32
str = getChannelLabel(md->destCh);
if ((dest == 0) || (model.mixData[dest-1].destCh != md->destCh)) {
if ((dest == 0) || (model->mixData[dest-1].destCh != md->destCh)) {
if (new_ch) *new_ch = 1;
//highlight channell if needed
if (md->destCh == highlightedSource) {
@@ -187,8 +187,10 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
str += " " + Qt::escape(tr("Switch(%1)").arg(md->swtch.toString()));
}
if (md->carryTrim>0) str += " " + Qt::escape(tr("NoTrim"));
else if (md->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model);
if (md->carryTrim > 0)
str += " " + Qt::escape(tr("NoTrim"));
else if (md->carryTrim<0)
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model);
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
@@ -215,39 +217,39 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
bool MixesPanel::gm_insertMix(int idx)
{
if (idx<0 || idx>=firmware->getCapability(Mixes) || model.mixData[firmware->getCapability(Mixes)-1].destCh > 0) {
if (idx<0 || idx>=firmware->getCapability(Mixes) || model->mixData[firmware->getCapability(Mixes)-1].destCh > 0) {
QMessageBox::information(this, "companion", tr("Not enough available mixers!"));
return false;
}
int i = model.mixData[idx].destCh;
memmove(&model.mixData[idx+1],&model.mixData[idx],
int i = model->mixData[idx].destCh;
memmove(&model->mixData[idx+1],&model->mixData[idx],
(firmware->getCapability(Mixes)-(idx+1))*sizeof(MixData) );
memset(&model.mixData[idx],0,sizeof(MixData));
model.mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE);
model.mixData[idx].destCh = i;
model.mixData[idx].weight = 100;
memset(&model->mixData[idx],0,sizeof(MixData));
model->mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE);
model->mixData[idx].destCh = i;
model->mixData[idx].weight = 100;
return true;
}
void MixesPanel::gm_deleteMix(int index)
{
memmove(&model.mixData[index],&model.mixData[index+1],
memmove(&model->mixData[index],&model->mixData[index+1],
(firmware->getCapability(Mixes)-(index+1))*sizeof(MixData));
memset(&model.mixData[firmware->getCapability(Mixes)-1],0,sizeof(MixData));
memset(&model->mixData[firmware->getCapability(Mixes)-1],0,sizeof(MixData));
}
void MixesPanel::gm_openMix(int index)
{
if(index<0 || index>=firmware->getCapability(Mixes)) return;
MixData mixd(model.mixData[index]);
MixData mixd(model->mixData[index]);
emit modified();
update();
MixerDialog *g = new MixerDialog(this, model, &mixd, generalSettings, firmware);
MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware);
if(g->exec()) {
model.mixData[index] = mixd;
model->mixData[index] = mixd;
emit modified();
update();
} else {
@@ -263,7 +265,7 @@ void MixesPanel::gm_openMix(int index)
int MixesPanel::getMixerIndex(unsigned int dch)
{
int i = 0;
while ((model.mixData[i].destCh<=dch) && (model.mixData[i].destCh) && (i<firmware->getCapability(Mixes))) i++;
while ((model->mixData[i].destCh<=dch) && (model->mixData[i].destCh) && (i<firmware->getCapability(Mixes))) i++;
if(i==firmware->getCapability(Mixes)) return -1;
return i;
}
@@ -276,7 +278,7 @@ void MixesPanel::mixerlistWidget_doubleClicked(QModelIndex index)
idx = getMixerIndex(i); //get mixer index to insert
if (!gm_insertMix(idx))
return;
model.mixData[idx].destCh = i;
model->mixData[idx].destCh = i;
mixInserted=true;
} else {
mixInserted=false;
@@ -349,7 +351,7 @@ void MixesPanel::mixersCopy()
QByteArray mxData;
foreach(int idx, list) {
mxData.append((char*)&model.mixData[idx],sizeof(MixData));
mxData.append((char*)&model->mixData[idx],sizeof(MixData));
}
QMimeData *mimeData = new QMimeData;
@@ -368,7 +370,7 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
idx = getMixerIndex(dch) - 1; //get mixer index to insert
} else {
idx = destIdx;
dch = model.mixData[idx].destCh;
dch = model->mixData[idx].destCh;
}
QByteArray mxData = mimeData->data("application/x-companion-mix");
@@ -380,7 +382,7 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
if (!gm_insertMix(idx))
break;
MixData *md = &model.mixData[idx];
MixData *md = &model->mixData[idx];
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
md->destCh = dch;
i += sizeof(MixData);
@@ -415,7 +417,7 @@ void MixesPanel::mixerOpen()
idx = getMixerIndex(i); //get mixer index to insert
if (!gm_insertMix(idx))
return;
model.mixData[idx].destCh = i;
model->mixData[idx].destCh = i;
mixInserted=true;
} else {
mixInserted=false;
@@ -432,7 +434,7 @@ void MixesPanel::mixerHighlight()
dest = -idx;
}
else {
dest = model.mixData[idx].destCh;
dest = model->mixData[idx].destCh;
}
highlightedSource = ( (int)highlightedSource == dest) ? 0 : dest;
// qDebug() << "MixesPanel::mixerHighlight(): " << highlightedSource ;
@@ -453,13 +455,13 @@ void MixesPanel::mixerAdd()
index = getMixerIndex(i); //get mixer index to insert
if (!gm_insertMix(index))
return;
model.mixData[index].destCh = i;
model->mixData[index].destCh = i;
mixInserted=true;
} else {
index++;
if (!gm_insertMix(index))
return;
model.mixData[index].destCh = model.mixData[index-1].destCh;
model->mixData[index].destCh = model->mixData[index-1].destCh;
mixInserted=true;
}
gm_openMix(index);
@@ -523,7 +525,7 @@ int MixesPanel::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up
{
if(idx>firmware->getCapability(Mixes) || (idx==firmware->getCapability(Mixes) && dir)) return idx;
MixData &src=model.mixData[idx];
MixData &src=model->mixData[idx];
if (idx==0 && !dir) {
//special case: topmost mixer moving up
@@ -532,7 +534,7 @@ int MixesPanel::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up
}
int tdx = dir ? idx+1 : idx-1;
MixData &tgt=model.mixData[tdx];
MixData &tgt=model->mixData[tdx];
unsigned int outputs = firmware->getCapability(Outputs);
if((src.destCh==0) || (src.destCh>outputs) || (tgt.destCh>outputs)) return idx;
@@ -578,7 +580,7 @@ void MixesPanel::moveMixDown()
void MixesPanel::clearMixes()
{
if (QMessageBox::question(this, tr("Clear Mixes?"), tr("Really clear all the mixes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
model.clearMixes();
model->clearMixes();
emit modified();
update();
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef MIXES_H
#define MIXES_H
#include "modelpanel.h"
#include "modeledit.h"
#include "mixerslist.h"
#include "mixerdialog.h"
+2 -3
View File
@@ -37,8 +37,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
addTab(chnPanel, tr("Servos"));
addTab(new Curves(this, model, generalSettings, firmware), tr("Curves"));
addTab(new LogicalSwitchesPanel(this, model, generalSettings, firmware), tr("Logical Switches"));
if (firmware->getCapability(CustomFunctions))
addTab(new CustomFunctionsPanel(this, model, generalSettings, firmware), tr("Special Functions"));
addTab(new CustomFunctionsPanel(this, &model, generalSettings, firmware), tr("Special Functions"));
if (firmware->getCapability(Telemetry) & TM_HASTELEMETRY)
addTab(new TelemetryPanel(this, model, generalSettings, firmware), tr("Telemetry"));
@@ -55,7 +54,7 @@ void ModelEdit::closeEvent(QCloseEvent *event)
g.modelEditGeo( saveGeometry() );
}
void ModelEdit::addTab(ModelPanel *panel, QString text)
void ModelEdit::addTab(GenericPanel *panel, QString text)
{
panels << panel;
QWidget * widget = new QWidget(ui->tabWidget);
+13 -4
View File
@@ -2,12 +2,21 @@
#define MODELEDIT_H
#include <QDialog>
#include "modelpanel.h"
#include "helpers.h"
namespace Ui {
class ModelEdit;
class ModelEdit;
}
class ModelPanel : public GenericPanel
{
public:
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GenericPanel(parent, &model, generalSettings, firmware)
{
}
};
class ModelEdit : public QDialog
{
Q_OBJECT
@@ -33,9 +42,9 @@ class ModelEdit : public QDialog
ModelData & model;
GeneralSettings & generalSettings;
FirmwareInterface * firmware;
QVector<ModelPanel *> panels;
QVector<GenericPanel *> panels;
void addTab(ModelPanel *panel, QString text);
void addTab(GenericPanel *panel, QString text);
void launchSimulation();
};
-17
View File
@@ -1,17 +0,0 @@
#include "modelpanel.h"
#include <QLabel>
#include <QComboBox>
#include <QSpinBox>
ModelPanel::ModelPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GenericPanel(parent),
model(model),
generalSettings(generalSettings),
firmware(firmware)
{
}
ModelPanel::~ModelPanel()
{
}
-21
View File
@@ -1,21 +0,0 @@
#ifndef MODELPANEL_H
#define MODELPANEL_H
#include "eeprominterface.h"
#include "helpers.h"
class ModelPanel : public GenericPanel
{
Q_OBJECT
public:
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
virtual ~ModelPanel();
protected:
ModelData & model;
GeneralSettings & generalSettings;
FirmwareInterface * firmware;
};
#endif // CHANNELS_H
+44 -44
View File
@@ -223,7 +223,7 @@ void ModulePanel::update()
break;
}
}
else if (!IS_TARANIS(firmware->getBoard()) || model.trainerMode != 0) {
else if (!IS_TARANIS(firmware->getBoard()) || model->trainerMode != 0) {
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT;
}
@@ -231,7 +231,7 @@ void ModulePanel::update()
ui->protocol->setVisible(mask & MASK_PROTOCOL);
ui->label_rxNumber->setVisible(mask & MASK_FAILSAFES);
ui->rxNumber->setVisible(mask & MASK_FAILSAFES);
ui->rxNumber->setValue(model.modelId);
ui->rxNumber->setValue(model->modelId);
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
ui->channelsStart->setValue(module.channelsStart+1);
@@ -250,7 +250,7 @@ void ModulePanel::update()
ui->ppmDelay->setValue(module.ppmDelay);
ui->label_ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
ui->ppmFrameLength->setMinimum(module.channelsCount*(model.extendedLimits ? 2.250 : 2)+3.5);
ui->ppmFrameLength->setMinimum(module.channelsCount*(model->extendedLimits ? 2.250 : 2)+3.5);
ui->ppmFrameLength->setMaximum(firmware->getCapability(PPMFrameLength));
ui->ppmFrameLength->setValue(22.5+((double)module.ppmFrameLength)*0.5);
@@ -271,7 +271,7 @@ void ModulePanel::update()
void ModulePanel::on_trainerMode_currentIndexChanged(int index)
{
if (!lock) {
model.trainerMode = index;
model->trainerMode = index;
update();
emit modified();
}
@@ -321,7 +321,7 @@ void ModulePanel::on_ppmDelay_editingFinished()
void ModulePanel::on_rxNumber_editingFinished()
{
model.modelId = ui->rxNumber->value();
model->modelId = ui->rxNumber->value();
emit modified();
}
@@ -522,39 +522,39 @@ SetupPanel::~SetupPanel()
void SetupPanel::on_extendedLimits_toggled(bool checked)
{
model.extendedLimits = checked;
model->extendedLimits = checked;
emit extendedLimitsToggled();
emit modified();
}
void SetupPanel::on_throttleWarning_toggled(bool checked)
{
model.disableThrottleWarning = !checked;
model->disableThrottleWarning = !checked;
emit modified();
}
void SetupPanel::on_throttleReverse_toggled(bool checked)
{
model.throttleReversed = checked;
model->throttleReversed = checked;
emit modified();
}
void SetupPanel::on_extendedTrims_toggled(bool checked)
{
model.extendedTrims = checked;
model->extendedTrims = checked;
emit modified();
}
void SetupPanel::on_trimIncrement_currentIndexChanged(int index)
{
model.trimInc = index-2;
model->trimInc = index-2;
emit modified();
}
void SetupPanel::on_throttleSource_currentIndexChanged(int index)
{
if (!lock) {
model.thrTraceSrc = ui->throttleSource->itemData(index).toInt();
model->thrTraceSrc = ui->throttleSource->itemData(index).toInt();
emit modified();
}
}
@@ -562,25 +562,25 @@ void SetupPanel::on_throttleSource_currentIndexChanged(int index)
void SetupPanel::on_name_editingFinished()
{
int length = ui->name->maxLength();
strncpy(model.name, ui->name->text().toAscii(), length);
strncpy(model->name, ui->name->text().toAscii(), length);
emit modified();
}
void SetupPanel::on_image_currentIndexChanged(int index)
{
if (!lock) {
strncpy(model.bitmap, ui->image->currentText().toAscii(), 10);
strncpy(model->bitmap, ui->image->currentText().toAscii(), 10);
QString path = g.profile[g.id()].sdPath();
path.append("/BMP/");
QDir qd(path);
if (qd.exists()) {
QString fileName=path;
fileName.append(model.bitmap);
fileName.append(model->bitmap);
fileName.append(".bmp");
QImage image(fileName);
if (image.isNull()) {
fileName=path;
fileName.append(model.bitmap);
fileName.append(model->bitmap);
fileName.append(".BMP");
image.load(fileName);
}
@@ -618,13 +618,13 @@ void SetupPanel::populateThrottleSourceCB()
}
}
if (model.thrTraceSrc < i)
ui->throttleSource->setCurrentIndex(model.thrTraceSrc);
if (model->thrTraceSrc < i)
ui->throttleSource->setCurrentIndex(model->thrTraceSrc);
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);
if (model.thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i))
if (model->thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i))
ui->throttleSource->setCurrentIndex(ui->throttleSource->count()-1);
}
@@ -633,18 +633,18 @@ void SetupPanel::populateThrottleSourceCB()
void SetupPanel::update()
{
ui->name->setText(model.name);
ui->name->setText(model->name);
ui->throttleReverse->setChecked(model.throttleReversed);
ui->throttleReverse->setChecked(model->throttleReversed);
populateThrottleSourceCB();
ui->throttleWarning->setChecked(!model.disableThrottleWarning);
ui->throttleWarning->setChecked(!model->disableThrottleWarning);
//trim inc, thro trim, thro expo, instatrim
ui->trimIncrement->setCurrentIndex(model.trimInc+2);
ui->throttleTrim->setChecked(model.thrTrim);
ui->extendedLimits->setChecked(model.extendedLimits);
ui->extendedTrims->setChecked(model.extendedTrims);
ui->displayText->setChecked(model.displayChecklist);
ui->trimIncrement->setCurrentIndex(model->trimInc+2);
ui->throttleTrim->setChecked(model->thrTrim);
ui->extendedLimits->setChecked(model->extendedLimits);
ui->extendedTrims->setChecked(model->extendedTrims);
ui->displayText->setChecked(model->displayChecklist);
updateBeepCenter();
updateStartupSwitches();
@@ -664,7 +664,7 @@ void SetupPanel::update()
void SetupPanel::updateBeepCenter()
{
for (int i=0; i<centerBeepCheckboxes.size(); i++) {
centerBeepCheckboxes[i]->setChecked(model.beepANACenter & (0x01 << i));
centerBeepCheckboxes[i]->setChecked(model->beepANACenter & (0x01 << i));
}
}
@@ -672,12 +672,12 @@ void SetupPanel::updateStartupSwitches()
{
lock = true;
unsigned int switchStates = model.switchWarningStates;
unsigned int switchStates = model->switchWarningStates;
for (int i=0; i<firmware->getCapability(Switches)-1; i++) {
QSlider * slider = startupSwitchesSliders[i];
QCheckBox * cb = startupSwitchesCheckboxes[i];
bool enabled = !(model.nSwToWarn & (1 << i));
bool enabled = !(model->nSwToWarn & (1 << i));
slider->setEnabled(enabled);
cb->setChecked(enabled);
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
@@ -721,10 +721,10 @@ void SetupPanel::startupSwitchEdited(int value)
}
}
model.switchWarningStates &= ~mask;
model->switchWarningStates &= ~mask;
if (value) {
model.switchWarningStates |= (value << shift);
model->switchWarningStates |= (value << shift);
}
updateStartupSwitches();
@@ -738,9 +738,9 @@ void SetupPanel::startupSwitchToggled(bool checked)
int index = sender()->property("index").toInt()-1;
if (checked)
model.nSwToWarn &= ~(1 << index);
model->nSwToWarn &= ~(1 << index);
else
model.nSwToWarn |= (1 << index);
model->nSwToWarn |= (1 << index);
updateStartupSwitches();
emit modified();
@@ -750,14 +750,14 @@ void SetupPanel::startupSwitchToggled(bool checked)
void SetupPanel::updatePotWarnings()
{
lock = true;
int mode = model.nPotsToWarn >> 6;
int mode = model->nPotsToWarn >> 6;
ui->potWarningMode->setCurrentIndex(mode);
if (mode == 0)
model.nPotsToWarn = 0x3F;
model->nPotsToWarn = 0x3F;
for (int i=0; i<potWarningCheckboxes.size(); i++) {
bool enabled = !(model.nPotsToWarn & (1 << i));
bool enabled = !(model->nPotsToWarn & (1 << i));
potWarningCheckboxes[i]->setChecked(enabled);
potWarningCheckboxes[i]->setDisabled(mode == 0);
@@ -771,9 +771,9 @@ void SetupPanel::potWarningToggled(bool checked)
int index = sender()->property("index").toInt()-1;
if(checked)
model.nPotsToWarn &= ~(1 << index);
model->nPotsToWarn &= ~(1 << index);
else
model.nPotsToWarn |= (1 << index);
model->nPotsToWarn |= (1 << index);
updatePotWarnings();
emit modified();
@@ -784,8 +784,8 @@ void SetupPanel::on_potWarningMode_currentIndexChanged(int index)
{
if (!lock) {
int mask = 0xC0;
model.nPotsToWarn = model.nPotsToWarn & ~mask;
model.nPotsToWarn = model.nPotsToWarn | ((index << 6) & mask);
model->nPotsToWarn = model->nPotsToWarn & ~mask;
model->nPotsToWarn = model->nPotsToWarn | ((index << 6) & mask);
updatePotWarnings();
emit modified();
@@ -794,13 +794,13 @@ void SetupPanel::on_potWarningMode_currentIndexChanged(int index)
void SetupPanel::on_displayText_toggled(bool checked)
{
model.displayChecklist = checked;
model->displayChecklist = checked;
emit modified();
}
void SetupPanel::on_throttleTrim_toggled(bool checked)
{
model.thrTrim = checked;
model->thrTrim = checked;
emit modified();
}
@@ -810,9 +810,9 @@ void SetupPanel::onBeepCenterToggled(bool checked)
int index = sender()->property("index").toInt();
unsigned int mask = (0x01 << index);
if (checked)
model.beepANACenter |= mask;
model->beepANACenter |= mask;
else
model.beepANACenter &= ~mask;
model->beepANACenter &= ~mask;
emit modified();
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef SETUP_H
#define SETUP_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QVector>
#include <QCheckBox>
#include <QSlider>
+39 -39
View File
@@ -367,12 +367,12 @@ void TelemetryCustomScreen::update()
for (int l=0; l<4; l++) {
for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model.frsky.usrProto);
populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model->frsky.usrProto);
}
}
for (int l=0; l<4; l++) {
populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto);
populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model->frsky.usrProto);
}
if (screen.type == TELEMETRY_SCREEN_BARS) {
@@ -540,7 +540,7 @@ TelemetryPanel::~TelemetryPanel()
void TelemetryPanel::update()
{
if (IS_TARANIS(firmware->getBoard())) {
if (model.moduleData[0].protocol == OFF && model.moduleData[1].protocol == PPM) {
if (model->moduleData[0].protocol == OFF && model->moduleData[1].protocol == PPM) {
ui->telemetryProtocol->setEnabled(true);
}
else {
@@ -556,11 +556,11 @@ void TelemetryPanel::setup()
lock = true;
ui->rssiAlarm1SB->setValue(model.frsky.rssiAlarms[0].value);
ui->rssiAlarm2SB->setValue(model.frsky.rssiAlarms[1].value);
ui->rssiAlarm1SB->setValue(model->frsky.rssiAlarms[0].value);
ui->rssiAlarm2SB->setValue(model->frsky.rssiAlarms[1].value);
if (!IS_TARANIS(firmware->getBoard())) {
ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level);
ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level);
ui->rssiAlarm1CB->setCurrentIndex(model->frsky.rssiAlarms[0].level);
ui->rssiAlarm2CB->setCurrentIndex(model->frsky.rssiAlarms[1].level);
}
else {
ui->rssiAlarm1CB->hide();
@@ -573,11 +573,11 @@ void TelemetryPanel::setup()
ui->AltitudeGPS_ChkB->hide();
}
else {
ui->AltitudeGPS_ChkB->setChecked(model.frsky.FrSkyGpsAlt);
ui->AltitudeGPS_ChkB->setChecked(model->frsky.FrSkyGpsAlt);
}
if (IS_TARANIS(firmware->getBoard())) {
ui->AltitudeToolbar_ChkB->setChecked(model.frsky.altitudeDisplayed);
ui->AltitudeToolbar_ChkB->setChecked(model->frsky.altitudeDisplayed);
}
else {
ui->AltitudeToolbar_ChkB->hide();
@@ -606,17 +606,17 @@ void TelemetryPanel::setup()
ui->VarioLabel_1->hide();
ui->VarioLabel_2->hide();
}
ui->varioLimitMin_DSB->setValue(model.frsky.varioMin-10);
ui->varioLimitMax_DSB->setValue(model.frsky.varioMax+10);
ui->varioLimitCenterMax_DSB->setValue((model.frsky.varioCenterMax/10.0)+0.5);
if (model.frsky.varioCenterMin==-16) {
ui->varioLimitMin_DSB->setValue(model->frsky.varioMin-10);
ui->varioLimitMax_DSB->setValue(model->frsky.varioMax+10);
ui->varioLimitCenterMax_DSB->setValue((model->frsky.varioCenterMax/10.0)+0.5);
if (model->frsky.varioCenterMin==-16) {
ui->varioLimitMinOff_ChkB->setChecked(true);
ui->varioLimitCenterMin_DSB->setValue(-2.0);
ui->varioLimitCenterMin_DSB->setDisabled(true);
}
else {
ui->varioLimitMinOff_ChkB->setChecked(false);
ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5);
ui->varioLimitCenterMin_DSB->setValue((model->frsky.varioCenterMin/10.0)-0.5);
}
}
@@ -636,7 +636,7 @@ void TelemetryPanel::setup()
ui->fasOffset_DSB->hide();
}
else {
ui->fasOffset_DSB->setValue(model.frsky.fasOffset/10.0);
ui->fasOffset_DSB->setValue(model->frsky.fasOffset/10.0);
ui->variousGB->show();
}
@@ -646,9 +646,9 @@ void TelemetryPanel::setup()
ui->mahCount_ChkB->hide();
}
else {
if (model.frsky.mAhPersistent) {
if (model->frsky.mAhPersistent) {
ui->mahCount_ChkB->setChecked(true);
ui->mahCount_SB->setValue(model.frsky.storedMah);
ui->mahCount_SB->setValue(model->frsky.storedMah);
}
else {
ui->mahCount_SB->setDisabled(true);
@@ -656,8 +656,8 @@ void TelemetryPanel::setup()
ui->variousGB->show();
}
ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto);
ui->bladesCount->setValue(model.frsky.blades);
ui->frskyProtoCB->setCurrentIndex(model->frsky.usrProto);
ui->bladesCount->setValue(model->frsky.blades);
populateVoltsSource();
populateCurrentSource();
@@ -669,7 +669,7 @@ void TelemetryPanel::setup()
void TelemetryPanel::populateVarioSource()
{
QUnsignedAutoComboBox * cb = ui->varioSourceCB;
cb->setField(&model.frsky.varioSource, this);
cb->setField(&model->frsky.varioSource, this);
if (!IS_TARANIS(firmware->getBoard())) {
cb->addItem(tr("Alti"), TELEMETRY_VARIO_SOURCE_ALTI);
cb->addItem(tr("Alti+"), TELEMETRY_VARIO_SOURCE_ALTI_PLUS);
@@ -685,7 +685,7 @@ void TelemetryPanel::populateVarioSource()
void TelemetryPanel::populateVoltsSource()
{
QUnsignedAutoComboBox * cb = ui->frskyVoltCB;
cb->setField(&model.frsky.voltsSource, this);
cb->setField(&model->frsky.voltsSource, this);
cb->addItem(tr("A1"), TELEMETRY_VOLTS_SOURCE_A1);
cb->addItem(tr("A2"), TELEMETRY_VOLTS_SOURCE_A2);
if (IS_ARM(firmware->getBoard())) {
@@ -699,7 +699,7 @@ void TelemetryPanel::populateVoltsSource()
void TelemetryPanel::populateCurrentSource()
{
QUnsignedAutoComboBox * cb = ui->frskyCurrentCB;
cb->setField(&model.frsky.currentSource, this);
cb->setField(&model->frsky.currentSource, this);
cb->addItem(tr("---"), TELEMETRY_CURRENT_SOURCE_NONE);
cb->addItem(tr("A1"), TELEMETRY_CURRENT_SOURCE_A1);
cb->addItem(tr("A2"), TELEMETRY_CURRENT_SOURCE_A2);
@@ -712,7 +712,7 @@ void TelemetryPanel::populateCurrentSource()
void TelemetryPanel::on_telemetryProtocol_currentIndexChanged(int index)
{
model.telemetryProtocol = index;
model->telemetryProtocol = index;
emit modified();
}
@@ -723,13 +723,13 @@ void TelemetryPanel::onAnalogModified()
void TelemetryPanel::on_bladesCount_editingFinished()
{
model.frsky.blades = ui->bladesCount->value();
model->frsky.blades = ui->bladesCount->value();
emit modified();
}
void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
{
model.frsky.usrProto = index;
model->frsky.usrProto = index;
for (int i=0; i<firmware->getCapability(TelemetryCustomScreens); i++)
telemetryCustomScreens[i]->update();
emit modified();
@@ -737,49 +737,49 @@ void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index)
{
model.frsky.rssiAlarms[0].level = index;
model->frsky.rssiAlarms[0].level = index;
emit modified();
}
void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index)
{
model.frsky.rssiAlarms[1].level = index;
model->frsky.rssiAlarms[1].level = index;
emit modified();
}
void TelemetryPanel::on_rssiAlarm1SB_editingFinished()
{
model.frsky.rssiAlarms[0].value = ui->rssiAlarm1SB->value();
model->frsky.rssiAlarms[0].value = ui->rssiAlarm1SB->value();
emit modified();
}
void TelemetryPanel::on_rssiAlarm2SB_editingFinished()
{
model.frsky.rssiAlarms[1].value = ui->rssiAlarm2SB->value();
model->frsky.rssiAlarms[1].value = ui->rssiAlarm2SB->value();
emit modified();
}
void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked)
{
model.frsky.FrSkyGpsAlt = checked;
model->frsky.FrSkyGpsAlt = checked;
emit modified();
}
void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked)
{
model.frsky.altitudeDisplayed = checked;
model->frsky.altitudeDisplayed = checked;
emit modified();
}
void TelemetryPanel::on_varioLimitMin_DSB_editingFinished()
{
model.frsky.varioMin = round(ui->varioLimitMin_DSB->value()+10);
model->frsky.varioMin = round(ui->varioLimitMin_DSB->value()+10);
emit modified();
}
void TelemetryPanel::on_varioLimitMax_DSB_editingFinished()
{
model.frsky.varioMax = round(ui->varioLimitMax_DSB->value()-10);
model->frsky.varioMax = round(ui->varioLimitMax_DSB->value()-10);
emit modified();
}
@@ -789,7 +789,7 @@ void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
}
model.frsky.varioCenterMin = round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
model->frsky.varioCenterMin = round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
emit modified();
}
}
@@ -797,7 +797,7 @@ void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
{
if (!lock) {
model.frsky.varioCenterMin = -16;
model->frsky.varioCenterMin = -16;
if (!checked) {
lock=true;
ui->varioLimitCenterMin_DSB->setValue(-2.0);
@@ -818,26 +818,26 @@ void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished()
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
}
model.frsky.varioCenterMax = round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
model->frsky.varioCenterMax = round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
emit modified();
}
}
void TelemetryPanel::on_fasOffset_DSB_editingFinished()
{
model.frsky.fasOffset = ui->fasOffset_DSB->value() * 10;
model->frsky.fasOffset = ui->fasOffset_DSB->value() * 10;
emit modified();
}
void TelemetryPanel::on_mahCount_SB_editingFinished()
{
model.frsky.storedMah = ui->mahCount_SB->value();
model->frsky.storedMah = ui->mahCount_SB->value();
emit modified();
}
void TelemetryPanel::on_mahCount_ChkB_toggled(bool checked)
{
model.frsky.mAhPersistent = checked;
model->frsky.mAhPersistent = checked;
ui->mahCount_SB->setDisabled(!checked);
emit modified();
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef TELEMETRY_H
#define TELEMETRY_H
#include "modelpanel.h"
#include "modeledit.h"
#include <QGroupBox>
#include <QComboBox>
#include <QDoubleSpinBox>