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

Some refactoring in the new Wizard

This commit is contained in:
bsongis 2014-03-13 08:44:50 +01:00
parent 13e998ec2d
commit e0582cd398
8 changed files with 72 additions and 48 deletions

View file

@ -177,7 +177,6 @@ set(companion_MOC_HDRS
mainwindow.h
qcustomplot.h
helpers.h
wizarddata.h
wizarddialog.h
)

View file

@ -972,25 +972,6 @@ bool ModelData::isempty()
return !used;
}
void ModelData::importWizardData( unsigned int id, const WizMix mix )
{
clear();
used = true;
modelId = id+1;
// Safe copy model name
strncpy ( name, mix.name, WIZ_MODEL_NAME_LENGTH);
name[WIZ_MODEL_NAME_LENGTH] = 0;
for (int i=0; i<WIZ_MAX_CHANNELS; i++ ){
Channel ch = mix.channel[i];
if (ch.sourceDlg > 0){
//**** INSERT MIXER HERE ****
}
}
}
void ModelData::setDefaultMixes(GeneralSettings & settings)
{
if (IS_TARANIS(GetEepromInterface()->getBoard())) {

View file

@ -24,7 +24,6 @@
#include <QList>
#include <QtXml>
#include <iostream>
#include "wizarddata.h"
#if __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
@ -951,7 +950,6 @@ class ModelData {
void clear();
bool isempty();
void importWizardData(unsigned int, const WizMix);
void setDefaultMixes(GeneralSettings & settings);
void setDefaultValues(unsigned int id, GeneralSettings & settings);

View file

@ -185,11 +185,10 @@ void MdiChild::wizardEdit()
int row = ui->modelsList->currentRow();
if (row > 0) {
checkAndInitModel(row);
WizardDialog *wizard = new WizardDialog(this);
WizardDialog * wizard = new WizardDialog(row, this);
wizard->exec();
if (wizard->mix.complete){
ModelData &model = radioData.models[row - 1];
model.importWizardData(row - 1, wizard->mix);
if (wizard->mix.complete /*TODO rather test the exec() result?*/) {
radioData.models[row - 1] = wizard->mix;
setModified();
}
}

View file

@ -28,11 +28,33 @@ void Channel::clear()
weight2 = 0;
}
WizMix::WizMix()
WizMix::WizMix(const unsigned int modelId):
complete(false),
modelId(modelId),
vehicle(NOVEHICLE)
{
complete = false;
strcpy(name, " ");
vehicle = NOVEHICLE;
}
WizMix::operator ModelData()
{
ModelData model;
model.used = true;
model.modelId = modelId;
// Safe copy model name
strncpy(model.name, name, WIZ_MODEL_NAME_LENGTH);
model.name[WIZ_MODEL_NAME_LENGTH] = 0;
for (int i=0; i<WIZ_MAX_CHANNELS; i++ ) {
Channel ch = channel[i];
if (ch.sourceDlg > 0) {
//**** INSERT MIXER HERE ****
}
}
return model;
}

View file

@ -15,15 +15,34 @@
#ifndef WIZARDDATA_H
#define WIZARDDATA_H
#include "eeprominterface.h"
#define WIZ_MAX_CHANNELS 8
// TODO use a constant common to the whole companion
// TODO when in the wizard use the getCapacity(...) to know how long the name can be
#define WIZ_MODEL_NAME_LENGTH 12
enum Input {NOINPUT, THROTTLE, RUDDER, ELEVATOR, AILERON, FLAP, AIRBREAK};
enum Vehicle {NOVEHICLE, PLANE, MULTICOPTER, HELICOPTER };
enum Input {
NOINPUT,
THROTTLE,
RUDDER,
ELEVATOR,
AILERON,
FLAP,
AIRBREAK
};
enum Vehicle {
NOVEHICLE,
PLANE,
MULTICOPTER,
HELICOPTER
};
class Channel
{
public:
public:
int sourceDlg; // Originating dialog, only of interest for producer
Input input1;
Input input2;
@ -36,12 +55,17 @@ public:
class WizMix
{
public:
public:
bool complete;
char name[WIZ_MODEL_NAME_LENGTH + 1];
unsigned int modelId;
Vehicle vehicle;
Channel channel[WIZ_MAX_CHANNELS];
explicit WizMix(const unsigned int modelId);
operator ModelData();
private:
WizMix();
};

View file

@ -16,8 +16,9 @@
#include "wizarddialog.h"
#include "wizarddata.h"
WizardDialog::WizardDialog(QWidget *parent)
: QWizard(parent)
WizardDialog::WizardDialog(unsigned int modelId, QWidget *parent)
: QWizard(parent),
mix(modelId)
{
setWindowTitle(tr("Model Wizard"));

View file

@ -36,7 +36,7 @@ public:
Page_Conclusion };
WizMix mix;
WizardDialog(QWidget *parent = 0);
WizardDialog(const unsigned int modelId, QWidget *parent = 0);
private slots:
void showHelp();