LP-106 Setup Wizard refresh : Add dual servo setup (dual aileron or
[librepilot.git] / ground / gcs / src / plugins / setupwizard / vehicletemplateselectorwidget.h
blob0fd37f18c97dfc6cb2c55fe178b420d9ab81dd0e
1 /**
2 ******************************************************************************
4 * @file vehicletemplateselectorwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
6 * @addtogroup [Group]
7 * @{
8 * @addtogroup VehicleTemplateSelectorWidget
9 * @{
10 * @brief [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 VEHICLETEMPLATESELECTORWIDGET_H
29 #define VEHICLETEMPLATESELECTORWIDGET_H
31 #include <QGraphicsItem>
32 #include <QJsonObject>
33 #include <QWidget>
35 namespace Ui {
36 class VehicleTemplateSelectorWidget;
39 class VehicleTemplate {
40 public:
41 VehicleTemplate(QJsonObject *templateObject, bool editable, QString templatePath) :
42 m_templateObject(templateObject), m_editable(editable), m_templatePath(templatePath) {}
44 ~VehicleTemplate()
46 if (m_templateObject) {
47 delete m_templateObject;
51 QJsonObject *templateObject()
53 return m_templateObject;
56 bool editable()
58 return m_editable;
61 QString templatePath()
63 return m_templatePath;
66 private:
67 QJsonObject *m_templateObject;
68 bool m_editable;
69 QString m_templatePath;
72 class VehicleTemplateSelectorWidget : public QWidget {
73 Q_OBJECT
75 public:
76 explicit VehicleTemplateSelectorWidget(QWidget *parent = 0);
77 ~VehicleTemplateSelectorWidget();
78 void setTemplateInfo(int vehicleType, int vehicleSubType, bool showTemplateControls);
79 QJsonObject *selectedTemplate() const;
80 public slots:
81 void templateSelectionChanged();
83 protected:
84 void resizeEvent(QResizeEvent *);
85 void showEvent(QShowEvent *);
87 private:
88 Ui::VehicleTemplateSelectorWidget *ui;
89 int m_vehicleType;
90 int m_vehicleSubType;
92 QMap<QString, VehicleTemplate *> m_templates;
93 QGraphicsPixmapItem *m_photoItem;
95 void loadValidFiles();
96 void loadFilesInDir(QString templateBasePath, bool local);
97 void setupTemplateList();
98 QString getTemplateKey(QJsonObject *templ);
99 void updatePhoto(QJsonObject *templ);
100 void updateDescription(QJsonObject *templ);
101 bool airframeIsCompatible(int vehicleType, int vehicleSubType);
102 QString getTemplatePath();
103 bool selectedTemplateEditable() const;
104 QString selectedTemplatePath() const;
106 private slots:
107 void updateTemplates();
108 void deleteSelectedTemplate();
109 void addTemplate();
112 Q_DECLARE_METATYPE(QJsonObject *)
114 #endif // VEHICLETEMPLATESELECTORWIDGET_H