Merge pull request #2712 from opentx/griebd/model_wizard_issue_2711

Griebd/model wizard issue 2711
This commit is contained in:
Damjan Adamic
2015-08-16 09:02:13 +02:00
2 changed files with 75 additions and 41 deletions
+46 -16
View File
@@ -1,6 +1,6 @@
/* /*
* Author - Kjell Kernen * Author - Kjell Kernen
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
@@ -181,6 +181,16 @@ int StandardPage::nextFreeChannel(int channel)
return -1; return -1;
} }
int StandardPage::totalChannelsAvailable()
{
int c = 0;
for(int i=0; i<WIZ_MAX_CHANNELS; i++)
if (wizDlg->mix.channel[i].page == Page_None)
c++;
return c;
}
void StandardPage::populateCB(QComboBox *cb, int preferred) void StandardPage::populateCB(QComboBox *cb, int preferred)
{ {
cb->clear(); cb->clear();
@@ -214,7 +224,7 @@ bool StandardPage::bookChannel(QComboBox * cb, Input input1, int weight1, Input
{ {
int channel = cb->itemData(cb->currentIndex()).toInt(); int channel = cb->itemData(cb->currentIndex()).toInt();
if (channel<0 || channel>=WIZ_MAX_CHANNELS) if (channel<0 || channel>=WIZ_MAX_CHANNELS)
return false; return false;
if (wizDlg->mix.channel[channel].page != Page_None) if (wizDlg->mix.channel[channel].page != Page_None)
return false; return false;
@@ -231,7 +241,7 @@ void StandardPage::releaseBookings()
{ {
for (int i=0; i<WIZ_MAX_CHANNELS; i++) { for (int i=0; i<WIZ_MAX_CHANNELS; i++) {
if (wizDlg->mix.channel[i].page == pageCurrent) { if (wizDlg->mix.channel[i].page == pageCurrent) {
wizDlg->mix.channel[i].clear(); wizDlg->mix.channel[i].clear();
} }
} }
} }
@@ -298,7 +308,7 @@ bool ModelSelectionPage::validatePage()
return true; return true;
} }
int ModelSelectionPage::nextId() const int ModelSelectionPage::nextId() const
{ {
if (helicopterRB->isChecked()) if (helicopterRB->isChecked())
return Page_Cyclic; return Page_Cyclic;
@@ -432,7 +442,7 @@ AileronsPage::AileronsPage(WizardDialog *dlg, QString image, QString title, QStr
l->addWidget(aileron1CB); l->addWidget(aileron1CB);
l->addWidget(new QLabel(tr("Second Aileron Channel:"))); l->addWidget(new QLabel(tr("Second Aileron Channel:")));
l->addWidget(aileron2CB); l->addWidget(aileron2CB);
connect(noAileronsRB, SIGNAL(toggled(bool)), this, SLOT(noAileronChannel())); connect(noAileronsRB, SIGNAL(toggled(bool)), this, SLOT(noAileronChannel()));
connect(oneAileronRB, SIGNAL(toggled(bool)), this, SLOT(oneAileronChannel())); connect(oneAileronRB, SIGNAL(toggled(bool)), this, SLOT(oneAileronChannel()));
connect(twoAileronsRB, SIGNAL(toggled(bool)), this, SLOT(twoAileronChannels())); connect(twoAileronsRB, SIGNAL(toggled(bool)), this, SLOT(twoAileronChannels()));
@@ -448,10 +458,10 @@ void AileronsPage::initializePage()
bool AileronsPage::validatePage() bool AileronsPage::validatePage()
{ {
releaseBookings(); releaseBookings();
if (noAileronsRB->isChecked()) { if (noAileronsRB->isChecked()) {
return true; return true;
} }
if (oneAileronRB->isChecked()) { if (oneAileronRB->isChecked()) {
return (bookChannel(aileron1CB, AILERONS_INPUT, 100 )); return (bookChannel(aileron1CB, AILERONS_INPUT, 100 ));
} }
return( bookChannel(aileron1CB, AILERONS_INPUT, 100 ) && return( bookChannel(aileron1CB, AILERONS_INPUT, 100 ) &&
@@ -497,7 +507,7 @@ FlapsPage::FlapsPage(WizardDialog *dlg, QString image, QString title, QString te
l->addWidget(flap1CB); l->addWidget(flap1CB);
l->addWidget(new QLabel(tr("Second Flap Channel:"))); l->addWidget(new QLabel(tr("Second Flap Channel:")));
l->addWidget(flap2CB); l->addWidget(flap2CB);
connect(noFlapsRB, SIGNAL(toggled(bool)), this, SLOT(noFlapChannel())); connect(noFlapsRB, SIGNAL(toggled(bool)), this, SLOT(noFlapChannel()));
connect(oneFlapRB, SIGNAL(toggled(bool)), this, SLOT(oneFlapChannel())); connect(oneFlapRB, SIGNAL(toggled(bool)), this, SLOT(oneFlapChannel()));
connect(twoFlapsRB, SIGNAL(toggled(bool)), this, SLOT(twoFlapChannels())); connect(twoFlapsRB, SIGNAL(toggled(bool)), this, SLOT(twoFlapChannels()));
@@ -512,10 +522,10 @@ void FlapsPage::initializePage()
bool FlapsPage::validatePage() { bool FlapsPage::validatePage() {
releaseBookings(); releaseBookings();
if (noFlapsRB->isChecked()) { if (noFlapsRB->isChecked()) {
return true; return true;
} }
if (oneFlapRB->isChecked()) { if (oneFlapRB->isChecked()) {
return (bookChannel(flap1CB, FLAPS_INPUT, 100 )); return (bookChannel(flap1CB, FLAPS_INPUT, 100 ));
} }
return( bookChannel(flap1CB, FLAPS_INPUT, 100 ) && return( bookChannel(flap1CB, FLAPS_INPUT, 100 ) &&
@@ -561,7 +571,7 @@ AirbrakesPage::AirbrakesPage(WizardDialog *dlg, QString image, QString title, QS
l->addWidget(airbrake1CB); l->addWidget(airbrake1CB);
l->addWidget(new QLabel(tr("Second Airbrake Channel:"))); l->addWidget(new QLabel(tr("Second Airbrake Channel:")));
l->addWidget(airbrake2CB); l->addWidget(airbrake2CB);
connect(noAirbrakesRB, SIGNAL(toggled(bool)), this, SLOT(noAirbrakeChannel())); connect(noAirbrakesRB, SIGNAL(toggled(bool)), this, SLOT(noAirbrakeChannel()));
connect(oneAirbrakeRB, SIGNAL(toggled(bool)), this, SLOT(oneAirbrakeChannel())); connect(oneAirbrakeRB, SIGNAL(toggled(bool)), this, SLOT(oneAirbrakeChannel()));
connect(twoAirbrakesRB, SIGNAL(toggled(bool)), this, SLOT(twoAirbrakeChannels())); connect(twoAirbrakesRB, SIGNAL(toggled(bool)), this, SLOT(twoAirbrakeChannels()));
@@ -577,10 +587,10 @@ void AirbrakesPage::initializePage()
bool AirbrakesPage::validatePage() bool AirbrakesPage::validatePage()
{ {
releaseBookings(); releaseBookings();
if (noAirbrakesRB->isChecked()) { if (noAirbrakesRB->isChecked()) {
return true; return true;
} }
if (oneAirbrakeRB->isChecked()) { if (oneAirbrakeRB->isChecked()) {
return (bookChannel(airbrake1CB, AIRBRAKES_INPUT, 100 )); return (bookChannel(airbrake1CB, AIRBRAKES_INPUT, 100 ));
} }
return( bookChannel(airbrake1CB, AIRBRAKES_INPUT, 100 ) && return( bookChannel(airbrake1CB, AIRBRAKES_INPUT, 100 ) &&
@@ -708,11 +718,13 @@ TailPage::TailPage(WizardDialog *dlg, QString image, QString title, QString text
elevatorCB = new QComboBox(); elevatorCB = new QComboBox();
rudderCB = new QComboBox(); rudderCB = new QComboBox();
QLayout *l = layout(); l = layout();
l->addWidget(new QLabel(tr("Rudder Channel:"))); l->addWidget(new QLabel(tr("Rudder Channel:")));
l->addWidget(rudderCB); l->addWidget(rudderCB);
l->addWidget(new QLabel(tr("Elevator Channel:"))); l->addWidget(new QLabel(tr("Elevator Channel:")));
l->addWidget(elevatorCB); l->addWidget(elevatorCB);
errorMessage = NULL;
} }
void TailPage::initializePage() void TailPage::initializePage()
@@ -720,6 +732,13 @@ void TailPage::initializePage()
populateCB(elevatorCB, getDefaultChannel(ELEVATOR_INPUT)); populateCB(elevatorCB, getDefaultChannel(ELEVATOR_INPUT));
populateCB(rudderCB, getDefaultChannel(RUDDER_INPUT)); populateCB(rudderCB, getDefaultChannel(RUDDER_INPUT));
StandardPage::initializePage(); StandardPage::initializePage();
if (totalChannelsAvailable() < 2) {
errorMessage = new QLabel(tr("Only one channel still available!<br>"
"You probably should configure your model without using the wizard."));
errorMessage->setStyleSheet("QLabel { color : red; }");
l->addWidget(errorMessage);
}
} }
bool TailPage::validatePage() bool TailPage::validatePage()
@@ -729,9 +748,20 @@ bool TailPage::validatePage()
bookChannel(rudderCB, RUDDER_INPUT, 100)); bookChannel(rudderCB, RUDDER_INPUT, 100));
} }
void TailPage::cleanupPage()
{
if (errorMessage)
{
l->removeWidget(errorMessage);
delete errorMessage;
errorMessage = NULL;
}
StandardPage::cleanupPage();
}
SimpleTailPage::SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage) SimpleTailPage::SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage)
: StandardPage(Page_Simpletail, dlg, image, title, text, nextPage) : StandardPage(Page_Simpletail, dlg, image, title, text, nextPage)
{ {
elevatorCB = new QComboBox(); elevatorCB = new QComboBox();
QLayout *l = layout(); QLayout *l = layout();
@@ -1001,7 +1031,7 @@ WizardPrinter::WizardPrinter(WizMix *wizMix)
{ {
mix = wizMix; mix = wizMix;
} }
QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, int weight2 ) QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, int weight2 )
{ {
QString str; QString str;
+29 -25
View File
@@ -1,6 +1,6 @@
/* /*
* Author - Kjell Kernen * Author - Kjell Kernen
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
@@ -15,7 +15,7 @@
#ifndef WIZARDDIALOG_H #ifndef WIZARDDIALOG_H
#define WIZARDDIALOG_H #define WIZARDDIALOG_H
#include <QWizard> #include <QWizard>
#include "wizarddata.h" #include "wizarddata.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCheckBox; class QCheckBox;
@@ -46,7 +46,7 @@ class StandardPage: public QWizardPage
StandardPage(WizardPage curPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); StandardPage(WizardPage curPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
WizardDialog *wizDlg; WizardDialog *wizDlg;
protected: protected:
void releaseBookings(); void releaseBookings();
void releasePreBookings(); void releasePreBookings();
void initializePage(); void initializePage();
@@ -55,6 +55,7 @@ class StandardPage: public QWizardPage
int nextFreeChannel(int channel = 0); int nextFreeChannel(int channel = 0);
void populateCB(QComboBox * cb, int preferred=-1); void populateCB(QComboBox * cb, int preferred=-1);
bool bookChannel(QComboBox * cb, Input input1, int weight1, Input input2=NO_INPUT, int weight2=0); bool bookChannel(QComboBox * cb, Input input1, int weight1, Input input2=NO_INPUT, int weight2=0);
int totalChannelsAvailable();
private: private:
QLabel *topLabel; QLabel *topLabel;
@@ -67,48 +68,48 @@ class ModelSelectionPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
ModelSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); ModelSelectionPage(WizardDialog *dlg, QString image, QString title, QString text);
private: private:
QLineEdit *nameLineEdit; QLineEdit *nameLineEdit;
QRadioButton *planeRB; QRadioButton *planeRB;
QRadioButton *multirotorRB; QRadioButton *multirotorRB;
QRadioButton *helicopterRB; QRadioButton *helicopterRB;
bool validatePage(); bool validatePage();
int nextId() const; int nextId() const;
}; };
class WingtypeSelectionPage: public StandardPage class WingtypeSelectionPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
WingtypeSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); WingtypeSelectionPage(WizardDialog *dlg, QString image, QString title, QString text);
private: private:
QRadioButton *deltaWingRB; QRadioButton *deltaWingRB;
QRadioButton *standardWingRB; QRadioButton *standardWingRB;
int nextId() const; int nextId() const;
}; };
class TailSelectionPage: public StandardPage class TailSelectionPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
TailSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); TailSelectionPage(WizardDialog *dlg, QString image, QString title, QString text);
private: private:
QRadioButton *vTailRB; QRadioButton *vTailRB;
QRadioButton *standardTailRB; QRadioButton *standardTailRB;
QRadioButton *simpleTailRB; QRadioButton *simpleTailRB;
int nextId() const; int nextId() const;
}; };
class FlybarSelectionPage: public StandardPage class FlybarSelectionPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
FlybarSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); FlybarSelectionPage(WizardDialog *dlg, QString image, QString title, QString text);
private: private:
QRadioButton *flybarRB; QRadioButton *flybarRB;
QRadioButton *noFlybarRB; QRadioButton *noFlybarRB;
int nextId() const; int nextId() const;
}; };
class ThrottlePage: public StandardPage class ThrottlePage: public StandardPage
@@ -133,10 +134,10 @@ class AileronsPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
AileronsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); AileronsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
protected slots: protected slots:
void noAileronChannel(); void noAileronChannel();
void oneAileronChannel(); void oneAileronChannel();
@@ -154,7 +155,7 @@ class FlapsPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
FlapsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); FlapsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
@@ -175,7 +176,7 @@ class AirbrakesPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
AirbrakesPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); AirbrakesPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
@@ -229,19 +230,22 @@ class TailPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
TailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); TailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
void cleanupPage();
bool validatePage(); bool validatePage();
private: private:
QComboBox *elevatorCB; QComboBox *elevatorCB;
QComboBox *rudderCB; QComboBox *rudderCB;
QLayout *l;
QLabel *errorMessage;
}; };
class VTailPage: public StandardPage class VTailPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
VTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); VTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -253,7 +257,7 @@ class SimpleTailPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -264,7 +268,7 @@ class CyclicPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
CyclicPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); CyclicPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -278,7 +282,7 @@ class GyroPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
GyroPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); GyroPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -291,7 +295,7 @@ class FblPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
FblPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); FblPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -305,7 +309,7 @@ class HeliPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
HeliPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); HeliPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -319,7 +323,7 @@ class MultirotorPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
MultirotorPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); MultirotorPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -333,7 +337,7 @@ class OptionsPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
OptionsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); OptionsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private:
@@ -346,7 +350,7 @@ class ConclusionPage: public StandardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
ConclusionPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); ConclusionPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void initializePage(); void initializePage();
bool validatePage(); bool validatePage();
private: private: