@@ -0,0 +1,238 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include "grid.h" | |||
|
22 | #include "charts.h" | |||
|
23 | #include <qchart.h> | |||
|
24 | #include <QGraphicsGridLayout> | |||
|
25 | #include <QGraphicsSceneMouseEvent> | |||
|
26 | #include <QDebug> | |||
|
27 | ||||
|
28 | Grid::Grid(int size,QGraphicsItem *parent):QGraphicsWidget(parent), | |||
|
29 | m_listCount(3), | |||
|
30 | m_valueMax(10), | |||
|
31 | m_valueCount(7), | |||
|
32 | m_size(size), | |||
|
33 | m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)), | |||
|
34 | m_rubberBand(new QGraphicsRectItem()), | |||
|
35 | m_gridLayout(new QGraphicsGridLayout()) | |||
|
36 | { | |||
|
37 | setLayout(m_gridLayout); | |||
|
38 | m_rubberBand->setParentItem(this); | |||
|
39 | m_rubberBand->setVisible(false); | |||
|
40 | m_rubberBand->setZValue(2); | |||
|
41 | } | |||
|
42 | ||||
|
43 | Grid::~Grid() | |||
|
44 | { | |||
|
45 | ||||
|
46 | } | |||
|
47 | ||||
|
48 | void Grid::createCharts() | |||
|
49 | { | |||
|
50 | clear(); | |||
|
51 | ||||
|
52 | Charts::ChartList list = Charts::chartList(); | |||
|
53 | ||||
|
54 | for (int i = 0; i < m_size * m_size; ++i) { | |||
|
55 | QChart *chart = 0; | |||
|
56 | if (i < list.size()) { | |||
|
57 | chart = list.at(i)->createChart(m_dataTable); | |||
|
58 | } | |||
|
59 | else { | |||
|
60 | chart = new QChart(); | |||
|
61 | chart->setTitle(QObject::tr("Empty")); | |||
|
62 | } | |||
|
63 | ||||
|
64 | m_gridLayout->addItem(chart, i / m_size, i % m_size); | |||
|
65 | m_chartHash[chart] = i; | |||
|
66 | } | |||
|
67 | ||||
|
68 | } | |||
|
69 | ||||
|
70 | void Grid::createCharts(const QString& category) | |||
|
71 | { | |||
|
72 | clear(); | |||
|
73 | ||||
|
74 | QChart *qchart(0); | |||
|
75 | Charts::ChartList list = Charts::chartList(); | |||
|
76 | ||||
|
77 | int j = 0; | |||
|
78 | for (int i = 0; i < list.size(); ++i) { | |||
|
79 | Chart *chart = list.at(i); | |||
|
80 | if (chart->category() == category && j < m_size * m_size) { | |||
|
81 | qchart = list.at(i)->createChart(m_dataTable); | |||
|
82 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); | |||
|
83 | m_chartHash[qchart] = j; | |||
|
84 | j++; | |||
|
85 | } | |||
|
86 | } | |||
|
87 | for (; j < m_size * m_size; ++j) { | |||
|
88 | qchart = new QChart(); | |||
|
89 | qchart->setTitle(QObject::tr("Empty")); | |||
|
90 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); | |||
|
91 | m_chartHash[qchart] = j; | |||
|
92 | } | |||
|
93 | ||||
|
94 | m_gridLayout->activate(); | |||
|
95 | } | |||
|
96 | ||||
|
97 | void Grid::clear() | |||
|
98 | { | |||
|
99 | for (int i = 0; i < m_gridLayout->count(); ++i) { | |||
|
100 | m_gridLayout->removeAt(i); | |||
|
101 | } | |||
|
102 | ||||
|
103 | qDeleteAll(m_chartHash.keys()); | |||
|
104 | m_chartHash.clear(); | |||
|
105 | } | |||
|
106 | ||||
|
107 | QList<QChart*> Grid::charts() | |||
|
108 | { | |||
|
109 | return m_chartHash.keys(); | |||
|
110 | } | |||
|
111 | ||||
|
112 | void Grid::setState(State state) | |||
|
113 | { | |||
|
114 | m_state = state; | |||
|
115 | } | |||
|
116 | ||||
|
117 | void Grid::setRubberPen(const QPen& pen) | |||
|
118 | { | |||
|
119 | m_rubberBand->setPen(pen); | |||
|
120 | } | |||
|
121 | ||||
|
122 | void Grid::replaceChart(QChart* oldChart, Chart* newChart) | |||
|
123 | { | |||
|
124 | int index = m_chartHash[oldChart]; | |||
|
125 | //not in 4.7.2 m_baseLayout->removeItem(qchart); | |||
|
126 | for (int i = 0; i < m_gridLayout->count(); ++i) { | |||
|
127 | if (m_gridLayout->itemAt(i) == oldChart) { | |||
|
128 | m_gridLayout->removeAt(i); | |||
|
129 | break; | |||
|
130 | } | |||
|
131 | } | |||
|
132 | m_chartHash.remove(oldChart); | |||
|
133 | QChart *chart = newChart->createChart(m_dataTable); | |||
|
134 | m_gridLayout->addItem(chart, index / m_size, index % m_size); | |||
|
135 | m_chartHash[chart] = index; | |||
|
136 | delete oldChart; | |||
|
137 | } | |||
|
138 | ||||
|
139 | void Grid::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||
|
140 | { | |||
|
141 | if (event->button() == Qt::LeftButton) { | |||
|
142 | ||||
|
143 | m_origin = event->pos(); | |||
|
144 | m_currentState = NoState; | |||
|
145 | ||||
|
146 | foreach (QChart *chart, charts()) { | |||
|
147 | ||||
|
148 | QRectF geometryRect = chart->geometry(); | |||
|
149 | QRectF plotArea = chart->plotArea(); | |||
|
150 | plotArea.translate(geometryRect.topLeft()); | |||
|
151 | if (plotArea.contains(m_origin)) { | |||
|
152 | m_currentState = m_state; | |||
|
153 | if (m_currentState == NoState) emit chartSelected(chart); | |||
|
154 | break; | |||
|
155 | } | |||
|
156 | } | |||
|
157 | if (m_currentState == ZoomState) { | |||
|
158 | m_rubberBand->setRect(QRectF(m_origin, QSize())); | |||
|
159 | m_rubberBand->setVisible(true); | |||
|
160 | } | |||
|
161 | ||||
|
162 | event->accept(); | |||
|
163 | } | |||
|
164 | ||||
|
165 | if (event->button() == Qt::RightButton) { | |||
|
166 | m_origin = event->pos(); | |||
|
167 | m_currentState = m_state; | |||
|
168 | } | |||
|
169 | } | |||
|
170 | ||||
|
171 | void Grid::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||
|
172 | { | |||
|
173 | if (m_currentState != NoState) { | |||
|
174 | ||||
|
175 | foreach (QChart *chart, charts()) { | |||
|
176 | ||||
|
177 | QRectF geometryRect = chart->geometry(); | |||
|
178 | QRectF plotArea = chart->plotArea(); | |||
|
179 | plotArea.translate(geometryRect.topLeft()); | |||
|
180 | ||||
|
181 | if (plotArea.contains(m_origin)) { | |||
|
182 | if (m_currentState == ScrollState) { | |||
|
183 | QPointF delta = m_origin - event->pos(); | |||
|
184 | chart->scroll(delta.x(), -delta.y()); | |||
|
185 | } | |||
|
186 | if (m_currentState == ZoomState && plotArea.contains(event->pos())) | |||
|
187 | m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized()); | |||
|
188 | break; | |||
|
189 | } | |||
|
190 | } | |||
|
191 | if (m_currentState == ScrollState) | |||
|
192 | m_origin = event->pos(); | |||
|
193 | event->accept(); | |||
|
194 | } | |||
|
195 | } | |||
|
196 | ||||
|
197 | void Grid::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) | |||
|
198 | { | |||
|
199 | if (event->button() == Qt::LeftButton) { | |||
|
200 | if (m_currentState == ZoomState) { | |||
|
201 | m_rubberBand->setVisible(false); | |||
|
202 | ||||
|
203 | foreach (QChart *chart, charts()) { | |||
|
204 | ||||
|
205 | QRectF geometryRect = chart->geometry(); | |||
|
206 | QRectF plotArea = chart->plotArea(); | |||
|
207 | plotArea.translate(geometryRect.topLeft()); | |||
|
208 | ||||
|
209 | if (plotArea.contains(m_origin)) { | |||
|
210 | QRectF rect = m_rubberBand->rect(); | |||
|
211 | rect.translate(-geometryRect.topLeft()); | |||
|
212 | chart->zoomIn(rect); | |||
|
213 | break; | |||
|
214 | } | |||
|
215 | } | |||
|
216 | } | |||
|
217 | ||||
|
218 | m_currentState = NoState; | |||
|
219 | event->accept(); | |||
|
220 | } | |||
|
221 | ||||
|
222 | if (event->button() == Qt::RightButton) { | |||
|
223 | ||||
|
224 | if (m_currentState == ZoomState) { | |||
|
225 | foreach (QChart *chart, charts()) { | |||
|
226 | ||||
|
227 | QRectF geometryRect = chart->geometry(); | |||
|
228 | QRectF plotArea = chart->plotArea(); | |||
|
229 | plotArea.translate(geometryRect.topLeft()); | |||
|
230 | ||||
|
231 | if (plotArea.contains(m_origin)) { | |||
|
232 | chart->zoomOut(); | |||
|
233 | break; | |||
|
234 | } | |||
|
235 | } | |||
|
236 | } | |||
|
237 | } | |||
|
238 | } |
@@ -0,0 +1,75 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #ifndef GRID_H_ | |||
|
22 | #define GRID_H_ | |||
|
23 | ||||
|
24 | #include "model.h" | |||
|
25 | #include <QGraphicsWidget> | |||
|
26 | #include <QChartGlobal> | |||
|
27 | ||||
|
28 | class QGraphicsGridLayout; | |||
|
29 | class GridControl; | |||
|
30 | class Chart; | |||
|
31 | ||||
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
33 | class QChart; | |||
|
34 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
35 | ||||
|
36 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
37 | ||||
|
38 | class Grid : public QGraphicsWidget | |||
|
39 | { | |||
|
40 | Q_OBJECT | |||
|
41 | public: | |||
|
42 | enum State { NoState = 0, ZoomState, ScrollState}; | |||
|
43 | Grid(int size , QGraphicsItem *parent = 0 ); | |||
|
44 | ~Grid(); | |||
|
45 | QList<QChart*> charts(); | |||
|
46 | void createCharts(); | |||
|
47 | void createCharts(const QString& category); | |||
|
48 | void replaceChart(QChart* oldChart, Chart* newChart); | |||
|
49 | void setState(State state); | |||
|
50 | State state(){ return m_state; }; | |||
|
51 | void setRubberPen(const QPen& pen); | |||
|
52 | Q_SIGNAL | |||
|
53 | void chartSelected(QChart* chart); | |||
|
54 | protected: | |||
|
55 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |||
|
56 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event); | |||
|
57 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | |||
|
58 | private: | |||
|
59 | void clear(); | |||
|
60 | private: | |||
|
61 | int m_listCount; | |||
|
62 | int m_valueMax; | |||
|
63 | int m_valueCount; | |||
|
64 | int m_size; | |||
|
65 | DataTable m_dataTable; | |||
|
66 | QHash<QChart *, int> m_chartHash; | |||
|
67 | GridControl* m_control; | |||
|
68 | State m_state; | |||
|
69 | State m_currentState; | |||
|
70 | QPointF m_origin; | |||
|
71 | QGraphicsRectItem *m_rubberBand; | |||
|
72 | QGraphicsGridLayout* m_gridLayout; | |||
|
73 | }; | |||
|
74 | ||||
|
75 | #endif /* GRID_H_ */ |
@@ -1,8 +1,8 | |||||
1 | !include( ../demos.pri ):error( "Couldn't find the demos.pri file!" ) |
|
1 | !include( ../demos.pri ):error( "Couldn't find the demos.pri file!" ) | |
2 | include(charts/charts.pri) |
|
2 | include(charts/charts.pri) | |
3 | TARGET = chartviewer |
|
3 | TARGET = chartviewer | |
4 | QT += opengl |
|
4 | QT += opengl | |
5 | INCLUDEPATH += . |
|
5 | INCLUDEPATH += . | |
6 |
SOURCES += main.cpp window.cpp view.cpp |
|
6 | SOURCES += main.cpp window.cpp view.cpp grid.cpp | |
7 | HEADERS += window.h view.h charts.h model.h |
|
7 | HEADERS += window.h view.h charts.h model.h grid.h | |
8 |
|
8 |
@@ -1,615 +1,448 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "window.h" |
|
21 | #include "window.h" | |
22 | #include "view.h" |
|
22 | #include "view.h" | |
|
23 | #include "grid.h" | |||
23 | #include "charts.h" |
|
24 | #include "charts.h" | |
24 | #include <QChartView> |
|
25 | #include <QChartView> | |
25 | #include <QAreaSeries> |
|
26 | #include <QAreaSeries> | |
26 | #include <QLegend> |
|
27 | #include <QLegend> | |
27 | #include <QGridLayout> |
|
28 | #include <QGridLayout> | |
28 | #include <QFormLayout> |
|
29 | #include <QFormLayout> | |
29 | #include <QComboBox> |
|
30 | #include <QComboBox> | |
30 | #include <QSpinBox> |
|
31 | #include <QSpinBox> | |
31 | #include <QCheckBox> |
|
32 | #include <QCheckBox> | |
32 | #include <QGroupBox> |
|
33 | #include <QGroupBox> | |
33 | #include <QLabel> |
|
34 | #include <QLabel> | |
34 | #include <QGraphicsScene> |
|
35 | #include <QGraphicsScene> | |
35 | #include <QGraphicsGridLayout> |
|
|||
36 | #include <QGraphicsLinearLayout> |
|
36 | #include <QGraphicsLinearLayout> | |
37 | #include <QGraphicsProxyWidget> |
|
37 | #include <QGraphicsProxyWidget> | |
38 | #include <QGLWidget> |
|
38 | #include <QGLWidget> | |
39 | #include <QApplication> |
|
39 | #include <QApplication> | |
40 | #include <QDebug> |
|
40 | #include <QDebug> | |
41 | #include <QMenu> |
|
41 | #include <QMenu> | |
42 |
|
42 | |||
43 | Window::Window(const QVariantHash& parameters,QWidget *parent) : |
|
43 | Window::Window(const QVariantHash& parameters,QWidget *parent) : | |
44 | QMainWindow(parent), |
|
44 | QMainWindow(parent), | |
45 | m_listCount(3), |
|
|||
46 | m_valueMax(10), |
|
|||
47 | m_valueCount(7), |
|
|||
48 | m_scene(new QGraphicsScene(this)), |
|
45 | m_scene(new QGraphicsScene(this)), | |
49 | m_view(0), |
|
46 | m_view(0), | |
50 | m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)), |
|
|||
51 | m_form(0), |
|
47 | m_form(0), | |
52 | m_themeComboBox(0), |
|
48 | m_themeComboBox(0), | |
53 | m_antialiasCheckBox(0), |
|
49 | m_antialiasCheckBox(0), | |
54 | m_animatedComboBox(0), |
|
50 | m_animatedComboBox(0), | |
55 | m_legendComboBox(0), |
|
51 | m_legendComboBox(0), | |
56 | m_templateComboBox(0), |
|
52 | m_templateComboBox(0), | |
57 | m_openGLCheckBox(0), |
|
53 | m_openGLCheckBox(0), | |
58 | m_zoomCheckBox(0), |
|
54 | m_zoomCheckBox(0), | |
59 | m_scrollCheckBox(0), |
|
55 | m_scrollCheckBox(0), | |
60 |
m_ |
|
56 | m_baseLayout(new QGraphicsLinearLayout()), | |
61 | m_baseLayout(new QGraphicsGridLayout()), |
|
|||
62 | m_menu(createMenu()), |
|
57 | m_menu(createMenu()), | |
63 |
m_ |
|
58 | m_template(0), | |
64 | m_currentState(NoState), |
|
59 | m_grid(new Grid(3)) | |
65 | m_template(0) |
|
|||
66 | { |
|
60 | { | |
67 | createProxyWidgets(); |
|
61 | createProxyWidgets(); | |
68 | // create layout |
|
62 | // create layout | |
69 | QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout(); |
|
63 | QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout(); | |
70 | settingsLayout->setOrientation(Qt::Vertical); |
|
64 | settingsLayout->setOrientation(Qt::Vertical); | |
71 | settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
|
65 | settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); | |
72 | settingsLayout->addItem(m_widgetHash["openGLCheckBox"]); |
|
66 | settingsLayout->addItem(m_widgetHash["openGLCheckBox"]); | |
73 | settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]); |
|
67 | settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]); | |
74 | settingsLayout->addItem(m_widgetHash["themeLabel"]); |
|
68 | settingsLayout->addItem(m_widgetHash["themeLabel"]); | |
75 | settingsLayout->addItem(m_widgetHash["themeComboBox"]); |
|
69 | settingsLayout->addItem(m_widgetHash["themeComboBox"]); | |
76 | settingsLayout->addItem(m_widgetHash["animationsLabel"]); |
|
70 | settingsLayout->addItem(m_widgetHash["animationsLabel"]); | |
77 | settingsLayout->addItem(m_widgetHash["animatedComboBox"]); |
|
71 | settingsLayout->addItem(m_widgetHash["animatedComboBox"]); | |
78 | settingsLayout->addItem(m_widgetHash["legendLabel"]); |
|
72 | settingsLayout->addItem(m_widgetHash["legendLabel"]); | |
79 | settingsLayout->addItem(m_widgetHash["legendComboBox"]); |
|
73 | settingsLayout->addItem(m_widgetHash["legendComboBox"]); | |
80 | settingsLayout->addItem(m_widgetHash["templateLabel"]); |
|
74 | settingsLayout->addItem(m_widgetHash["templateLabel"]); | |
81 | settingsLayout->addItem(m_widgetHash["templateComboBox"]); |
|
75 | settingsLayout->addItem(m_widgetHash["templateComboBox"]); | |
82 | settingsLayout->addItem(m_widgetHash["scrollCheckBox"]); |
|
76 | settingsLayout->addItem(m_widgetHash["scrollCheckBox"]); | |
83 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); |
|
77 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); | |
84 | settingsLayout->addStretch(); |
|
78 | settingsLayout->addStretch(); | |
85 | m_baseLayout->addItem(settingsLayout, 0, 3, 2, 1); |
|
|||
86 |
|
79 | |||
87 |
|
|
80 | m_grid->createCharts(); | |
88 | Charts::ChartList list = Charts::chartList(); |
|
|||
89 |
|
81 | |||
90 | for (int i = 0; i < 9; ++i) { |
|
82 | m_baseLayout->setOrientation(Qt::Horizontal); | |
91 | QChart *chart = 0; |
|
83 | m_baseLayout->addItem(m_grid); | |
92 | if (i < list.size()) { |
|
84 | m_baseLayout->addItem(settingsLayout); | |
93 | chart = list.at(i)->createChart(m_dataTable); |
|
|||
94 | } else { |
|
|||
95 | chart = new QChart(); |
|
|||
96 | chart->setTitle(tr("Empty")); |
|
|||
97 | } |
|
|||
98 |
|
||||
99 | m_baseLayout->addItem(chart, i / 3, i % 3); |
|
|||
100 | m_chartHash[chart] = i; |
|
|||
101 | } |
|
|||
102 |
|
85 | |||
103 | m_form = new QGraphicsWidget(); |
|
86 | m_form = new QGraphicsWidget(); | |
104 | m_form->setLayout(m_baseLayout); |
|
87 | m_form->setLayout(m_baseLayout); | |
105 | m_scene->addItem(m_form); |
|
88 | m_scene->addItem(m_form); | |
106 | m_scene->addItem(m_rubberBand); |
|
|||
107 | m_rubberBand->setVisible(false); |
|
|||
108 |
|
89 | |||
109 | m_view = new View(m_scene, m_form); |
|
90 | m_view = new View(m_scene, m_form); | |
110 | m_view->setMinimumSize(m_form->minimumSize().toSize()); |
|
91 | m_view->setMinimumSize(m_form->minimumSize().toSize()); | |
111 |
|
92 | |||
112 | // Set defaults |
|
93 | // Set defaults | |
113 | m_antialiasCheckBox->setChecked(true); |
|
94 | m_antialiasCheckBox->setChecked(true); | |
114 | initializeFromParamaters(parameters); |
|
95 | initializeFromParamaters(parameters); | |
115 | updateUI(); |
|
96 | updateUI(); | |
116 | setCentralWidget(m_view); |
|
97 | setCentralWidget(m_view); | |
117 |
|
98 | |||
118 | connectSignals(); |
|
99 | connectSignals(); | |
119 | } |
|
100 | } | |
120 |
|
101 | |||
121 | Window::~Window() |
|
102 | Window::~Window() | |
122 | { |
|
103 | { | |
123 | } |
|
104 | } | |
124 |
|
105 | |||
125 | void Window::connectSignals() |
|
106 | void Window::connectSignals() | |
126 | { |
|
107 | { | |
127 | QObject::connect(m_form, SIGNAL(geometryChanged()), this , SLOT(handleGeometryChanged())); |
|
108 | QObject::connect(m_form, SIGNAL(geometryChanged()), this , SLOT(handleGeometryChanged())); | |
128 | QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
109 | QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
129 | QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
110 | QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
130 | QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
111 | QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
131 | QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
112 | QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
132 | QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
113 | QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
133 | QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
114 | QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
134 | QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
115 | QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
135 | QObject::connect(m_templateComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
116 | QObject::connect(m_templateComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
|
117 | QObject::connect(m_grid, SIGNAL(chartSelected(QChart*)),this,SLOT(handleChartSelected(QChart*))); | |||
136 | } |
|
118 | } | |
137 |
|
119 | |||
138 | void Window::createProxyWidgets() |
|
120 | void Window::createProxyWidgets() | |
139 | { |
|
121 | { | |
140 | m_themeComboBox = createThemeBox(); |
|
122 | m_themeComboBox = createThemeBox(); | |
141 | m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing")); |
|
123 | m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing")); | |
142 | m_animatedComboBox = createAnimationBox(); |
|
124 | m_animatedComboBox = createAnimationBox(); | |
143 | m_legendComboBox = createLegendBox(); |
|
125 | m_legendComboBox = createLegendBox(); | |
144 | m_openGLCheckBox = new QCheckBox(tr("OpenGL")); |
|
126 | m_openGLCheckBox = new QCheckBox(tr("OpenGL")); | |
145 | m_zoomCheckBox = new QCheckBox(tr("Zoom")); |
|
127 | m_zoomCheckBox = new QCheckBox(tr("Zoom")); | |
146 | m_scrollCheckBox = new QCheckBox(tr("Scroll")); |
|
128 | m_scrollCheckBox = new QCheckBox(tr("Scroll")); | |
147 | m_templateComboBox = createTempleteBox(); |
|
129 | m_templateComboBox = createTempleteBox(); | |
148 | m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox); |
|
130 | m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox); | |
149 | m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox); |
|
131 | m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox); | |
150 | m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox); |
|
132 | m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox); | |
151 | m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox); |
|
133 | m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox); | |
152 | m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox); |
|
134 | m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox); | |
153 | m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme")); |
|
135 | m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme")); | |
154 | m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations")); |
|
136 | m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations")); | |
155 | m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend")); |
|
137 | m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend")); | |
156 | m_widgetHash["templateLabel"] = m_scene->addWidget(new QLabel("Chart template")); |
|
138 | m_widgetHash["templateLabel"] = m_scene->addWidget(new QLabel("Chart template")); | |
157 | m_widgetHash["templateComboBox"] = m_scene->addWidget(m_templateComboBox); |
|
139 | m_widgetHash["templateComboBox"] = m_scene->addWidget(m_templateComboBox); | |
158 | m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox); |
|
140 | m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox); | |
159 | m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox); |
|
141 | m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox); | |
160 |
|
142 | |||
161 | } |
|
143 | } | |
162 |
|
144 | |||
163 | QComboBox *Window::createThemeBox() |
|
145 | QComboBox *Window::createThemeBox() | |
164 | { |
|
146 | { | |
165 | QComboBox *themeComboBox = new ComboBox(this); |
|
147 | QComboBox *themeComboBox = new ComboBox(this); | |
166 | themeComboBox->addItem("Light", QChart::ChartThemeLight); |
|
148 | themeComboBox->addItem("Light", QChart::ChartThemeLight); | |
167 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); |
|
149 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); | |
168 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); |
|
150 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); | |
169 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); |
|
151 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); | |
170 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); |
|
152 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); | |
171 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); |
|
153 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); | |
172 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); |
|
154 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); | |
173 | return themeComboBox; |
|
155 | return themeComboBox; | |
174 | } |
|
156 | } | |
175 |
|
157 | |||
176 | QComboBox *Window::createAnimationBox() |
|
158 | QComboBox *Window::createAnimationBox() | |
177 | { |
|
159 | { | |
178 | QComboBox *animationComboBox = new ComboBox(this); |
|
160 | QComboBox *animationComboBox = new ComboBox(this); | |
179 | animationComboBox->addItem("No Animations", QChart::NoAnimation); |
|
161 | animationComboBox->addItem("No Animations", QChart::NoAnimation); | |
180 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); |
|
162 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); | |
181 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); |
|
163 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); | |
182 | animationComboBox->addItem("All Animations", QChart::AllAnimations); |
|
164 | animationComboBox->addItem("All Animations", QChart::AllAnimations); | |
183 | return animationComboBox; |
|
165 | return animationComboBox; | |
184 | } |
|
166 | } | |
185 |
|
167 | |||
186 | QComboBox *Window::createLegendBox() |
|
168 | QComboBox *Window::createLegendBox() | |
187 | { |
|
169 | { | |
188 | QComboBox *legendComboBox = new ComboBox(this); |
|
170 | QComboBox *legendComboBox = new ComboBox(this); | |
189 | legendComboBox->addItem("No Legend ", 0); |
|
171 | legendComboBox->addItem("No Legend ", 0); | |
190 | legendComboBox->addItem("Legend Top", Qt::AlignTop); |
|
172 | legendComboBox->addItem("Legend Top", Qt::AlignTop); | |
191 | legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); |
|
173 | legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); | |
192 | legendComboBox->addItem("Legend Left", Qt::AlignLeft); |
|
174 | legendComboBox->addItem("Legend Left", Qt::AlignLeft); | |
193 | legendComboBox->addItem("Legend Right", Qt::AlignRight); |
|
175 | legendComboBox->addItem("Legend Right", Qt::AlignRight); | |
194 | return legendComboBox; |
|
176 | return legendComboBox; | |
195 | } |
|
177 | } | |
196 |
|
178 | |||
197 | QComboBox *Window::createTempleteBox() |
|
179 | QComboBox *Window::createTempleteBox() | |
198 | { |
|
180 | { | |
199 | QComboBox *templateComboBox = new ComboBox(this); |
|
181 | QComboBox *templateComboBox = new ComboBox(this); | |
200 | templateComboBox->addItem("No Template", 0); |
|
182 | templateComboBox->addItem("No Template", 0); | |
201 |
|
183 | |||
202 | Charts::ChartList list = Charts::chartList(); |
|
184 | Charts::ChartList list = Charts::chartList(); | |
203 | QMultiMap<QString, Chart *> categoryMap; |
|
185 | QMultiMap<QString, Chart *> categoryMap; | |
204 |
|
186 | |||
205 | foreach (Chart *chart, list) |
|
187 | foreach (Chart *chart, list) | |
206 | categoryMap.insertMulti(chart->category(), chart); |
|
188 | categoryMap.insertMulti(chart->category(), chart); | |
207 |
|
189 | |||
208 | foreach (const QString &category, categoryMap.uniqueKeys()) |
|
190 | foreach (const QString &category, categoryMap.uniqueKeys()) | |
209 | templateComboBox->addItem(category, category); |
|
191 | templateComboBox->addItem(category, category); | |
210 |
|
192 | |||
211 | return templateComboBox; |
|
193 | return templateComboBox; | |
212 | } |
|
194 | } | |
213 |
|
195 | |||
214 | void Window::initializeFromParamaters(const QVariantHash& parameters) |
|
196 | void Window::initializeFromParamaters(const QVariantHash& parameters) | |
215 | { |
|
197 | { | |
216 | if (parameters.contains("template")) { |
|
198 | if (parameters.contains("template")) { | |
217 | QString t = parameters["template"].toString(); |
|
199 | QString t = parameters["template"].toString(); | |
218 | for (int i = 0; i < m_templateComboBox->count(); ++i) { |
|
200 | for (int i = 0; i < m_templateComboBox->count(); ++i) { | |
219 | if (m_templateComboBox->itemText(i) == t) { |
|
201 | if (m_templateComboBox->itemText(i) == t) { | |
220 | m_templateComboBox->setCurrentIndex(i); |
|
202 | m_templateComboBox->setCurrentIndex(i); | |
221 | break; |
|
203 | break; | |
222 | } |
|
204 | } | |
223 | } |
|
205 | } | |
224 | } |
|
206 | } | |
225 | if (parameters.contains("opengl")) { |
|
207 | if (parameters.contains("opengl")) { | |
226 | bool checked = parameters["opengl"].toBool(); |
|
208 | bool checked = parameters["opengl"].toBool(); | |
227 | m_openGLCheckBox->setChecked(checked); |
|
209 | m_openGLCheckBox->setChecked(checked); | |
228 | } |
|
210 | } | |
229 | if (parameters.contains("theme")) { |
|
211 | if (parameters.contains("theme")) { | |
230 | QString t = parameters["theme"].toString(); |
|
212 | QString t = parameters["theme"].toString(); | |
231 | for (int i = 0; i < m_themeComboBox->count(); ++i) { |
|
213 | for (int i = 0; i < m_themeComboBox->count(); ++i) { | |
232 | if (m_themeComboBox->itemText(i) == t) { |
|
214 | if (m_themeComboBox->itemText(i) == t) { | |
233 | m_themeComboBox->setCurrentIndex(i); |
|
215 | m_themeComboBox->setCurrentIndex(i); | |
234 | break; |
|
216 | break; | |
235 | } |
|
217 | } | |
236 | } |
|
218 | } | |
237 | } |
|
219 | } | |
238 | if (parameters.contains("animation")) { |
|
220 | if (parameters.contains("animation")) { | |
239 | QString t = parameters["animation"].toString(); |
|
221 | QString t = parameters["animation"].toString(); | |
240 | for (int i = 0; i < m_animatedComboBox->count(); ++i) { |
|
222 | for (int i = 0; i < m_animatedComboBox->count(); ++i) { | |
241 | if (m_animatedComboBox->itemText(i) == t) { |
|
223 | if (m_animatedComboBox->itemText(i) == t) { | |
242 | m_animatedComboBox->setCurrentIndex(i); |
|
224 | m_animatedComboBox->setCurrentIndex(i); | |
243 | break; |
|
225 | break; | |
244 | } |
|
226 | } | |
245 | } |
|
227 | } | |
246 | } |
|
228 | } | |
247 | if (parameters.contains("legend")) { |
|
229 | if (parameters.contains("legend")) { | |
248 | QString t = parameters["legend"].toString(); |
|
230 | QString t = parameters["legend"].toString(); | |
249 | for (int i = 0; i < m_legendComboBox->count(); ++i) { |
|
231 | for (int i = 0; i < m_legendComboBox->count(); ++i) { | |
250 | if (m_legendComboBox->itemText(i) == t) { |
|
232 | if (m_legendComboBox->itemText(i) == t) { | |
251 | m_legendComboBox->setCurrentIndex(i); |
|
233 | m_legendComboBox->setCurrentIndex(i); | |
252 | break; |
|
234 | break; | |
253 | } |
|
235 | } | |
254 | } |
|
236 | } | |
255 | } |
|
237 | } | |
256 | } |
|
238 | } | |
257 |
|
239 | |||
258 | void Window::updateUI() |
|
240 | void Window::updateUI() | |
259 | { |
|
241 | { | |
260 | checkTemplate(); |
|
242 | checkTemplate(); | |
261 | checkOpenGL(); |
|
243 | checkOpenGL(); | |
262 | checkTheme(); |
|
244 | checkTheme(); | |
263 | checkAnimationOptions(); |
|
245 | checkAnimationOptions(); | |
264 | checkLegend(); |
|
246 | checkLegend(); | |
265 | checkState(); |
|
247 | checkState(); | |
266 | } |
|
248 | } | |
267 |
|
249 | |||
268 | void Window::checkLegend() |
|
250 | void Window::checkLegend() | |
269 | { |
|
251 | { | |
270 | Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); |
|
252 | Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); | |
271 |
|
253 | |||
272 | if (!alignment) { |
|
254 | if (!alignment) { | |
273 |
foreach (QChart *chart, m_chart |
|
255 | foreach (QChart *chart, m_grid->charts()) | |
274 | chart->legend()->hide(); |
|
256 | chart->legend()->hide(); | |
275 | } else { |
|
257 | } else { | |
276 |
foreach (QChart *chart, m_chart |
|
258 | foreach (QChart *chart, m_grid->charts()) { | |
277 | chart->legend()->setAlignment(alignment); |
|
259 | chart->legend()->setAlignment(alignment); | |
278 | chart->legend()->show(); |
|
260 | chart->legend()->show(); | |
279 | } |
|
261 | } | |
280 | } |
|
262 | } | |
281 | } |
|
263 | } | |
282 |
|
264 | |||
283 | void Window::checkOpenGL() |
|
265 | void Window::checkOpenGL() | |
284 | { |
|
266 | { | |
285 | bool opengl = m_openGLCheckBox->isChecked(); |
|
267 | bool opengl = m_openGLCheckBox->isChecked(); | |
286 | bool isOpengl = qobject_cast<QGLWidget *>(m_view->viewport()); |
|
268 | bool isOpengl = qobject_cast<QGLWidget *>(m_view->viewport()); | |
287 | if ((isOpengl && !opengl) || (!isOpengl && opengl)) { |
|
269 | if ((isOpengl && !opengl) || (!isOpengl && opengl)) { | |
288 | m_view->deleteLater(); |
|
270 | m_view->deleteLater(); | |
289 | m_view = new View(m_scene, m_form); |
|
271 | m_view = new View(m_scene, m_form); | |
290 | m_view->setViewport(!opengl ? new QWidget() : new QGLWidget()); |
|
272 | m_view->setViewport(!opengl ? new QWidget() : new QGLWidget()); | |
291 | setCentralWidget(m_view); |
|
273 | setCentralWidget(m_view); | |
292 | } |
|
274 | } | |
293 |
|
275 | |||
294 | bool antialias = m_antialiasCheckBox->isChecked(); |
|
276 | bool antialias = m_antialiasCheckBox->isChecked(); | |
295 |
|
277 | |||
296 | if (opengl) |
|
278 | if (opengl) | |
297 | m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); |
|
279 | m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); | |
298 | else |
|
280 | else | |
299 | m_view->setRenderHint(QPainter::Antialiasing, antialias); |
|
281 | m_view->setRenderHint(QPainter::Antialiasing, antialias); | |
300 | } |
|
282 | } | |
301 |
|
283 | |||
302 | void Window::checkAnimationOptions() |
|
284 | void Window::checkAnimationOptions() | |
303 | { |
|
285 | { | |
304 | QChart::AnimationOptions options( |
|
286 | QChart::AnimationOptions options( | |
305 | m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); |
|
287 | m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); | |
306 |
|
288 | |||
307 | if (!m_chartHash.isEmpty() && m_chartHash.keys().at(0)->animationOptions() != options) { |
|
289 | QList<QChart*> charts = m_grid->charts(); | |
308 | foreach (QChart *chart, m_chartHash.keys()) |
|
290 | ||
|
291 | if (!charts.isEmpty() && charts.at(0)->animationOptions() != options) { | |||
|
292 | foreach (QChart *chart, charts) | |||
309 | chart->setAnimationOptions(options); |
|
293 | chart->setAnimationOptions(options); | |
310 | } |
|
294 | } | |
311 | } |
|
295 | } | |
312 |
|
296 | |||
313 | void Window::checkState() |
|
297 | void Window::checkState() | |
314 | { |
|
298 | { | |
315 | bool scroll = m_scrollCheckBox->isChecked(); |
|
299 | bool scroll = m_scrollCheckBox->isChecked(); | |
316 |
|
300 | |||
317 | if (m_state != ScrollState && scroll) { |
|
301 | ||
318 | m_state = ScrollState; |
|
302 | if (m_grid->state() != Grid::ScrollState && scroll) { | |
|
303 | m_grid->setState(Grid::ScrollState); | |||
319 | m_zoomCheckBox->setChecked(false); |
|
304 | m_zoomCheckBox->setChecked(false); | |
320 | } else if (!scroll && m_state == ScrollState) { |
|
305 | } else if (!scroll && m_grid->state() == Grid::ScrollState) { | |
321 |
m_ |
|
306 | m_grid->setState(Grid::NoState); | |
322 | } |
|
307 | } | |
323 |
|
308 | |||
324 | bool zoom = m_zoomCheckBox->isChecked(); |
|
309 | bool zoom = m_zoomCheckBox->isChecked(); | |
325 |
|
310 | |||
326 | if (m_state != ZoomState && zoom) { |
|
311 | if (m_grid->state() != Grid::ZoomState && zoom) { | |
327 |
m_ |
|
312 | m_grid->setState(Grid::ZoomState); | |
328 | m_scrollCheckBox->setChecked(false); |
|
313 | m_scrollCheckBox->setChecked(false); | |
329 | } else if (!zoom && m_state == ZoomState) { |
|
314 | } else if (!zoom && m_grid->state() == Grid::ZoomState) { | |
330 |
m_ |
|
315 | m_grid->setState(Grid::NoState); | |
331 | } |
|
316 | } | |
332 | } |
|
317 | } | |
333 |
|
318 | |||
334 | void Window::checkTemplate() |
|
319 | void Window::checkTemplate() | |
335 | { |
|
320 | { | |
336 |
|
||||
337 | int index = m_templateComboBox->currentIndex(); |
|
321 | int index = m_templateComboBox->currentIndex(); | |
338 | if (m_template == index || index == 0) |
|
322 | if (m_template == index || index == 0) | |
339 | return; |
|
323 | return; | |
340 |
|
324 | |||
341 | m_template = index; |
|
325 | m_template = index; | |
342 |
|
||||
343 | QString category = m_templateComboBox->itemData(index).toString(); |
|
326 | QString category = m_templateComboBox->itemData(index).toString(); | |
344 | Charts::ChartList list = Charts::chartList(); |
|
327 | m_grid->createCharts(category); | |
345 |
|
||||
346 | QList<QChart *> qchartList = m_chartHash.keys(); |
|
|||
347 |
|
||||
348 | foreach (QChart *qchart, qchartList) { |
|
|||
349 | for (int i = 0 ; i < m_baseLayout->count(); ++i) { |
|
|||
350 | if (m_baseLayout->itemAt(i) == qchart) { |
|
|||
351 | m_baseLayout->removeAt(i); |
|
|||
352 | break; |
|
|||
353 | } |
|
|||
354 | } |
|
|||
355 | } |
|
|||
356 |
|
||||
357 | m_chartHash.clear(); |
|
|||
358 | qDeleteAll(qchartList); |
|
|||
359 |
|
||||
360 | QChart *qchart(0); |
|
|||
361 |
|
||||
362 | int j = 0; |
|
|||
363 | for (int i = 0; i < list.size(); ++i) { |
|
|||
364 | Chart *chart = list.at(i); |
|
|||
365 | if (chart->category() == category && j < 9) { |
|
|||
366 | qchart = list.at(i)->createChart(m_dataTable); |
|
|||
367 | m_baseLayout->addItem(qchart, j / 3, j % 3); |
|
|||
368 | m_chartHash[qchart] = j; |
|
|||
369 | j++; |
|
|||
370 | } |
|
|||
371 | } |
|
|||
372 | for (; j < 9; ++j) { |
|
|||
373 | qchart = new QChart(); |
|
|||
374 | qchart->setTitle(tr("Empty")); |
|
|||
375 | m_baseLayout->addItem(qchart, j / 3, j % 3); |
|
|||
376 | m_chartHash[qchart] = j; |
|
|||
377 | } |
|
|||
378 | m_baseLayout->activate(); |
|
|||
379 | } |
|
328 | } | |
380 |
|
329 | |||
381 | void Window::checkTheme() |
|
330 | void Window::checkTheme() | |
382 | { |
|
331 | { | |
383 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( |
|
332 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( | |
384 | m_themeComboBox->currentIndex()).toInt(); |
|
333 | m_themeComboBox->currentIndex()).toInt(); | |
385 |
|
334 | |||
386 |
foreach (QChart *chart, m_chart |
|
335 | foreach (QChart *chart, m_grid->charts()) | |
387 | chart->setTheme(theme); |
|
336 | chart->setTheme(theme); | |
388 |
|
337 | |||
389 | QPalette pal = window()->palette(); |
|
338 | QPalette pal = window()->palette(); | |
390 | if (theme == QChart::ChartThemeLight) { |
|
339 | if (theme == QChart::ChartThemeLight) { | |
391 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
340 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); | |
392 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
341 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
393 | } else if (theme == QChart::ChartThemeDark) { |
|
342 | } else if (theme == QChart::ChartThemeDark) { | |
394 | pal.setColor(QPalette::Window, QRgb(0x121218)); |
|
343 | pal.setColor(QPalette::Window, QRgb(0x121218)); | |
395 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
344 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); | |
396 | } else if (theme == QChart::ChartThemeBlueCerulean) { |
|
345 | } else if (theme == QChart::ChartThemeBlueCerulean) { | |
397 | pal.setColor(QPalette::Window, QRgb(0x40434a)); |
|
346 | pal.setColor(QPalette::Window, QRgb(0x40434a)); | |
398 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
347 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); | |
399 | } else if (theme == QChart::ChartThemeBrownSand) { |
|
348 | } else if (theme == QChart::ChartThemeBrownSand) { | |
400 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); |
|
349 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); | |
401 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
350 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
402 | } else if (theme == QChart::ChartThemeBlueNcs) { |
|
351 | } else if (theme == QChart::ChartThemeBlueNcs) { | |
403 | pal.setColor(QPalette::Window, QRgb(0x018bba)); |
|
352 | pal.setColor(QPalette::Window, QRgb(0x018bba)); | |
404 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
353 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
405 | } else if (theme == QChart::ChartThemeHighContrast) { |
|
354 | } else if (theme == QChart::ChartThemeHighContrast) { | |
406 | pal.setColor(QPalette::Window, QRgb(0xffab03)); |
|
355 | pal.setColor(QPalette::Window, QRgb(0xffab03)); | |
407 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); |
|
356 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); | |
408 | } else if (theme == QChart::ChartThemeBlueIcy) { |
|
357 | } else if (theme == QChart::ChartThemeBlueIcy) { | |
409 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); |
|
358 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); | |
410 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
359 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
411 | } else { |
|
360 | } else { | |
412 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
361 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); | |
413 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
362 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
414 | } |
|
363 | } | |
415 | foreach (QGraphicsProxyWidget *widget, m_widgetHash) |
|
364 | foreach (QGraphicsProxyWidget *widget, m_widgetHash) | |
416 | widget->setPalette(pal); |
|
365 | widget->setPalette(pal); | |
417 | m_view->setBackgroundBrush(pal.color((QPalette::Window))); |
|
366 | m_view->setBackgroundBrush(pal.color((QPalette::Window))); | |
418 |
m_ |
|
367 | m_grid->setRubberPen(pal.color((QPalette::WindowText))); | |
419 | } |
|
|||
420 |
|
||||
421 | void Window::mousePressEvent(QMouseEvent *event) |
|
|||
422 | { |
|
|||
423 | if (event->button() == Qt::LeftButton) { |
|
|||
424 |
|
||||
425 | m_origin = event->pos(); |
|
|||
426 | m_currentState = NoState; |
|
|||
427 |
|
||||
428 | foreach (QChart *chart, m_chartHash.keys()) { |
|
|||
429 |
|
||||
430 | QRectF geometryRect = chart->geometry(); |
|
|||
431 | QRectF plotArea = chart->plotArea(); |
|
|||
432 | plotArea.translate(geometryRect.topLeft()); |
|
|||
433 | if (plotArea.contains(m_origin)) { |
|
|||
434 | m_currentState = m_state; |
|
|||
435 | if (m_currentState == NoState && m_templateComboBox->currentIndex() == 0) |
|
|||
436 | handleMenu(chart); |
|
|||
437 | break; |
|
|||
438 | } |
|
|||
439 | } |
|
|||
440 |
|
||||
441 | if (m_currentState == ZoomState) { |
|
|||
442 | m_rubberBand->setRect(QRectF(m_origin, QSize())); |
|
|||
443 | m_rubberBand->setVisible(true); |
|
|||
444 | } |
|
|||
445 |
|
||||
446 | event->accept(); |
|
|||
447 | } |
|
|||
448 |
|
||||
449 | if (event->button() == Qt::RightButton) { |
|
|||
450 | m_origin = event->pos(); |
|
|||
451 | m_currentState = m_state; |
|
|||
452 | } |
|
|||
453 | } |
|
|||
454 |
|
||||
455 | void Window::mouseMoveEvent(QMouseEvent *event) |
|
|||
456 | { |
|
|||
457 | if (m_currentState != NoState) { |
|
|||
458 |
|
||||
459 | foreach (QChart *chart, m_chartHash.keys()) { |
|
|||
460 |
|
||||
461 | QRectF geometryRect = chart->geometry(); |
|
|||
462 | QRectF plotArea = chart->plotArea(); |
|
|||
463 | plotArea.translate(geometryRect.topLeft()); |
|
|||
464 |
|
||||
465 | if (plotArea.contains(m_origin)) { |
|
|||
466 | if (m_currentState == ScrollState) { |
|
|||
467 | QPointF delta = m_origin - event->pos(); |
|
|||
468 | chart->scroll(delta.x(), -delta.y()); |
|
|||
469 | } |
|
|||
470 | if (m_currentState == ZoomState && plotArea.contains(event->pos())) |
|
|||
471 | m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized()); |
|
|||
472 | break; |
|
|||
473 | } |
|
|||
474 | } |
|
|||
475 | if (m_currentState == ScrollState) |
|
|||
476 | m_origin = event->pos(); |
|
|||
477 | event->accept(); |
|
|||
478 | } |
|
|||
479 | } |
|
|||
480 |
|
||||
481 | void Window::mouseReleaseEvent(QMouseEvent *event) |
|
|||
482 | { |
|
|||
483 | if (event->button() == Qt::LeftButton) { |
|
|||
484 | if (m_currentState == ZoomState) { |
|
|||
485 | m_rubberBand->setVisible(false); |
|
|||
486 |
|
||||
487 | foreach (QChart *chart, m_chartHash.keys()) { |
|
|||
488 |
|
||||
489 | QRectF geometryRect = chart->geometry(); |
|
|||
490 | QRectF plotArea = chart->plotArea(); |
|
|||
491 | plotArea.translate(geometryRect.topLeft()); |
|
|||
492 |
|
||||
493 | if (plotArea.contains(m_origin)) { |
|
|||
494 | QRectF rect = m_rubberBand->rect(); |
|
|||
495 | rect.translate(-geometryRect.topLeft()); |
|
|||
496 | chart->zoomIn(rect); |
|
|||
497 | break; |
|
|||
498 | } |
|
|||
499 | } |
|
|||
500 | } |
|
|||
501 |
|
||||
502 | m_currentState = NoState; |
|
|||
503 | event->accept(); |
|
|||
504 | } |
|
|||
505 |
|
||||
506 | if (event->button() == Qt::RightButton) { |
|
|||
507 |
|
||||
508 | if (m_currentState == ZoomState) { |
|
|||
509 | foreach (QChart *chart, m_chartHash.keys()) { |
|
|||
510 |
|
||||
511 | QRectF geometryRect = chart->geometry(); |
|
|||
512 | QRectF plotArea = chart->plotArea(); |
|
|||
513 | plotArea.translate(geometryRect.topLeft()); |
|
|||
514 |
|
||||
515 | if (plotArea.contains(m_origin)) { |
|
|||
516 | chart->zoomOut(); |
|
|||
517 | break; |
|
|||
518 | } |
|
|||
519 | } |
|
|||
520 | } |
|
|||
521 | } |
|
|||
522 | } |
|
368 | } | |
523 |
|
369 | |||
524 | void Window::comboBoxFocused(QComboBox *combobox) |
|
370 | void Window::comboBoxFocused(QComboBox *combobox) | |
525 | { |
|
371 | { | |
526 | foreach (QGraphicsProxyWidget *widget , m_widgetHash) { |
|
372 | foreach (QGraphicsProxyWidget *widget , m_widgetHash) { | |
527 | if (widget->widget() == combobox) |
|
373 | if (widget->widget() == combobox) | |
528 | widget->setZValue(2.0); |
|
374 | widget->setZValue(2.0); | |
529 | else |
|
375 | else | |
530 | widget->setZValue(0.0); |
|
376 | widget->setZValue(0.0); | |
531 | } |
|
377 | } | |
532 | } |
|
378 | } | |
533 |
|
379 | |||
534 |
void Window::handle |
|
380 | void Window::handleChartSelected(QChart *qchart) | |
535 | { |
|
381 | { | |
|
382 | if(m_templateComboBox->currentIndex() != 0) return; | |||
|
383 | ||||
536 | QAction *chosen = m_menu->exec(QCursor::pos()); |
|
384 | QAction *chosen = m_menu->exec(QCursor::pos()); | |
537 |
|
385 | |||
538 | if (chosen) { |
|
386 | if (chosen) { | |
539 | Chart *chart = (Chart *) chosen->data().value<void *>(); |
|
387 | Chart *chart = (Chart *) chosen->data().value<void *>(); | |
540 | int index = m_chartHash[qchart]; |
|
388 | m_grid->replaceChart(qchart,chart); | |
541 | //not in 4.7.2 m_baseLayout->removeItem(qchart); |
|
|||
542 | for (int i = 0 ; i < m_baseLayout->count(); ++i) { |
|
|||
543 | if (m_baseLayout->itemAt(i) == qchart) { |
|
|||
544 | m_baseLayout->removeAt(i); |
|
|||
545 | break; |
|
|||
546 | } |
|
|||
547 | } |
|
|||
548 |
|
||||
549 | m_chartHash.remove(qchart); |
|
|||
550 | QChart *newChart = chart->createChart(m_dataTable); |
|
|||
551 | m_baseLayout->addItem(newChart, index / 3, index % 3); |
|
|||
552 | m_chartHash[newChart] = index; |
|
|||
553 | delete qchart; |
|
|||
554 | updateUI(); |
|
389 | updateUI(); | |
555 | } |
|
390 | } | |
556 |
|
||||
557 | } |
|
391 | } | |
558 |
|
392 | |||
559 | QMenu *Window::createMenu() |
|
393 | QMenu *Window::createMenu() | |
560 | { |
|
394 | { | |
561 | Charts::ChartList list = Charts::chartList(); |
|
395 | Charts::ChartList list = Charts::chartList(); | |
562 | QMultiMap<QString, Chart *> categoryMap; |
|
396 | QMultiMap<QString, Chart *> categoryMap; | |
563 |
|
397 | |||
564 | QMenu *result = new QMenu(this); |
|
398 | QMenu *result = new QMenu(this); | |
565 |
|
399 | |||
566 | foreach (Chart *chart, list) |
|
400 | foreach (Chart *chart, list) | |
567 | categoryMap.insertMulti(chart->category(), chart); |
|
401 | categoryMap.insertMulti(chart->category(), chart); | |
568 |
|
402 | |||
569 | foreach (const QString &category, categoryMap.uniqueKeys()) { |
|
403 | foreach (const QString &category, categoryMap.uniqueKeys()) { | |
570 | QMenu *menu(0); |
|
404 | QMenu *menu(0); | |
571 | QMultiMap<QString, Chart *> subCategoryMap; |
|
405 | QMultiMap<QString, Chart *> subCategoryMap; | |
572 | if (category.isEmpty()) { |
|
406 | if (category.isEmpty()) { | |
573 | menu = result; |
|
407 | menu = result; | |
574 | } else { |
|
408 | } else { | |
575 | menu = new QMenu(category, this); |
|
409 | menu = new QMenu(category, this); | |
576 | result->addMenu(menu); |
|
410 | result->addMenu(menu); | |
577 | } |
|
411 | } | |
578 |
|
412 | |||
579 | foreach (Chart *chart, categoryMap.values(category)) |
|
413 | foreach (Chart *chart, categoryMap.values(category)) | |
580 | subCategoryMap.insert(chart->subCategory(), chart); |
|
414 | subCategoryMap.insert(chart->subCategory(), chart); | |
581 |
|
415 | |||
582 | foreach (const QString &subCategory, subCategoryMap.uniqueKeys()) { |
|
416 | foreach (const QString &subCategory, subCategoryMap.uniqueKeys()) { | |
583 | QMenu *subMenu(0); |
|
417 | QMenu *subMenu(0); | |
584 | if (subCategory.isEmpty()) { |
|
418 | if (subCategory.isEmpty()) { | |
585 | subMenu = menu; |
|
419 | subMenu = menu; | |
586 | } else { |
|
420 | } else { | |
587 | subMenu = new QMenu(subCategory, this); |
|
421 | subMenu = new QMenu(subCategory, this); | |
588 | menu->addMenu(subMenu); |
|
422 | menu->addMenu(subMenu); | |
589 | } |
|
423 | } | |
590 |
|
424 | |||
591 | foreach (Chart *chart, subCategoryMap.values(subCategory)) { |
|
425 | foreach (Chart *chart, subCategoryMap.values(subCategory)) { | |
592 | createMenuAction(subMenu, QIcon(), chart->name(), |
|
426 | createMenuAction(subMenu, QIcon(), chart->name(), | |
593 | qVariantFromValue((void *) chart)); |
|
427 | qVariantFromValue((void *) chart)); | |
594 | } |
|
428 | } | |
595 | } |
|
429 | } | |
596 | } |
|
430 | } | |
597 |
|
||||
598 | return result; |
|
431 | return result; | |
599 | } |
|
432 | } | |
600 |
|
433 | |||
601 | QAction *Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, |
|
434 | QAction *Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, | |
602 | const QVariant &data) |
|
435 | const QVariant &data) | |
603 | { |
|
436 | { | |
604 | QAction *action = menu->addAction(icon, text); |
|
437 | QAction *action = menu->addAction(icon, text); | |
605 | action->setCheckable(false); |
|
438 | action->setCheckable(false); | |
606 | action->setData(data); |
|
439 | action->setData(data); | |
607 | return action; |
|
440 | return action; | |
608 | } |
|
441 | } | |
609 |
|
442 | |||
610 | void Window::handleGeometryChanged() |
|
443 | void Window::handleGeometryChanged() | |
611 | { |
|
444 | { | |
612 | QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize); |
|
445 | QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize); | |
613 | m_view->scene()->setSceneRect(0, 0, this->width(), this->height()); |
|
446 | m_view->scene()->setSceneRect(0, 0, this->width(), this->height()); | |
614 | m_view->setMinimumSize(size.toSize()); |
|
447 | m_view->setMinimumSize(size.toSize()); | |
615 | } |
|
448 | } |
@@ -1,124 +1,115 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef WINDOW_H |
|
21 | #ifndef WINDOW_H | |
22 | #define WINDOW_H |
|
22 | #define WINDOW_H | |
23 | #include "model.h" |
|
|||
24 | #include <QMainWindow> |
|
23 | #include <QMainWindow> | |
25 | #include <QChartGlobal> |
|
24 | #include <QChartGlobal> | |
26 | #include <QHash> |
|
25 | #include <QHash> | |
27 | #include <QComboBox> |
|
26 | #include <QComboBox> | |
28 |
|
27 | |||
29 | class QCheckBox; |
|
28 | class QCheckBox; | |
30 | class QGraphicsRectItem; |
|
29 | class QGraphicsRectItem; | |
31 | class QGraphicsScene; |
|
30 | class QGraphicsScene; | |
32 | class QGraphicsWidget; |
|
31 | class QGraphicsWidget; | |
33 | class View; |
|
32 | class View; | |
34 |
class QGraphics |
|
33 | class QGraphicsLinearLayout; | |
35 | class Chart; |
|
34 | class Chart; | |
|
35 | class Grid; | |||
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 | class QChart; |
|
38 | class QChart; | |
39 | QTCOMMERCIALCHART_END_NAMESPACE |
|
39 | QTCOMMERCIALCHART_END_NAMESPACE | |
40 |
|
40 | |||
41 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
41 | QTCOMMERCIALCHART_USE_NAMESPACE | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | class Window: public QMainWindow |
|
44 | class Window: public QMainWindow | |
45 | { |
|
45 | { | |
46 | Q_OBJECT |
|
46 | Q_OBJECT | |
47 | enum State { NoState = 0, ZoomState, ScrollState}; |
|
|||
48 | public: |
|
47 | public: | |
49 | explicit Window(const QVariantHash& parameters, QWidget *parent = 0); |
|
48 | explicit Window(const QVariantHash& parameters, QWidget *parent = 0); | |
50 | ~Window(); |
|
49 | ~Window(); | |
51 |
|
50 | |||
52 | private Q_SLOTS: |
|
51 | private Q_SLOTS: | |
53 | void updateUI(); |
|
52 | void updateUI(); | |
54 | void handleGeometryChanged(); |
|
53 | void handleGeometryChanged(); | |
|
54 | void handleChartSelected(QChart *chart); | |||
55 | private: |
|
55 | private: | |
56 | QComboBox *createThemeBox(); |
|
56 | QComboBox *createThemeBox(); | |
57 | QComboBox *createAnimationBox(); |
|
57 | QComboBox *createAnimationBox(); | |
58 | QComboBox *createLegendBox(); |
|
58 | QComboBox *createLegendBox(); | |
59 | QComboBox *createTempleteBox(); |
|
59 | QComboBox *createTempleteBox(); | |
60 | void connectSignals(); |
|
60 | void connectSignals(); | |
61 | void createProxyWidgets(); |
|
61 | void createProxyWidgets(); | |
62 | void comboBoxFocused(QComboBox *combox); |
|
62 | void comboBoxFocused(QComboBox *combox); | |
63 | inline void checkAnimationOptions(); |
|
63 | inline void checkAnimationOptions(); | |
64 | inline void checkLegend(); |
|
64 | inline void checkLegend(); | |
65 | inline void checkOpenGL(); |
|
65 | inline void checkOpenGL(); | |
66 | inline void checkTheme(); |
|
66 | inline void checkTheme(); | |
67 | inline void checkState(); |
|
67 | inline void checkState(); | |
68 | inline void checkTemplate(); |
|
68 | inline void checkTemplate(); | |
69 | QMenu *createMenu(); |
|
69 | QMenu *createMenu(); | |
70 | void handleMenu(QChart *chart); |
|
|||
71 | QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data); |
|
70 | QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data); | |
72 | void initializeFromParamaters(const QVariantHash& parameters); |
|
71 | void initializeFromParamaters(const QVariantHash& parameters); | |
73 |
|
72 | |||
74 | protected: |
|
73 | protected: | |
75 | void mousePressEvent(QMouseEvent *event); |
|
74 | //void mousePressEvent(QMouseEvent *event); | |
76 | void mouseMoveEvent(QMouseEvent *event); |
|
75 | //void mouseMoveEvent(QMouseEvent *event); | |
77 | void mouseReleaseEvent(QMouseEvent *event); |
|
76 | //void mouseReleaseEvent(QMouseEvent *event); | |
78 |
|
77 | |||
79 | private: |
|
78 | private: | |
80 | int m_listCount; |
|
|||
81 | int m_valueMax; |
|
|||
82 | int m_valueCount; |
|
|||
83 | QGraphicsScene *m_scene; |
|
79 | QGraphicsScene *m_scene; | |
84 | View *m_view; |
|
80 | View *m_view; | |
85 | QHash<QString, QGraphicsProxyWidget *> m_widgetHash; |
|
81 | QHash<QString, QGraphicsProxyWidget *> m_widgetHash; | |
86 | QHash<QChart *, int> m_chartHash; |
|
|||
87 | DataTable m_dataTable; |
|
|||
88 |
|
82 | |||
89 | QGraphicsWidget *m_form; |
|
83 | QGraphicsWidget *m_form; | |
90 | QComboBox *m_themeComboBox; |
|
84 | QComboBox *m_themeComboBox; | |
91 | QCheckBox *m_antialiasCheckBox; |
|
85 | QCheckBox *m_antialiasCheckBox; | |
92 | QComboBox *m_animatedComboBox; |
|
86 | QComboBox *m_animatedComboBox; | |
93 | QComboBox *m_legendComboBox; |
|
87 | QComboBox *m_legendComboBox; | |
94 | QComboBox *m_templateComboBox; |
|
88 | QComboBox *m_templateComboBox; | |
95 | QCheckBox *m_openGLCheckBox; |
|
89 | QCheckBox *m_openGLCheckBox; | |
96 | QCheckBox *m_zoomCheckBox; |
|
90 | QCheckBox *m_zoomCheckBox; | |
97 | QCheckBox *m_scrollCheckBox; |
|
91 | QCheckBox *m_scrollCheckBox; | |
98 | QPoint m_origin; |
|
92 | QGraphicsLinearLayout *m_baseLayout; | |
99 | QGraphicsRectItem *m_rubberBand; |
|
|||
100 | QGraphicsGridLayout *m_baseLayout; |
|
|||
101 | QMenu *m_menu; |
|
93 | QMenu *m_menu; | |
102 | State m_state; |
|
|||
103 | State m_currentState; |
|
|||
104 | int m_template; |
|
94 | int m_template; | |
|
95 | Grid* m_grid; | |||
105 |
|
96 | |||
106 | friend class ComboBox; |
|
97 | friend class ComboBox; | |
107 | }; |
|
98 | }; | |
108 |
|
99 | |||
109 | class ComboBox: public QComboBox |
|
100 | class ComboBox: public QComboBox | |
110 | { |
|
101 | { | |
111 | public: |
|
102 | public: | |
112 | ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window) |
|
103 | ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window) | |
113 | {} |
|
104 | {} | |
114 |
|
105 | |||
115 | protected: |
|
106 | protected: | |
116 | void focusInEvent(QFocusEvent *e) { |
|
107 | void focusInEvent(QFocusEvent *e) { | |
117 | QComboBox::focusInEvent(e); |
|
108 | QComboBox::focusInEvent(e); | |
118 | m_window->comboBoxFocused(this); |
|
109 | m_window->comboBoxFocused(this); | |
119 | } |
|
110 | } | |
120 | private: |
|
111 | private: | |
121 | Window *m_window; |
|
112 | Window *m_window; | |
122 | }; |
|
113 | }; | |
123 |
|
114 | |||
124 | #endif |
|
115 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now