2 ******************************************************************************
4 * @file vehicletemplateselectorwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
8 * @addtogroup VehicleTemplateSelectorWidget
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
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>
36 class VehicleTemplateSelectorWidget
;
39 class VehicleTemplate
{
41 VehicleTemplate(QJsonObject
*templateObject
, bool editable
, QString templatePath
) :
42 m_templateObject(templateObject
), m_editable(editable
), m_templatePath(templatePath
) {}
46 if (m_templateObject
) {
47 delete m_templateObject
;
51 QJsonObject
*templateObject()
53 return m_templateObject
;
61 QString
templatePath()
63 return m_templatePath
;
67 QJsonObject
*m_templateObject
;
69 QString m_templatePath
;
72 class VehicleTemplateSelectorWidget
: public QWidget
{
76 explicit VehicleTemplateSelectorWidget(QWidget
*parent
= 0);
77 ~VehicleTemplateSelectorWidget();
78 void setTemplateInfo(int vehicleType
, int vehicleSubType
, bool showTemplateControls
);
79 QJsonObject
*selectedTemplate() const;
81 void templateSelectionChanged();
84 void resizeEvent(QResizeEvent
*);
85 void showEvent(QShowEvent
*);
88 Ui::VehicleTemplateSelectorWidget
*ui
;
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;
107 void updateTemplates();
108 void deleteSelectedTemplate();
112 Q_DECLARE_METATYPE(QJsonObject
*)
114 #endif // VEHICLETEMPLATESELECTORWIDGET_H