@@ -1,65 +1,64 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "charts.h" |
|
22 | 22 | #include "qchart.h" |
|
23 | 23 | #include "qbarseries.h" |
|
24 | 24 | #include "qbarset.h" |
|
25 | 25 | #include "qvalueaxis.h" |
|
26 | 26 | #include "qbarcategoryaxis.h" |
|
27 | 27 | |
|
28 | 28 | class BarCategoryAxisX: public Chart |
|
29 | 29 | { |
|
30 | 30 | public: |
|
31 | 31 | QString name() { return "AxisX"; } |
|
32 | 32 | QString category() { return QObject::tr("Axis"); } |
|
33 | 33 | QString subCategory() { return "BarCategoryAxis"; } |
|
34 | 34 | |
|
35 | 35 | QChart *createChart(const DataTable &table) |
|
36 | 36 | { |
|
37 | 37 | QChart *chart = new QChart(); |
|
38 | 38 | chart->setTitle(" BarCateogry X , Value Y"); |
|
39 | 39 | |
|
40 | 40 | QString name("Series "); |
|
41 | 41 | QBarSeries *series = new QBarSeries(chart); |
|
42 | 42 | QValueAxis *valueaxis = new QValueAxis(); |
|
43 | 43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); |
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
44 | for (int i(0); i < table.count(); i++) { | |
|
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
|
46 | foreach (Data data, table[i]) | |
|
47 | *set << data.first.y(); | |
|
48 | series->append(set); | |
|
49 | } | |
|
50 | chart->addSeries(series); | |
|
51 | 51 | |
|
52 | 52 | int count = series->barSets().first()->count(); |
|
53 | 53 | |
|
54 |
for(int i =0 |
|
|
54 | for (int i = 0; i < count; i++) | |
|
55 | 55 | barcategory->append(QString::number(i)); |
|
56 | } | |
|
57 | 56 | |
|
58 | 57 | chart->setAxisY(valueaxis, series); |
|
59 | 58 | chart->setAxisX(barcategory, series); |
|
60 | 59 | |
|
61 | 60 | return chart; |
|
62 | 61 | } |
|
63 | 62 | }; |
|
64 | 63 | |
|
65 | 64 | DECLARE_CHART(BarCategoryAxisX); |
@@ -1,65 +1,64 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "charts.h" |
|
22 | 22 | #include "qchart.h" |
|
23 | 23 | #include "qhorizontalbarseries.h" |
|
24 | 24 | #include "qbarset.h" |
|
25 | 25 | #include "qvalueaxis.h" |
|
26 | 26 | #include "qbarcategoryaxis.h" |
|
27 | 27 | |
|
28 | 28 | class BarCategoryAxisY: public Chart |
|
29 | 29 | { |
|
30 | 30 | public: |
|
31 | 31 | QString name() { return "AxisY"; } |
|
32 | 32 | QString category() { return QObject::tr("Axis"); } |
|
33 | 33 | QString subCategory() { return "BarCategoryAxis"; } |
|
34 | 34 | |
|
35 | 35 | QChart *createChart(const DataTable &table) |
|
36 | 36 | { |
|
37 | 37 | QChart *chart = new QChart(); |
|
38 | 38 | chart->setTitle(" BarCateogry Y , Value X"); |
|
39 | 39 | |
|
40 | 40 | QString name("Series "); |
|
41 | 41 | QHorizontalBarSeries *series = new QHorizontalBarSeries(chart); |
|
42 | 42 | QValueAxis *valueaxis = new QValueAxis(); |
|
43 | 43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); |
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
44 | for (int i(0); i < table.count(); i++) { | |
|
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
|
46 | foreach(Data data, table[i]) | |
|
47 | *set << data.first.y(); | |
|
48 | series->append(set); | |
|
49 | } | |
|
50 | chart->addSeries(series); | |
|
51 | 51 | |
|
52 | 52 | int count = series->barSets().first()->count(); |
|
53 | 53 | |
|
54 |
for(int i =0 |
|
|
54 | for (int i = 0; i < count; i++) | |
|
55 | 55 | barcategory->append(QString::number(i)); |
|
56 | } | |
|
57 | 56 | |
|
58 | 57 | chart->setAxisX(valueaxis, series); |
|
59 | 58 | chart->setAxisY(barcategory, series); |
|
60 | 59 | |
|
61 | 60 | return chart; |
|
62 | 61 | } |
|
63 | 62 | }; |
|
64 | 63 | |
|
65 | 64 | DECLARE_CHART(BarCategoryAxisY); |
@@ -1,62 +1,62 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "charts.h" |
|
22 | 22 | #include "qchart.h" |
|
23 | 23 | #include "qlineseries.h" |
|
24 | 24 | #include "qvalueaxis.h" |
|
25 | 25 | #include "qdatetimeaxis.h" |
|
26 | 26 | |
|
27 | 27 | class DateTimeAxisX: public Chart |
|
28 | 28 | { |
|
29 | 29 | public: |
|
30 | 30 | QString name() { return "AxisX"; } |
|
31 | 31 | QString category() { return QObject::tr("Axis"); } |
|
32 | 32 | QString subCategory() { return "DateTimeAxis"; } |
|
33 | 33 | |
|
34 | 34 | QChart *createChart(const DataTable &table) |
|
35 | 35 | { |
|
36 | 36 | QChart *chart = new QChart(); |
|
37 | 37 | chart->setTitle("DateTime X , Value Y"); |
|
38 | 38 | QValueAxis *valueaxis = new QValueAxis(); |
|
39 | 39 | QDateTimeAxis *datetimeaxis = new QDateTimeAxis(); |
|
40 | 40 | datetimeaxis->setTickCount(10); |
|
41 | 41 | datetimeaxis->setFormat("yyyy"); |
|
42 | 42 | |
|
43 | 43 | QString name("Series "); |
|
44 | 44 | int nameIndex = 0; |
|
45 | 45 | foreach (DataList list, table) { |
|
46 | 46 | QLineSeries *series = new QLineSeries(chart); |
|
47 | foreach (Data data, list){ | |
|
47 | foreach (Data data, list) { | |
|
48 | 48 | QPointF point = data.first; |
|
49 | series->append(1000l*60l*60l*24l*365l*30l+point.x()*1000l*60l*60l*24l*365l,point.y()); | |
|
49 | series->append(1000l * 60l * 60l * 24l * 365l * 30l + point.x() * 1000l * 60l * 60l * 24l * 365l, point.y()); | |
|
50 | 50 | } |
|
51 | 51 | series->setName(name + QString::number(nameIndex)); |
|
52 | 52 | nameIndex++; |
|
53 | 53 | chart->addSeries(series); |
|
54 | 54 | chart->setAxisX(datetimeaxis, series); |
|
55 | 55 | chart->setAxisY(valueaxis, series); |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | return chart; |
|
59 | 59 | } |
|
60 | 60 | }; |
|
61 | 61 | |
|
62 | 62 | DECLARE_CHART(DateTimeAxisX); |
@@ -1,62 +1,62 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "charts.h" |
|
22 | 22 | #include "qchart.h" |
|
23 | 23 | #include "qlineseries.h" |
|
24 | 24 | #include "qvalueaxis.h" |
|
25 | 25 | #include "qdatetimeaxis.h" |
|
26 | 26 | |
|
27 | 27 | class DateTimeAxisY: public Chart |
|
28 | 28 | { |
|
29 | 29 | public: |
|
30 | 30 | QString name() { return "AxisY"; } |
|
31 | 31 | QString category() { return QObject::tr("Axis"); } |
|
32 | 32 | QString subCategory() { return "DateTimeAxis"; } |
|
33 | 33 | |
|
34 | 34 | QChart *createChart(const DataTable &table) |
|
35 | 35 | { |
|
36 | 36 | QChart *chart = new QChart(); |
|
37 | 37 | chart->setTitle("Value X , DateTime Y"); |
|
38 | 38 | QValueAxis *valueaxis = new QValueAxis(); |
|
39 | 39 | QDateTimeAxis *datetimeaxis = new QDateTimeAxis(); |
|
40 | 40 | datetimeaxis->setTickCount(10); |
|
41 | 41 | datetimeaxis->setFormat("yyyy"); |
|
42 | 42 | |
|
43 | 43 | QString name("Series "); |
|
44 | 44 | int nameIndex = 0; |
|
45 | 45 | foreach (DataList list, table) { |
|
46 | 46 | QLineSeries *series = new QLineSeries(chart); |
|
47 | foreach (Data data, list){ | |
|
47 | foreach (Data data, list) { | |
|
48 | 48 | QPointF point = data.first; |
|
49 | series->append(point.x(),1000l*60l*60l*24l*365l*30l+point.y()*1000l*60l*60l*24l*365l); | |
|
49 | series->append(point.x(), 1000l * 60l * 60l * 24l * 365l * 30l + point.y() * 1000l * 60l * 60l * 24l * 365l); | |
|
50 | 50 | } |
|
51 | 51 | series->setName(name + QString::number(nameIndex)); |
|
52 | 52 | nameIndex++; |
|
53 | 53 | chart->addSeries(series); |
|
54 | 54 | chart->setAxisY(datetimeaxis, series); |
|
55 | 55 | chart->setAxisX(valueaxis, series); |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | return chart; |
|
59 | 59 | } |
|
60 | 60 | }; |
|
61 | 61 | |
|
62 | 62 | DECLARE_CHART(DateTimeAxisY); |
@@ -1,55 +1,55 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "charts.h" |
|
22 | 22 | #include "qchart.h" |
|
23 | 23 | #include "qpieseries.h" |
|
24 | 24 | |
|
25 | 25 | class DonutChart: public Chart |
|
26 | 26 | { |
|
27 | 27 | public: |
|
28 | 28 | QString name() { return QObject::tr("DonutChart"); } |
|
29 | 29 | QString category() { return QObject::tr("PieSeries"); } |
|
30 | 30 | QString subCategory() { return QString::null; } |
|
31 | 31 | |
|
32 | 32 | QChart *createChart(const DataTable &table) |
|
33 |
|
|
|
33 | { | |
|
34 | 34 | QChart *chart = new QChart(); |
|
35 | 35 | chart->setTitle("Donut chart"); |
|
36 | 36 | for (int i = 0, j = table.count(); i < table.count(); i++, j--) { |
|
37 | 37 | QPieSeries *series = new QPieSeries(chart); |
|
38 | 38 | foreach (Data data, table[i]) { |
|
39 | 39 | QPieSlice *slice = series->append(data.second, data.first.y()); |
|
40 | 40 | if (data == table[i].first()) |
|
41 | 41 | slice->setLabelVisible(); |
|
42 | 42 | } |
|
43 | 43 | series->setPieSize(j / (qreal) table.count()); |
|
44 | 44 | if (j > 1) |
|
45 | 45 | series->setHoleSize((j - 1) / (qreal) table.count() + 0.1); |
|
46 | 46 | series->setHorizontalPosition(0.5); |
|
47 | 47 | series->setVerticalPosition(0.5); |
|
48 | 48 | chart->addSeries(series); |
|
49 | 49 | } |
|
50 | 50 | return chart; |
|
51 | 51 | } |
|
52 | 52 | }; |
|
53 | 53 | |
|
54 | 54 | DECLARE_CHART(DonutChart) |
|
55 | 55 |
@@ -1,246 +1,231 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "grid.h" |
|
22 | 22 | #include "charts.h" |
|
23 | 23 | #include <qchart.h> |
|
24 | 24 | #include <QGraphicsGridLayout> |
|
25 | 25 | #include <QGraphicsSceneMouseEvent> |
|
26 | 26 | #include <QDebug> |
|
27 | 27 | |
|
28 |
Grid::Grid(int size,QGraphicsItem *parent) |
|
|
29 | m_listCount(3), | |
|
30 | m_valueMax(10), | |
|
31 |
m_value |
|
|
32 | m_size(size), | |
|
33 | m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)), | |
|
34 | m_state(NoState), | |
|
35 |
|
|
|
36 | m_rubberBand(new QGraphicsRectItem()), | |
|
37 | m_gridLayout(new QGraphicsGridLayout()) | |
|
28 | Grid::Grid(int size, QGraphicsItem *parent) | |
|
29 | : QGraphicsWidget(parent), | |
|
30 | m_listCount(3), | |
|
31 | m_valueMax(10), | |
|
32 | m_valueCount(7), | |
|
33 | m_size(size), | |
|
34 | m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)), | |
|
35 | m_state(NoState), | |
|
36 | m_currentState(NoState), | |
|
37 | m_rubberBand(new QGraphicsRectItem()), | |
|
38 | m_gridLayout(new QGraphicsGridLayout()) | |
|
38 | 39 | { |
|
39 | 40 | setLayout(m_gridLayout); |
|
40 | 41 | m_rubberBand->setParentItem(this); |
|
41 | 42 | m_rubberBand->setVisible(false); |
|
42 | 43 | m_rubberBand->setZValue(2); |
|
43 | 44 | } |
|
44 | 45 | |
|
45 | 46 | Grid::~Grid() |
|
46 | 47 | { |
|
47 | 48 | |
|
48 | 49 | } |
|
49 | 50 | |
|
50 |
void Grid::createCharts(const QString& |
|
|
51 | void Grid::createCharts(const QString &category) | |
|
51 | 52 | { |
|
52 | 53 | clear(); |
|
53 | 54 | |
|
54 | 55 | QChart *qchart(0); |
|
55 | 56 | Charts::ChartList list = Charts::chartList(); |
|
56 | 57 | |
|
57 | 58 | if (category.isEmpty()) { |
|
58 | ||
|
59 | 59 | for (int i = 0; i < m_size * m_size; ++i) { |
|
60 | 60 | QChart *chart = 0; |
|
61 | 61 | if (i < list.size()) { |
|
62 | 62 | chart = list.at(i)->createChart(m_dataTable); |
|
63 | } | |
|
64 | else { | |
|
63 | } else { | |
|
65 | 64 | chart = new QChart(); |
|
66 | 65 | chart->setTitle(QObject::tr("Empty")); |
|
67 | 66 | } |
|
68 | ||
|
69 | 67 | m_gridLayout->addItem(chart, i / m_size, i % m_size); |
|
70 | 68 | m_chartHash[chart] = i; |
|
71 | 69 | } |
|
72 | } | |
|
73 | else { | |
|
74 | ||
|
70 | } else { | |
|
75 | 71 | int j = 0; |
|
76 | 72 | for (int i = 0; i < list.size(); ++i) { |
|
77 | 73 | Chart *chart = list.at(i); |
|
78 | 74 | if (chart->category() == category && j < m_size * m_size) { |
|
79 | 75 | qchart = list.at(i)->createChart(m_dataTable); |
|
80 | 76 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); |
|
81 | 77 | m_chartHash[qchart] = j; |
|
82 | 78 | j++; |
|
83 | 79 | } |
|
84 | 80 | } |
|
85 | 81 | for (; j < m_size * m_size; ++j) { |
|
86 | 82 | qchart = new QChart(); |
|
87 | 83 | qchart->setTitle(QObject::tr("Empty")); |
|
88 | 84 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); |
|
89 | 85 | m_chartHash[qchart] = j; |
|
90 | 86 | } |
|
91 | 87 | } |
|
92 | 88 | m_category = category; |
|
93 | 89 | m_gridLayout->activate(); |
|
94 | 90 | } |
|
95 | 91 | |
|
96 | 92 | void Grid::clear() |
|
97 | 93 | { |
|
98 |
for (int i = 0; i < m_gridLayout->count(); ++i) |
|
|
94 | for (int i = 0; i < m_gridLayout->count(); ++i) | |
|
99 | 95 | m_gridLayout->removeAt(i); |
|
100 | } | |
|
101 | 96 | |
|
102 | 97 | qDeleteAll(m_chartHash.keys()); |
|
103 | 98 | m_chartHash.clear(); |
|
104 | 99 | } |
|
105 | 100 | |
|
106 | QList<QChart*> Grid::charts() | |
|
101 | QList<QChart *> Grid::charts() | |
|
107 | 102 | { |
|
108 | 103 | return m_chartHash.keys(); |
|
109 | 104 | } |
|
110 | 105 | |
|
111 | 106 | void Grid::setState(State state) |
|
112 | 107 | { |
|
113 | 108 | m_state = state; |
|
114 | 109 | } |
|
115 | 110 | |
|
116 | 111 | void Grid::setSize(int size) |
|
117 | 112 | { |
|
118 | if(m_size !=size) | |
|
119 | { | |
|
120 | m_size = size; | |
|
121 | createCharts(m_category); | |
|
113 | if (m_size != size) { | |
|
114 | m_size = size; | |
|
115 | createCharts(m_category); | |
|
122 | 116 | } |
|
123 | 117 | } |
|
124 | 118 | |
|
125 |
void Grid::setRubberPen(const QPen& |
|
|
119 | void Grid::setRubberPen(const QPen &pen) | |
|
126 | 120 | { |
|
127 | 121 | m_rubberBand->setPen(pen); |
|
128 | 122 | } |
|
129 | 123 | |
|
130 |
void Grid::replaceChart(QChart* |
|
|
124 | void Grid::replaceChart(QChart *oldChart, Chart *newChart) | |
|
131 | 125 | { |
|
132 | 126 | int index = m_chartHash[oldChart]; |
|
133 | 127 | //not in 4.7.2 m_baseLayout->removeItem(qchart); |
|
134 | 128 | for (int i = 0; i < m_gridLayout->count(); ++i) { |
|
135 | 129 | if (m_gridLayout->itemAt(i) == oldChart) { |
|
136 | 130 | m_gridLayout->removeAt(i); |
|
137 | 131 | break; |
|
138 | 132 | } |
|
139 | 133 | } |
|
140 | 134 | m_chartHash.remove(oldChart); |
|
141 | 135 | QChart *chart = newChart->createChart(m_dataTable); |
|
142 | 136 | m_gridLayout->addItem(chart, index / m_size, index % m_size); |
|
143 | 137 | m_chartHash[chart] = index; |
|
144 | 138 | delete oldChart; |
|
145 | 139 | } |
|
146 | 140 | |
|
147 | 141 | void Grid::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
148 | 142 | { |
|
149 | 143 | if (event->button() == Qt::LeftButton) { |
|
150 | 144 | |
|
151 | 145 | m_origin = event->pos(); |
|
152 | 146 | m_currentState = NoState; |
|
153 | 147 | |
|
154 | 148 | foreach (QChart *chart, charts()) { |
|
155 | ||
|
156 | 149 | QRectF geometryRect = chart->geometry(); |
|
157 | 150 | QRectF plotArea = chart->plotArea(); |
|
158 | 151 | plotArea.translate(geometryRect.topLeft()); |
|
159 | 152 | if (plotArea.contains(m_origin)) { |
|
160 | 153 | m_currentState = m_state; |
|
161 | 154 | if (m_currentState == NoState) emit chartSelected(chart); |
|
162 | 155 | break; |
|
163 | 156 | } |
|
164 | 157 | } |
|
165 | 158 | if (m_currentState == ZoomState) { |
|
166 | 159 | m_rubberBand->setRect(QRectF(m_origin, QSize())); |
|
167 | 160 | m_rubberBand->setVisible(true); |
|
168 | 161 | } |
|
169 | 162 | |
|
170 | 163 | event->accept(); |
|
171 | 164 | } |
|
172 | 165 | |
|
173 | 166 | if (event->button() == Qt::RightButton) { |
|
174 | 167 | m_origin = event->pos(); |
|
175 | 168 | m_currentState = m_state; |
|
176 | 169 | } |
|
177 | 170 | } |
|
178 | 171 | |
|
179 | 172 | void Grid::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
180 | 173 | { |
|
181 | 174 | if (m_currentState != NoState) { |
|
182 | 175 | |
|
183 | 176 | foreach (QChart *chart, charts()) { |
|
184 | ||
|
185 | 177 | QRectF geometryRect = chart->geometry(); |
|
186 | 178 | QRectF plotArea = chart->plotArea(); |
|
187 | 179 | plotArea.translate(geometryRect.topLeft()); |
|
188 | ||
|
189 | 180 | if (plotArea.contains(m_origin)) { |
|
190 | 181 | if (m_currentState == ScrollState) { |
|
191 | 182 | QPointF delta = m_origin - event->pos(); |
|
192 | 183 | chart->scroll(delta.x(), -delta.y()); |
|
193 | 184 | } |
|
194 | 185 | if (m_currentState == ZoomState && plotArea.contains(event->pos())) |
|
195 | 186 | m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized()); |
|
196 | 187 | break; |
|
197 | 188 | } |
|
198 | 189 | } |
|
199 | 190 | if (m_currentState == ScrollState) |
|
200 | 191 | m_origin = event->pos(); |
|
201 | 192 | event->accept(); |
|
202 | 193 | } |
|
203 | 194 | } |
|
204 | 195 | |
|
205 | 196 | void Grid::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
206 | 197 | { |
|
207 | 198 | if (event->button() == Qt::LeftButton) { |
|
208 | 199 | if (m_currentState == ZoomState) { |
|
209 | 200 | m_rubberBand->setVisible(false); |
|
210 | 201 | |
|
211 | 202 | foreach (QChart *chart, charts()) { |
|
212 | ||
|
213 | 203 | QRectF geometryRect = chart->geometry(); |
|
214 | 204 | QRectF plotArea = chart->plotArea(); |
|
215 | 205 | plotArea.translate(geometryRect.topLeft()); |
|
216 | ||
|
217 | 206 | if (plotArea.contains(m_origin)) { |
|
218 | 207 | QRectF rect = m_rubberBand->rect(); |
|
219 | 208 | rect.translate(-geometryRect.topLeft()); |
|
220 | 209 | chart->zoomIn(rect); |
|
221 | 210 | break; |
|
222 | 211 | } |
|
223 | 212 | } |
|
224 | 213 | } |
|
225 | ||
|
226 | 214 | m_currentState = NoState; |
|
227 | 215 | event->accept(); |
|
228 | 216 | } |
|
229 | 217 | |
|
230 | 218 | if (event->button() == Qt::RightButton) { |
|
231 | ||
|
232 | 219 | if (m_currentState == ZoomState) { |
|
233 | 220 | foreach (QChart *chart, charts()) { |
|
234 | ||
|
235 | 221 | QRectF geometryRect = chart->geometry(); |
|
236 | 222 | QRectF plotArea = chart->plotArea(); |
|
237 | 223 | plotArea.translate(geometryRect.topLeft()); |
|
238 | ||
|
239 | 224 | if (plotArea.contains(m_origin)) { |
|
240 | 225 | chart->zoomOut(); |
|
241 | 226 | break; |
|
242 | 227 | } |
|
243 | 228 | } |
|
244 | 229 | } |
|
245 | 230 | } |
|
246 | 231 | } |
@@ -1,75 +1,81 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef GRID_H_ |
|
22 | 22 | #define GRID_H_ |
|
23 | 23 | |
|
24 | 24 | #include "model.h" |
|
25 | 25 | #include <QGraphicsWidget> |
|
26 | 26 | #include <QChartGlobal> |
|
27 | 27 | |
|
28 | 28 | class QGraphicsGridLayout; |
|
29 | 29 | class Chart; |
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | class QChart; |
|
33 | 33 | QTCOMMERCIALCHART_END_NAMESPACE |
|
34 | 34 | |
|
35 | 35 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
36 | 36 | |
|
37 | 37 | class Grid : public QGraphicsWidget |
|
38 | 38 | { |
|
39 | 39 | Q_OBJECT |
|
40 | 40 | public: |
|
41 | 41 | enum State { NoState = 0, ZoomState, ScrollState}; |
|
42 | Grid(int size , QGraphicsItem *parent = 0 ); | |
|
42 | ||
|
43 | Grid(int size, QGraphicsItem *parent = 0); | |
|
43 | 44 | ~Grid(); |
|
44 | QList<QChart*> charts(); | |
|
45 | void createCharts(const QString& category = QString()); | |
|
46 | void replaceChart(QChart* oldChart, Chart* newChart); | |
|
45 | ||
|
46 | QList<QChart *> charts(); | |
|
47 | void createCharts(const QString &category = QString()); | |
|
48 | void replaceChart(QChart *oldChart, Chart *newChart); | |
|
47 | 49 | void setState(State state); |
|
48 | 50 | State state() const { return m_state; }; |
|
49 |
void setRubberPen(const QPen& |
|
|
51 | void setRubberPen(const QPen &pen); | |
|
50 | 52 | void setSize(int size); |
|
51 | 53 | int size() const {return m_size;} |
|
52 | Q_SIGNAL | |
|
53 | void chartSelected(QChart* chart); | |
|
54 | ||
|
55 | Q_SIGNALS: | |
|
56 | void chartSelected(QChart *chart); | |
|
57 | ||
|
54 | 58 | protected: |
|
55 | 59 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
56 | 60 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
|
57 | 61 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
|
62 | ||
|
58 | 63 | private: |
|
59 | 64 | void clear(); |
|
65 | ||
|
60 | 66 | private: |
|
61 | 67 | int m_listCount; |
|
62 | 68 | int m_valueMax; |
|
63 | 69 | int m_valueCount; |
|
64 | 70 | int m_size; |
|
65 | 71 | DataTable m_dataTable; |
|
66 | 72 | QHash<QChart *, int> m_chartHash; |
|
67 | 73 | State m_state; |
|
68 | 74 | State m_currentState; |
|
69 | 75 | QPointF m_origin; |
|
70 | 76 | QGraphicsRectItem *m_rubberBand; |
|
71 |
QGraphicsGridLayout* |
|
|
77 | QGraphicsGridLayout *m_gridLayout; | |
|
72 | 78 | QString m_category; |
|
73 | 79 | }; |
|
74 | 80 | |
|
75 | 81 | #endif /* GRID_H_ */ |
@@ -1,67 +1,65 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "window.h" |
|
22 | 22 | #include <QApplication> |
|
23 | 23 | #include <QMainWindow> |
|
24 | 24 | |
|
25 | 25 | QVariantHash parseArgs(QStringList args) |
|
26 | 26 | { |
|
27 | 27 | QVariantHash parameters; |
|
28 | 28 | |
|
29 | 29 | while (!args.isEmpty()) { |
|
30 | 30 | |
|
31 | 31 | QString param = args.takeFirst(); |
|
32 | 32 | if (param.startsWith("--")) { |
|
33 | 33 | param.remove(0, 2); |
|
34 | 34 | |
|
35 | 35 | if (args.isEmpty() || args.first().startsWith("--")) { |
|
36 | 36 | parameters[param] = true; |
|
37 | } | |
|
38 | else { | |
|
39 | ||
|
37 | } else { | |
|
40 | 38 | QString value = args.takeFirst(); |
|
41 | 39 | if (value == "true" || value == "on" || value == "enabled") { |
|
42 | 40 | parameters[param] = true; |
|
43 | } | |
|
44 | else if (value == "false" || value == "off" || value == "disable") { | |
|
41 | } else if (value == "false" || value == "off" || value == "disable") { | |
|
45 | 42 | parameters[param] = false; |
|
46 | } | |
|
47 | else { | |
|
48 |
|
|
|
49 |
if(value.startsWith( |
|
|
43 | } else { | |
|
44 | if (value.endsWith('"')) | |
|
45 | value.chop(1); | |
|
46 | if (value.startsWith('"')) | |
|
47 | value.remove(0, 1); | |
|
50 | 48 | parameters[param] = value; |
|
51 | 49 | } |
|
52 | 50 | } |
|
53 | 51 | } |
|
54 | 52 | } |
|
55 | 53 | |
|
56 | 54 | return parameters; |
|
57 | 55 | } |
|
58 | 56 | |
|
59 | 57 | int main(int argc, char *argv[]) |
|
60 | 58 | { |
|
61 | 59 | QApplication a(argc, argv); |
|
62 | 60 | QVariantHash parameters = parseArgs(QApplication::arguments()); |
|
63 | 61 | Window window(parameters); |
|
64 | 62 | window.show(); |
|
65 | 63 | return a.exec(); |
|
66 | 64 | } |
|
67 | 65 |
@@ -1,484 +1,484 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "window.h" |
|
22 | 22 | #include "view.h" |
|
23 | 23 | #include "grid.h" |
|
24 | 24 | #include "charts.h" |
|
25 | 25 | #include <QChartView> |
|
26 | 26 | #include <QAreaSeries> |
|
27 | 27 | #include <QLegend> |
|
28 | 28 | #include <QGridLayout> |
|
29 | 29 | #include <QFormLayout> |
|
30 | 30 | #include <QComboBox> |
|
31 | 31 | #include <QSpinBox> |
|
32 | 32 | #include <QCheckBox> |
|
33 | 33 | #include <QGroupBox> |
|
34 | 34 | #include <QLabel> |
|
35 | 35 | #include <QGraphicsScene> |
|
36 | 36 | #include <QGraphicsLinearLayout> |
|
37 | 37 | #include <QGraphicsProxyWidget> |
|
38 | 38 | #include <QGLWidget> |
|
39 | 39 | #include <QApplication> |
|
40 | 40 | #include <QDebug> |
|
41 | 41 | #include <QMenu> |
|
42 | 42 | #include <QPushButton> |
|
43 | 43 | |
|
44 |
Window::Window(const QVariantHash& |
|
|
45 | QMainWindow(parent), | |
|
46 | m_scene(new QGraphicsScene(this)), | |
|
47 | m_view(0), | |
|
48 | m_form(0), | |
|
49 | m_themeComboBox(0), | |
|
50 | m_antialiasCheckBox(0), | |
|
51 | m_animatedComboBox(0), | |
|
52 | m_legendComboBox(0), | |
|
53 | m_templateComboBox(0), | |
|
54 | m_viewComboBox(0), | |
|
55 | m_openGLCheckBox(0), | |
|
56 | m_zoomCheckBox(0), | |
|
57 | m_scrollCheckBox(0), | |
|
58 | m_baseLayout(new QGraphicsLinearLayout()), | |
|
59 | m_menu(createMenu()), | |
|
60 | m_template(0), | |
|
61 | m_grid(new Grid(1)) | |
|
44 | Window::Window(const QVariantHash ¶meters, QWidget *parent) | |
|
45 | : QMainWindow(parent), | |
|
46 | m_scene(new QGraphicsScene(this)), | |
|
47 | m_view(0), | |
|
48 | m_form(0), | |
|
49 | m_themeComboBox(0), | |
|
50 | m_antialiasCheckBox(0), | |
|
51 | m_animatedComboBox(0), | |
|
52 | m_legendComboBox(0), | |
|
53 | m_templateComboBox(0), | |
|
54 | m_viewComboBox(0), | |
|
55 | m_openGLCheckBox(0), | |
|
56 | m_zoomCheckBox(0), | |
|
57 | m_scrollCheckBox(0), | |
|
58 | m_baseLayout(new QGraphicsLinearLayout()), | |
|
59 | m_menu(createMenu()), | |
|
60 | m_template(0), | |
|
61 | m_grid(new Grid(1)) | |
|
62 | 62 | { |
|
63 | 63 | createProxyWidgets(); |
|
64 | 64 | // create layout |
|
65 | 65 | QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout(); |
|
66 | 66 | |
|
67 | 67 | settingsLayout->setOrientation(Qt::Vertical); |
|
68 | 68 | settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
|
69 | 69 | settingsLayout->addItem(m_widgetHash["openGLCheckBox"]); |
|
70 | 70 | settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]); |
|
71 | 71 | settingsLayout->addItem(m_widgetHash["viewLabel"]); |
|
72 | 72 | settingsLayout->addItem(m_widgetHash["viewComboBox"]); |
|
73 | 73 | settingsLayout->addItem(m_widgetHash["themeLabel"]); |
|
74 | 74 | settingsLayout->addItem(m_widgetHash["themeComboBox"]); |
|
75 | 75 | settingsLayout->addItem(m_widgetHash["animationsLabel"]); |
|
76 | 76 | settingsLayout->addItem(m_widgetHash["animatedComboBox"]); |
|
77 | 77 | settingsLayout->addItem(m_widgetHash["legendLabel"]); |
|
78 | 78 | settingsLayout->addItem(m_widgetHash["legendComboBox"]); |
|
79 | 79 | settingsLayout->addItem(m_widgetHash["templateLabel"]); |
|
80 | 80 | settingsLayout->addItem(m_widgetHash["templateComboBox"]); |
|
81 | 81 | settingsLayout->addItem(m_widgetHash["scrollCheckBox"]); |
|
82 | 82 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); |
|
83 | 83 | settingsLayout->addStretch(); |
|
84 | 84 | |
|
85 | 85 | m_grid->createCharts(); |
|
86 | 86 | |
|
87 | 87 | m_baseLayout->setOrientation(Qt::Horizontal); |
|
88 | 88 | m_baseLayout->addItem(m_grid); |
|
89 | 89 | m_baseLayout->addItem(settingsLayout); |
|
90 | 90 | |
|
91 | 91 | m_form = new QGraphicsWidget(); |
|
92 | 92 | m_form->setLayout(m_baseLayout); |
|
93 | 93 | m_scene->addItem(m_form); |
|
94 | 94 | |
|
95 | 95 | m_view = new View(m_scene, m_form); |
|
96 | 96 | m_view->setMinimumSize(m_form->minimumSize().toSize()); |
|
97 | 97 | |
|
98 | 98 | // Set defaults |
|
99 | 99 | m_antialiasCheckBox->setChecked(true); |
|
100 | 100 | initializeFromParamaters(parameters); |
|
101 | 101 | updateUI(); |
|
102 | 102 | handleGeometryChanged(); |
|
103 | 103 | setCentralWidget(m_view); |
|
104 | 104 | |
|
105 | 105 | connectSignals(); |
|
106 | 106 | } |
|
107 | 107 | |
|
108 | 108 | Window::~Window() |
|
109 | 109 | { |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | void Window::connectSignals() |
|
113 | 113 | { |
|
114 | 114 | QObject::connect(m_form, SIGNAL(geometryChanged()), this , SLOT(handleGeometryChanged())); |
|
115 | 115 | QObject::connect(m_viewComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
116 | 116 | QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
117 | 117 | QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
118 | 118 | QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
119 | 119 | QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
120 | 120 | QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
121 | 121 | QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
122 | 122 | QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
123 | 123 | QObject::connect(m_templateComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
124 | QObject::connect(m_grid, SIGNAL(chartSelected(QChart*)),this,SLOT(handleChartSelected(QChart*))); | |
|
124 | QObject::connect(m_grid, SIGNAL(chartSelected(QChart*)), this, SLOT(handleChartSelected(QChart*))); | |
|
125 | 125 | } |
|
126 | 126 | |
|
127 | 127 | void Window::createProxyWidgets() |
|
128 | 128 | { |
|
129 | 129 | m_themeComboBox = createThemeBox(); |
|
130 | 130 | m_viewComboBox = createViewBox(); |
|
131 | 131 | m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing")); |
|
132 | 132 | m_animatedComboBox = createAnimationBox(); |
|
133 | 133 | m_legendComboBox = createLegendBox(); |
|
134 | 134 | m_openGLCheckBox = new QCheckBox(tr("OpenGL")); |
|
135 | 135 | m_zoomCheckBox = new QCheckBox(tr("Zoom")); |
|
136 | 136 | m_scrollCheckBox = new QCheckBox(tr("Scroll")); |
|
137 | 137 | m_templateComboBox = createTempleteBox(); |
|
138 | 138 | m_widgetHash["viewLabel"] = m_scene->addWidget(new QLabel("View")); |
|
139 | 139 | m_widgetHash["viewComboBox"] = m_scene->addWidget(m_viewComboBox); |
|
140 | 140 | m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox); |
|
141 | 141 | m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox); |
|
142 | 142 | m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox); |
|
143 | 143 | m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox); |
|
144 | 144 | m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox); |
|
145 | 145 | m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme")); |
|
146 | 146 | m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations")); |
|
147 | 147 | m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend")); |
|
148 | 148 | m_widgetHash["templateLabel"] = m_scene->addWidget(new QLabel("Chart template")); |
|
149 | 149 | m_widgetHash["templateComboBox"] = m_scene->addWidget(m_templateComboBox); |
|
150 | 150 | m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox); |
|
151 | 151 | m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox); |
|
152 | 152 | } |
|
153 | 153 | |
|
154 | 154 | QComboBox *Window::createThemeBox() |
|
155 | 155 | { |
|
156 | 156 | QComboBox *themeComboBox = new ComboBox(this); |
|
157 | 157 | themeComboBox->addItem("Light", QChart::ChartThemeLight); |
|
158 | 158 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); |
|
159 | 159 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); |
|
160 | 160 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); |
|
161 | 161 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); |
|
162 | 162 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); |
|
163 | 163 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); |
|
164 | 164 | return themeComboBox; |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | QComboBox *Window::createViewBox() |
|
168 | 168 | { |
|
169 | 169 | QComboBox *viewComboBox = new ComboBox(this); |
|
170 | 170 | viewComboBox->addItem("1 chart", 1); |
|
171 | 171 | viewComboBox->addItem("4 charts", 2); |
|
172 | 172 | viewComboBox->addItem("9 charts", 3); |
|
173 | 173 | viewComboBox->addItem("16 charts", 4); |
|
174 | 174 | return viewComboBox; |
|
175 | 175 | } |
|
176 | 176 | |
|
177 | 177 | QComboBox *Window::createAnimationBox() |
|
178 | 178 | { |
|
179 | 179 | QComboBox *animationComboBox = new ComboBox(this); |
|
180 | 180 | animationComboBox->addItem("No Animations", QChart::NoAnimation); |
|
181 | 181 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); |
|
182 | 182 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); |
|
183 | 183 | animationComboBox->addItem("All Animations", QChart::AllAnimations); |
|
184 | 184 | return animationComboBox; |
|
185 | 185 | } |
|
186 | 186 | |
|
187 | 187 | QComboBox *Window::createLegendBox() |
|
188 | 188 | { |
|
189 | 189 | QComboBox *legendComboBox = new ComboBox(this); |
|
190 | 190 | legendComboBox->addItem("No Legend ", 0); |
|
191 | 191 | legendComboBox->addItem("Legend Top", Qt::AlignTop); |
|
192 | 192 | legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); |
|
193 | 193 | legendComboBox->addItem("Legend Left", Qt::AlignLeft); |
|
194 | 194 | legendComboBox->addItem("Legend Right", Qt::AlignRight); |
|
195 | 195 | return legendComboBox; |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | QComboBox *Window::createTempleteBox() |
|
199 | 199 | { |
|
200 | 200 | QComboBox *templateComboBox = new ComboBox(this); |
|
201 | 201 | templateComboBox->addItem("No Template", 0); |
|
202 | 202 | |
|
203 | 203 | Charts::ChartList list = Charts::chartList(); |
|
204 | 204 | QMultiMap<QString, Chart *> categoryMap; |
|
205 | 205 | |
|
206 | 206 | foreach (Chart *chart, list) |
|
207 | 207 | categoryMap.insertMulti(chart->category(), chart); |
|
208 | 208 | |
|
209 | 209 | foreach (const QString &category, categoryMap.uniqueKeys()) |
|
210 | 210 | templateComboBox->addItem(category, category); |
|
211 | 211 | |
|
212 | 212 | return templateComboBox; |
|
213 | 213 | } |
|
214 | 214 | |
|
215 |
void Window::initializeFromParamaters(const QVariantHash& |
|
|
215 | void Window::initializeFromParamaters(const QVariantHash ¶meters) | |
|
216 | 216 | { |
|
217 | 217 | if (parameters.contains("template")) { |
|
218 | 218 | QString t = parameters["template"].toString(); |
|
219 | 219 | for (int i = 0; i < m_templateComboBox->count(); ++i) { |
|
220 | 220 | if (m_templateComboBox->itemText(i) == t) { |
|
221 | 221 | m_templateComboBox->setCurrentIndex(i); |
|
222 | 222 | break; |
|
223 | 223 | } |
|
224 | 224 | } |
|
225 | 225 | } |
|
226 | 226 | if (parameters.contains("opengl")) { |
|
227 | 227 | bool checked = parameters["opengl"].toBool(); |
|
228 | 228 | m_openGLCheckBox->setChecked(checked); |
|
229 | 229 | } |
|
230 | 230 | if (parameters.contains("theme")) { |
|
231 | 231 | QString t = parameters["theme"].toString(); |
|
232 | 232 | for (int i = 0; i < m_themeComboBox->count(); ++i) { |
|
233 | 233 | if (m_themeComboBox->itemText(i) == t) { |
|
234 | 234 | m_themeComboBox->setCurrentIndex(i); |
|
235 | 235 | break; |
|
236 | 236 | } |
|
237 | 237 | } |
|
238 | 238 | } |
|
239 | 239 | if (parameters.contains("animation")) { |
|
240 | 240 | QString t = parameters["animation"].toString(); |
|
241 | 241 | for (int i = 0; i < m_animatedComboBox->count(); ++i) { |
|
242 | 242 | if (m_animatedComboBox->itemText(i) == t) { |
|
243 | 243 | m_animatedComboBox->setCurrentIndex(i); |
|
244 | 244 | break; |
|
245 | 245 | } |
|
246 | 246 | } |
|
247 | 247 | } |
|
248 | 248 | if (parameters.contains("legend")) { |
|
249 | 249 | QString t = parameters["legend"].toString(); |
|
250 | 250 | for (int i = 0; i < m_legendComboBox->count(); ++i) { |
|
251 | 251 | if (m_legendComboBox->itemText(i) == t) { |
|
252 | 252 | m_legendComboBox->setCurrentIndex(i); |
|
253 | 253 | break; |
|
254 | 254 | } |
|
255 | 255 | } |
|
256 | 256 | } |
|
257 | 257 | if (parameters.contains("view")) { |
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 | ||
|
262 | m_viewComboBox->setCurrentIndex(i); | |
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 | } | |
|
258 | int t = parameters["view"].toInt(); | |
|
259 | for (int i = 0; i < m_viewComboBox->count(); ++i) { | |
|
260 | if (m_viewComboBox->itemData(i).toInt() == t) { | |
|
261 | m_viewComboBox->setCurrentIndex(i); | |
|
262 | break; | |
|
263 | } | |
|
264 | } | |
|
265 | } | |
|
267 | 266 | } |
|
268 | 267 | |
|
269 | 268 | void Window::updateUI() |
|
270 | 269 | { |
|
271 | 270 | checkTemplate(); |
|
272 | 271 | checkView(); |
|
273 | 272 | checkOpenGL(); |
|
274 | 273 | checkTheme(); |
|
275 | 274 | checkAnimationOptions(); |
|
276 | 275 | checkLegend(); |
|
277 | 276 | checkState(); |
|
278 | 277 | } |
|
279 | 278 | |
|
280 | 279 | void Window::checkView() |
|
281 | 280 | { |
|
282 | 281 | int count(m_viewComboBox->itemData(m_viewComboBox->currentIndex()).toInt()); |
|
283 | 282 | m_grid->setSize(count); |
|
284 | 283 | } |
|
285 | 284 | |
|
286 | 285 | void Window::checkLegend() |
|
287 | 286 | { |
|
288 | 287 | Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); |
|
289 | 288 | |
|
290 | 289 | if (!alignment) { |
|
291 | 290 | foreach (QChart *chart, m_grid->charts()) |
|
292 | 291 | chart->legend()->hide(); |
|
293 | 292 | } else { |
|
294 | 293 | foreach (QChart *chart, m_grid->charts()) { |
|
295 | 294 | chart->legend()->setAlignment(alignment); |
|
296 | 295 | chart->legend()->show(); |
|
297 | 296 | } |
|
298 | 297 | } |
|
299 | 298 | } |
|
300 | 299 | |
|
301 | 300 | void Window::checkOpenGL() |
|
302 | 301 | { |
|
303 | 302 | bool opengl = m_openGLCheckBox->isChecked(); |
|
304 | 303 | bool isOpengl = qobject_cast<QGLWidget *>(m_view->viewport()); |
|
305 | 304 | if ((isOpengl && !opengl) || (!isOpengl && opengl)) { |
|
306 | 305 | m_view->deleteLater(); |
|
307 | 306 | m_view = new View(m_scene, m_form); |
|
308 | 307 | m_view->setViewport(!opengl ? new QWidget() : new QGLWidget()); |
|
309 | 308 | setCentralWidget(m_view); |
|
310 | 309 | } |
|
311 | 310 | |
|
312 | 311 | bool antialias = m_antialiasCheckBox->isChecked(); |
|
313 | 312 | |
|
314 | 313 | if (opengl) |
|
315 | 314 | m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); |
|
316 | 315 | else |
|
317 | 316 | m_view->setRenderHint(QPainter::Antialiasing, antialias); |
|
318 | 317 | } |
|
319 | 318 | |
|
320 | 319 | void Window::checkAnimationOptions() |
|
321 | 320 | { |
|
322 | 321 | QChart::AnimationOptions options( |
|
323 | 322 | m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); |
|
324 | 323 | |
|
325 | QList<QChart*> charts = m_grid->charts(); | |
|
324 | QList<QChart *> charts = m_grid->charts(); | |
|
326 | 325 | |
|
327 | 326 | if (!charts.isEmpty() && charts.at(0)->animationOptions() != options) { |
|
328 | 327 | foreach (QChart *chart, charts) |
|
329 | 328 | chart->setAnimationOptions(options); |
|
330 | 329 | } |
|
331 | 330 | } |
|
332 | 331 | |
|
333 | 332 | void Window::checkState() |
|
334 | 333 | { |
|
335 | 334 | bool scroll = m_scrollCheckBox->isChecked(); |
|
336 | 335 | |
|
337 | 336 | |
|
338 | 337 | if (m_grid->state() != Grid::ScrollState && scroll) { |
|
339 | 338 | m_grid->setState(Grid::ScrollState); |
|
340 | 339 | m_zoomCheckBox->setChecked(false); |
|
341 | 340 | } else if (!scroll && m_grid->state() == Grid::ScrollState) { |
|
342 | 341 | m_grid->setState(Grid::NoState); |
|
343 | 342 | } |
|
344 | 343 | |
|
345 | 344 | bool zoom = m_zoomCheckBox->isChecked(); |
|
346 | 345 | |
|
347 | 346 | if (m_grid->state() != Grid::ZoomState && zoom) { |
|
348 | 347 | m_grid->setState(Grid::ZoomState); |
|
349 | 348 | m_scrollCheckBox->setChecked(false); |
|
350 | 349 | } else if (!zoom && m_grid->state() == Grid::ZoomState) { |
|
351 | 350 | m_grid->setState(Grid::NoState); |
|
352 | 351 | } |
|
353 | 352 | } |
|
354 | 353 | |
|
355 | 354 | void Window::checkTemplate() |
|
356 | 355 | { |
|
357 | 356 | int index = m_templateComboBox->currentIndex(); |
|
358 | 357 | if (m_template == index || index == 0) |
|
359 | 358 | return; |
|
360 | 359 | |
|
361 | 360 | m_template = index; |
|
362 | 361 | QString category = m_templateComboBox->itemData(index).toString(); |
|
363 | 362 | m_grid->createCharts(category); |
|
364 | 363 | } |
|
365 | 364 | |
|
366 | 365 | void Window::checkTheme() |
|
367 | 366 | { |
|
368 | 367 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( |
|
369 | 368 | m_themeComboBox->currentIndex()).toInt(); |
|
370 | 369 | |
|
371 | 370 | foreach (QChart *chart, m_grid->charts()) |
|
372 | 371 | chart->setTheme(theme); |
|
373 | 372 | |
|
374 | 373 | QPalette pal = window()->palette(); |
|
375 | 374 | if (theme == QChart::ChartThemeLight) { |
|
376 | 375 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
377 | 376 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
378 | 377 | } else if (theme == QChart::ChartThemeDark) { |
|
379 | 378 | pal.setColor(QPalette::Window, QRgb(0x121218)); |
|
380 | 379 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
381 | 380 | } else if (theme == QChart::ChartThemeBlueCerulean) { |
|
382 | 381 | pal.setColor(QPalette::Window, QRgb(0x40434a)); |
|
383 | 382 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
384 | 383 | } else if (theme == QChart::ChartThemeBrownSand) { |
|
385 | 384 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); |
|
386 | 385 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
387 | 386 | } else if (theme == QChart::ChartThemeBlueNcs) { |
|
388 | 387 | pal.setColor(QPalette::Window, QRgb(0x018bba)); |
|
389 | 388 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
390 | 389 | } else if (theme == QChart::ChartThemeHighContrast) { |
|
391 | 390 | pal.setColor(QPalette::Window, QRgb(0xffab03)); |
|
392 | 391 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); |
|
393 | 392 | } else if (theme == QChart::ChartThemeBlueIcy) { |
|
394 | 393 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); |
|
395 | 394 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
396 | 395 | } else { |
|
397 | 396 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
398 | 397 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
399 | 398 | } |
|
400 | 399 | foreach (QGraphicsProxyWidget *widget, m_widgetHash) |
|
401 | 400 | widget->setPalette(pal); |
|
402 | 401 | m_view->setBackgroundBrush(pal.color((QPalette::Window))); |
|
403 | 402 | m_grid->setRubberPen(pal.color((QPalette::WindowText))); |
|
404 | 403 | } |
|
405 | 404 | |
|
406 | 405 | void Window::comboBoxFocused(QComboBox *combobox) |
|
407 | 406 | { |
|
408 | 407 | foreach (QGraphicsProxyWidget *widget , m_widgetHash) { |
|
409 | 408 | if (widget->widget() == combobox) |
|
410 | 409 | widget->setZValue(2.0); |
|
411 | 410 | else |
|
412 | 411 | widget->setZValue(0.0); |
|
413 | 412 | } |
|
414 | 413 | } |
|
415 | 414 | |
|
416 | 415 | void Window::handleChartSelected(QChart *qchart) |
|
417 | 416 | { |
|
418 |
if(m_templateComboBox->currentIndex() != 0) |
|
|
417 | if (m_templateComboBox->currentIndex() != 0) | |
|
418 | return; | |
|
419 | 419 | |
|
420 | 420 | QAction *chosen = m_menu->exec(QCursor::pos()); |
|
421 | 421 | |
|
422 | 422 | if (chosen) { |
|
423 | 423 | Chart *chart = (Chart *) chosen->data().value<void *>(); |
|
424 | m_grid->replaceChart(qchart,chart); | |
|
424 | m_grid->replaceChart(qchart, chart); | |
|
425 | 425 | updateUI(); |
|
426 | 426 | } |
|
427 | 427 | } |
|
428 | 428 | |
|
429 | 429 | QMenu *Window::createMenu() |
|
430 | 430 | { |
|
431 | 431 | Charts::ChartList list = Charts::chartList(); |
|
432 | 432 | QMultiMap<QString, Chart *> categoryMap; |
|
433 | 433 | |
|
434 | 434 | QMenu *result = new QMenu(this); |
|
435 | 435 | |
|
436 | 436 | foreach (Chart *chart, list) |
|
437 | 437 | categoryMap.insertMulti(chart->category(), chart); |
|
438 | 438 | |
|
439 | 439 | foreach (const QString &category, categoryMap.uniqueKeys()) { |
|
440 | 440 | QMenu *menu(0); |
|
441 | 441 | QMultiMap<QString, Chart *> subCategoryMap; |
|
442 | 442 | if (category.isEmpty()) { |
|
443 | 443 | menu = result; |
|
444 | 444 | } else { |
|
445 | 445 | menu = new QMenu(category, this); |
|
446 | 446 | result->addMenu(menu); |
|
447 | 447 | } |
|
448 | 448 | |
|
449 | 449 | foreach (Chart *chart, categoryMap.values(category)) |
|
450 | 450 | subCategoryMap.insert(chart->subCategory(), chart); |
|
451 | 451 | |
|
452 | 452 | foreach (const QString &subCategory, subCategoryMap.uniqueKeys()) { |
|
453 | 453 | QMenu *subMenu(0); |
|
454 | 454 | if (subCategory.isEmpty()) { |
|
455 | 455 | subMenu = menu; |
|
456 | 456 | } else { |
|
457 | 457 | subMenu = new QMenu(subCategory, this); |
|
458 | 458 | menu->addMenu(subMenu); |
|
459 | 459 | } |
|
460 | 460 | |
|
461 | 461 | foreach (Chart *chart, subCategoryMap.values(subCategory)) { |
|
462 | 462 | createMenuAction(subMenu, QIcon(), chart->name(), |
|
463 | 463 | qVariantFromValue((void *) chart)); |
|
464 | 464 | } |
|
465 | 465 | } |
|
466 | 466 | } |
|
467 | 467 | return result; |
|
468 | 468 | } |
|
469 | 469 | |
|
470 | 470 | QAction *Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, |
|
471 | 471 | const QVariant &data) |
|
472 | 472 | { |
|
473 | 473 | QAction *action = menu->addAction(icon, text); |
|
474 | 474 | action->setCheckable(false); |
|
475 | 475 | action->setData(data); |
|
476 | 476 | return action; |
|
477 | 477 | } |
|
478 | 478 | |
|
479 | 479 | void Window::handleGeometryChanged() |
|
480 | 480 | { |
|
481 | 481 | QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize); |
|
482 | 482 | m_view->scene()->setSceneRect(0, 0, this->width(), this->height()); |
|
483 | 483 | m_view->setMinimumSize(size.toSize()); |
|
484 | 484 | } |
@@ -1,114 +1,114 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef WINDOW_H |
|
22 | 22 | #define WINDOW_H |
|
23 | 23 | #include <QMainWindow> |
|
24 | 24 | #include <QChartGlobal> |
|
25 | 25 | #include <QHash> |
|
26 | 26 | #include <QComboBox> |
|
27 | 27 | |
|
28 | 28 | class QCheckBox; |
|
29 | 29 | class QGraphicsRectItem; |
|
30 | 30 | class QGraphicsScene; |
|
31 | 31 | class QGraphicsWidget; |
|
32 | 32 | class View; |
|
33 | 33 | class QGraphicsLinearLayout; |
|
34 | 34 | class Chart; |
|
35 | 35 | class Grid; |
|
36 | 36 | class QPushButton; |
|
37 | 37 | |
|
38 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | 39 | class QChart; |
|
40 | 40 | QTCOMMERCIALCHART_END_NAMESPACE |
|
41 | 41 | |
|
42 | 42 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
43 | 43 | |
|
44 | 44 | |
|
45 | 45 | class Window: public QMainWindow |
|
46 | 46 | { |
|
47 | 47 | Q_OBJECT |
|
48 | 48 | public: |
|
49 |
explicit Window(const QVariantHash& |
|
|
49 | explicit Window(const QVariantHash ¶meters, QWidget *parent = 0); | |
|
50 | 50 | ~Window(); |
|
51 | 51 | |
|
52 | 52 | private Q_SLOTS: |
|
53 | 53 | void updateUI(); |
|
54 | 54 | void handleGeometryChanged(); |
|
55 | 55 | void handleChartSelected(QChart *chart); |
|
56 | 56 | private: |
|
57 | 57 | QComboBox *createViewBox(); |
|
58 | 58 | QComboBox *createThemeBox(); |
|
59 | 59 | QComboBox *createAnimationBox(); |
|
60 | 60 | QComboBox *createLegendBox(); |
|
61 | 61 | QComboBox *createTempleteBox(); |
|
62 | 62 | void connectSignals(); |
|
63 | 63 | void createProxyWidgets(); |
|
64 | 64 | void comboBoxFocused(QComboBox *combox); |
|
65 | 65 | inline void checkAnimationOptions(); |
|
66 | 66 | inline void checkView(); |
|
67 | 67 | inline void checkLegend(); |
|
68 | 68 | inline void checkOpenGL(); |
|
69 | 69 | inline void checkTheme(); |
|
70 | 70 | inline void checkState(); |
|
71 | 71 | inline void checkTemplate(); |
|
72 | 72 | QMenu *createMenu(); |
|
73 | 73 | QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data); |
|
74 |
void initializeFromParamaters(const QVariantHash& |
|
|
74 | void initializeFromParamaters(const QVariantHash ¶meters); | |
|
75 | 75 | |
|
76 | 76 | private: |
|
77 | 77 | QGraphicsScene *m_scene; |
|
78 | 78 | View *m_view; |
|
79 | 79 | QHash<QString, QGraphicsProxyWidget *> m_widgetHash; |
|
80 | 80 | |
|
81 | 81 | QGraphicsWidget *m_form; |
|
82 | 82 | QComboBox *m_themeComboBox; |
|
83 | 83 | QCheckBox *m_antialiasCheckBox; |
|
84 | 84 | QComboBox *m_animatedComboBox; |
|
85 | 85 | QComboBox *m_legendComboBox; |
|
86 | 86 | QComboBox *m_templateComboBox; |
|
87 | 87 | QComboBox *m_viewComboBox; |
|
88 | 88 | QCheckBox *m_openGLCheckBox; |
|
89 | 89 | QCheckBox *m_zoomCheckBox; |
|
90 | 90 | QCheckBox *m_scrollCheckBox; |
|
91 | 91 | QGraphicsLinearLayout *m_baseLayout; |
|
92 | 92 | QMenu *m_menu; |
|
93 | 93 | int m_template; |
|
94 |
Grid* |
|
|
94 | Grid *m_grid; | |
|
95 | 95 | |
|
96 | 96 | friend class ComboBox; |
|
97 | 97 | }; |
|
98 | 98 | |
|
99 | 99 | class ComboBox: public QComboBox |
|
100 | 100 | { |
|
101 | 101 | public: |
|
102 | 102 | ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window) |
|
103 | 103 | {} |
|
104 | 104 | |
|
105 | 105 | protected: |
|
106 | 106 | void focusInEvent(QFocusEvent *e) { |
|
107 | 107 | QComboBox::focusInEvent(e); |
|
108 | 108 | m_window->comboBoxFocused(this); |
|
109 | 109 | } |
|
110 | 110 | private: |
|
111 | 111 | Window *m_window; |
|
112 | 112 | }; |
|
113 | 113 | |
|
114 | 114 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now