##// END OF EJS Templates
Adds donut and precent charts to chartviewer
Michal Klocek -
r1865:27e7b2d61433
parent child
Show More
@@ -0,0 +1,57
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 "charts.h"
22 #include "qchart.h"
23 #include "qpieseries.h"
24
25 class DonutChart: public Chart
26 {
27 public:
28 QString name() { return QObject::tr("DonutChart"); }
29 QString category() { return QObject::tr("PieSeries"); }
30 QString subCategory() { return QString::null; }
31
32 QChart* createChart(const DataTable& table)
33 {
34 QChart* chart = new QChart();
35 chart->setTitle("Donut chart");
36
37 for (int i = 0, j = table.count(); i < table.count(); i++,j--) {
38 QPieSeries *series = new QPieSeries(chart);
39 foreach (Data data, table[i]) {
40 QPieSlice *slice = series->append(data.second, data.first.y());
41 if (data == table[i].first()) {
42 slice->setLabelVisible();
43 }
44 }
45 series->setPieSize( j / (qreal) table.count());
46 if(j>1) series->setHoleSize( (j-1)/ (qreal) table.count()+0.1);
47 series->setHorizontalPosition(0.5);
48 series->setVerticalPosition(0.5);
49 chart->addSeries(series);
50 }
51 return chart;
52 }
53
54 };
55
56 DECLARE_CHART(DonutChart)
57
@@ -0,0 +1,55
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 "charts.h"
22 #include "qchart.h"
23 #include "qhorizontalpercentbarseries.h"
24 #include "qbarset.h"
25
26 class HorizontalPercentBarChart: public Chart
27 {
28 public:
29 QString name() { return QObject::tr("HorizontalPercentBarChart"); }
30 QString category() { return QObject::tr("BarSeries"); }
31 QString subCategory() { return QObject::tr("Horizontal"); }
32
33 QChart* createChart(const DataTable& table)
34 {
35
36 QChart* chart = new QChart();
37
38 chart->setTitle("Horizontal percent chart");
39
40 QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(chart);
41 for (int i(0); i < table.count(); i++) {
42 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 foreach (Data data, table[i])
44 *set << data.first.y();
45 series->append(set);
46 }
47 chart->addSeries(series);
48 chart->createDefaultAxes();
49 return chart;
50 }
51
52 };
53
54 DECLARE_CHART(HorizontalPercentBarChart)
55
@@ -0,0 +1,55
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 "charts.h"
22 #include "qchart.h"
23 #include "qpercentbarseries.h"
24 #include "qbarset.h"
25
26 class VerticalPercentBarChart: public Chart
27 {
28 public:
29 QString name() { return QObject::tr("VerticalPercentBarChart"); }
30 QString category() { return QObject::tr("BarSeries"); }
31 QString subCategory() { return QObject::tr("Vertical"); }
32
33 QChart* createChart(const DataTable& table)
34 {
35
36 QChart* chart = new QChart();
37
38 chart->setTitle("Stacked bar chart");
39
40 QPercentBarSeries* series = new QPercentBarSeries(chart);
41 for (int i(0); i < table.count(); i++) {
42 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 foreach (Data data, table[i])
44 *set << data.first.y();
45 series->append(set);
46 }
47 chart->addSeries(series);
48 chart->createDefaultAxes();
49 return chart;
50 }
51
52 };
53
54 DECLARE_CHART(VerticalPercentBarChart)
55
@@ -1,13 +1,14
1 INCLUDEPATH += $$PWD
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
2 DEPENDPATH += $$PWD
3
3 SOURCES += linechart.cpp \
4 SOURCES+= \
4 scatterchart.cpp \
5 linechart.cpp \
5 splinechart.cpp \
6 scatterchart.cpp \
6 verticalstackedbarchart.cpp \
7 splinechart.cpp \
7 horizontalstackedbarchart.cpp \
8 piechart.cpp \
8 verticalbarchart.cpp \
9 verticalstackedbarchart.cpp \
9 horizontalbarchart.cpp \
10 horizontalstackedbarchart.cpp \
10 horizontalpercentbarchart.cpp \
11 verticalbarchart.cpp \
11 verticalpercentbarchart.cpp \
12 horizontalbarchart.cpp \
12 areachart.cpp \
13 areachart.cpp No newline at end of file
13 piechart.cpp \
14 donutchart.cpp
@@ -1,581 +1,583
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 #include <QChartView>
24 #include <QChartView>
25 #include <QAreaSeries>
25 #include <QAreaSeries>
26 #include <QLegend>
26 #include <QLegend>
27 #include <QGridLayout>
27 #include <QGridLayout>
28 #include <QFormLayout>
28 #include <QFormLayout>
29 #include <QComboBox>
29 #include <QComboBox>
30 #include <QSpinBox>
30 #include <QSpinBox>
31 #include <QCheckBox>
31 #include <QCheckBox>
32 #include <QGroupBox>
32 #include <QGroupBox>
33 #include <QLabel>
33 #include <QLabel>
34 #include <QGraphicsScene>
34 #include <QGraphicsScene>
35 #include <QGraphicsGridLayout>
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(QWidget* parent) :
43 Window::Window(QWidget* parent) :
44 QMainWindow(parent),
44 QMainWindow(parent),
45 m_listCount(3),
45 m_listCount(3),
46 m_valueMax(10),
46 m_valueMax(10),
47 m_valueCount(7),
47 m_valueCount(7),
48 m_scene(new QGraphicsScene(this)),
48 m_scene(new QGraphicsScene(this)),
49 m_view(0),
49 m_view(0),
50 m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)),
50 m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)),
51 m_form(0),
51 m_form(0),
52 m_themeComboBox(0),
52 m_themeComboBox(0),
53 m_antialiasCheckBox(0),
53 m_antialiasCheckBox(0),
54 m_animatedComboBox(0),
54 m_animatedComboBox(0),
55 m_legendComboBox(0),
55 m_legendComboBox(0),
56 m_templateComboBox(0),
56 m_templateComboBox(0),
57 m_openGLCheckBox(0),
57 m_openGLCheckBox(0),
58 m_zoomCheckBox(0),
58 m_zoomCheckBox(0),
59 m_scrollCheckBox(0),
59 m_scrollCheckBox(0),
60 m_rubberBand(new QGraphicsRectItem()),
60 m_rubberBand(new QGraphicsRectItem()),
61 m_baseLayout(new QGraphicsGridLayout()),
61 m_baseLayout(new QGraphicsGridLayout()),
62 m_menu(createMenu()),
62 m_menu(createMenu()),
63 m_state(NoState),
63 m_state(NoState),
64 m_currentState(NoState),
64 m_currentState(NoState),
65 m_template(0)
65 m_template(0)
66 {
66 {
67 createProxyWidgets();
67 createProxyWidgets();
68 connectSignals();
68 connectSignals();
69
69
70 // create layout
70 // create layout
71 QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout();
71 QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout();
72 settingsLayout->setOrientation(Qt::Vertical);
72 settingsLayout->setOrientation(Qt::Vertical);
73 settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
73 settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
74 settingsLayout->addItem(m_widgetHash["openGLCheckBox"]);
74 settingsLayout->addItem(m_widgetHash["openGLCheckBox"]);
75 settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]);
75 settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]);
76 settingsLayout->addItem(m_widgetHash["themeLabel"]);
76 settingsLayout->addItem(m_widgetHash["themeLabel"]);
77 settingsLayout->addItem(m_widgetHash["themeComboBox"]);
77 settingsLayout->addItem(m_widgetHash["themeComboBox"]);
78 settingsLayout->addItem(m_widgetHash["animationsLabel"]);
78 settingsLayout->addItem(m_widgetHash["animationsLabel"]);
79 settingsLayout->addItem(m_widgetHash["animatedComboBox"]);
79 settingsLayout->addItem(m_widgetHash["animatedComboBox"]);
80 settingsLayout->addItem(m_widgetHash["legendLabel"]);
80 settingsLayout->addItem(m_widgetHash["legendLabel"]);
81 settingsLayout->addItem(m_widgetHash["legendComboBox"]);
81 settingsLayout->addItem(m_widgetHash["legendComboBox"]);
82 settingsLayout->addItem(m_widgetHash["templateLabel"]);
82 settingsLayout->addItem(m_widgetHash["templateLabel"]);
83 settingsLayout->addItem(m_widgetHash["templateComboBox"]);
83 settingsLayout->addItem(m_widgetHash["templateComboBox"]);
84 settingsLayout->addItem(m_widgetHash["scrollCheckBox"]);
84 settingsLayout->addItem(m_widgetHash["scrollCheckBox"]);
85 settingsLayout->addItem(m_widgetHash["zoomCheckBox"]);
85 settingsLayout->addItem(m_widgetHash["zoomCheckBox"]);
86 settingsLayout->addStretch();
86 settingsLayout->addStretch();
87 m_baseLayout->addItem(settingsLayout, 0, 3, 2, 1);
87 m_baseLayout->addItem(settingsLayout, 0, 3, 2, 1);
88
88
89 //create charts
89 //create charts
90 Charts::ChartList list = Charts::chartList();
90 Charts::ChartList list = Charts::chartList();
91
91
92 for (int i = 0; i < 9; ++i) {
92 for (int i = 0; i < 9; ++i) {
93 QChart* chart = 0;
93 QChart* chart = 0;
94 if(i<list.size()){
94 if(i<list.size()){
95 chart = list.at(i)->createChart(m_dataTable);
95 chart = list.at(i)->createChart(m_dataTable);
96 }else{
96 }else{
97 chart = new QChart();
97 chart = new QChart();
98 chart->setTitle(tr("Empty"));
98 chart->setTitle(tr("Empty"));
99 }
99 }
100
100
101 m_baseLayout->addItem(chart, i / 3, i % 3);
101 m_baseLayout->addItem(chart, i / 3, i % 3);
102 m_chartHash[chart] = i;
102 m_chartHash[chart] = i;
103 }
103 }
104
104
105 m_form = new QGraphicsWidget();
105 m_form = new QGraphicsWidget();
106 m_form->setLayout(m_baseLayout);
106 m_form->setLayout(m_baseLayout);
107 m_scene->addItem(m_form);
107 m_scene->addItem(m_form);
108 m_scene->addItem(m_rubberBand);
108 m_scene->addItem(m_rubberBand);
109 m_rubberBand->setVisible(false);
109 m_rubberBand->setVisible(false);
110
110
111 m_view = new View(m_scene, m_form);
111 m_view = new View(m_scene, m_form);
112 m_view->setMinimumSize(m_form->preferredSize().toSize());
112 m_view->setMinimumSize(m_form->preferredSize().toSize());
113
113
114 // Set defaults
114 // Set defaults
115 m_antialiasCheckBox->setChecked(true);
115 m_antialiasCheckBox->setChecked(true);
116 updateUI();
116 updateUI();
117 setCentralWidget(m_view);
117 setCentralWidget(m_view);
118 }
118 }
119
119
120 Window::~Window()
120 Window::~Window()
121 {
121 {
122 }
122 }
123
123
124 void Window::connectSignals()
124 void Window::connectSignals()
125 {
125 {
126 QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
126 QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
127 QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
127 QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
128 QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
128 QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
129 QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
129 QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
130 QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
130 QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
131 QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
131 QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
132 QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
132 QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
133 QObject::connect(m_templateComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
133 QObject::connect(m_templateComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
134 }
134 }
135
135
136 void Window::createProxyWidgets()
136 void Window::createProxyWidgets()
137 {
137 {
138 m_themeComboBox = createThemeBox();
138 m_themeComboBox = createThemeBox();
139 m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing"));
139 m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing"));
140 m_animatedComboBox = createAnimationBox();
140 m_animatedComboBox = createAnimationBox();
141 m_legendComboBox = createLegendBox();
141 m_legendComboBox = createLegendBox();
142 m_openGLCheckBox = new QCheckBox(tr("OpenGL"));
142 m_openGLCheckBox = new QCheckBox(tr("OpenGL"));
143 m_zoomCheckBox = new QCheckBox(tr("Zoom"));
143 m_zoomCheckBox = new QCheckBox(tr("Zoom"));
144 m_scrollCheckBox = new QCheckBox(tr("Scroll"));
144 m_scrollCheckBox = new QCheckBox(tr("Scroll"));
145 m_templateComboBox= createTempleteBox();
145 m_templateComboBox= createTempleteBox();
146 m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox);
146 m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox);
147 m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox);
147 m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox);
148 m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox);
148 m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox);
149 m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox);
149 m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox);
150 m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox);
150 m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox);
151 m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme"));
151 m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme"));
152 m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations"));
152 m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations"));
153 m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend"));
153 m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend"));
154 m_widgetHash["templateLabel"] = m_scene->addWidget(new QLabel("Chart template"));
154 m_widgetHash["templateLabel"] = m_scene->addWidget(new QLabel("Chart template"));
155 m_widgetHash["templateComboBox"] = m_scene->addWidget(m_templateComboBox);
155 m_widgetHash["templateComboBox"] = m_scene->addWidget(m_templateComboBox);
156 m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox);
156 m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox);
157 m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox);
157 m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox);
158
158
159 }
159 }
160
160
161 QComboBox* Window::createThemeBox()
161 QComboBox* Window::createThemeBox()
162 {
162 {
163 QComboBox* themeComboBox = new ComboBox(this);
163 QComboBox* themeComboBox = new ComboBox(this);
164 themeComboBox->addItem("Light", QChart::ChartThemeLight);
164 themeComboBox->addItem("Light", QChart::ChartThemeLight);
165 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
165 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
166 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
166 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
167 themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand);
167 themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand);
168 themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs);
168 themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs);
169 themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast);
169 themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast);
170 themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy);
170 themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy);
171 return themeComboBox;
171 return themeComboBox;
172 }
172 }
173
173
174 QComboBox* Window::createAnimationBox()
174 QComboBox* Window::createAnimationBox()
175 {
175 {
176 QComboBox* animationComboBox = new ComboBox(this);
176 QComboBox* animationComboBox = new ComboBox(this);
177 animationComboBox->addItem("No Animations", QChart::NoAnimation);
177 animationComboBox->addItem("No Animations", QChart::NoAnimation);
178 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
178 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
179 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
179 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
180 animationComboBox->addItem("All Animations", QChart::AllAnimations);
180 animationComboBox->addItem("All Animations", QChart::AllAnimations);
181 return animationComboBox;
181 return animationComboBox;
182 }
182 }
183
183
184 QComboBox* Window::createLegendBox()
184 QComboBox* Window::createLegendBox()
185 {
185 {
186 QComboBox* legendComboBox = new ComboBox(this);
186 QComboBox* legendComboBox = new ComboBox(this);
187 legendComboBox->addItem("No Legend ", 0);
187 legendComboBox->addItem("No Legend ", 0);
188 legendComboBox->addItem("Legend Top", Qt::AlignTop);
188 legendComboBox->addItem("Legend Top", Qt::AlignTop);
189 legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
189 legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
190 legendComboBox->addItem("Legend Left", Qt::AlignLeft);
190 legendComboBox->addItem("Legend Left", Qt::AlignLeft);
191 legendComboBox->addItem("Legend Right", Qt::AlignRight);
191 legendComboBox->addItem("Legend Right", Qt::AlignRight);
192 return legendComboBox;
192 return legendComboBox;
193 }
193 }
194
194
195 QComboBox* Window::createTempleteBox()
195 QComboBox* Window::createTempleteBox()
196 {
196 {
197 QComboBox* templateComboBox = new ComboBox(this);
197 QComboBox* templateComboBox = new ComboBox(this);
198 templateComboBox->addItem("No Template", 0);
198 templateComboBox->addItem("No Template", 0);
199
199
200 Charts::ChartList list = Charts::chartList();
200 Charts::ChartList list = Charts::chartList();
201 QMultiMap<QString, Chart*> categoryMap;
201 QMultiMap<QString, Chart*> categoryMap;
202
202
203 foreach(Chart* chart, list) {
203 foreach(Chart* chart, list) {
204 categoryMap.insertMulti(chart->category(), chart);
204 categoryMap.insertMulti(chart->category(), chart);
205 }
205 }
206 foreach(const QString& category, categoryMap.uniqueKeys()) {
206 foreach(const QString& category, categoryMap.uniqueKeys()) {
207 templateComboBox->addItem(category, category);
207 templateComboBox->addItem(category, category);
208 }
208 }
209 return templateComboBox;
209 return templateComboBox;
210 }
210 }
211
211
212
212
213 void Window::updateUI()
213 void Window::updateUI()
214 {
214 {
215 checkTemplate();
215 checkTemplate();
216 checkOpenGL();
216 checkOpenGL();
217 checkTheme();
217 checkTheme();
218 checkAnimationOptions();
218 checkAnimationOptions();
219 checkLegend();
219 checkLegend();
220 checkState();
220 checkState();
221 }
221 }
222
222
223 void Window::checkLegend()
223 void Window::checkLegend()
224 {
224 {
225 Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt());
225 Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt());
226
226
227 if (!alignment) {
227 if (!alignment) {
228 foreach (QChart *chart, m_chartHash.keys()) {
228 foreach (QChart *chart, m_chartHash.keys()) {
229 chart->legend()->hide();
229 chart->legend()->hide();
230 }
230 }
231 }
231 }
232 else {
232 else {
233 foreach (QChart *chart, m_chartHash.keys()) {
233 foreach (QChart *chart, m_chartHash.keys()) {
234 chart->legend()->setAlignment(alignment);
234 chart->legend()->setAlignment(alignment);
235 chart->legend()->show();
235 chart->legend()->show();
236 }
236 }
237 }
237 }
238 }
238 }
239
239
240 void Window::checkOpenGL()
240 void Window::checkOpenGL()
241 {
241 {
242 bool opengl = m_openGLCheckBox->isChecked();
242 bool opengl = m_openGLCheckBox->isChecked();
243 bool isOpengl = qobject_cast<QGLWidget*>(m_view->viewport());
243 bool isOpengl = qobject_cast<QGLWidget*>(m_view->viewport());
244 if ((isOpengl && !opengl) || (!isOpengl && opengl)) {
244 if ((isOpengl && !opengl) || (!isOpengl && opengl)) {
245 m_view->deleteLater();
245 m_view->deleteLater();
246 m_view = new View(m_scene, m_form);
246 m_view = new View(m_scene, m_form);
247 m_view->setViewport(!opengl ? new QWidget() : new QGLWidget());
247 m_view->setViewport(!opengl ? new QWidget() : new QGLWidget());
248 setCentralWidget(m_view);
248 setCentralWidget(m_view);
249 }
249 }
250
250
251 bool antialias = m_antialiasCheckBox->isChecked();
251 bool antialias = m_antialiasCheckBox->isChecked();
252
252
253 if (opengl)
253 if (opengl)
254 m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias);
254 m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias);
255 else
255 else
256 m_view->setRenderHint(QPainter::Antialiasing, antialias);
256 m_view->setRenderHint(QPainter::Antialiasing, antialias);
257 }
257 }
258
258
259 void Window::checkAnimationOptions()
259 void Window::checkAnimationOptions()
260 {
260 {
261 QChart::AnimationOptions options(
261 QChart::AnimationOptions options(
262 m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
262 m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
263 if (!m_chartHash.isEmpty() && m_chartHash.keys().at(0)->animationOptions() != options) {
263 if (!m_chartHash.isEmpty() && m_chartHash.keys().at(0)->animationOptions() != options) {
264 foreach (QChart *chart, m_chartHash.keys())
264 foreach (QChart *chart, m_chartHash.keys())
265 chart->setAnimationOptions(options);
265 chart->setAnimationOptions(options);
266 }
266 }
267 }
267 }
268
268
269 void Window::checkState()
269 void Window::checkState()
270 {
270 {
271 bool scroll = m_scrollCheckBox->isChecked();
271 bool scroll = m_scrollCheckBox->isChecked();
272
272
273 if (m_state != ScrollState && scroll) {
273 if (m_state != ScrollState && scroll) {
274 m_state = ScrollState;
274 m_state = ScrollState;
275 m_zoomCheckBox->setChecked(false);
275 m_zoomCheckBox->setChecked(false);
276 }
276 }
277 else if (!scroll && m_state == ScrollState) {
277 else if (!scroll && m_state == ScrollState) {
278 m_state = NoState;
278 m_state = NoState;
279 }
279 }
280
280
281 bool zoom = m_zoomCheckBox->isChecked();
281 bool zoom = m_zoomCheckBox->isChecked();
282
282
283 if (m_state != ZoomState && zoom) {
283 if (m_state != ZoomState && zoom) {
284 m_state = ZoomState;
284 m_state = ZoomState;
285 m_scrollCheckBox->setChecked(false);
285 m_scrollCheckBox->setChecked(false);
286 }
286 }
287 else if (!zoom && m_state == ZoomState) {
287 else if (!zoom && m_state == ZoomState) {
288 m_state = NoState;
288 m_state = NoState;
289 }
289 }
290 }
290 }
291
291
292 void Window::checkTemplate()
292 void Window::checkTemplate()
293 {
293 {
294
294
295 int index = m_templateComboBox->currentIndex();
295 int index = m_templateComboBox->currentIndex();
296 if (m_template == index || index == 0)
296 if (m_template == index || index == 0)
297 return;
297 return;
298
298
299 m_template = index;
300
299 QString category = m_templateComboBox->itemData(index).toString();
301 QString category = m_templateComboBox->itemData(index).toString();
300 Charts::ChartList list = Charts::chartList();
302 Charts::ChartList list = Charts::chartList();
301
303
302 QList<QChart*> qchartList = m_chartHash.keys();
304 QList<QChart*> qchartList = m_chartHash.keys();
303
305
304 foreach(QChart* qchart,qchartList){
306 foreach(QChart* qchart,qchartList){
305 for(int i = 0 ; i < m_baseLayout->count();++i)
307 for(int i = 0 ; i < m_baseLayout->count();++i)
306 {
308 {
307 if(m_baseLayout->itemAt(i)==qchart){
309 if(m_baseLayout->itemAt(i)==qchart){
308 m_baseLayout->removeAt(i);
310 m_baseLayout->removeAt(i);
309 break;
311 break;
310 }
312 }
311 }
313 }
312 }
314 }
313
315
314 m_chartHash.clear();
316 m_chartHash.clear();
315 qDeleteAll(qchartList);
317 qDeleteAll(qchartList);
316
318
317 QChart* qchart(0);
319 QChart* qchart(0);
318
320
319 int j=0;
321 int j=0;
320 for (int i = 0; i < list.size(); ++i) {
322 for (int i = 0; i < list.size(); ++i) {
321 Chart* chart = list.at(i);
323 Chart* chart = list.at(i);
322 if (chart->category() == category && j < 9) {
324 if (chart->category() == category && j < 9) {
323 qchart = list.at(i)->createChart(m_dataTable);
325 qchart = list.at(i)->createChart(m_dataTable);
324 m_baseLayout->addItem(qchart, j / 3, j % 3);
326 m_baseLayout->addItem(qchart, j / 3, j % 3);
325 m_chartHash[qchart] = j;
327 m_chartHash[qchart] = j;
326 j++;
328 j++;
327 }
329 }
328 }
330 }
329 for (; j < 9; ++j) {
331 for (; j < 9; ++j) {
330 qchart = new QChart();
332 qchart = new QChart();
331 qchart->setTitle(tr("Empty"));
333 qchart->setTitle(tr("Empty"));
332 m_baseLayout->addItem(qchart, j / 3, j % 3);
334 m_baseLayout->addItem(qchart, j / 3, j % 3);
333 m_chartHash[qchart] = j;
335 m_chartHash[qchart] = j;
334 }
336 }
335 }
337 }
336
338
337 void Window::checkTheme()
339 void Window::checkTheme()
338 {
340 {
339 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(
341 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(
340 m_themeComboBox->currentIndex()).toInt();
342 m_themeComboBox->currentIndex()).toInt();
341
343
342 foreach (QChart *chart, m_chartHash.keys())
344 foreach (QChart *chart, m_chartHash.keys())
343 chart->setTheme(theme);
345 chart->setTheme(theme);
344
346
345 QPalette pal = window()->palette();
347 QPalette pal = window()->palette();
346 if (theme == QChart::ChartThemeLight) {
348 if (theme == QChart::ChartThemeLight) {
347 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
349 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
348 pal.setColor(QPalette::WindowText, QRgb(0x404044));
350 pal.setColor(QPalette::WindowText, QRgb(0x404044));
349 }
351 }
350 else if (theme == QChart::ChartThemeDark) {
352 else if (theme == QChart::ChartThemeDark) {
351 pal.setColor(QPalette::Window, QRgb(0x121218));
353 pal.setColor(QPalette::Window, QRgb(0x121218));
352 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
354 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
353 }
355 }
354 else if (theme == QChart::ChartThemeBlueCerulean) {
356 else if (theme == QChart::ChartThemeBlueCerulean) {
355 pal.setColor(QPalette::Window, QRgb(0x40434a));
357 pal.setColor(QPalette::Window, QRgb(0x40434a));
356 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
358 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
357 }
359 }
358 else if (theme == QChart::ChartThemeBrownSand) {
360 else if (theme == QChart::ChartThemeBrownSand) {
359 pal.setColor(QPalette::Window, QRgb(0x9e8965));
361 pal.setColor(QPalette::Window, QRgb(0x9e8965));
360 pal.setColor(QPalette::WindowText, QRgb(0x404044));
362 pal.setColor(QPalette::WindowText, QRgb(0x404044));
361 }
363 }
362 else if (theme == QChart::ChartThemeBlueNcs) {
364 else if (theme == QChart::ChartThemeBlueNcs) {
363 pal.setColor(QPalette::Window, QRgb(0x018bba));
365 pal.setColor(QPalette::Window, QRgb(0x018bba));
364 pal.setColor(QPalette::WindowText, QRgb(0x404044));
366 pal.setColor(QPalette::WindowText, QRgb(0x404044));
365 }
367 }
366 else if (theme == QChart::ChartThemeHighContrast) {
368 else if (theme == QChart::ChartThemeHighContrast) {
367 pal.setColor(QPalette::Window, QRgb(0xffab03));
369 pal.setColor(QPalette::Window, QRgb(0xffab03));
368 pal.setColor(QPalette::WindowText, QRgb(0x181818));
370 pal.setColor(QPalette::WindowText, QRgb(0x181818));
369 }
371 }
370 else if (theme == QChart::ChartThemeBlueIcy) {
372 else if (theme == QChart::ChartThemeBlueIcy) {
371 pal.setColor(QPalette::Window, QRgb(0xcee7f0));
373 pal.setColor(QPalette::Window, QRgb(0xcee7f0));
372 pal.setColor(QPalette::WindowText, QRgb(0x404044));
374 pal.setColor(QPalette::WindowText, QRgb(0x404044));
373 }
375 }
374 else {
376 else {
375 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
377 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
376 pal.setColor(QPalette::WindowText, QRgb(0x404044));
378 pal.setColor(QPalette::WindowText, QRgb(0x404044));
377 }
379 }
378 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
380 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
379 widget->setPalette(pal);
381 widget->setPalette(pal);
380 }
382 }
381 m_view->setBackgroundBrush(pal.color((QPalette::Window)));
383 m_view->setBackgroundBrush(pal.color((QPalette::Window)));
382 m_rubberBand->setPen(pal.color((QPalette::WindowText)));
384 m_rubberBand->setPen(pal.color((QPalette::WindowText)));
383 }
385 }
384
386
385 void Window::mousePressEvent(QMouseEvent *event)
387 void Window::mousePressEvent(QMouseEvent *event)
386 {
388 {
387 if (event->button() == Qt::LeftButton) {
389 if (event->button() == Qt::LeftButton) {
388
390
389 m_origin = event->pos();
391 m_origin = event->pos();
390 m_currentState = NoState;
392 m_currentState = NoState;
391
393
392 foreach (QChart *chart, m_chartHash.keys()) {
394 foreach (QChart *chart, m_chartHash.keys()) {
393
395
394 QRectF geometryRect = chart->geometry();
396 QRectF geometryRect = chart->geometry();
395 QRectF plotArea = chart->plotArea();
397 QRectF plotArea = chart->plotArea();
396 plotArea.translate(geometryRect.topLeft());
398 plotArea.translate(geometryRect.topLeft());
397 if (plotArea.contains(m_origin)) {
399 if (plotArea.contains(m_origin)) {
398 m_currentState = m_state;
400 m_currentState = m_state;
399
401
400 if (m_currentState == NoState && m_templateComboBox->currentIndex()==0) {
402 if (m_currentState == NoState && m_templateComboBox->currentIndex()==0) {
401 handleMenu(chart);
403 handleMenu(chart);
402 }
404 }
403 break;
405 break;
404 }
406 }
405 }
407 }
406
408
407 if (m_currentState == ZoomState) {
409 if (m_currentState == ZoomState) {
408 m_rubberBand->setRect(QRectF(m_origin, QSize()));
410 m_rubberBand->setRect(QRectF(m_origin, QSize()));
409 m_rubberBand->setVisible(true);
411 m_rubberBand->setVisible(true);
410 }
412 }
411
413
412 event->accept();
414 event->accept();
413 }
415 }
414
416
415 if (event->button() == Qt::RightButton) {
417 if (event->button() == Qt::RightButton) {
416 m_origin = event->pos();
418 m_origin = event->pos();
417 m_currentState = m_state;
419 m_currentState = m_state;
418 }
420 }
419 }
421 }
420
422
421 void Window::mouseMoveEvent(QMouseEvent *event)
423 void Window::mouseMoveEvent(QMouseEvent *event)
422 {
424 {
423 if ( m_currentState != NoState) {
425 if ( m_currentState != NoState) {
424
426
425 foreach (QChart *chart, m_chartHash.keys()) {
427 foreach (QChart *chart, m_chartHash.keys()) {
426
428
427 QRectF geometryRect = chart->geometry();
429 QRectF geometryRect = chart->geometry();
428 QRectF plotArea = chart->plotArea();
430 QRectF plotArea = chart->plotArea();
429 plotArea.translate(geometryRect.topLeft());
431 plotArea.translate(geometryRect.topLeft());
430
432
431 if (plotArea.contains(m_origin)) {
433 if (plotArea.contains(m_origin)) {
432 if (m_currentState == ScrollState) {
434 if (m_currentState == ScrollState) {
433 QPointF delta = m_origin - event->pos();
435 QPointF delta = m_origin - event->pos();
434 chart->scroll(delta.x(), -delta.y());
436 chart->scroll(delta.x(), -delta.y());
435 }
437 }
436 if (m_currentState == ZoomState && plotArea.contains(event->pos())) {
438 if (m_currentState == ZoomState && plotArea.contains(event->pos())) {
437 m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized());
439 m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized());
438 }
440 }
439 break;
441 break;
440 }
442 }
441 }
443 }
442 if(m_currentState == ScrollState) m_origin = event->pos();
444 if(m_currentState == ScrollState) m_origin = event->pos();
443 event->accept();
445 event->accept();
444 }
446 }
445 }
447 }
446
448
447 void Window::mouseReleaseEvent(QMouseEvent *event)
449 void Window::mouseReleaseEvent(QMouseEvent *event)
448 {
450 {
449 if (event->button() == Qt::LeftButton) {
451 if (event->button() == Qt::LeftButton) {
450 if (m_currentState == ZoomState) {
452 if (m_currentState == ZoomState) {
451 m_rubberBand->setVisible(false);
453 m_rubberBand->setVisible(false);
452
454
453 foreach (QChart *chart, m_chartHash.keys()) {
455 foreach (QChart *chart, m_chartHash.keys()) {
454
456
455 QRectF geometryRect = chart->geometry();
457 QRectF geometryRect = chart->geometry();
456 QRectF plotArea = chart->plotArea();
458 QRectF plotArea = chart->plotArea();
457 plotArea.translate(geometryRect.topLeft());
459 plotArea.translate(geometryRect.topLeft());
458
460
459 if (plotArea.contains(m_origin)) {
461 if (plotArea.contains(m_origin)) {
460 QRectF rect = m_rubberBand->rect();
462 QRectF rect = m_rubberBand->rect();
461 rect.translate(-geometryRect.topLeft());
463 rect.translate(-geometryRect.topLeft());
462 chart->zoomIn(rect);
464 chart->zoomIn(rect);
463 break;
465 break;
464 }
466 }
465 }
467 }
466 }
468 }
467
469
468 m_currentState = NoState;
470 m_currentState = NoState;
469 event->accept();
471 event->accept();
470 }
472 }
471
473
472 if (event->button() == Qt::RightButton) {
474 if (event->button() == Qt::RightButton) {
473
475
474 if (m_currentState == ZoomState) {
476 if (m_currentState == ZoomState) {
475 foreach (QChart *chart, m_chartHash.keys()) {
477 foreach (QChart *chart, m_chartHash.keys()) {
476
478
477 QRectF geometryRect = chart->geometry();
479 QRectF geometryRect = chart->geometry();
478 QRectF plotArea = chart->plotArea();
480 QRectF plotArea = chart->plotArea();
479 plotArea.translate(geometryRect.topLeft());
481 plotArea.translate(geometryRect.topLeft());
480
482
481 if (plotArea.contains(m_origin)) {
483 if (plotArea.contains(m_origin)) {
482 QRectF rect = m_rubberBand->rect();
484 QRectF rect = m_rubberBand->rect();
483 chart->zoomOut();
485 chart->zoomOut();
484 break;
486 break;
485 }
487 }
486 }
488 }
487 }
489 }
488 }
490 }
489 }
491 }
490
492
491 void Window::comboBoxFocused(QComboBox *combobox)
493 void Window::comboBoxFocused(QComboBox *combobox)
492 {
494 {
493 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
495 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
494 if(widget->widget()==combobox)
496 if(widget->widget()==combobox)
495 widget->setZValue(2.0);
497 widget->setZValue(2.0);
496 else
498 else
497 widget->setZValue(0.0);
499 widget->setZValue(0.0);
498 }
500 }
499 }
501 }
500
502
501 void Window::handleMenu(QChart* qchart)
503 void Window::handleMenu(QChart* qchart)
502 {
504 {
503 QAction *chosen = m_menu->exec(QCursor::pos());
505 QAction *chosen = m_menu->exec(QCursor::pos());
504
506
505 if (chosen) {
507 if (chosen) {
506 Chart* chart = (Chart *) chosen->data().value<void *>();
508 Chart* chart = (Chart *) chosen->data().value<void *>();
507 int index = m_chartHash[qchart];
509 int index = m_chartHash[qchart];
508 //not in 4.7.2 m_baseLayout->removeItem(qchart);
510 //not in 4.7.2 m_baseLayout->removeItem(qchart);
509 for(int i = 0 ; i < m_baseLayout->count();++i)
511 for(int i = 0 ; i < m_baseLayout->count();++i)
510 {
512 {
511 if(m_baseLayout->itemAt(i)==qchart){
513 if(m_baseLayout->itemAt(i)==qchart){
512 m_baseLayout->removeAt(i);
514 m_baseLayout->removeAt(i);
513 break;
515 break;
514 }
516 }
515 }
517 }
516
518
517 m_chartHash.remove(qchart);
519 m_chartHash.remove(qchart);
518 QChart* newChart = chart->createChart(m_dataTable);
520 QChart* newChart = chart->createChart(m_dataTable);
519 m_baseLayout->addItem(newChart, index / 3, index % 3);
521 m_baseLayout->addItem(newChart, index / 3, index % 3);
520 m_chartHash[newChart] = index;
522 m_chartHash[newChart] = index;
521 delete qchart;
523 delete qchart;
522 updateUI();
524 updateUI();
523 }
525 }
524
526
525 }
527 }
526
528
527 QMenu* Window::createMenu()
529 QMenu* Window::createMenu()
528 {
530 {
529 Charts::ChartList list = Charts::chartList();
531 Charts::ChartList list = Charts::chartList();
530 QMultiMap<QString, Chart*> categoryMap;
532 QMultiMap<QString, Chart*> categoryMap;
531
533
532 QMenu* result = new QMenu(this);
534 QMenu* result = new QMenu(this);
533
535
534 foreach(Chart* chart, list) {
536 foreach(Chart* chart, list) {
535 categoryMap.insertMulti(chart->category(), chart);
537 categoryMap.insertMulti(chart->category(), chart);
536 }
538 }
537
539
538 foreach(const QString& category, categoryMap.uniqueKeys()) {
540 foreach(const QString& category, categoryMap.uniqueKeys()) {
539 QMenu* menu(0);
541 QMenu* menu(0);
540 QMultiMap<QString, Chart*> subCategoryMap;
542 QMultiMap<QString, Chart*> subCategoryMap;
541 if (category.isEmpty()) {
543 if (category.isEmpty()) {
542 menu = result;
544 menu = result;
543 }
545 }
544 else {
546 else {
545 menu = new QMenu(category, this);
547 menu = new QMenu(category, this);
546 result->addMenu(menu);
548 result->addMenu(menu);
547 }
549 }
548
550
549 foreach(Chart* chart , categoryMap.values(category)) {
551 foreach(Chart* chart , categoryMap.values(category)) {
550 subCategoryMap.insert(chart->subCategory(), chart);
552 subCategoryMap.insert(chart->subCategory(), chart);
551 }
553 }
552
554
553 foreach(const QString& subCategory, subCategoryMap.uniqueKeys()) {
555 foreach(const QString& subCategory, subCategoryMap.uniqueKeys()) {
554 QMenu* subMenu(0);
556 QMenu* subMenu(0);
555 if (subCategory.isEmpty()) {
557 if (subCategory.isEmpty()) {
556 subMenu = menu;
558 subMenu = menu;
557 }
559 }
558 else {
560 else {
559 subMenu = new QMenu(subCategory, this);
561 subMenu = new QMenu(subCategory, this);
560 menu->addMenu(subMenu);
562 menu->addMenu(subMenu);
561 }
563 }
562
564
563 foreach(Chart* chart , subCategoryMap.values(subCategory)) {
565 foreach(Chart* chart , subCategoryMap.values(subCategory)) {
564
566
565 createMenuAction(subMenu, QIcon(), chart->name(),
567 createMenuAction(subMenu, QIcon(), chart->name(),
566 qVariantFromValue((void *) chart));
568 qVariantFromValue((void *) chart));
567 }
569 }
568 }
570 }
569 }
571 }
570
572
571 return result;
573 return result;
572 }
574 }
573
575
574 QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text,
576 QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text,
575 const QVariant &data)
577 const QVariant &data)
576 {
578 {
577 QAction *action = menu->addAction(icon, text);
579 QAction *action = menu->addAction(icon, text);
578 action->setCheckable(false);
580 action->setCheckable(false);
579 action->setData(data);
581 action->setData(data);
580 return action;
582 return action;
581 }
583 }
General Comments 0
You need to be logged in to leave comments. Login now