QVisu
Qt-based visualization for smart homes
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
C:/Users/max/ti/qt5/qvisu/qvsvgwidget.h
1 /* QVisu (c) 2015 Maximilian Gauger mgauger@kalassi.de
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12 
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef QVSVGWIDGET_H
18 #define QVSVGWIDGET_H
19 
20 #include <QSvgWidget>
21 #include <QByteArray>
22 #include <QtXml>
23 
24 class QVSvgWidget : public QSvgWidget
25 {
26  Q_OBJECT
27 public:
28  explicit QVSvgWidget(QWidget *parent = 0);
29  explicit QVSvgWidget(QString file, QWidget *parent = 0);
30 
31  QSize defaultSize() const;
32  float aspectRatio() const;
33 
34  void mousePressEvent(QMouseEvent*);
35  void mouseMoveEvent(QMouseEvent*);
36  void resizeEvent(QResizeEvent*);
37  void mouseReleaseEvent(QMouseEvent*);
38 
39 signals:
40  void clicked(double xrel, double yrel);
41  void dragged(double xrel, double yrel);
42  void released(double xrel, double yrel);
43 
44 public slots:
45  void load(const QByteArray&);
46  void setPathStyle(QString property, QString value, QString id = "", bool force_insert = false);
47  void preserveAspectRatio(bool);
48 
49 private:
50  QByteArray svg_data;
51  void updateSubPath(QDomElement &elem, QString property, QString value, QString id, bool force_insert);
52  QTime drag_timer;
53 
54  bool preserve_aspect_ratio;
55 };
56 
57 #endif // QVSVGWIDGET_H
Definition: qvsvgwidget.h:24