1 /* 2 Copyright 2006-2019 The QElectroTech Team 3 This file is part of QElectroTech. 4 5 QElectroTech is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 2 of the License, or 8 (at your option) any later version. 9 10 QElectroTech is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 #ifndef POLYGON_EDITOR_H 19 #define POLYGON_EDITOR_H 20 21 #include "elementitemeditor.h" 22 #include <QTreeWidget> 23 #include <QCheckBox> 24 25 class PartPolygon; 26 class StyleEditor; 27 class QTreeWidget; 28 29 /** 30 This class provides a widget to edit polygons within the element editor. 31 */ 32 class PolygonEditor : public ElementItemEditor { 33 34 Q_OBJECT 35 36 // constructors, destructor 37 public: 38 PolygonEditor(QETElementEditor *, PartPolygon * = nullptr, QWidget * = nullptr); 39 ~PolygonEditor() override; 40 41 private: 42 PolygonEditor(const PolygonEditor &); 43 44 // attributes 45 private: 46 PartPolygon *part; 47 StyleEditor *style_; 48 QTreeWidget points_list; 49 QCheckBox close_polygon; 50 51 // methods 52 public: 53 bool setPart(CustomElementPart *) override; 54 CustomElementPart *currentPart() const override; 55 56 private: 57 QVector<QPointF> getPointsFromTree(); 58 59 public slots: 60 void updatePolygonPoints(); 61 void updatePolygonClosedState(); 62 void updateForm() override; 63 void validColumn(QTreeWidgetItem *qtwi, int column); 64 65 private: 66 void activeConnections(bool); 67 }; 68 #endif 69