@@ -1,430 +1,433 | |||||
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 "charts.h" |
|
23 | #include "charts.h" | |
24 |
|
24 | |||
25 | #include <QChartView> |
|
25 | #include <QChartView> | |
26 | #include <QPieSeries> |
|
26 | #include <QPieSeries> | |
27 | #include <QPieSlice> |
|
27 | #include <QPieSlice> | |
28 | #include <QPercentBarSeries> |
|
28 | #include <QPercentBarSeries> | |
29 | #include <QStackedBarSeries> |
|
29 | #include <QStackedBarSeries> | |
30 | #include <QBarSeries> |
|
30 | #include <QBarSeries> | |
31 | #include <QBarSet> |
|
31 | #include <QBarSet> | |
32 | #include <QLineSeries> |
|
32 | #include <QLineSeries> | |
33 | #include <QSplineSeries> |
|
33 | #include <QSplineSeries> | |
34 | #include <QScatterSeries> |
|
34 | #include <QScatterSeries> | |
35 | #include <QAreaSeries> |
|
35 | #include <QAreaSeries> | |
36 | #include <QLegend> |
|
36 | #include <QLegend> | |
37 | #include <QGridLayout> |
|
37 | #include <QGridLayout> | |
38 | #include <QFormLayout> |
|
38 | #include <QFormLayout> | |
39 | #include <QComboBox> |
|
39 | #include <QComboBox> | |
40 | #include <QSpinBox> |
|
40 | #include <QSpinBox> | |
41 | #include <QCheckBox> |
|
41 | #include <QCheckBox> | |
42 | #include <QGroupBox> |
|
42 | #include <QGroupBox> | |
43 | #include <QLabel> |
|
43 | #include <QLabel> | |
44 | #include <QTime> |
|
44 | #include <QTime> | |
45 | #include <QBarCategoriesAxis> |
|
45 | #include <QBarCategoriesAxis> | |
46 | #include <QGraphicsScene> |
|
46 | #include <QGraphicsScene> | |
47 | #include <QGraphicsGridLayout> |
|
47 | #include <QGraphicsGridLayout> | |
48 | #include <QGraphicsLinearLayout> |
|
48 | #include <QGraphicsLinearLayout> | |
49 | #include <QGraphicsProxyWidget> |
|
49 | #include <QGraphicsProxyWidget> | |
50 | #include <QGLWidget> |
|
50 | #include <QGLWidget> | |
51 | #include <QApplication> |
|
51 | #include <QApplication> | |
52 | #include <QDebug> |
|
52 | #include <QDebug> | |
53 |
|
53 | |||
54 | Window::Window(QWidget* parent) : |
|
54 | Window::Window(QWidget* parent) : | |
55 | QMainWindow(parent), |
|
55 | QMainWindow(parent), | |
56 | m_listCount(3), |
|
56 | m_listCount(3), | |
57 | m_valueMax(10), |
|
57 | m_valueMax(10), | |
58 | m_valueCount(7), |
|
58 | m_valueCount(7), | |
59 | m_scene(new QGraphicsScene(this)), |
|
59 | m_scene(new QGraphicsScene(this)), | |
60 | m_view(0), |
|
60 | m_view(0), | |
61 | m_dataTable(generateRandomData(m_listCount, m_valueMax, m_valueCount)), |
|
61 | m_dataTable(generateRandomData(m_listCount, m_valueMax, m_valueCount)), | |
62 | m_form(0), |
|
62 | m_form(0), | |
63 | m_themeComboBox(0), |
|
63 | m_themeComboBox(0), | |
64 | m_antialiasCheckBox(0), |
|
64 | m_antialiasCheckBox(0), | |
65 | m_animatedComboBox(0), |
|
65 | m_animatedComboBox(0), | |
66 | m_legendComboBox(0), |
|
66 | m_legendComboBox(0), | |
67 | m_openGLCheckBox(0), |
|
67 | m_openGLCheckBox(0), | |
68 | m_zoomCheckBox(0), |
|
68 | m_zoomCheckBox(0), | |
69 | m_scrollCheckBox(0), |
|
69 | m_scrollCheckBox(0), | |
70 | m_rubberBand(new QGraphicsRectItem()), |
|
70 | m_rubberBand(new QGraphicsRectItem()), | |
71 | m_isScrolling(false), |
|
71 | m_isScrolling(false), | |
72 | m_isZooming(false), |
|
72 | m_isZooming(false), | |
73 | m_scroll(false), |
|
73 | m_scroll(false), | |
74 | m_zoom(false) |
|
74 | m_zoom(false) | |
75 | { |
|
75 | { | |
76 | createProxyWidgets(); |
|
76 | createProxyWidgets(); | |
77 | connectSignals(); |
|
77 | connectSignals(); | |
78 |
|
78 | |||
79 | // create layout |
|
79 | // create layout | |
80 | QGraphicsGridLayout* baseLayout = new QGraphicsGridLayout(); |
|
80 | QGraphicsGridLayout* baseLayout = new QGraphicsGridLayout(); | |
81 | QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout(); |
|
81 | QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout(); | |
82 | settingsLayout->setOrientation(Qt::Vertical); |
|
82 | settingsLayout->setOrientation(Qt::Vertical); | |
83 | settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
|
83 | settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); | |
84 | settingsLayout->addItem(m_widgetHash["openGLCheckBox"]); |
|
84 | settingsLayout->addItem(m_widgetHash["openGLCheckBox"]); | |
85 | settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]); |
|
85 | settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]); | |
86 | settingsLayout->addItem(m_widgetHash["themeLabel"]); |
|
86 | settingsLayout->addItem(m_widgetHash["themeLabel"]); | |
87 | settingsLayout->addItem(m_widgetHash["themeComboBox"]); |
|
87 | settingsLayout->addItem(m_widgetHash["themeComboBox"]); | |
88 | settingsLayout->addItem(m_widgetHash["animationsLabel"]); |
|
88 | settingsLayout->addItem(m_widgetHash["animationsLabel"]); | |
89 | settingsLayout->addItem(m_widgetHash["animatedComboBox"]); |
|
89 | settingsLayout->addItem(m_widgetHash["animatedComboBox"]); | |
90 | settingsLayout->addItem(m_widgetHash["legendLabel"]); |
|
90 | settingsLayout->addItem(m_widgetHash["legendLabel"]); | |
91 | settingsLayout->addItem(m_widgetHash["legendComboBox"]); |
|
91 | settingsLayout->addItem(m_widgetHash["legendComboBox"]); | |
92 | settingsLayout->addItem(m_widgetHash["scrollCheckBox"]); |
|
92 | settingsLayout->addItem(m_widgetHash["scrollCheckBox"]); | |
93 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); |
|
93 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); | |
94 | settingsLayout->addStretch(); |
|
94 | settingsLayout->addStretch(); | |
95 | baseLayout->addItem(settingsLayout, 0, 3, 2, 1); |
|
95 | baseLayout->addItem(settingsLayout, 0, 3, 2, 1); | |
96 | //create charts |
|
96 | //create charts | |
97 |
|
97 | |||
98 | int i = m_widgetHash.count(); |
|
|||
99 | foreach(QGraphicsProxyWidget* widget , m_widgetHash) { |
|
|||
100 | widget->setZValue(i--); |
|
|||
101 | widget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
|
|||
102 | } |
|
|||
103 |
|
||||
104 |
|
||||
105 | Charts::ChartList list = Charts::chartList(); |
|
98 | Charts::ChartList list = Charts::chartList(); | |
106 |
|
99 | |||
107 | for(int i = 0 ; i < 6 ; ++i) |
|
100 | for(int i = 0 ; i < 6 ; ++i) | |
108 | { |
|
101 | { | |
109 | if(!(i<list.size()) || list.isEmpty()) break; |
|
102 | if(!(i<list.size()) || list.isEmpty()) break; | |
110 | QChart* chart = list.at(i)->createChart(m_dataTable); |
|
103 | QChart* chart = list.at(i)->createChart(m_dataTable); | |
111 | baseLayout->addItem(chart, i/3, i%3); |
|
104 | baseLayout->addItem(chart, i/3, i%3); | |
112 | m_chartList << chart; |
|
105 | m_chartList << chart; | |
113 | } |
|
106 | } | |
114 |
|
107 | |||
115 | m_form = new QGraphicsWidget(); |
|
108 | m_form = new QGraphicsWidget(); | |
116 | m_form->setLayout(baseLayout); |
|
109 | m_form->setLayout(baseLayout); | |
117 | m_scene->addItem(m_form); |
|
110 | m_scene->addItem(m_form); | |
118 | m_scene->addItem(m_rubberBand); |
|
111 | m_scene->addItem(m_rubberBand); | |
119 | m_rubberBand->setVisible(false); |
|
112 | m_rubberBand->setVisible(false); | |
120 |
|
113 | |||
121 | m_view = new View(m_scene, m_form); |
|
114 | m_view = new View(m_scene, m_form); | |
122 | m_view->setMinimumSize(m_form->preferredSize().toSize()); |
|
115 | m_view->setMinimumSize(m_form->preferredSize().toSize()); | |
123 |
|
116 | |||
124 | // Set defaults |
|
117 | // Set defaults | |
125 | m_antialiasCheckBox->setChecked(true); |
|
118 | m_antialiasCheckBox->setChecked(true); | |
126 | updateUI(); |
|
119 | updateUI(); | |
127 | setCentralWidget(m_view); |
|
120 | setCentralWidget(m_view); | |
128 | } |
|
121 | } | |
129 |
|
122 | |||
130 | Window::~Window() |
|
123 | Window::~Window() | |
131 | { |
|
124 | { | |
132 | } |
|
125 | } | |
133 |
|
126 | |||
134 | void Window::connectSignals() |
|
127 | void Window::connectSignals() | |
135 | { |
|
128 | { | |
136 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
129 | QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
137 | connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
130 | QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
138 | connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
131 | QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
139 | connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
132 | QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
140 | connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
133 | QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
141 | connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
134 | QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
142 | connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
135 | QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
143 | } |
|
136 | } | |
144 |
|
137 | |||
145 | DataTable Window::generateRandomData(int listCount, int valueMax, int valueCount) const |
|
138 | DataTable Window::generateRandomData(int listCount, int valueMax, int valueCount) const | |
146 | { |
|
139 | { | |
147 | DataTable dataTable; |
|
140 | DataTable dataTable; | |
148 |
|
141 | |||
149 | // set seed for random stuff |
|
142 | // set seed for random stuff | |
150 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); |
|
143 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); | |
151 |
|
144 | |||
152 | // generate random data |
|
145 | // generate random data | |
153 | for (int i(0); i < listCount; i++) { |
|
146 | for (int i(0); i < listCount; i++) { | |
154 | DataList dataList; |
|
147 | DataList dataList; | |
155 | qreal yValue(0); |
|
148 | qreal yValue(0); | |
156 | for (int j(0); j < valueCount; j++) { |
|
149 | for (int j(0); j < valueCount; j++) { | |
157 | yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; |
|
150 | yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; | |
158 | QPointF value( |
|
151 | QPointF value( | |
159 | (j + (qreal) qrand() / (qreal) RAND_MAX) |
|
152 | (j + (qreal) qrand() / (qreal) RAND_MAX) | |
160 | * ((qreal) m_valueMax / (qreal) valueCount), yValue); |
|
153 | * ((qreal) m_valueMax / (qreal) valueCount), yValue); | |
161 | QString label = "Slice " + QString::number(i) + ":" + QString::number(j); |
|
154 | QString label = "Slice " + QString::number(i) + ":" + QString::number(j); | |
162 | dataList << Data(value, label); |
|
155 | dataList << Data(value, label); | |
163 | } |
|
156 | } | |
164 | dataTable << dataList; |
|
157 | dataTable << dataList; | |
165 | } |
|
158 | } | |
166 |
|
159 | |||
167 | return dataTable; |
|
160 | return dataTable; | |
168 | } |
|
161 | } | |
169 |
|
162 | |||
170 | void Window::createProxyWidgets() |
|
163 | void Window::createProxyWidgets() | |
171 | { |
|
164 | { | |
172 | m_themeComboBox = createThemeBox(); |
|
165 | m_themeComboBox = createThemeBox(); | |
173 | m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing")); |
|
166 | m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing")); | |
174 | m_animatedComboBox = createAnimationBox(); |
|
167 | m_animatedComboBox = createAnimationBox(); | |
175 | m_legendComboBox = createLegendBox(); |
|
168 | m_legendComboBox = createLegendBox(); | |
176 | m_openGLCheckBox = new QCheckBox(tr("OpenGL")); |
|
169 | m_openGLCheckBox = new QCheckBox(tr("OpenGL")); | |
177 | m_zoomCheckBox = new QCheckBox(tr("Zoom")); |
|
170 | m_zoomCheckBox = new QCheckBox(tr("Zoom")); | |
178 | m_scrollCheckBox = new QCheckBox(tr("Scroll")); |
|
171 | m_scrollCheckBox = new QCheckBox(tr("Scroll")); | |
179 | m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox); |
|
172 | m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox); | |
180 | m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox); |
|
173 | m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox); | |
181 | m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox); |
|
174 | m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox); | |
182 | m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox); |
|
175 | m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox); | |
183 | m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox); |
|
176 | m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox); | |
184 | m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme")); |
|
177 | m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme")); | |
185 | m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations")); |
|
178 | m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations")); | |
186 | m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend")); |
|
179 | m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend")); | |
187 | m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox); |
|
180 | m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox); | |
188 | m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox); |
|
181 | m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox); | |
189 | } |
|
182 | } | |
190 |
|
183 | |||
191 |
QComboBox* Window::createThemeBox() |
|
184 | QComboBox* Window::createThemeBox() | |
192 | { |
|
185 | { | |
193 | // settings layoutQGLWidgetβ |
|
186 | // settings layoutQGLWidgetβ | |
194 |
QComboBox* themeComboBox = new |
|
187 | QComboBox* themeComboBox = new ComboBox(this); | |
195 | themeComboBox->addItem("Light", QChart::ChartThemeLight); |
|
188 | themeComboBox->addItem("Light", QChart::ChartThemeLight); | |
196 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); |
|
189 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); | |
197 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); |
|
190 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); | |
198 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); |
|
191 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); | |
199 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); |
|
192 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); | |
200 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); |
|
193 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); | |
201 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); |
|
194 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); | |
202 | return themeComboBox; |
|
195 | return themeComboBox; | |
203 | } |
|
196 | } | |
204 |
|
197 | |||
205 |
QComboBox* Window::createAnimationBox() |
|
198 | QComboBox* Window::createAnimationBox() | |
206 | { |
|
199 | { | |
207 | // settings layout |
|
200 | // settings layout | |
208 |
QComboBox* animationComboBox = new |
|
201 | QComboBox* animationComboBox = new ComboBox(this); | |
209 | animationComboBox->addItem("No Animations", QChart::NoAnimation); |
|
202 | animationComboBox->addItem("No Animations", QChart::NoAnimation); | |
210 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); |
|
203 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); | |
211 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); |
|
204 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); | |
212 | animationComboBox->addItem("All Animations", QChart::AllAnimations); |
|
205 | animationComboBox->addItem("All Animations", QChart::AllAnimations); | |
213 | return animationComboBox; |
|
206 | return animationComboBox; | |
214 | } |
|
207 | } | |
215 |
|
208 | |||
216 |
QComboBox* Window::createLegendBox() |
|
209 | QComboBox* Window::createLegendBox() | |
217 | { |
|
210 | { | |
218 |
QComboBox* legendComboBox = new |
|
211 | QComboBox* legendComboBox = new ComboBox(this); | |
219 | legendComboBox->addItem("No Legend ", 0); |
|
212 | legendComboBox->addItem("No Legend ", 0); | |
220 | legendComboBox->addItem("Legend Top", Qt::AlignTop); |
|
213 | legendComboBox->addItem("Legend Top", Qt::AlignTop); | |
221 | legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); |
|
214 | legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); | |
222 | legendComboBox->addItem("Legend Left", Qt::AlignLeft); |
|
215 | legendComboBox->addItem("Legend Left", Qt::AlignLeft); | |
223 | legendComboBox->addItem("Legend Right", Qt::AlignRight); |
|
216 | legendComboBox->addItem("Legend Right", Qt::AlignRight); | |
224 | return legendComboBox; |
|
217 | return legendComboBox; | |
225 | } |
|
218 | } | |
226 |
|
219 | |||
227 | void Window::updateUI() |
|
220 | void Window::updateUI() | |
228 | { |
|
221 | { | |
229 | bool opengl = m_openGLCheckBox->isChecked(); |
|
222 | bool opengl = m_openGLCheckBox->isChecked(); | |
230 | bool isOpengl = qobject_cast<QGLWidget*>(m_view->viewport()); |
|
223 | bool isOpengl = qobject_cast<QGLWidget*>(m_view->viewport()); | |
231 | if ((isOpengl && !opengl) || (!isOpengl && opengl)) { |
|
224 | if ((isOpengl && !opengl) || (!isOpengl && opengl)) { | |
232 | m_view->deleteLater(); |
|
225 | m_view->deleteLater(); | |
233 | m_view = new View(m_scene, m_form); |
|
226 | m_view = new View(m_scene, m_form); | |
234 | m_view->setViewport(!opengl ? new QWidget() : new QGLWidget()); |
|
227 | m_view->setViewport(!opengl ? new QWidget() : new QGLWidget()); | |
235 | setCentralWidget(m_view); |
|
228 | setCentralWidget(m_view); | |
236 | } |
|
229 | } | |
237 |
|
230 | |||
238 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( |
|
231 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( | |
239 | m_themeComboBox->currentIndex()).toInt(); |
|
232 | m_themeComboBox->currentIndex()).toInt(); | |
240 |
|
233 | |||
241 | foreach (QChart *chart, m_chartList) |
|
234 | foreach (QChart *chart, m_chartList) | |
242 | chart->setTheme(theme); |
|
235 | chart->setTheme(theme); | |
243 |
|
236 | |||
244 | QPalette pal = window()->palette(); |
|
237 | QPalette pal = window()->palette(); | |
245 | if (theme == QChart::ChartThemeLight) { |
|
238 | if (theme == QChart::ChartThemeLight) { | |
246 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
239 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); | |
247 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
240 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
248 | } |
|
241 | } | |
249 | else if (theme == QChart::ChartThemeDark) { |
|
242 | else if (theme == QChart::ChartThemeDark) { | |
250 | pal.setColor(QPalette::Window, QRgb(0x121218)); |
|
243 | pal.setColor(QPalette::Window, QRgb(0x121218)); | |
251 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
244 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); | |
252 | } |
|
245 | } | |
253 | else if (theme == QChart::ChartThemeBlueCerulean) { |
|
246 | else if (theme == QChart::ChartThemeBlueCerulean) { | |
254 | pal.setColor(QPalette::Window, QRgb(0x40434a)); |
|
247 | pal.setColor(QPalette::Window, QRgb(0x40434a)); | |
255 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
248 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); | |
256 | } |
|
249 | } | |
257 | else if (theme == QChart::ChartThemeBrownSand) { |
|
250 | else if (theme == QChart::ChartThemeBrownSand) { | |
258 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); |
|
251 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); | |
259 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
252 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
260 | } |
|
253 | } | |
261 | else if (theme == QChart::ChartThemeBlueNcs) { |
|
254 | else if (theme == QChart::ChartThemeBlueNcs) { | |
262 | pal.setColor(QPalette::Window, QRgb(0x018bba)); |
|
255 | pal.setColor(QPalette::Window, QRgb(0x018bba)); | |
263 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
256 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
264 | } |
|
257 | } | |
265 | else if (theme == QChart::ChartThemeHighContrast) { |
|
258 | else if (theme == QChart::ChartThemeHighContrast) { | |
266 | pal.setColor(QPalette::Window, QRgb(0xffab03)); |
|
259 | pal.setColor(QPalette::Window, QRgb(0xffab03)); | |
267 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); |
|
260 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); | |
268 | } |
|
261 | } | |
269 | else if (theme == QChart::ChartThemeBlueIcy) { |
|
262 | else if (theme == QChart::ChartThemeBlueIcy) { | |
270 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); |
|
263 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); | |
271 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
264 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
272 | } |
|
265 | } | |
273 | else { |
|
266 | else { | |
274 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
267 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); | |
275 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
268 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
276 | } |
|
269 | } | |
277 | foreach(QGraphicsProxyWidget* widget , m_widgetHash) { |
|
270 | foreach(QGraphicsProxyWidget* widget , m_widgetHash) { | |
278 | widget->setPalette(pal); |
|
271 | widget->setPalette(pal); | |
279 | } |
|
272 | } | |
280 | m_view->setBackgroundBrush(pal.color((QPalette::Window))); |
|
273 | m_view->setBackgroundBrush(pal.color((QPalette::Window))); | |
281 | m_rubberBand->setPen(pal.color((QPalette::WindowText))); |
|
274 | m_rubberBand->setPen(pal.color((QPalette::WindowText))); | |
282 |
|
275 | |||
283 | QChart::AnimationOptions options( |
|
276 | QChart::AnimationOptions options( | |
284 | m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); |
|
277 | m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); | |
285 | if (!m_chartList.isEmpty() && m_chartList.at(0)->animationOptions() != options) { |
|
278 | if (!m_chartList.isEmpty() && m_chartList.at(0)->animationOptions() != options) { | |
286 | foreach (QChart *chart, m_chartList) |
|
279 | foreach (QChart *chart, m_chartList) | |
287 | chart->setAnimationOptions(options); |
|
280 | chart->setAnimationOptions(options); | |
288 | } |
|
281 | } | |
289 |
|
282 | |||
290 | Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); |
|
283 | Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); | |
291 |
|
284 | |||
292 | if (!alignment) { |
|
285 | if (!alignment) { | |
293 | foreach (QChart *chart, m_chartList) { |
|
286 | foreach (QChart *chart, m_chartList) { | |
294 | chart->legend()->hide(); |
|
287 | chart->legend()->hide(); | |
295 | } |
|
288 | } | |
296 | } |
|
289 | } | |
297 | else { |
|
290 | else { | |
298 | foreach (QChart *chart, m_chartList) { |
|
291 | foreach (QChart *chart, m_chartList) { | |
299 | chart->legend()->setAlignment(alignment); |
|
292 | chart->legend()->setAlignment(alignment); | |
300 | chart->legend()->show(); |
|
293 | chart->legend()->show(); | |
301 | } |
|
294 | } | |
302 | } |
|
295 | } | |
303 |
|
296 | |||
304 | bool antialias = m_antialiasCheckBox->isChecked(); |
|
297 | bool antialias = m_antialiasCheckBox->isChecked(); | |
305 |
|
298 | |||
306 | if (opengl) |
|
299 | if (opengl) | |
307 | m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); |
|
300 | m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); | |
308 | else |
|
301 | else | |
309 | m_view->setRenderHint(QPainter::Antialiasing, antialias); |
|
302 | m_view->setRenderHint(QPainter::Antialiasing, antialias); | |
310 |
|
303 | |||
311 | bool scroll = m_scrollCheckBox->isChecked(); |
|
304 | bool scroll = m_scrollCheckBox->isChecked(); | |
312 |
|
305 | |||
313 | if(!m_scroll & scroll){ |
|
306 | if(!m_scroll & scroll){ | |
314 | m_scroll=true; |
|
307 | m_scroll=true; | |
315 | m_zoom=false; |
|
308 | m_zoom=false; | |
316 | m_zoomCheckBox->setChecked(false); |
|
309 | m_zoomCheckBox->setChecked(false); | |
317 | } |
|
310 | } | |
318 |
|
311 | |||
319 | bool zoom = m_zoomCheckBox->isChecked(); |
|
312 | bool zoom = m_zoomCheckBox->isChecked(); | |
320 |
|
313 | |||
321 | if(!m_zoom & zoom){ |
|
314 | if(!m_zoom & zoom){ | |
322 | m_scroll=false; |
|
315 | m_scroll=false; | |
323 | m_zoom=true; |
|
316 | m_zoom=true; | |
324 | m_scrollCheckBox->setChecked(false); |
|
317 | m_scrollCheckBox->setChecked(false); | |
325 | } |
|
318 | } | |
326 |
|
319 | |||
327 | } |
|
320 | } | |
328 |
|
321 | |||
329 | void Window::mousePressEvent(QMouseEvent *event) |
|
322 | void Window::mousePressEvent(QMouseEvent *event) | |
330 | { |
|
323 | { | |
331 | if (event->button() == Qt::LeftButton) { |
|
324 | if (event->button() == Qt::LeftButton) { | |
332 |
|
325 | |||
333 | m_origin = event->pos(); |
|
326 | m_origin = event->pos(); | |
334 | m_isScrolling = false; |
|
327 | m_isScrolling = false; | |
335 | m_isZooming = false; |
|
328 | m_isZooming = false; | |
336 |
|
329 | |||
337 | foreach (QChart *chart, m_chartList) { |
|
330 | foreach (QChart *chart, m_chartList) { | |
338 |
|
331 | |||
339 | QRectF geometryRect = chart->geometry(); |
|
332 | QRectF geometryRect = chart->geometry(); | |
340 | QRectF plotArea = chart->plotArea(); |
|
333 | QRectF plotArea = chart->plotArea(); | |
341 | plotArea.translate(geometryRect.topLeft()); |
|
334 | plotArea.translate(geometryRect.topLeft()); | |
342 | if (plotArea.contains(m_origin)) { |
|
335 | if (plotArea.contains(m_origin)) { | |
343 | m_isScrolling = m_scroll; |
|
336 | m_isScrolling = m_scroll; | |
344 | m_isZooming = m_zoom; |
|
337 | m_isZooming = m_zoom; | |
345 | break; |
|
338 | break; | |
346 | } |
|
339 | } | |
347 | } |
|
340 | } | |
348 |
|
341 | |||
349 | if (m_isZooming) { |
|
342 | if (m_isZooming) { | |
350 | m_rubberBand->setRect(QRectF(m_origin, QSize())); |
|
343 | m_rubberBand->setRect(QRectF(m_origin, QSize())); | |
351 | m_rubberBand->setVisible(true); |
|
344 | m_rubberBand->setVisible(true); | |
352 | } |
|
345 | } | |
353 | event->accept(); |
|
346 | event->accept(); | |
354 | } |
|
347 | } | |
355 |
|
348 | |||
356 | if (event->button() == Qt::RightButton) { |
|
349 | if (event->button() == Qt::RightButton) { | |
357 | m_origin = event->pos(); |
|
350 | m_origin = event->pos(); | |
358 | m_isZooming = m_zoom; |
|
351 | m_isZooming = m_zoom; | |
359 | } |
|
352 | } | |
360 | } |
|
353 | } | |
361 |
|
354 | |||
362 | void Window::mouseMoveEvent(QMouseEvent *event) |
|
355 | void Window::mouseMoveEvent(QMouseEvent *event) | |
363 | { |
|
356 | { | |
364 | if (m_isScrolling || m_isZooming) { |
|
357 | if (m_isScrolling || m_isZooming) { | |
365 |
|
358 | |||
366 | foreach (QChart *chart, m_chartList) { |
|
359 | foreach (QChart *chart, m_chartList) { | |
367 |
|
360 | |||
368 | QRectF geometryRect = chart->geometry(); |
|
361 | QRectF geometryRect = chart->geometry(); | |
369 | QRectF plotArea = chart->plotArea(); |
|
362 | QRectF plotArea = chart->plotArea(); | |
370 | plotArea.translate(geometryRect.topLeft()); |
|
363 | plotArea.translate(geometryRect.topLeft()); | |
371 |
|
364 | |||
372 | if (plotArea.contains(m_origin)) { |
|
365 | if (plotArea.contains(m_origin)) { | |
373 | if (m_isScrolling) { |
|
366 | if (m_isScrolling) { | |
374 | QPointF delta = m_origin - event->pos(); |
|
367 | QPointF delta = m_origin - event->pos(); | |
375 | chart->scroll(delta.x(), -delta.y()); |
|
368 | chart->scroll(delta.x(), -delta.y()); | |
376 | } |
|
369 | } | |
377 | if (m_isZooming && plotArea.contains(event->pos())) { |
|
370 | if (m_isZooming && plotArea.contains(event->pos())) { | |
378 | m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized()); |
|
371 | m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized()); | |
379 | } |
|
372 | } | |
380 | break; |
|
373 | break; | |
381 | } |
|
374 | } | |
382 | } |
|
375 | } | |
383 | if(m_isScrolling) m_origin = event->pos(); |
|
376 | if(m_isScrolling) m_origin = event->pos(); | |
384 | event->accept(); |
|
377 | event->accept(); | |
385 | } |
|
378 | } | |
386 | } |
|
379 | } | |
387 |
|
380 | |||
388 | void Window::mouseReleaseEvent(QMouseEvent *event) |
|
381 | void Window::mouseReleaseEvent(QMouseEvent *event) | |
389 | { |
|
382 | { | |
390 | if (event->button() == Qt::LeftButton) { |
|
383 | if (event->button() == Qt::LeftButton) { | |
391 | m_isScrolling = false; |
|
384 | m_isScrolling = false; | |
392 | if (m_isZooming) { |
|
385 | if (m_isZooming) { | |
393 | m_isZooming = false; |
|
386 | m_isZooming = false; | |
394 | m_rubberBand->setVisible(false); |
|
387 | m_rubberBand->setVisible(false); | |
395 |
|
388 | |||
396 | foreach (QChart *chart, m_chartList) { |
|
389 | foreach (QChart *chart, m_chartList) { | |
397 |
|
390 | |||
398 | QRectF geometryRect = chart->geometry(); |
|
391 | QRectF geometryRect = chart->geometry(); | |
399 | QRectF plotArea = chart->plotArea(); |
|
392 | QRectF plotArea = chart->plotArea(); | |
400 | plotArea.translate(geometryRect.topLeft()); |
|
393 | plotArea.translate(geometryRect.topLeft()); | |
401 |
|
394 | |||
402 | if (plotArea.contains(m_origin)) { |
|
395 | if (plotArea.contains(m_origin)) { | |
403 | QRectF rect = m_rubberBand->rect(); |
|
396 | QRectF rect = m_rubberBand->rect(); | |
404 | rect.translate(-geometryRect.topLeft()); |
|
397 | rect.translate(-geometryRect.topLeft()); | |
405 | chart->zoomIn(rect); |
|
398 | chart->zoomIn(rect); | |
406 | break; |
|
399 | break; | |
407 | } |
|
400 | } | |
408 | } |
|
401 | } | |
409 | } |
|
402 | } | |
410 | event->accept(); |
|
403 | event->accept(); | |
411 | } |
|
404 | } | |
412 |
|
405 | |||
413 | if (event->button() == Qt::RightButton) { |
|
406 | if (event->button() == Qt::RightButton) { | |
414 |
|
407 | |||
415 | if (m_isZooming) { |
|
408 | if (m_isZooming) { | |
416 | foreach (QChart *chart, m_chartList) { |
|
409 | foreach (QChart *chart, m_chartList) { | |
417 |
|
410 | |||
418 | QRectF geometryRect = chart->geometry(); |
|
411 | QRectF geometryRect = chart->geometry(); | |
419 | QRectF plotArea = chart->plotArea(); |
|
412 | QRectF plotArea = chart->plotArea(); | |
420 | plotArea.translate(geometryRect.topLeft()); |
|
413 | plotArea.translate(geometryRect.topLeft()); | |
421 |
|
414 | |||
422 | if (plotArea.contains(m_origin)) { |
|
415 | if (plotArea.contains(m_origin)) { | |
423 | QRectF rect = m_rubberBand->rect(); |
|
416 | QRectF rect = m_rubberBand->rect(); | |
424 | chart->zoomOut(); |
|
417 | chart->zoomOut(); | |
425 | break; |
|
418 | break; | |
426 | } |
|
419 | } | |
427 | } |
|
420 | } | |
428 | } |
|
421 | } | |
429 | } |
|
422 | } | |
430 | } |
|
423 | } | |
|
424 | ||||
|
425 | void Window::comboBoxFocused(QComboBox *combobox) | |||
|
426 | { | |||
|
427 | foreach(QGraphicsProxyWidget* widget , m_widgetHash) { | |||
|
428 | if(widget->widget()==combobox) | |||
|
429 | widget->setZValue(2.0); | |||
|
430 | else | |||
|
431 | widget->setZValue(0.0); | |||
|
432 | } | |||
|
433 | } |
@@ -1,96 +1,116 | |||||
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 <QMainWindow> |
|
23 | #include <QMainWindow> | |
24 | #include <QChartGlobal> |
|
24 | #include <QChartGlobal> | |
25 | #include <QHash> |
|
25 | #include <QHash> | |
|
26 | #include <QComboBox> | |||
26 |
|
27 | |||
27 | class QComboBox; |
|
|||
28 | class QCheckBox; |
|
28 | class QCheckBox; | |
29 | class QGraphicsRectItem; |
|
29 | class QGraphicsRectItem; | |
30 | class QGraphicsScene; |
|
30 | class QGraphicsScene; | |
31 | class QGraphicsWidget; |
|
31 | class QGraphicsWidget; | |
32 | class View; |
|
32 | class View; | |
33 |
|
33 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 | class QChart; |
|
35 | class QChart; | |
36 | QTCOMMERCIALCHART_END_NAMESPACE |
|
36 | QTCOMMERCIALCHART_END_NAMESPACE | |
37 |
|
37 | |||
38 | typedef QPair<QPointF, QString> Data; |
|
38 | typedef QPair<QPointF, QString> Data; | |
39 | typedef QList<Data> DataList; |
|
39 | typedef QList<Data> DataList; | |
40 | typedef QList<DataList> DataTable; |
|
40 | typedef QList<DataList> DataTable; | |
41 |
|
41 | |||
42 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
42 | QTCOMMERCIALCHART_USE_NAMESPACE | |
43 |
|
43 | |||
|
44 | ||||
44 | class Window: public QMainWindow |
|
45 | class Window: public QMainWindow | |
45 | { |
|
46 | { | |
46 | Q_OBJECT |
|
47 | Q_OBJECT | |
47 | public: |
|
48 | public: | |
48 | explicit Window(QWidget *parent = 0); |
|
49 | explicit Window(QWidget *parent = 0); | |
49 | ~Window(); |
|
50 | ~Window(); | |
50 |
|
51 | |||
51 | private Q_SLOTS: |
|
52 | private Q_SLOTS: | |
52 | void updateUI(); |
|
53 | void updateUI(); | |
53 |
|
54 | |||
54 |
|
55 | |||
55 | private: |
|
56 | private: | |
56 | DataTable generateRandomData(int listCount,int valueMax,int valueCount) const; |
|
57 | DataTable generateRandomData(int listCount,int valueMax,int valueCount) const; | |
57 |
QComboBox* createThemeBox() |
|
58 | QComboBox* createThemeBox(); | |
58 |
QComboBox* createAnimationBox() |
|
59 | QComboBox* createAnimationBox(); | |
59 |
QComboBox* createLegendBox() |
|
60 | QComboBox* createLegendBox(); | |
60 | void connectSignals(); |
|
61 | void connectSignals(); | |
61 | void createProxyWidgets(); |
|
62 | void createProxyWidgets(); | |
|
63 | void comboBoxFocused(QComboBox *combox); | |||
62 |
|
64 | |||
63 | protected: |
|
65 | protected: | |
64 | void mousePressEvent(QMouseEvent *event); |
|
66 | void mousePressEvent(QMouseEvent *event); | |
65 | void mouseMoveEvent(QMouseEvent *event); |
|
67 | void mouseMoveEvent(QMouseEvent *event); | |
66 | void mouseReleaseEvent(QMouseEvent *event); |
|
68 | void mouseReleaseEvent(QMouseEvent *event); | |
67 |
|
69 | |||
68 |
|
70 | |||
69 | private: |
|
71 | private: | |
70 | int m_listCount; |
|
72 | int m_listCount; | |
71 | int m_valueMax; |
|
73 | int m_valueMax; | |
72 | int m_valueCount; |
|
74 | int m_valueCount; | |
73 | QGraphicsScene* m_scene; |
|
75 | QGraphicsScene* m_scene; | |
74 | View* m_view; |
|
76 | View* m_view; | |
75 | QHash<QString, QGraphicsProxyWidget*> m_widgetHash; |
|
77 | QHash<QString, QGraphicsProxyWidget*> m_widgetHash; | |
76 | QList<QChart*> m_chartList; |
|
78 | QList<QChart*> m_chartList; | |
77 | DataTable m_dataTable; |
|
79 | DataTable m_dataTable; | |
78 |
|
80 | |||
79 | QGraphicsWidget *m_form; |
|
81 | QGraphicsWidget *m_form; | |
80 | QComboBox *m_themeComboBox; |
|
82 | QComboBox *m_themeComboBox; | |
81 | QCheckBox *m_antialiasCheckBox; |
|
83 | QCheckBox *m_antialiasCheckBox; | |
82 | QComboBox *m_animatedComboBox; |
|
84 | QComboBox *m_animatedComboBox; | |
83 | QComboBox *m_legendComboBox; |
|
85 | QComboBox *m_legendComboBox; | |
84 | QCheckBox *m_openGLCheckBox; |
|
86 | QCheckBox *m_openGLCheckBox; | |
85 | QCheckBox *m_zoomCheckBox; |
|
87 | QCheckBox *m_zoomCheckBox; | |
86 | QCheckBox *m_scrollCheckBox; |
|
88 | QCheckBox *m_scrollCheckBox; | |
87 | QPoint m_origin; |
|
89 | QPoint m_origin; | |
88 | QGraphicsRectItem* m_rubberBand; |
|
90 | QGraphicsRectItem* m_rubberBand; | |
89 |
|
91 | |||
90 | bool m_isScrolling; |
|
92 | bool m_isScrolling; | |
91 | bool m_isZooming; |
|
93 | bool m_isZooming; | |
92 | bool m_scroll; |
|
94 | bool m_scroll; | |
93 | bool m_zoom; |
|
95 | bool m_zoom; | |
|
96 | ||||
|
97 | friend class ComboBox; | |||
|
98 | }; | |||
|
99 | ||||
|
100 | class ComboBox: public QComboBox | |||
|
101 | { | |||
|
102 | public: | |||
|
103 | ComboBox(Window* window,QWidget *parent = 0):QComboBox(parent),m_window(window) | |||
|
104 | {} | |||
|
105 | ||||
|
106 | protected: | |||
|
107 | void focusInEvent(QFocusEvent *e) | |||
|
108 | { | |||
|
109 | QComboBox::focusInEvent(e); | |||
|
110 | m_window->comboBoxFocused(this); | |||
|
111 | } | |||
|
112 | private: | |||
|
113 | Window* m_window; | |||
94 | }; |
|
114 | }; | |
95 |
|
115 | |||
96 | #endif |
|
116 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now