##// END OF EJS Templates
coding style fixes for demos
Jani Honkonen -
r2099:dacd8b696e6b
parent child
Show More
@@ -54,7 +54,7 qreal Chart::distance(const QPointF &p1, const QPointF &p2)
54 54
55 55 void Chart::setPointClicked(bool clicked)
56 56 {
57 m_clicked = clicked;
57 m_clicked = clicked;
58 58 }
59 59
60 60 void Chart::handlePointMove(const QPoint &point)
@@ -63,30 +63,30 void Chart::handlePointMove(const QPoint &point)
63 63 //Map the point clicked from the ChartView
64 64 //to the area occupied by the chart.
65 65 QPoint mappedPoint = point;
66 mappedPoint.setX(point.x()-this->plotArea().x());
67 mappedPoint.setY(point.y()-this->plotArea().y());
66 mappedPoint.setX(point.x() - this->plotArea().x());
67 mappedPoint.setY(point.y() - this->plotArea().y());
68 68
69 69 //Get the x- and y axis to be able to convert the mapped
70 70 //coordinate point to the charts scale.
71 QAbstractAxis * axisx = this->axisX();
72 QValueAxis* haxis = 0;
71 QAbstractAxis *axisx = this->axisX();
72 QValueAxis *haxis = 0;
73 73 if (axisx->type() == QAbstractAxis::AxisTypeValue)
74 haxis = qobject_cast<QValueAxis*>(axisx);
74 haxis = qobject_cast<QValueAxis *>(axisx);
75 75
76 QAbstractAxis * axisy = this->axisY();
77 QValueAxis* vaxis = 0;
76 QAbstractAxis *axisy = this->axisY();
77 QValueAxis *vaxis = 0;
78 78 if (axisy->type() == QAbstractAxis::AxisTypeValue)
79 vaxis = qobject_cast<QValueAxis*>(axisy);
79 vaxis = qobject_cast<QValueAxis *>(axisy);
80 80
81 81 if (haxis && vaxis) {
82 82 //Calculate the "unit" between points on the x
83 83 //y axis.
84 double xUnit = this->plotArea().width()/haxis->max();
85 double yUnit = this->plotArea().height()/vaxis->max();
84 double xUnit = this->plotArea().width() / haxis->max();
85 double yUnit = this->plotArea().height() / vaxis->max();
86 86
87 87 //Convert the mappedPoint to the actual chart scale.
88 double x = mappedPoint.x()/xUnit;
89 double y = vaxis->max() - mappedPoint.y()/yUnit;
88 double x = mappedPoint.x() / xUnit;
89 double y = vaxis->max() - mappedPoint.y() / yUnit;
90 90
91 91 //Replace the old point with the new one.
92 92 m_series->replace(m_movingPoint, QPointF(x, y));
@@ -33,7 +33,7 int main(int argc, char *argv[])
33 33 {
34 34 QApplication a(argc, argv);
35 35
36 QLineSeries* series = new QLineSeries();
36 QLineSeries *series = new QLineSeries();
37 37
38 38 series->append(0, 6);
39 39 series->append(1, 3);
@@ -43,7 +43,7 int main(int argc, char *argv[])
43 43 series->append(10, 5);
44 44 *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
45 45
46 Chart* chart = new Chart(0, 0, series);
46 Chart *chart = new Chart(0, 0, series);
47 47 chart->legend()->hide();
48 48 chart->addSeries(series);
49 49 QPen p = series->pen();
@@ -62,7 +62,7 int main(int argc, char *argv[])
62 62
63 63 QObject::connect(series, SIGNAL(clicked(QPointF)), chart, SLOT(clickPoint(QPointF)));
64 64
65 ChartView* chartView = new ChartView(chart);
65 ChartView *chartView = new ChartView(chart);
66 66 chartView->setRenderHint(QPainter::Antialiasing);
67 67
68 68 QMainWindow window;
@@ -26,7 +26,7 int main(int argc, char *argv[])
26 26 {
27 27 QApplication a(argc, argv);
28 28 QMainWindow window;
29 ThemeWidget* widget = new ThemeWidget();
29 ThemeWidget *widget = new ThemeWidget();
30 30 window.setCentralWidget(widget);
31 31 window.resize(900, 600);
32 32 window.show();
@@ -43,12 +43,12
43 43 #include <QTime>
44 44 #include <QBarCategoryAxis>
45 45
46 ThemeWidget::ThemeWidget(QWidget* parent) :
46 ThemeWidget::ThemeWidget(QWidget *parent) :
47 47 QWidget(parent),
48 48 m_listCount(3),
49 49 m_valueMax(10),
50 50 m_valueCount(7),
51 m_dataTable(generateRandomData(m_listCount,m_valueMax,m_valueCount)),
51 m_dataTable(generateRandomData(m_listCount, m_valueMax, m_valueCount)),
52 52 m_themeComboBox(createThemeBox()),
53 53 m_antialiasCheckBox(new QCheckBox("Anti-aliasing")),
54 54 m_animatedComboBox(createAnimationBox()),
@@ -56,7 +56,7 ThemeWidget::ThemeWidget(QWidget* parent) :
56 56 {
57 57 connectSignals();
58 58 // create layout
59 QGridLayout* baseLayout = new QGridLayout();
59 QGridLayout *baseLayout = new QGridLayout();
60 60 QHBoxLayout *settingsLayout = new QHBoxLayout();
61 61 settingsLayout->addWidget(new QLabel("Theme:"));
62 62 settingsLayout->addWidget(m_themeComboBox);
@@ -116,7 +116,7 void ThemeWidget::connectSignals()
116 116 connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
117 117 }
118 118
119 DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCount) const
119 DataTable ThemeWidget::generateRandomData(int listCount, int valueMax, int valueCount) const
120 120 {
121 121 DataTable dataTable;
122 122
@@ -128,7 +128,7 DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCo
128 128 DataList dataList;
129 129 qreal yValue(0);
130 130 for (int j(0); j < valueCount; j++) {
131 yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount;
131 yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount;
132 132 QPointF value((j + (qreal) rand() / (qreal) RAND_MAX) * ((qreal) m_valueMax / (qreal) valueCount),
133 133 yValue);
134 134 QString label = "Slice " + QString::number(i) + ":" + QString::number(j);
@@ -140,10 +140,10 DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCo
140 140 return dataTable;
141 141 }
142 142
143 QComboBox* ThemeWidget::createThemeBox() const
143 QComboBox *ThemeWidget::createThemeBox() const
144 144 {
145 145 // settings layout
146 QComboBox* themeComboBox = new QComboBox();
146 QComboBox *themeComboBox = new QComboBox();
147 147 themeComboBox->addItem("Light", QChart::ChartThemeLight);
148 148 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
149 149 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
@@ -154,10 +154,10 QComboBox* ThemeWidget::createThemeBox() const
154 154 return themeComboBox;
155 155 }
156 156
157 QComboBox* ThemeWidget::createAnimationBox() const
157 QComboBox *ThemeWidget::createAnimationBox() const
158 158 {
159 159 // settings layout
160 QComboBox* animationComboBox = new QComboBox();
160 QComboBox *animationComboBox = new QComboBox();
161 161 animationComboBox->addItem("No Animations", QChart::NoAnimation);
162 162 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
163 163 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
@@ -165,9 +165,9 QComboBox* ThemeWidget::createAnimationBox() const
165 165 return animationComboBox;
166 166 }
167 167
168 QComboBox* ThemeWidget::createLegendBox() const
168 QComboBox *ThemeWidget::createLegendBox() const
169 169 {
170 QComboBox* legendComboBox = new QComboBox();
170 QComboBox *legendComboBox = new QComboBox();
171 171 legendComboBox->addItem("No Legend ", 0);
172 172 legendComboBox->addItem("Legend Top", Qt::AlignTop);
173 173 legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
@@ -176,7 +176,7 QComboBox* ThemeWidget::createLegendBox() const
176 176 return legendComboBox;
177 177 }
178 178
179 QChart* ThemeWidget::createAreaChart() const
179 QChart *ThemeWidget::createAreaChart() const
180 180 {
181 181 QChart *chart = new QChart();
182 182 // chart->axisX()->setNiceNumbersEnabled(true);
@@ -191,11 +191,12 QChart* ThemeWidget::createAreaChart() const
191 191 QLineSeries *upperSeries = new QLineSeries(chart);
192 192 for (int j(0); j < m_dataTable[i].count(); j++) {
193 193 Data data = m_dataTable[i].at(j);
194 if (lowerSeries){
194 if (lowerSeries) {
195 195 const QList<QPointF>& points = lowerSeries->points();
196 196 upperSeries->append(QPointF(j, points[i].y() + data.first.y()));
197 }else
197 } else {
198 198 upperSeries->append(QPointF(j, data.first.y()));
199 }
199 200 }
200 201 QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries);
201 202 area->setName(name + QString::number(nameIndex));
@@ -208,13 +209,13 QChart* ThemeWidget::createAreaChart() const
208 209 return chart;
209 210 }
210 211
211 QChart* ThemeWidget::createBarChart(int valueCount) const
212 QChart *ThemeWidget::createBarChart(int valueCount) const
212 213 {
213 214 Q_UNUSED(valueCount);
214 QChart* chart = new QChart();
215 QChart *chart = new QChart();
215 216 chart->setTitle("Bar chart");
216 217
217 QStackedBarSeries* series = new QStackedBarSeries(chart);
218 QStackedBarSeries *series = new QStackedBarSeries(chart);
218 219 for (int i(0); i < m_dataTable.count(); i++) {
219 220 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
220 221 foreach (Data data, m_dataTable[i])
@@ -227,9 +228,9 QChart* ThemeWidget::createBarChart(int valueCount) const
227 228 return chart;
228 229 }
229 230
230 QChart* ThemeWidget::createLineChart() const
231 QChart *ThemeWidget::createLineChart() const
231 232 {
232 QChart* chart = new QChart();
233 QChart *chart = new QChart();
233 234 chart->setTitle("Line chart");
234 235
235 236 QString name("Series ");
@@ -247,9 +248,9 QChart* ThemeWidget::createLineChart() const
247 248 return chart;
248 249 }
249 250
250 QChart* ThemeWidget::createPieChart() const
251 QChart *ThemeWidget::createPieChart() const
251 252 {
252 QChart* chart = new QChart();
253 QChart *chart = new QChart();
253 254 chart->setTitle("Pie chart");
254 255
255 256 qreal pieSize = 1.0 / m_dataTable.count();
@@ -272,9 +273,10 QChart* ThemeWidget::createPieChart() const
272 273 return chart;
273 274 }
274 275
275 QChart* ThemeWidget::createSplineChart() const
276 { // spine chart
277 QChart* chart = new QChart();
276 QChart *ThemeWidget::createSplineChart() const
277 {
278 // spine chart
279 QChart *chart = new QChart();
278 280 chart->setTitle("Spline chart");
279 281 QString name("Series ");
280 282 int nameIndex = 0;
@@ -290,9 +292,10 QChart* ThemeWidget::createSplineChart() const
290 292 return chart;
291 293 }
292 294
293 QChart* ThemeWidget::createScatterChart() const
294 { // scatter chart
295 QChart* chart = new QChart();
295 QChart *ThemeWidget::createScatterChart() const
296 {
297 // scatter chart
298 QChart *chart = new QChart();
296 299 chart->setTitle("Scatter chart");
297 300 QString name("Series ");
298 301 int nameIndex = 0;
@@ -358,9 +361,8 void ThemeWidget::updateUI()
358 361 Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt());
359 362
360 363 if (!alignment) {
361 foreach (QChartView *chartView, m_charts) {
364 foreach (QChartView *chartView, m_charts)
362 365 chartView->chart()->legend()->hide();
363 }
364 366 } else {
365 367 foreach (QChartView *chartView, m_charts) {
366 368 chartView->chart()->legend()->setAlignment(alignment);
@@ -49,23 +49,23 private Q_SLOTS:
49 49 void updateUI();
50 50
51 51 private:
52 DataTable generateRandomData(int listCount,int valueMax,int valueCount) const;
53 QComboBox* createThemeBox() const;
54 QComboBox* createAnimationBox() const;
55 QComboBox* createLegendBox() const;
52 DataTable generateRandomData(int listCount, int valueMax, int valueCount) const;
53 QComboBox *createThemeBox() const;
54 QComboBox *createAnimationBox() const;
55 QComboBox *createLegendBox() const;
56 56 void connectSignals();
57 QChart* createAreaChart() const;
58 QChart* createBarChart(int valueCount) const;
59 QChart* createPieChart() const;
60 QChart* createLineChart() const;
61 QChart* createSplineChart() const;
62 QChart* createScatterChart() const;
57 QChart *createAreaChart() const;
58 QChart *createBarChart(int valueCount) const;
59 QChart *createPieChart() const;
60 QChart *createLineChart() const;
61 QChart *createSplineChart() const;
62 QChart *createScatterChart() const;
63 63
64 64 private:
65 65 int m_listCount;
66 66 int m_valueMax;
67 67 int m_valueCount;
68 QList<QChartView*> m_charts;
68 QList<QChartView *> m_charts;
69 69 DataTable m_dataTable;
70 70
71 71 QComboBox *m_themeComboBox;
@@ -35,8 +35,8 QTCOMMERCIALCHART_USE_NAMESPACE
35 35 class Chart
36 36 {
37 37 public:
38 virtual ~Chart(){};
39 virtual QChart* createChart(const DataTable& table) = 0;
38 virtual ~Chart() {};
39 virtual QChart *createChart(const DataTable &table) = 0;
40 40 virtual QString name() = 0;
41 41 virtual QString category() = 0;
42 42 virtual QString subCategory() = 0;
@@ -46,46 +46,41 public:
46 46 namespace Charts
47 47 {
48 48
49 typedef QList<Chart*> ChartList;
49 typedef QList<Chart *> ChartList;
50 50
51 inline ChartList& chartList()
52 {
53 static ChartList list;
54 return list;
55 }
56
57 inline bool findChart(Chart* chart)
58 {
59 ChartList& list = chartList();
60 if (list.contains(chart)) {
61 return true;
51 inline ChartList &chartList()
52 {
53 static ChartList list;
54 return list;
62 55 }
63 foreach (Chart* item, list) {
64 if (item->name() == chart->name() && item->category() == chart->category() && item->subCategory() == chart->subCategory()) {
56
57 inline bool findChart(Chart *chart)
58 {
59 ChartList &list = chartList();
60 if (list.contains(chart))
65 61 return true;
62
63 foreach (Chart *item, list) {
64 if (item->name() == chart->name() && item->category() == chart->category() && item->subCategory() == chart->subCategory())
65 return true;
66 66 }
67 return false;
67 68 }
68 return false;
69 }
70 69
71 inline void addChart(Chart* chart)
72 {
73 ChartList& list = chartList();
74 if (!findChart(chart)) {
75 list.append(chart);
70 inline void addChart(Chart *chart)
71 {
72 ChartList &list = chartList();
73 if (!findChart(chart))
74 list.append(chart);
76 75 }
77 76 }
78 }
79 77
80 78 template <class T>
81 79 class ChartWrapper
82 80 {
83 81 public:
84 82 QSharedPointer<T> chart;
85 ChartWrapper() : chart(new T)
86 {
87 Charts::addChart(chart.data());
88 }
83 ChartWrapper() : chart(new T) { Charts::addChart(chart.data()); }
89 84 };
90 85
91 86 #define DECLARE_CHART(chartType) static ChartWrapper<chartType> chartType;
@@ -30,39 +30,38 public:
30 30 QString category() { return QObject::tr("Axis"); }
31 31 QString subCategory() { return QString::null; }
32 32
33 QChart* createChart(const DataTable& table) {
33 QChart *createChart(const DataTable &table)
34 {
35 QChart *chart = new QChart();
36 chart->setTitle("Category X , Category Y ");
34 37
35 QChart* chart = new QChart();
36 chart->setTitle("Category X , Category Y ");
38 QString name("Series ");
39 int nameIndex = 0;
40 foreach (DataList list, table) {
41 QLineSeries *series = new QLineSeries(chart);
42 foreach(Data data, list)
43 series->append(data.first);
44 series->setName(name + QString::number(nameIndex));
45 nameIndex++;
46 chart->addSeries(series);
47 }
37 48
38 QString name("Series ");
39 int nameIndex = 0;
40 foreach (DataList list, table) {
41 QLineSeries *series = new QLineSeries(chart);
42 foreach (Data data, list)
43 series->append(data.first);
44 series->setName(name + QString::number(nameIndex));
45 nameIndex++;
46 chart->addSeries(series);
47 }
49 QCategoryAxis *axisX = new QCategoryAxis;
50 axisX->append("low", 5);
51 axisX->append("avg.", 12);
52 axisX->append("high", 19);
53 axisX->setRange(0, 20);
54 chart->setAxisX(axisX, chart->series().at(0));
48 55
49 QCategoryAxis *axisX = new QCategoryAxis;
50 axisX->append("low", 5);
51 axisX->append("avg.", 12);
52 axisX->append("high", 19);
53 axisX->setRange(0, 20);
54 chart->setAxisX(axisX, chart->series().at(0));
56 QCategoryAxis *axisY = new QCategoryAxis;
57 axisY->append("cheap", 5);
58 axisY->append("fair", 12);
59 axisY->append("pricy", 20);
60 axisY->setRange(0, 20);
61 chart->setAxisY(axisY, chart->series().at(0));
55 62
56 QCategoryAxis *axisY = new QCategoryAxis;
57 axisY->append("cheap", 5);
58 axisY->append("fair", 12);
59 axisY->append("pricy", 20);
60 axisY->setRange(0, 20);
61 chart->setAxisY(axisY, chart->series().at(0));
62
63 return chart;
63 return chart;
64 64 }
65
66 65 };
67 66
68 67 DECLARE_CHART(CategoryLineChart)
@@ -31,30 +31,29 public:
31 31 QString category() { return QObject::tr("Axis"); }
32 32 QString subCategory() { return QString::null; }
33 33
34 QChart* createChart(const DataTable& table) {
35
36 QChart* chart = new QChart();
37 chart->setTitle("Value X , Value Y");
38
39 QString name("Series ");
40 int nameIndex = 0;
41 foreach (DataList list, table) {
42 QLineSeries *series = new QLineSeries(chart);
43 foreach (Data data, list)
44 series->append(data.first);
45 series->setName(name + QString::number(nameIndex));
46 nameIndex++;
47 chart->addSeries(series);
48 }
49
50 chart->createDefaultAxes();
51 QValueAxis* axis = new QValueAxis();
52 foreach (QAbstractSeries* series,chart->series())
53 chart->setAxisX(axis,series);
54
55 return chart;
34 QChart *createChart(const DataTable &table)
35 {
36 QChart *chart = new QChart();
37 chart->setTitle("Value X , Value Y");
38
39 QString name("Series ");
40 int nameIndex = 0;
41 foreach (DataList list, table) {
42 QLineSeries *series = new QLineSeries(chart);
43 foreach (Data data, list)
44 series->append(data.first);
45 series->setName(name + QString::number(nameIndex));
46 nameIndex++;
47 chart->addSeries(series);
48 }
49
50 chart->createDefaultAxes();
51 QValueAxis *axis = new QValueAxis();
52 foreach (QAbstractSeries *series, chart->series())
53 chart->setAxisX(axis, series);
54
55 return chart;
56 56 }
57
58 57 };
59 58
60 59 DECLARE_CHART(ValueAxis);
@@ -30,14 +30,11 public:
30 30 QString category() { return QObject::tr("BarSeries"); }
31 31 QString subCategory() { return QObject::tr("Horizontal"); }
32 32
33 QChart* createChart(const DataTable& table)
34 {
35
36 QChart* chart = new QChart();
37
33 QChart *createChart(const DataTable &table)
34 {
35 QChart *chart = new QChart();
38 36 chart->setTitle("Horizontal bar chart");
39
40 QHorizontalBarSeries* series = new QHorizontalBarSeries(chart);
37 QHorizontalBarSeries *series = new QHorizontalBarSeries(chart);
41 38 for (int i(0); i < table.count(); i++) {
42 39 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 40 foreach (Data data, table[i])
@@ -48,7 +45,6 public:
48 45 chart->createDefaultAxes();
49 46 return chart;
50 47 }
51
52 48 };
53 49
54 50 DECLARE_CHART(HorizontalBarChart)
@@ -30,14 +30,11 public:
30 30 QString category() { return QObject::tr("BarSeries"); }
31 31 QString subCategory() { return QObject::tr("Horizontal"); }
32 32
33 QChart* createChart(const DataTable& table)
33 QChart *createChart(const DataTable &table)
34 34 {
35
36 QChart* chart = new QChart();
37
35 QChart *chart = new QChart();
38 36 chart->setTitle("Horizontal percent chart");
39
40 QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(chart);
37 QHorizontalPercentBarSeries *series = new QHorizontalPercentBarSeries(chart);
41 38 for (int i(0); i < table.count(); i++) {
42 39 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 40 foreach (Data data, table[i])
@@ -48,7 +45,6 public:
48 45 chart->createDefaultAxes();
49 46 return chart;
50 47 }
51
52 48 };
53 49
54 50 DECLARE_CHART(HorizontalPercentBarChart)
@@ -30,14 +30,11 public:
30 30 QString category() { return QObject::tr("BarSeries"); }
31 31 QString subCategory() { return QObject::tr("Horizontal"); }
32 32
33 QChart* createChart(const DataTable& table)
33 QChart *createChart(const DataTable &table)
34 34 {
35
36 QChart* chart = new QChart();
37
35 QChart *chart = new QChart();
38 36 chart->setTitle("Horizontal stacked chart");
39
40 QHorizontalStackedBarSeries* series = new QHorizontalStackedBarSeries(chart);
37 QHorizontalStackedBarSeries *series = new QHorizontalStackedBarSeries(chart);
41 38 for (int i(0); i < table.count(); i++) {
42 39 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 40 foreach (Data data, table[i])
@@ -48,7 +45,6 public:
48 45 chart->createDefaultAxes();
49 46 return chart;
50 47 }
51
52 48 };
53 49
54 50 DECLARE_CHART(HorizontalStackedBarChart)
@@ -30,14 +30,11 public:
30 30 QString category() { return QObject::tr("BarSeries"); }
31 31 QString subCategory() { return QObject::tr("Vertical"); }
32 32
33 QChart* createChart(const DataTable& table)
33 QChart *createChart(const DataTable &table)
34 34 {
35
36 QChart* chart = new QChart();
37
35 QChart *chart = new QChart();
38 36 chart->setTitle("Vertical bar chart");
39
40 QBarSeries* series = new QBarSeries(chart);
37 QBarSeries *series = new QBarSeries(chart);
41 38 for (int i(0); i < table.count(); i++) {
42 39 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 40 foreach (Data data, table[i])
@@ -48,7 +45,6 public:
48 45 chart->createDefaultAxes();
49 46 return chart;
50 47 }
51
52 48 };
53 49
54 50 DECLARE_CHART(VerticalBarChart)
@@ -30,14 +30,11 public:
30 30 QString category() { return QObject::tr("BarSeries"); }
31 31 QString subCategory() { return QObject::tr("Vertical"); }
32 32
33 QChart* createChart(const DataTable& table)
33 QChart *createChart(const DataTable &table)
34 34 {
35
36 QChart* chart = new QChart();
37
35 QChart *chart = new QChart();
38 36 chart->setTitle("Stacked bar chart");
39
40 QPercentBarSeries* series = new QPercentBarSeries(chart);
37 QPercentBarSeries *series = new QPercentBarSeries(chart);
41 38 for (int i(0); i < table.count(); i++) {
42 39 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 40 foreach (Data data, table[i])
@@ -48,7 +45,6 public:
48 45 chart->createDefaultAxes();
49 46 return chart;
50 47 }
51
52 48 };
53 49
54 50 DECLARE_CHART(VerticalPercentBarChart)
@@ -30,14 +30,11 public:
30 30 QString category() { return QObject::tr("BarSeries"); }
31 31 QString subCategory() { return QObject::tr("Vertical"); }
32 32
33 QChart* createChart(const DataTable& table)
33 QChart *createChart(const DataTable &table)
34 34 {
35
36 QChart* chart = new QChart();
37
35 QChart *chart = new QChart();
38 36 chart->setTitle("Stacked bar chart");
39
40 QStackedBarSeries* series = new QStackedBarSeries(chart);
37 QStackedBarSeries *series = new QStackedBarSeries(chart);
41 38 for (int i(0); i < table.count(); i++) {
42 39 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
43 40 foreach (Data data, table[i])
@@ -48,7 +45,6 public:
48 45 chart->createDefaultAxes();
49 46 return chart;
50 47 }
51
52 48 };
53 49
54 50 DECLARE_CHART(VerticalStackedBarChart)
@@ -25,86 +25,90
25 25 class FontChart: public Chart
26 26 {
27 27 public:
28 FontChart(int fontSize):m_fontSize(fontSize){};
28 FontChart(int fontSize): m_fontSize(fontSize) {};
29 29 QString name() { return QObject::tr("Font") + " " + QString::number(m_fontSize); }
30 30 QString category() { return QObject::tr("Font"); }
31 31 QString subCategory() { return QString::null; }
32 32
33 QChart* createChart(const DataTable& table) {
34
35 QChart* chart = new QChart();
36 chart->setTitle("Font size " + QString::number(m_fontSize));
37
38 QString name("Series ");
39 int nameIndex = 0;
40 foreach (DataList list, table) {
41 QLineSeries *series = new QLineSeries(chart);
42 foreach (Data data, list)
43 series->append(data.first);
44 series->setName(name + QString::number(nameIndex));
45 nameIndex++;
46 chart->addSeries(series);
47 }
48
49 chart->createDefaultAxes();
50 QFont font;
51 font.setPixelSize(m_fontSize);
52 chart->setTitleFont(font);
53 chart->axisX()->setLabelsFont(font);
54 chart->axisY()->setLabelsFont(font);
55
56 return chart;
33 QChart *createChart(const DataTable &table)
34 {
35 QChart *chart = new QChart();
36 chart->setTitle("Font size " + QString::number(m_fontSize));
37 QString name("Series ");
38 int nameIndex = 0;
39 foreach (DataList list, table) {
40 QLineSeries *series = new QLineSeries(chart);
41 foreach (Data data, list)
42 series->append(data.first);
43 series->setName(name + QString::number(nameIndex));
44 nameIndex++;
45 chart->addSeries(series);
46 }
47 chart->createDefaultAxes();
48 QFont font;
49 font.setPixelSize(m_fontSize);
50 chart->setTitleFont(font);
51 chart->axisX()->setLabelsFont(font);
52 chart->axisY()->setLabelsFont(font);
53 return chart;
57 54 }
58 55
59 56 private:
60 57 int m_fontSize;
61
62 58 };
63 59
64 class FontChart6:public FontChart{
60 class FontChart6: public FontChart
61 {
65 62 public:
66 FontChart6():FontChart(6){};
63 FontChart6(): FontChart(6) {};
67 64 };
68 65
69 class FontChart8:public FontChart{
66 class FontChart8: public FontChart
67 {
70 68 public:
71 FontChart8():FontChart(8){};
69 FontChart8(): FontChart(8) {};
72 70 };
73 71
74 class FontChart10:public FontChart{
72 class FontChart10: public FontChart
73 {
75 74 public:
76 FontChart10():FontChart(10){};
75 FontChart10(): FontChart(10) {};
77 76 };
78 77
79 class FontChart14:public FontChart{
78 class FontChart14: public FontChart
79 {
80 80 public:
81 FontChart14():FontChart(14){};
81 FontChart14(): FontChart(14) {};
82 82 };
83 83
84
85 class FontChart18:public FontChart{
84 class FontChart18: public FontChart
85 {
86 86 public:
87 FontChart18():FontChart(18){};
87 FontChart18(): FontChart(18) {};
88 88 };
89 89
90 class FontChart20:public FontChart{
90 class FontChart20: public FontChart
91 {
91 92 public:
92 FontChart20():FontChart(20){};
93 FontChart20(): FontChart(20) {};
93 94 };
94 95
95 class FontChart24:public FontChart{
96 class FontChart24: public FontChart
97 {
96 98 public:
97 FontChart24():FontChart(24){};
99 FontChart24(): FontChart(24) {};
98 100 };
99 101
100 class FontChart28:public FontChart{
102 class FontChart28: public FontChart
103 {
101 104 public:
102 FontChart28():FontChart(28){};
105 FontChart28(): FontChart(28) {};
103 106 };
104 107
105 class FontChart32:public FontChart{
108 class FontChart32: public FontChart
109 {
106 110 public:
107 FontChart32():FontChart(32){};
111 FontChart32(): FontChart(32) {};
108 112 };
109 113
110 114 DECLARE_CHART(FontChart6);
@@ -29,28 +29,26 public:
29 29 QString category() { return QObject::tr("PieSeries"); }
30 30 QString subCategory() { return QString::null; }
31 31
32 QChart* createChart(const DataTable& table)
33 {
34 QChart* chart = new QChart();
32 QChart *createChart(const DataTable &table)
33 {
34 QChart *chart = new QChart();
35 35 chart->setTitle("Donut chart");
36
37 for (int i = 0, j = table.count(); i < table.count(); i++,j--) {
36 for (int i = 0, j = table.count(); i < table.count(); i++, j--) {
38 37 QPieSeries *series = new QPieSeries(chart);
39 38 foreach (Data data, table[i]) {
40 39 QPieSlice *slice = series->append(data.second, data.first.y());
41 if (data == table[i].first()) {
40 if (data == table[i].first())
42 41 slice->setLabelVisible();
43 }
44 42 }
45 series->setPieSize( j / (qreal) table.count());
46 if(j>1) series->setHoleSize( (j-1)/ (qreal) table.count()+0.1);
43 series->setPieSize(j / (qreal) table.count());
44 if (j > 1)
45 series->setHoleSize((j - 1) / (qreal) table.count() + 0.1);
47 46 series->setHorizontalPosition(0.5);
48 47 series->setVerticalPosition(0.5);
49 48 chart->addSeries(series);
50 49 }
51 50 return chart;
52 51 }
53
54 52 };
55 53
56 54 DECLARE_CHART(DonutChart)
@@ -29,11 +29,10 public:
29 29 QString category() { return QObject::tr("PieSeries"); }
30 30 QString subCategory() { return QString::null; }
31 31
32 QChart* createChart(const DataTable& table)
32 QChart *createChart(const DataTable &table)
33 33 {
34 QChart* chart = new QChart();
34 QChart *chart = new QChart();
35 35 chart->setTitle("Pie chart");
36
37 36 qreal pieSize = 1.0 / table.count();
38 37 for (int i = 0; i < table.count(); i++) {
39 38 QPieSeries *series = new QPieSeries(chart);
@@ -52,7 +51,6 public:
52 51 }
53 52 return chart;
54 53 }
55
56 54 };
57 55
58 56 DECLARE_CHART(PieChart)
@@ -30,9 +30,8 public:
30 30 QString category() { return QObject::tr("XYSeries"); }
31 31 QString subCategory() { return QString::null; }
32 32
33 QChart* createChart(const DataTable& table)
33 QChart *createChart(const DataTable &table)
34 34 {
35
36 35 QChart *chart = new QChart();
37 36 chart->setTitle("Area chart");
38 37
@@ -47,9 +46,9 public:
47 46 if (lowerSeries) {
48 47 const QList<QPointF>& points = lowerSeries->points();
49 48 upperSeries->append(QPointF(j, points[i].y() + data.first.y()));
50 }
51 else
49 } else {
52 50 upperSeries->append(QPointF(j, data.first.y()));
51 }
53 52 }
54 53 QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries);
55 54 area->setName(name + QString::number(nameIndex));
@@ -58,11 +57,8 public:
58 57 chart->createDefaultAxes();
59 58 lowerSeries = upperSeries;
60 59 }
61
62 60 return chart;
63
64 61 }
65
66 62 };
67 63
68 64 DECLARE_CHART(AreaChart)
@@ -29,27 +29,23 public:
29 29 QString category() { return QObject::tr("XYSeries"); }
30 30 QString subCategory() { return QString::null; }
31 31
32 QChart* createChart(const DataTable& table) {
33
34 QChart* chart = new QChart();
35 chart->setTitle("Line chart");
36
37 QString name("Series ");
38 int nameIndex = 0;
39 foreach (DataList list, table) {
40 QLineSeries *series = new QLineSeries(chart);
41 foreach (Data data, list)
42 series->append(data.first);
43 series->setName(name + QString::number(nameIndex));
44 nameIndex++;
45 chart->addSeries(series);
46 }
47
48 chart->createDefaultAxes();
49
50 return chart;
32 QChart *createChart(const DataTable &table)
33 {
34 QChart *chart = new QChart();
35 chart->setTitle("Line chart");
36 QString name("Series ");
37 int nameIndex = 0;
38 foreach (DataList list, table) {
39 QLineSeries *series = new QLineSeries(chart);
40 foreach (Data data, list)
41 series->append(data.first);
42 series->setName(name + QString::number(nameIndex));
43 nameIndex++;
44 chart->addSeries(series);
45 }
46 chart->createDefaultAxes();
47 return chart;
51 48 }
52
53 49 };
54 50
55 51 DECLARE_CHART(LineChart)
@@ -29,10 +29,9 public:
29 29 QString category() { return QObject::tr("XYSeries"); }
30 30 QString subCategory() { return QString::null; }
31 31
32 QChart* createChart(const DataTable& table)
32 QChart *createChart(const DataTable &table)
33 33 {
34
35 QChart* chart = new QChart();
34 QChart *chart = new QChart();
36 35 chart->setTitle("Scatter chart");
37 36 QString name("Series ");
38 37 int nameIndex = 0;
@@ -45,10 +44,8 public:
45 44 chart->addSeries(series);
46 45 }
47 46 chart->createDefaultAxes();
48
49 47 return chart;
50 48 }
51
52 49 };
53 50
54 51 DECLARE_CHART(ScatterChart)
@@ -29,11 +29,9 public:
29 29 QString category() { return QObject::tr("XYSeries"); }
30 30 QString subCategory() { return QString::null; }
31 31
32 QChart* createChart(const DataTable& table)
32 QChart *createChart(const DataTable &table)
33 33 {
34
35 QChart* chart = new QChart();
36
34 QChart *chart = new QChart();
37 35 chart->setTitle("Spline chart");
38 36 QString name("Series ");
39 37 int nameIndex = 0;
@@ -48,7 +46,6 public:
48 46 chart->createDefaultAxes();
49 47 return chart;
50 48 }
51
52 49 };
53 50
54 51 DECLARE_CHART(SplineChart)
@@ -35,7 +35,7 typedef QList<DataList> DataTable;
35 35 class Model
36 36 {
37 37 private:
38 Model(){}
38 Model() {}
39 39
40 40 public:
41 41 static DataTable generateRandomData(int listCount, int valueMax, int valueCount)
@@ -50,19 +50,17 public:
50 50 DataList dataList;
51 51 qreal yValue(0);
52 52 for (int j(0); j < valueCount; j++) {
53 yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount;
53 yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount;
54 54 QPointF value(
55 55 (j + (qreal) qrand() / (qreal) RAND_MAX)
56 * ((qreal) valueMax / (qreal) valueCount), yValue);
56 * ((qreal) valueMax / (qreal) valueCount), yValue);
57 57 QString label = "Slice " + QString::number(i) + ":" + QString::number(j);
58 58 dataList << Data(value, label);
59 59 }
60 60 dataTable << dataList;
61 61 }
62
63 62 return dataTable;
64 63 }
65
66 64 };
67 65
68 66 #endif
@@ -23,8 +23,9
23 23 #include <QResizeEvent>
24 24 #include <QDebug>
25 25
26 View::View(QGraphicsScene *scene, QGraphicsWidget *form , QWidget *parent):QGraphicsView(scene,parent),
27 m_form(form)
26 View::View(QGraphicsScene *scene, QGraphicsWidget *form , QWidget *parent)
27 : QGraphicsView(scene, parent),
28 m_form(form)
28 29 {
29 30 setDragMode(QGraphicsView::NoDrag);
30 31 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -49,8 +50,7 void View::mouseMoveEvent(QMouseEvent *event)
49 50
50 51 void View::mouseReleaseEvent(QMouseEvent *event)
51 52 {
52
53 53 QGraphicsView::mouseReleaseEvent(event);
54 //BugFix somehow view always eats the mouse release event;
54 //BugFix somehow view always eats the mouse release event;
55 55 event->setAccepted(false);
56 56 }
@@ -40,7 +40,7
40 40 #include <QDebug>
41 41 #include <QMenu>
42 42
43 Window::Window(QWidget* parent) :
43 Window::Window(QWidget *parent) :
44 44 QMainWindow(parent),
45 45 m_listCount(3),
46 46 m_valueMax(10),
@@ -88,12 +88,12 Window::Window(QWidget* parent) :
88 88 Charts::ChartList list = Charts::chartList();
89 89
90 90 for (int i = 0; i < 9; ++i) {
91 QChart* chart = 0;
92 if(i<list.size()){
93 chart = list.at(i)->createChart(m_dataTable);
94 }else{
95 chart = new QChart();
96 chart->setTitle(tr("Empty"));
91 QChart *chart = 0;
92 if (i < list.size()) {
93 chart = list.at(i)->createChart(m_dataTable);
94 } else {
95 chart = new QChart();
96 chart->setTitle(tr("Empty"));
97 97 }
98 98
99 99 m_baseLayout->addItem(chart, i / 3, i % 3);
@@ -123,7 +123,7 Window::~Window()
123 123
124 124 void Window::connectSignals()
125 125 {
126 QObject::connect(m_form, SIGNAL(geometryChanged()),this ,SLOT(handleGeometryChanged()));
126 QObject::connect(m_form, SIGNAL(geometryChanged()), this , SLOT(handleGeometryChanged()));
127 127 QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
128 128 QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
129 129 QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
@@ -143,7 +143,7 void Window::createProxyWidgets()
143 143 m_openGLCheckBox = new QCheckBox(tr("OpenGL"));
144 144 m_zoomCheckBox = new QCheckBox(tr("Zoom"));
145 145 m_scrollCheckBox = new QCheckBox(tr("Scroll"));
146 m_templateComboBox= createTempleteBox();
146 m_templateComboBox = createTempleteBox();
147 147 m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox);
148 148 m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox);
149 149 m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox);
@@ -159,9 +159,9 void Window::createProxyWidgets()
159 159
160 160 }
161 161
162 QComboBox* Window::createThemeBox()
162 QComboBox *Window::createThemeBox()
163 163 {
164 QComboBox* themeComboBox = new ComboBox(this);
164 QComboBox *themeComboBox = new ComboBox(this);
165 165 themeComboBox->addItem("Light", QChart::ChartThemeLight);
166 166 themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
167 167 themeComboBox->addItem("Dark", QChart::ChartThemeDark);
@@ -172,9 +172,9 QComboBox* Window::createThemeBox()
172 172 return themeComboBox;
173 173 }
174 174
175 QComboBox* Window::createAnimationBox()
175 QComboBox *Window::createAnimationBox()
176 176 {
177 QComboBox* animationComboBox = new ComboBox(this);
177 QComboBox *animationComboBox = new ComboBox(this);
178 178 animationComboBox->addItem("No Animations", QChart::NoAnimation);
179 179 animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
180 180 animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
@@ -182,9 +182,9 QComboBox* Window::createAnimationBox()
182 182 return animationComboBox;
183 183 }
184 184
185 QComboBox* Window::createLegendBox()
185 QComboBox *Window::createLegendBox()
186 186 {
187 QComboBox* legendComboBox = new ComboBox(this);
187 QComboBox *legendComboBox = new ComboBox(this);
188 188 legendComboBox->addItem("No Legend ", 0);
189 189 legendComboBox->addItem("Legend Top", Qt::AlignTop);
190 190 legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
@@ -193,20 +193,20 QComboBox* Window::createLegendBox()
193 193 return legendComboBox;
194 194 }
195 195
196 QComboBox* Window::createTempleteBox()
196 QComboBox *Window::createTempleteBox()
197 197 {
198 QComboBox* templateComboBox = new ComboBox(this);
198 QComboBox *templateComboBox = new ComboBox(this);
199 199 templateComboBox->addItem("No Template", 0);
200 200
201 201 Charts::ChartList list = Charts::chartList();
202 QMultiMap<QString, Chart*> categoryMap;
202 QMultiMap<QString, Chart *> categoryMap;
203 203
204 foreach(Chart* chart, list) {
205 categoryMap.insertMulti(chart->category(), chart);
206 }
207 foreach(const QString& category, categoryMap.uniqueKeys()) {
204 foreach (Chart *chart, list)
205 categoryMap.insertMulti(chart->category(), chart);
206
207 foreach (const QString &category, categoryMap.uniqueKeys())
208 208 templateComboBox->addItem(category, category);
209 }
209
210 210 return templateComboBox;
211 211 }
212 212
@@ -226,11 +226,9 void Window::checkLegend()
226 226 Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt());
227 227
228 228 if (!alignment) {
229 foreach (QChart *chart, m_chartHash.keys()) {
229 foreach (QChart *chart, m_chartHash.keys())
230 230 chart->legend()->hide();
231 }
232 }
233 else {
231 } else {
234 232 foreach (QChart *chart, m_chartHash.keys()) {
235 233 chart->legend()->setAlignment(alignment);
236 234 chart->legend()->show();
@@ -241,7 +239,7 void Window::checkLegend()
241 239 void Window::checkOpenGL()
242 240 {
243 241 bool opengl = m_openGLCheckBox->isChecked();
244 bool isOpengl = qobject_cast<QGLWidget*>(m_view->viewport());
242 bool isOpengl = qobject_cast<QGLWidget *>(m_view->viewport());
245 243 if ((isOpengl && !opengl) || (!isOpengl && opengl)) {
246 244 m_view->deleteLater();
247 245 m_view = new View(m_scene, m_form);
@@ -251,20 +249,21 void Window::checkOpenGL()
251 249
252 250 bool antialias = m_antialiasCheckBox->isChecked();
253 251
254 if (opengl)
255 m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias);
256 else
257 m_view->setRenderHint(QPainter::Antialiasing, antialias);
252 if (opengl)
253 m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias);
254 else
255 m_view->setRenderHint(QPainter::Antialiasing, antialias);
258 256 }
259 257
260 258 void Window::checkAnimationOptions()
261 259 {
262 260 QChart::AnimationOptions options(
263 m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
264 if (!m_chartHash.isEmpty() && m_chartHash.keys().at(0)->animationOptions() != options) {
265 foreach (QChart *chart, m_chartHash.keys())
266 chart->setAnimationOptions(options);
267 }
261 m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
262
263 if (!m_chartHash.isEmpty() && m_chartHash.keys().at(0)->animationOptions() != options) {
264 foreach (QChart *chart, m_chartHash.keys())
265 chart->setAnimationOptions(options);
266 }
268 267 }
269 268
270 269 void Window::checkState()
@@ -274,8 +273,7 void Window::checkState()
274 273 if (m_state != ScrollState && scroll) {
275 274 m_state = ScrollState;
276 275 m_zoomCheckBox->setChecked(false);
277 }
278 else if (!scroll && m_state == ScrollState) {
276 } else if (!scroll && m_state == ScrollState) {
279 277 m_state = NoState;
280 278 }
281 279
@@ -284,8 +282,7 void Window::checkState()
284 282 if (m_state != ZoomState && zoom) {
285 283 m_state = ZoomState;
286 284 m_scrollCheckBox->setChecked(false);
287 }
288 else if (!zoom && m_state == ZoomState) {
285 } else if (!zoom && m_state == ZoomState) {
289 286 m_state = NoState;
290 287 }
291 288 }
@@ -302,26 +299,25 void Window::checkTemplate()
302 299 QString category = m_templateComboBox->itemData(index).toString();
303 300 Charts::ChartList list = Charts::chartList();
304 301
305 QList<QChart*> qchartList = m_chartHash.keys();
302 QList<QChart *> qchartList = m_chartHash.keys();
306 303
307 foreach(QChart* qchart,qchartList){
308 for(int i = 0 ; i < m_baseLayout->count();++i)
309 {
310 if(m_baseLayout->itemAt(i)==qchart){
311 m_baseLayout->removeAt(i);
312 break;
313 }
314 }
304 foreach (QChart *qchart, qchartList) {
305 for (int i = 0 ; i < m_baseLayout->count(); ++i) {
306 if (m_baseLayout->itemAt(i) == qchart) {
307 m_baseLayout->removeAt(i);
308 break;
309 }
310 }
315 311 }
316 312
317 313 m_chartHash.clear();
318 314 qDeleteAll(qchartList);
319 315
320 QChart* qchart(0);
316 QChart *qchart(0);
321 317
322 int j=0;
318 int j = 0;
323 319 for (int i = 0; i < list.size(); ++i) {
324 Chart* chart = list.at(i);
320 Chart *chart = list.at(i);
325 321 if (chart->category() == category && j < 9) {
326 322 qchart = list.at(i)->createChart(m_dataTable);
327 323 m_baseLayout->addItem(qchart, j / 3, j % 3);
@@ -341,7 +337,7 void Window::checkTemplate()
341 337 void Window::checkTheme()
342 338 {
343 339 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(
344 m_themeComboBox->currentIndex()).toInt();
340 m_themeComboBox->currentIndex()).toInt();
345 341
346 342 foreach (QChart *chart, m_chartHash.keys())
347 343 chart->setTheme(theme);
@@ -350,38 +346,30 void Window::checkTheme()
350 346 if (theme == QChart::ChartThemeLight) {
351 347 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
352 348 pal.setColor(QPalette::WindowText, QRgb(0x404044));
353 }
354 else if (theme == QChart::ChartThemeDark) {
349 } else if (theme == QChart::ChartThemeDark) {
355 350 pal.setColor(QPalette::Window, QRgb(0x121218));
356 351 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
357 }
358 else if (theme == QChart::ChartThemeBlueCerulean) {
352 } else if (theme == QChart::ChartThemeBlueCerulean) {
359 353 pal.setColor(QPalette::Window, QRgb(0x40434a));
360 354 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
361 }
362 else if (theme == QChart::ChartThemeBrownSand) {
355 } else if (theme == QChart::ChartThemeBrownSand) {
363 356 pal.setColor(QPalette::Window, QRgb(0x9e8965));
364 357 pal.setColor(QPalette::WindowText, QRgb(0x404044));
365 }
366 else if (theme == QChart::ChartThemeBlueNcs) {
358 } else if (theme == QChart::ChartThemeBlueNcs) {
367 359 pal.setColor(QPalette::Window, QRgb(0x018bba));
368 360 pal.setColor(QPalette::WindowText, QRgb(0x404044));
369 }
370 else if (theme == QChart::ChartThemeHighContrast) {
361 } else if (theme == QChart::ChartThemeHighContrast) {
371 362 pal.setColor(QPalette::Window, QRgb(0xffab03));
372 363 pal.setColor(QPalette::WindowText, QRgb(0x181818));
373 }
374 else if (theme == QChart::ChartThemeBlueIcy) {
364 } else if (theme == QChart::ChartThemeBlueIcy) {
375 365 pal.setColor(QPalette::Window, QRgb(0xcee7f0));
376 366 pal.setColor(QPalette::WindowText, QRgb(0x404044));
377 }
378 else {
367 } else {
379 368 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
380 369 pal.setColor(QPalette::WindowText, QRgb(0x404044));
381 370 }
382 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
371 foreach (QGraphicsProxyWidget *widget, m_widgetHash)
383 372 widget->setPalette(pal);
384 }
385 373 m_view->setBackgroundBrush(pal.color((QPalette::Window)));
386 374 m_rubberBand->setPen(pal.color((QPalette::WindowText)));
387 375 }
@@ -400,10 +388,8 void Window::mousePressEvent(QMouseEvent *event)
400 388 plotArea.translate(geometryRect.topLeft());
401 389 if (plotArea.contains(m_origin)) {
402 390 m_currentState = m_state;
403
404 if (m_currentState == NoState && m_templateComboBox->currentIndex()==0) {
391 if (m_currentState == NoState && m_templateComboBox->currentIndex() == 0)
405 392 handleMenu(chart);
406 }
407 393 break;
408 394 }
409 395 }
@@ -424,7 +410,7 void Window::mousePressEvent(QMouseEvent *event)
424 410
425 411 void Window::mouseMoveEvent(QMouseEvent *event)
426 412 {
427 if ( m_currentState != NoState) {
413 if (m_currentState != NoState) {
428 414
429 415 foreach (QChart *chart, m_chartHash.keys()) {
430 416
@@ -437,13 +423,13 void Window::mouseMoveEvent(QMouseEvent *event)
437 423 QPointF delta = m_origin - event->pos();
438 424 chart->scroll(delta.x(), -delta.y());
439 425 }
440 if (m_currentState == ZoomState && plotArea.contains(event->pos())) {
426 if (m_currentState == ZoomState && plotArea.contains(event->pos()))
441 427 m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized());
442 }
443 428 break;
444 429 }
445 430 }
446 if(m_currentState == ScrollState) m_origin = event->pos();
431 if (m_currentState == ScrollState)
432 m_origin = event->pos();
447 433 event->accept();
448 434 }
449 435 }
@@ -493,32 +479,31 void Window::mouseReleaseEvent(QMouseEvent *event)
493 479
494 480 void Window::comboBoxFocused(QComboBox *combobox)
495 481 {
496 foreach(QGraphicsProxyWidget* widget , m_widgetHash) {
497 if(widget->widget()==combobox)
498 widget->setZValue(2.0);
499 else
500 widget->setZValue(0.0);
482 foreach (QGraphicsProxyWidget *widget , m_widgetHash) {
483 if (widget->widget() == combobox)
484 widget->setZValue(2.0);
485 else
486 widget->setZValue(0.0);
501 487 }
502 488 }
503 489
504 void Window::handleMenu(QChart* qchart)
490 void Window::handleMenu(QChart *qchart)
505 491 {
506 492 QAction *chosen = m_menu->exec(QCursor::pos());
507 493
508 494 if (chosen) {
509 Chart* chart = (Chart *) chosen->data().value<void *>();
495 Chart *chart = (Chart *) chosen->data().value<void *>();
510 496 int index = m_chartHash[qchart];
511 497 //not in 4.7.2 m_baseLayout->removeItem(qchart);
512 for(int i = 0 ; i < m_baseLayout->count();++i)
513 {
514 if(m_baseLayout->itemAt(i)==qchart){
498 for (int i = 0 ; i < m_baseLayout->count(); ++i) {
499 if (m_baseLayout->itemAt(i) == qchart) {
515 500 m_baseLayout->removeAt(i);
516 501 break;
517 502 }
518 503 }
519 504
520 505 m_chartHash.remove(qchart);
521 QChart* newChart = chart->createChart(m_dataTable);
506 QChart *newChart = chart->createChart(m_dataTable);
522 507 m_baseLayout->addItem(newChart, index / 3, index % 3);
523 508 m_chartHash[newChart] = index;
524 509 delete qchart;
@@ -527,46 +512,41 void Window::handleMenu(QChart* qchart)
527 512
528 513 }
529 514
530 QMenu* Window::createMenu()
515 QMenu *Window::createMenu()
531 516 {
532 517 Charts::ChartList list = Charts::chartList();
533 QMultiMap<QString, Chart*> categoryMap;
518 QMultiMap<QString, Chart *> categoryMap;
534 519
535 QMenu* result = new QMenu(this);
520 QMenu *result = new QMenu(this);
536 521
537 foreach(Chart* chart, list) {
522 foreach (Chart *chart, list)
538 523 categoryMap.insertMulti(chart->category(), chart);
539 }
540 524
541 foreach(const QString& category, categoryMap.uniqueKeys()) {
542 QMenu* menu(0);
543 QMultiMap<QString, Chart*> subCategoryMap;
525 foreach (const QString &category, categoryMap.uniqueKeys()) {
526 QMenu *menu(0);
527 QMultiMap<QString, Chart *> subCategoryMap;
544 528 if (category.isEmpty()) {
545 529 menu = result;
546 }
547 else {
530 } else {
548 531 menu = new QMenu(category, this);
549 532 result->addMenu(menu);
550 533 }
551 534
552 foreach(Chart* chart , categoryMap.values(category)) {
535 foreach (Chart *chart, categoryMap.values(category))
553 536 subCategoryMap.insert(chart->subCategory(), chart);
554 }
555 537
556 foreach(const QString& subCategory, subCategoryMap.uniqueKeys()) {
557 QMenu* subMenu(0);
538 foreach (const QString &subCategory, subCategoryMap.uniqueKeys()) {
539 QMenu *subMenu(0);
558 540 if (subCategory.isEmpty()) {
559 541 subMenu = menu;
560 }
561 else {
542 } else {
562 543 subMenu = new QMenu(subCategory, this);
563 544 menu->addMenu(subMenu);
564 545 }
565 546
566 foreach(Chart* chart , subCategoryMap.values(subCategory)) {
567
547 foreach(Chart *chart, subCategoryMap.values(subCategory)) {
568 548 createMenuAction(subMenu, QIcon(), chart->name(),
569 qVariantFromValue((void *) chart));
549 qVariantFromValue((void *) chart));
570 550 }
571 551 }
572 552 }
@@ -574,8 +554,8 QMenu* Window::createMenu()
574 554 return result;
575 555 }
576 556
577 QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text,
578 const QVariant &data)
557 QAction *Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text,
558 const QVariant &data)
579 559 {
580 560 QAction *action = menu->addAction(icon, text);
581 561 action->setCheckable(false);
@@ -585,7 +565,7 QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString
585 565
586 566 void Window::handleGeometryChanged()
587 567 {
588 QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize);
589 m_view->scene()->setSceneRect(0, 0, this->width(), this->height());
590 m_view->setMinimumSize(size.toSize());
568 QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize);
569 m_view->scene()->setSceneRect(0, 0, this->width(), this->height());
570 m_view->setMinimumSize(size.toSize());
591 571 }
@@ -44,7 +44,7 QTCOMMERCIALCHART_USE_NAMESPACE
44 44 class Window: public QMainWindow
45 45 {
46 46 Q_OBJECT
47 enum State{ NoState = 0, ZoomState, ScrollState};
47 enum State { NoState = 0, ZoomState, ScrollState};
48 48 public:
49 49 explicit Window(QWidget *parent = 0);
50 50 ~Window();
@@ -53,10 +53,10 private Q_SLOTS:
53 53 void updateUI();
54 54 void handleGeometryChanged();
55 55 private:
56 QComboBox* createThemeBox();
57 QComboBox* createAnimationBox();
58 QComboBox* createLegendBox();
59 QComboBox* createTempleteBox();
56 QComboBox *createThemeBox();
57 QComboBox *createAnimationBox();
58 QComboBox *createLegendBox();
59 QComboBox *createTempleteBox();
60 60 void connectSignals();
61 61 void createProxyWidgets();
62 62 void comboBoxFocused(QComboBox *combox);
@@ -66,9 +66,9 private:
66 66 inline void checkTheme();
67 67 inline void checkState();
68 68 inline void checkTemplate();
69 QMenu* createMenu();
70 void handleMenu(QChart * chart);
71 QAction* createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data);
69 QMenu *createMenu();
70 void handleMenu(QChart *chart);
71 QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data);
72 72
73 73 protected:
74 74 void mousePressEvent(QMouseEvent *event);
@@ -79,10 +79,10 private:
79 79 int m_listCount;
80 80 int m_valueMax;
81 81 int m_valueCount;
82 QGraphicsScene* m_scene;
83 View* m_view;
84 QHash<QString, QGraphicsProxyWidget*> m_widgetHash;
85 QHash<QChart*, int> m_chartHash;
82 QGraphicsScene *m_scene;
83 View *m_view;
84 QHash<QString, QGraphicsProxyWidget *> m_widgetHash;
85 QHash<QChart *, int> m_chartHash;
86 86 DataTable m_dataTable;
87 87
88 88 QGraphicsWidget *m_form;
@@ -95,9 +95,9 private:
95 95 QCheckBox *m_zoomCheckBox;
96 96 QCheckBox *m_scrollCheckBox;
97 97 QPoint m_origin;
98 QGraphicsRectItem* m_rubberBand;
99 QGraphicsGridLayout* m_baseLayout;
100 QMenu* m_menu;
98 QGraphicsRectItem *m_rubberBand;
99 QGraphicsGridLayout *m_baseLayout;
100 QMenu *m_menu;
101 101 State m_state;
102 102 State m_currentState;
103 103 int m_template;
@@ -108,17 +108,16 private:
108 108 class ComboBox: public QComboBox
109 109 {
110 110 public:
111 ComboBox(Window* window,QWidget *parent = 0):QComboBox(parent),m_window(window)
111 ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window)
112 112 {}
113 113
114 114 protected:
115 void focusInEvent(QFocusEvent *e)
116 {
115 void focusInEvent(QFocusEvent *e) {
117 116 QComboBox::focusInEvent(e);
118 117 m_window->comboBoxFocused(this);
119 118 }
120 119 private:
121 Window* m_window;
120 Window *m_window;
122 121 };
123 122
124 123 #endif
@@ -46,7 +46,7 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags):
46 46
47 47 addSeries(m_series);
48 48 createDefaultAxes();
49 setAxisX(m_axis,m_series);
49 setAxisX(m_axis, m_series);
50 50 m_axis->setTickCount(5);
51 51 axisX()->setRange(0, 10);
52 52 axisY()->setRange(-5, 10);
@@ -61,11 +61,12 Chart::~Chart()
61 61
62 62 void Chart::handleTimeout()
63 63 {
64 qreal x = plotArea().width()/m_axis->tickCount();
65 qreal y =(m_axis->max() - m_axis->min())/m_axis->tickCount();
64 qreal x = plotArea().width() / m_axis->tickCount();
65 qreal y = (m_axis->max() - m_axis->min()) / m_axis->tickCount();
66 66 m_x += y;
67 67 m_y = qrand() % 5 - 2.5;
68 68 m_series->append(m_x, m_y);
69 scroll(x,0);
70 if(m_x==100) m_timer.stop();
69 scroll(x, 0);
70 if (m_x == 100)
71 m_timer.stop();
71 72 }
@@ -44,9 +44,9 public slots:
44 44
45 45 private:
46 46 QTimer m_timer;
47 QSplineSeries* m_series;
47 QSplineSeries *m_series;
48 48 QStringList m_titles;
49 QValueAxis* m_axis;
49 QValueAxis *m_axis;
50 50 qreal m_step;
51 51 qreal m_x;
52 52 qreal m_y;
@@ -25,6 +25,5 int main(int argc, char *argv[])
25 25 QApplication a(argc, argv);
26 26 Widget w;
27 27 w.show();
28
29 28 return a.exec();
30 29 }
@@ -31,14 +31,14 QTCOMMERCIALCHART_USE_NAMESPACE
31 31
32 32 Widget::Widget(QWidget *parent)
33 33 : QWidget(parent)
34 {
34 {
35 35 setMinimumSize(800, 600);
36 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
36 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
37 37
38 38 //! [1]
39 39 QChartView *chartView = new QChartView;
40 40 chartView->setRenderHint(QPainter::Antialiasing);
41 QChart *chart = chartView->chart();
41 QChart *chart = chartView->chart();
42 42 chart->legend()->setVisible(false);
43 43 chart->setTitle("Nested donuts demo");
44 44 chart->setAnimationOptions(QChart::AllAnimations);
@@ -72,7 +72,7 Widget::Widget(QWidget *parent)
72 72
73 73 // create main layout
74 74 //! [4]
75 QGridLayout* mainLayout = new QGridLayout;
75 QGridLayout *mainLayout = new QGridLayout;
76 76 mainLayout->addWidget(chartView, 1, 1);
77 77 setLayout(mainLayout);
78 78 //! [4]
@@ -86,10 +86,10 Widget::Widget(QWidget *parent)
86 86
87 87 Widget::~Widget()
88 88 {
89
89
90 90 }
91 91
92 //! [6]
92 //! [6]
93 93 void Widget::updateRotation()
94 94 {
95 95 for (int i = 0; i < m_donuts.count(); i++) {
@@ -99,9 +99,9 void Widget::updateRotation()
99 99 donut->setPieEndAngle(donut->pieEndAngle() + phaseShift);
100 100 }
101 101 }
102 //! [6]
102 //! [6]
103 103
104 //! [7]
104 //! [7]
105 105 void Widget::explodeSlice(bool exploded)
106 106 {
107 107 QPieSlice *slice = qobject_cast<QPieSlice *>(sender());
@@ -125,4 +125,4 void Widget::explodeSlice(bool exploded)
125 125 }
126 126 slice->setExploded(exploded);
127 127 }
128 //! [7]
128 //! [7]
@@ -30,7 +30,7 QTCOMMERCIALCHART_USE_NAMESPACE
30 30 class Widget : public QWidget
31 31 {
32 32 Q_OBJECT
33
33
34 34 public:
35 35 Widget(QWidget *parent = 0);
36 36 ~Widget();
@@ -24,7 +24,7
24 24 #include <QColorDialog>
25 25
26 26 BrushTool::BrushTool(QString title, QWidget *parent)
27 :QWidget(parent)
27 : QWidget(parent)
28 28 {
29 29 setWindowTitle(title);
30 30 setWindowFlags(Qt::Tool);
@@ -23,7 +23,7
23 23 QTCOMMERCIALCHART_USE_NAMESPACE
24 24
25 25 CustomSlice::CustomSlice(QString label, qreal value)
26 :QPieSlice(label, value)
26 : QPieSlice(label, value)
27 27 {
28 28 connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool)));
29 29 }
@@ -34,8 +34,8
34 34
35 35 QTCOMMERCIALCHART_USE_NAMESPACE
36 36
37 MainWidget::MainWidget(QWidget* parent)
38 :QWidget(parent),
37 MainWidget::MainWidget(QWidget *parent)
38 : QWidget(parent),
39 39 m_slice(0)
40 40 {
41 41 // create chart
@@ -71,18 +71,18 MainWidget::MainWidget(QWidget* parent)
71 71
72 72 m_legendCheckBox = new QCheckBox();
73 73
74 QFormLayout* chartSettingsLayout = new QFormLayout();
74 QFormLayout *chartSettingsLayout = new QFormLayout();
75 75 chartSettingsLayout->addRow("Theme", m_themeComboBox);
76 76 chartSettingsLayout->addRow("Antialiasing", m_aaCheckBox);
77 77 chartSettingsLayout->addRow("Animations", m_animationsCheckBox);
78 78 chartSettingsLayout->addRow("Legend", m_legendCheckBox);
79 QGroupBox* chartSettings = new QGroupBox("Chart");
79 QGroupBox *chartSettings = new QGroupBox("Chart");
80 80 chartSettings->setLayout(chartSettingsLayout);
81 81
82 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateChartSettings()));
83 connect(m_aaCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings()));
84 connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings()));
85 connect(m_legendCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings()));
82 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChartSettings()));
83 connect(m_aaCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings()));
84 connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings()));
85 connect(m_legendCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings()));
86 86
87 87 // series settings
88 88 m_hPosition = new QDoubleSpinBox();
@@ -125,7 +125,7 MainWidget::MainWidget(QWidget* parent)
125 125 QPushButton *insertSlice = new QPushButton("Insert slice");
126 126 QPushButton *removeSlice = new QPushButton("Remove selected slice");
127 127
128 QFormLayout* seriesSettingsLayout = new QFormLayout();
128 QFormLayout *seriesSettingsLayout = new QFormLayout();
129 129 seriesSettingsLayout->addRow("Horizontal position", m_hPosition);
130 130 seriesSettingsLayout->addRow("Vertical position", m_vPosition);
131 131 seriesSettingsLayout->addRow("Size factor", m_sizeFactor);
@@ -135,7 +135,7 MainWidget::MainWidget(QWidget* parent)
135 135 seriesSettingsLayout->addRow(appendSlice);
136 136 seriesSettingsLayout->addRow(insertSlice);
137 137 seriesSettingsLayout->addRow(removeSlice);
138 QGroupBox* seriesSettings = new QGroupBox("Series");
138 QGroupBox *seriesSettings = new QGroupBox("Series");
139 139 seriesSettings->setLayout(seriesSettingsLayout);
140 140
141 141 connect(m_vPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
@@ -172,7 +172,7 MainWidget::MainWidget(QWidget* parent)
172 172 m_labelPosition->addItem("Inside tangential", QPieSlice::LabelInsideTangential);
173 173 m_labelPosition->addItem("Inside normal", QPieSlice::LabelInsideNormal);
174 174
175 QFormLayout* sliceSettingsLayout = new QFormLayout();
175 QFormLayout *sliceSettingsLayout = new QFormLayout();
176 176 sliceSettingsLayout->addRow("Label", m_sliceName);
177 177 sliceSettingsLayout->addRow("Value", m_sliceValue);
178 178 sliceSettingsLayout->addRow("Pen", m_pen);
@@ -184,7 +184,7 MainWidget::MainWidget(QWidget* parent)
184 184 sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor);
185 185 sliceSettingsLayout->addRow("Exploded", m_sliceExploded);
186 186 sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor);
187 QGroupBox* sliceSettings = new QGroupBox("Selected slice");
187 QGroupBox *sliceSettings = new QGroupBox("Selected slice");
188 188 sliceSettings->setLayout(sliceSettingsLayout);
189 189
190 190 connect(m_sliceName, SIGNAL(textChanged(QString)), this, SLOT(updateSliceSettings()));
@@ -213,7 +213,7 MainWidget::MainWidget(QWidget* parent)
213 213 settingsLayout->addWidget(sliceSettings);
214 214 settingsLayout->addStretch();
215 215
216 QGridLayout* baseLayout = new QGridLayout();
216 QGridLayout *baseLayout = new QGridLayout();
217 217 baseLayout->addLayout(settingsLayout, 0, 0);
218 218 baseLayout->addWidget(m_chartView, 0, 1);
219 219 setLayout(baseLayout);
@@ -272,9 +272,9 void MainWidget::updateSliceSettings()
272 272 m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value());
273 273 }
274 274
275 void MainWidget::handleSliceClicked(QPieSlice* slice)
275 void MainWidget::handleSliceClicked(QPieSlice *slice)
276 276 {
277 m_slice = static_cast<CustomSlice*>(slice);
277 m_slice = static_cast<CustomSlice *>(slice);
278 278
279 279 // name
280 280 m_sliceName->blockSignals(true);
@@ -332,7 +332,7 void MainWidget::showFontDialog()
332 332
333 333 void MainWidget::appendSlice()
334 334 {
335 *m_series << new CustomSlice("Slice " + QString::number(m_series->count()+1), 10.0);
335 *m_series << new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0);
336 336 }
337 337
338 338 void MainWidget::insertSlice()
@@ -342,7 +342,7 void MainWidget::insertSlice()
342 342
343 343 int i = m_series->slices().indexOf(m_slice);
344 344
345 m_series->insert(i, new CustomSlice("Slice " + QString::number(m_series->count()+1), 10.0));
345 m_series->insert(i, new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0));
346 346 }
347 347
348 348 void MainWidget::removeSlice()
@@ -45,13 +45,13 class MainWidget : public QWidget
45 45 Q_OBJECT
46 46
47 47 public:
48 explicit MainWidget(QWidget* parent = 0);
48 explicit MainWidget(QWidget *parent = 0);
49 49
50 50 public Q_SLOTS:
51 51 void updateChartSettings();
52 52 void updateSerieSettings();
53 53 void updateSliceSettings();
54 void handleSliceClicked(QPieSlice* slice);
54 void handleSliceClicked(QPieSlice *slice);
55 55 void showFontDialog();
56 56 void appendSlice();
57 57 void insertSlice();
@@ -63,23 +63,23 private:
63 63 QCheckBox *m_animationsCheckBox;
64 64 QCheckBox *m_legendCheckBox;
65 65
66 QChartView* m_chartView;
67 QPieSeries* m_series;
68 CustomSlice* m_slice;
66 QChartView *m_chartView;
67 QPieSeries *m_series;
68 CustomSlice *m_slice;
69 69
70 QDoubleSpinBox* m_hPosition;
71 QDoubleSpinBox* m_vPosition;
72 QDoubleSpinBox* m_sizeFactor;
73 QDoubleSpinBox* m_startAngle;
74 QDoubleSpinBox* m_endAngle;
75 QDoubleSpinBox* m_holeSize;
70 QDoubleSpinBox *m_hPosition;
71 QDoubleSpinBox *m_vPosition;
72 QDoubleSpinBox *m_sizeFactor;
73 QDoubleSpinBox *m_startAngle;
74 QDoubleSpinBox *m_endAngle;
75 QDoubleSpinBox *m_holeSize;
76 76
77 QLineEdit* m_sliceName;
78 QDoubleSpinBox* m_sliceValue;
79 QCheckBox* m_sliceLabelVisible;
80 QDoubleSpinBox* m_sliceLabelArmFactor;
81 QCheckBox* m_sliceExploded;
82 QDoubleSpinBox* m_sliceExplodedFactor;
77 QLineEdit *m_sliceName;
78 QDoubleSpinBox *m_sliceValue;
79 QCheckBox *m_sliceLabelVisible;
80 QDoubleSpinBox *m_sliceLabelArmFactor;
81 QCheckBox *m_sliceExploded;
82 QDoubleSpinBox *m_sliceExplodedFactor;
83 83 QPushButton *m_brush;
84 84 BrushTool *m_brushTool;
85 85 QPushButton *m_pen;
@@ -26,7 +26,7
26 26 #include <QColorDialog>
27 27
28 28 PenTool::PenTool(QString title, QWidget *parent)
29 :QWidget(parent)
29 : QWidget(parent)
30 30 {
31 31 setWindowTitle(title);
32 32 setWindowFlags(Qt::Tool);
@@ -1,40 +1,40
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 <QApplication>
22 #ifdef QT5_QUICK_1
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 <QApplication>
22 #ifdef QT5_QUICK_1
23 23 #include <QtQuick1/QDeclarativeEngine>
24 #else
24 #else
25 25 #include <QtDeclarative/QDeclarativeEngine>
26 #endif
27 #include "qmlapplicationviewer.h"
28
29 Q_DECL_EXPORT int main(int argc, char *argv[])
30 {
31 QScopedPointer<QApplication> app(createApplication(argc, argv));
32 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
33
34 //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
35 viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml"));
36 viewer->setRenderHint(QPainter::Antialiasing, true);
37 viewer->showExpanded();
38
39 return app->exec();
40 }
26 #endif
27 #include "qmlapplicationviewer.h"
28
29 Q_DECL_EXPORT int main(int argc, char *argv[])
30 {
31 QScopedPointer<QApplication> app(createApplication(argc, argv));
32 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
33
34 //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
35 viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml"));
36 viewer->setRenderHint(QPainter::Antialiasing, true);
37 viewer->showExpanded();
38
39 return app->exec();
40 }
1 NO CONTENT: modified file chmod 100755 => 100644
1 NO CONTENT: modified file chmod 100755 => 100644
@@ -31,13 +31,13 CustomTableModel::CustomTableModel(QObject *parent) :
31 31 {
32 32 }
33 33
34 int CustomTableModel::rowCount(const QModelIndex & parent) const
34 int CustomTableModel::rowCount(const QModelIndex &parent) const
35 35 {
36 36 Q_UNUSED(parent)
37 37 return m_data.count();
38 38 }
39 39
40 int CustomTableModel::columnCount(const QModelIndex & parent) const
40 int CustomTableModel::columnCount(const QModelIndex &parent) const
41 41 {
42 42 Q_UNUSED(parent)
43 43 return m_columnCount;
@@ -128,7 +128,7 bool CustomTableModel::removeRows(int row, int count, const QModelIndex &parent)
128 128 return removed;
129 129 }
130 130
131 Qt::ItemFlags CustomTableModel::flags ( const QModelIndex & index ) const
131 Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const
132 132 {
133 133 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
134 134 }
@@ -33,17 +33,17 class CustomTableModel : public QAbstractTableModel
33 33 public:
34 34 explicit CustomTableModel(QObject *parent = 0);
35 35
36 int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
37 int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
38 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
36 int rowCount(const QModelIndex &parent = QModelIndex()) const;
37 int columnCount(const QModelIndex &parent = QModelIndex()) const;
38 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
39 39 bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);
40 40 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
41 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
42 Qt::ItemFlags flags ( const QModelIndex & index ) const;
41 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
42 Qt::ItemFlags flags(const QModelIndex &index) const;
43 43 void insertColumn(int column, const QModelIndex &parent = QModelIndex());
44 44 void insertRow(int row, const QModelIndex &parent = QModelIndex());
45 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
46 Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex());
45 Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
46 Q_INVOKABLE bool removeRow(int row, const QModelIndex &parent = QModelIndex());
47 47 Q_INVOKABLE QVariant at(int row, int column);
48 48
49 49 private:
@@ -33,9 +33,9 class DataSource : public QObject
33 33 Q_OBJECT
34 34 public:
35 35 explicit DataSource(QDeclarativeView *appViewer, QObject *parent = 0);
36
36
37 37 signals:
38
38
39 39 public slots:
40 40 void generateData(int type, int rowCount, int colCount);
41 41 void update(QAbstractSeries *series);
General Comments 0
You need to be logged in to leave comments. Login now