LP-106 Setup Wizard refresh : Add dual servo setup (dual aileron or
[librepilot.git] / ground / gcs / src / plugins / setupwizard / pages / selectionpage.h
blob045998d42f7ffeb1ae5df5dc58c7ebc292fc49c7
1 /**
2 ******************************************************************************
4 * @file subvehiclepage.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
6 * @addtogroup
7 * @{
8 * @addtogroup SubVehiclePage
9 * @{
10 * @brief
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef SUBVEHICLEPAGEPAGE_H
29 #define SUBVEHICLEPAGEPAGE_H
31 #include <QtSvg/QGraphicsSvgItem>
32 #include <QtSvg/QSvgRenderer>
33 #include <QList>
35 #include "abstractwizardpage.h"
37 namespace Ui {
38 class SelectionPage;
41 class SelectionItem {
42 public:
43 SelectionItem(QString name, QString description, QString shapeId, int id, bool disabled = false);
45 QString name()
47 return m_name;
49 QString description()
51 return m_description;
53 QString shapeId()
55 return m_shapeId;
57 int id()
59 return m_id;
61 void setDisabled(bool disabled)
63 m_disabled = disabled;
65 bool disabled()
67 return m_disabled;
70 private:
71 QString m_name;
72 QString m_description;
73 QString m_shapeId;
74 int m_id;
75 bool m_disabled;
78 class Selection {
79 public:
80 Selection() {}
81 virtual void addItem(QString name, QString description, QString shapeId, int id, bool disabled = false) = 0;
82 virtual void setTitle(QString title) = 0;
83 virtual void setText(QString text) = 0;
84 virtual void setItemDisabled(int id, bool disabled) = 0;
87 class SelectionPage : public AbstractWizardPage, public Selection {
88 Q_OBJECT
90 public:
91 explicit SelectionPage(SetupWizard *wizard, QString shapeFile, QWidget *parent = 0);
92 ~SelectionPage();
94 void initializePage();
95 bool validatePage();
96 void addItem(QString name, QString description, QString shapeId, int id, bool disabled = false);
97 void setTitle(QString title);
98 void setText(QString text);
99 void setItemDisabled(int id, bool disabled);
100 void setSelectedItem(int id);
101 SelectionItem *getSelectedItem();
103 protected:
104 virtual void setupSelection(Selection *selection) = 0;
105 virtual void initializePage(VehicleConfigurationSource *settings) = 0;
106 virtual bool validatePage(SelectionItem *selectedItem) = 0;
107 void resizeEvent(QResizeEvent *event);
108 void showEvent(QShowEvent *event);
110 private:
111 Ui::SelectionPage *ui;
112 QGraphicsSvgItem *m_shape;
113 QList<SelectionItem *> m_selectionItems;
115 private slots:
116 void selectionChanged(int index);
117 void fitImage();
120 #endif // SUBVEHICLEPAGEPAGE_H