1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #ifndef WINDOW_H |
31 | #define WINDOW_H |
32 | #include <QtWidgets/QMainWindow> |
33 | #include <QtCharts/QChartGlobal> |
34 | #include <QtCore/QHash> |
35 | #include <QtWidgets/QComboBox> |
36 | #include <QtWidgets/QSpinBox> |
37 | |
38 | QT_BEGIN_NAMESPACE |
39 | class QCheckBox; |
40 | class QGraphicsLinearLayout; |
41 | class QGraphicsRectItem; |
42 | class QGraphicsScene; |
43 | class QGraphicsWidget; |
44 | QT_END_NAMESPACE |
45 | |
46 | class View; |
47 | class Chart; |
48 | class Grid; |
49 | |
50 | QT_CHARTS_BEGIN_NAMESPACE |
51 | class QChart; |
52 | QT_CHARTS_END_NAMESPACE |
53 | |
54 | QT_CHARTS_USE_NAMESPACE |
55 | |
56 | |
57 | class Window: public QMainWindow |
58 | { |
59 | Q_OBJECT |
60 | public: |
61 | explicit Window(const QVariantHash ¶meters, QWidget *parent = 0); |
62 | ~Window(); |
63 | |
64 | private Q_SLOTS: |
65 | void updateUI(); |
66 | void handleGeometryChanged(); |
67 | void handleChartSelected(QChart *chart); |
68 | private: |
69 | QComboBox *createViewBox(); |
70 | QComboBox *createThemeBox(); |
71 | QComboBox *createAnimationBox(); |
72 | QComboBox *createLegendBox(); |
73 | QComboBox *createTempleteBox(); |
74 | void connectSignals(); |
75 | void createProxyWidgets(); |
76 | void comboBoxFocused(QComboBox *combox); |
77 | inline void checkAnimationOptions(); |
78 | inline void checkView(); |
79 | inline void checkLegend(); |
80 | inline void checkOpenGL(); |
81 | inline void checkTheme(); |
82 | inline void checkState(); |
83 | inline void checkTemplate(); |
84 | inline void checkXTick(); |
85 | inline void checkYTick(); |
86 | inline void checkMinorXTick(); |
87 | inline void checkMinorYTick(); |
88 | QMenu *(); |
89 | QAction *(QMenu *, const QIcon &icon, const QString &text, const QVariant &data); |
90 | void initializeFromParamaters(const QVariantHash ¶meters); |
91 | |
92 | private: |
93 | QGraphicsScene *m_scene; |
94 | View *m_view; |
95 | QHash<QString, QGraphicsProxyWidget *> m_widgetHash; |
96 | |
97 | QGraphicsWidget *m_form; |
98 | QComboBox *m_themeComboBox; |
99 | QSpinBox *m_xTickSpinBox; |
100 | QSpinBox *m_yTickSpinBox; |
101 | QSpinBox *m_minorXTickSpinBox; |
102 | QSpinBox *m_minorYTickSpinBox; |
103 | QCheckBox *m_antialiasCheckBox; |
104 | QComboBox *m_animatedComboBox; |
105 | QComboBox *m_legendComboBox; |
106 | QComboBox *m_templateComboBox; |
107 | QComboBox *m_viewComboBox; |
108 | QCheckBox *m_openGLCheckBox; |
109 | QCheckBox *m_zoomCheckBox; |
110 | QCheckBox *m_scrollCheckBox; |
111 | QCheckBox *m_gridCheckBox; |
112 | QGraphicsLinearLayout *m_baseLayout; |
113 | QMenu *; |
114 | int m_template; |
115 | Grid *m_grid; |
116 | QString m_category; |
117 | QString m_subcategory; |
118 | QString m_name; |
119 | |
120 | friend class ComboBox; |
121 | }; |
122 | |
123 | class ComboBox: public QComboBox |
124 | { |
125 | public: |
126 | ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window) |
127 | {} |
128 | |
129 | protected: |
130 | void focusInEvent(QFocusEvent *e) { |
131 | QComboBox::focusInEvent(e); |
132 | m_window->comboBoxFocused(combox: this); |
133 | } |
134 | private: |
135 | Window *m_window; |
136 | }; |
137 | |
138 | #endif |
139 | |