QVisu
Qt-based visualization for smart homes
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
C:/Users/max/ti/qt5/qvisu/qvelement.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 QVELEMENT_H
18 #define QVELEMENT_H
19 
20 #include <QFrame>
21 #include <QPushButton>
22 #include <QList>
23 #include <QString>
24 #include <QtXml>
25 #include <QMap>
26 #include <QResizeEvent>
27 #include "qvitem.h"
28 
29 
34 class QVElement : public QFrame
35 {
36  Q_OBJECT
37 public:
47  explicit QVElement(QDomElement xml_desc,QString container,QWidget *parent = 0);
48 
50  QList<QString> getItemList();
52  QList<int> getGeometry();
53 
55  static QString findFilePath(QString name);
57  static QString colorString(QString);
58 
59 protected:
61  virtual void resizeEvent(QResizeEvent * event);
67  QString getItemByAction(QString action, int index = 0);
69  int w;
71  int h;
73  QString container;
75  QMap<QString,QVItem> items;
76 
78  int height();
80  int width();
82  int ofs_x();
84  int ofs_y();
85 
86  /* Defines (disguised as methods) */
87  double max_icon_width() { return 0.2; } /* Ratio of icon width to total width */
88  double max_label_height() { return 0.2; } /* Ratio of maximum label (icon+text) height to total height */
89 
90 signals:
92  void valueModified(QString,QString);
94  void requestSeries(QString item, QString series_type, QString start);
95 
96 public slots:
100  virtual void onValueChanged(QString,QString);
102  virtual void onSeriesReceived(QString,QMap<double,double>);
104  void onContainerChanged(QString);
106  virtual void onInitCompleted();
107 
108 protected:
109  QString color, active_color;
110 
111 private:
112  int x;
113  int y;
114 
115 };
116 
117 QVElement *createQVElement(QDomElement xml_desc, QString container, QWidget *parent = 0);
118 
119 #endif // QVELEMENT_H
int h
Definition: qvelement.h:71
QList< int > getGeometry()
Definition: qvelement.cpp:141
static QString colorString(QString)
Definition: qvelement.cpp:202
int ofs_y()
Definition: qvelement.cpp:196
QVElement(QDomElement xml_desc, QString container, QWidget *parent=0)
Definition: qvelement.cpp:33
Definition: qvelement.h:34
QMap< QString, QVItem > items
Definition: qvelement.h:75
int w
Definition: qvelement.h:69
virtual void onInitCompleted()
Definition: qvelement.cpp:174
int ofs_x()
Definition: qvelement.cpp:192
int width()
Definition: qvelement.cpp:184
QString getItemByAction(QString action, int index=0)
Definition: qvelement.cpp:132
QList< QString > getItemList()
Definition: qvelement.cpp:128
void requestSeries(QString item, QString series_type, QString start)
void valueModified(QString, QString)
virtual void onValueChanged(QString, QString)
Definition: qvelement.cpp:172
virtual void onSeriesReceived(QString, QMap< double, double >)
Definition: qvelement.cpp:173
void onContainerChanged(QString)
Definition: qvelement.cpp:176
static QString findFilePath(QString name)
Definition: qvelement.cpp:151
virtual void resizeEvent(QResizeEvent *event)
Definition: qvelement.cpp:171
QString container
Definition: qvelement.h:73
int height()
Definition: qvelement.cpp:188