| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#ifndef WINDOW_H |
| 5 |
#define WINDOW_H |
| 6 |
#include <QtWidgets/QMainWindow> |
| 7 |
#include <QtCharts/QChartGlobal> |
| 8 |
#include <QtCore/QHash> |
| 9 |
#include <QtWidgets/QComboBox> |
| 10 |
#include <QtWidgets/QSpinBox> |
| 11 |
|
| 12 |
QT_BEGIN_NAMESPACE |
| 13 |
class QCheckBox; |
| 14 |
class QGraphicsLinearLayout; |
| 15 |
class QGraphicsRectItem; |
| 16 |
class QGraphicsScene; |
| 17 |
class QGraphicsWidget; |
| 18 |
QT_END_NAMESPACE |
| 19 |
|
| 20 |
class View; |
| 21 |
class Chart; |
| 22 |
class Grid; |
| 23 |
|
| 24 |
QT_BEGIN_NAMESPACE |
| 25 |
class QChart; |
| 26 |
QT_END_NAMESPACE |
| 27 |
|
| 28 |
QT_USE_NAMESPACE |
| 29 |
|
| 30 |
|
| 31 |
class Window: public QMainWindow |
| 32 |
{ |
| 33 |
Q_OBJECT |
| 34 |
public: |
| 35 |
explicit Window(const QVariantHash ¶meters, QWidget *parent = 0); |
| 36 |
~Window(); |
| 37 |
|
| 38 |
private Q_SLOTS: |
| 39 |
void updateUI(); |
| 40 |
void handleGeometryChanged(); |
| 41 |
void handleChartSelected(QChart *chart); |
| 42 |
private: |
| 43 |
QComboBox *createViewBox(); |
| 44 |
QComboBox *createThemeBox(); |
| 45 |
QComboBox *createAnimationBox(); |
| 46 |
QComboBox *createLegendBox(); |
| 47 |
QComboBox *createTempleteBox(); |
| 48 |
void connectSignals(); |
| 49 |
void createProxyWidgets(); |
| 50 |
void comboBoxFocused(QComboBox *combox); |
| 51 |
inline void checkAnimationOptions(); |
| 52 |
inline void checkView(); |
| 53 |
inline void checkLegend(); |
| 54 |
inline void checkOpenGL(); |
| 55 |
inline void checkTheme(); |
| 56 |
inline void checkState(); |
| 57 |
inline void checkTemplate(); |
| 58 |
inline void checkXTick(); |
| 59 |
inline void checkYTick(); |
| 60 |
inline void checkMinorXTick(); |
| 61 |
inline void checkMinorYTick(); |
| 62 |
QMenu *createMenu(); |
| 63 |
QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data); |
| 64 |
void initializeFromParamaters(const QVariantHash ¶meters); |
| 65 |
|
| 66 |
private: |
| 67 |
QGraphicsScene *m_scene; |
| 68 |
View *m_view; |
| 69 |
QHash<QString, QGraphicsProxyWidget *> m_widgetHash; |
| 70 |
|
| 71 |
QGraphicsWidget *m_form; |
| 72 |
QComboBox *m_themeComboBox; |
| 73 |
QSpinBox *m_xTickSpinBox; |
| 74 |
QSpinBox *m_yTickSpinBox; |
| 75 |
QSpinBox *m_minorXTickSpinBox; |
| 76 |
QSpinBox *m_minorYTickSpinBox; |
| 77 |
QCheckBox *m_antialiasCheckBox; |
| 78 |
QComboBox *m_animatedComboBox; |
| 79 |
QComboBox *m_legendComboBox; |
| 80 |
QComboBox *m_templateComboBox; |
| 81 |
QComboBox *m_viewComboBox; |
| 82 |
QCheckBox *m_openGLCheckBox; |
| 83 |
QCheckBox *m_zoomCheckBox; |
| 84 |
QCheckBox *m_scrollCheckBox; |
| 85 |
QCheckBox *m_gridCheckBox; |
| 86 |
QGraphicsLinearLayout *m_baseLayout; |
| 87 |
QMenu *m_menu; |
| 88 |
int m_template; |
| 89 |
Grid *m_grid; |
| 90 |
QString m_category; |
| 91 |
QString m_subcategory; |
| 92 |
QString m_name; |
| 93 |
|
| 94 |
friend class ComboBox; |
| 95 |
}; |
| 96 |
|
| 97 |
class ComboBox: public QComboBox |
| 98 |
{ |
| 99 |
public: |
| 100 |
ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window) |
| 101 |
{} |
| 102 |
|
| 103 |
protected: |
| 104 |
void focusInEvent(QFocusEvent *e) { |
| 105 |
QComboBox::focusInEvent(e); |
| 106 |
m_window->comboBoxFocused(this); |
| 107 |
} |
| 108 |
private: |
| 109 |
Window *m_window; |
| 110 |
}; |
| 111 |
|
| 112 |
#endif |