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
38QT_BEGIN_NAMESPACE
39class QCheckBox;
40class QGraphicsLinearLayout;
41class QGraphicsRectItem;
42class QGraphicsScene;
43class QGraphicsWidget;
44QT_END_NAMESPACE
45
46class View;
47class Chart;
48class Grid;
49
50QT_CHARTS_BEGIN_NAMESPACE
51class QChart;
52QT_CHARTS_END_NAMESPACE
53
54QT_CHARTS_USE_NAMESPACE
55
56
57class Window: public QMainWindow
58{
59 Q_OBJECT
60public:
61 explicit Window(const QVariantHash &parameters, QWidget *parent = 0);
62 ~Window();
63
64private Q_SLOTS:
65 void updateUI();
66 void handleGeometryChanged();
67 void handleChartSelected(QChart *chart);
68private:
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 *createMenu();
89 QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data);
90 void initializeFromParamaters(const QVariantHash &parameters);
91
92private:
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 *m_menu;
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
123class ComboBox: public QComboBox
124{
125public:
126 ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window)
127 {}
128
129protected:
130 void focusInEvent(QFocusEvent *e) {
131 QComboBox::focusInEvent(e);
132 m_window->comboBoxFocused(combox: this);
133 }
134private:
135 Window *m_window;
136};
137
138#endif
139

source code of qtcharts/tests/manual/chartviewer/window.h