@@ -1,102 +1,100 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "qchartsplugin.h" |
|
19 | #include "qchartsplugin.h" | |
22 | #include <QtCharts/QChartView> |
|
20 | #include <QtCharts/QChartView> | |
23 | #include <QtCore/QtPlugin> |
|
21 | #include <QtCore/QtPlugin> | |
24 |
|
22 | |||
25 | QT_CHARTS_USE_NAMESPACE |
|
23 | QT_CHARTS_USE_NAMESPACE | |
26 |
|
24 | |||
27 | QChartsPlugin::QChartsPlugin(QObject *parent) : |
|
25 | QChartsPlugin::QChartsPlugin(QObject *parent) : | |
28 | QObject(parent) |
|
26 | QObject(parent) | |
29 | { |
|
27 | { | |
30 | } |
|
28 | } | |
31 |
|
29 | |||
32 | QChartsPlugin::~QChartsPlugin() |
|
30 | QChartsPlugin::~QChartsPlugin() | |
33 | { |
|
31 | { | |
34 | } |
|
32 | } | |
35 |
|
33 | |||
36 | QString QChartsPlugin::name() const |
|
34 | QString QChartsPlugin::name() const | |
37 | { |
|
35 | { | |
38 | return QStringLiteral("QtCharts::QChartView"); |
|
36 | return QStringLiteral("QtCharts::QChartView"); | |
39 | } |
|
37 | } | |
40 |
|
38 | |||
41 | QString QChartsPlugin::includeFile() const |
|
39 | QString QChartsPlugin::includeFile() const | |
42 | { |
|
40 | { | |
43 | #ifdef linux |
|
41 | #ifdef linux | |
44 | QString myNewLine = QStringLiteral("\n"); |
|
42 | QString myNewLine = QStringLiteral("\n"); | |
45 | #endif |
|
43 | #endif | |
46 | #ifdef WIN32 |
|
44 | #ifdef WIN32 | |
47 | QString myNewLine = QStringLiteral("\n\r"); |
|
45 | QString myNewLine = QStringLiteral("\n\r"); | |
48 | #endif |
|
46 | #endif | |
49 | #ifdef __APPLE__ |
|
47 | #ifdef __APPLE__ | |
50 | QString myNewLine = QStringLiteral("\n"); |
|
48 | QString myNewLine = QStringLiteral("\n"); | |
51 | #endif |
|
49 | #endif | |
52 | return QStringLiteral("<QtCharts/QChartView>") + myNewLine |
|
50 | return QStringLiteral("<QtCharts/QChartView>") + myNewLine | |
53 | + QStringLiteral("#include <chartsnamespace.h>"); |
|
51 | + QStringLiteral("#include <chartsnamespace.h>"); | |
54 | } |
|
52 | } | |
55 |
|
53 | |||
56 | QString QChartsPlugin::group() const |
|
54 | QString QChartsPlugin::group() const | |
57 | { |
|
55 | { | |
58 | return tr("Qt Charts Widgets"); |
|
56 | return tr("Qt Charts Widgets"); | |
59 | } |
|
57 | } | |
60 |
|
58 | |||
61 | QIcon QChartsPlugin::icon() const |
|
59 | QIcon QChartsPlugin::icon() const | |
62 | { |
|
60 | { | |
63 | return QIcon(QStringLiteral(":/images/qcharts.png")); |
|
61 | return QIcon(QStringLiteral(":/images/qcharts.png")); | |
64 | } |
|
62 | } | |
65 |
|
63 | |||
66 | QString QChartsPlugin::toolTip() const |
|
64 | QString QChartsPlugin::toolTip() const | |
67 | { |
|
65 | { | |
68 | return tr("A Qt Charts view widget"); |
|
66 | return tr("A Qt Charts view widget"); | |
69 | } |
|
67 | } | |
70 |
|
68 | |||
71 | QString QChartsPlugin::whatsThis() const |
|
69 | QString QChartsPlugin::whatsThis() const | |
72 | { |
|
70 | { | |
73 | return tr("This widget is presents QChartView widget"); |
|
71 | return tr("This widget is presents QChartView widget"); | |
74 | } |
|
72 | } | |
75 |
|
73 | |||
76 | bool QChartsPlugin::isContainer() const |
|
74 | bool QChartsPlugin::isContainer() const | |
77 | { |
|
75 | { | |
78 | return false; |
|
76 | return false; | |
79 | } |
|
77 | } | |
80 |
|
78 | |||
81 | QWidget *QChartsPlugin::createWidget(QWidget *parent) |
|
79 | QWidget *QChartsPlugin::createWidget(QWidget *parent) | |
82 | { |
|
80 | { | |
83 | return new QChartView(new QChart(), parent); |
|
81 | return new QChartView(new QChart(), parent); | |
84 | } |
|
82 | } | |
85 |
|
83 | |||
86 | QString QChartsPlugin::domXml() const |
|
84 | QString QChartsPlugin::domXml() const | |
87 | { |
|
85 | { | |
88 | return QStringLiteral("\ |
|
86 | return QStringLiteral("\ | |
89 | <ui language=\"c++\">\ |
|
87 | <ui language=\"c++\">\ | |
90 | <widget class=\"QtCharts::QChartView\" name=\"chartview\">\ |
|
88 | <widget class=\"QtCharts::QChartView\" name=\"chartview\">\ | |
91 | <property name=\"geometry\">\ |
|
89 | <property name=\"geometry\">\ | |
92 | <rect>\ |
|
90 | <rect>\ | |
93 | <x>0</x>\ |
|
91 | <x>0</x>\ | |
94 | <y>0</y>\ |
|
92 | <y>0</y>\ | |
95 | <width>200</width>\ |
|
93 | <width>200</width>\ | |
96 | <height>200</height>\ |
|
94 | <height>200</height>\ | |
97 | </rect>\ |
|
95 | </rect>\ | |
98 | </property>\ |
|
96 | </property>\ | |
99 | </widget>\ |
|
97 | </widget>\ | |
100 | </ui>"); |
|
98 | </ui>"); | |
101 | } |
|
99 | } | |
102 |
|
100 |
@@ -1,47 +1,45 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef QCHARTSPLUGIN_H |
|
19 | #ifndef QCHARTSPLUGIN_H | |
22 | #define QCHARTSPLUGIN_H |
|
20 | #define QCHARTSPLUGIN_H | |
23 |
|
21 | |||
24 | #include <QtDesigner/QDesignerCustomWidgetInterface> |
|
22 | #include <QtDesigner/QDesignerCustomWidgetInterface> | |
25 |
|
23 | |||
26 | class QChartsPlugin: public QObject, public QDesignerCustomWidgetInterface |
|
24 | class QChartsPlugin: public QObject, public QDesignerCustomWidgetInterface | |
27 | { |
|
25 | { | |
28 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") |
|
26 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") | |
29 |
|
27 | |||
30 | Q_OBJECT |
|
28 | Q_OBJECT | |
31 | Q_INTERFACES(QDesignerCustomWidgetInterface) |
|
29 | Q_INTERFACES(QDesignerCustomWidgetInterface) | |
32 | public: |
|
30 | public: | |
33 | QChartsPlugin(QObject *parent = 0); |
|
31 | QChartsPlugin(QObject *parent = 0); | |
34 | ~QChartsPlugin(); |
|
32 | ~QChartsPlugin(); | |
35 |
|
33 | |||
36 | QString name() const; |
|
34 | QString name() const; | |
37 | QString includeFile() const; |
|
35 | QString includeFile() const; | |
38 | QString group() const; |
|
36 | QString group() const; | |
39 | QIcon icon() const; |
|
37 | QIcon icon() const; | |
40 | QString toolTip() const; |
|
38 | QString toolTip() const; | |
41 | QString whatsThis() const; |
|
39 | QString whatsThis() const; | |
42 | bool isContainer() const; |
|
40 | bool isContainer() const; | |
43 | QWidget *createWidget(QWidget *parent); |
|
41 | QWidget *createWidget(QWidget *parent); | |
44 | QString domXml() const; |
|
42 | QString domXml() const; | |
45 | }; |
|
43 | }; | |
46 |
|
44 | |||
47 | #endif /* QCHARTSPLUGIN_H */ |
|
45 | #endif /* QCHARTSPLUGIN_H */ |
@@ -1,33 +1,31 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "brushwidget.h" |
|
19 | #include "brushwidget.h" | |
22 |
|
20 | |||
23 | BrushWidget::BrushWidget(QWidget *parent):QWidget(parent) |
|
21 | BrushWidget::BrushWidget(QWidget *parent):QWidget(parent) | |
24 | { |
|
22 | { | |
25 |
|
23 | |||
26 |
|
24 | |||
27 | } |
|
25 | } | |
28 |
|
26 | |||
29 | BrushWidget::~BrushWidget() |
|
27 | BrushWidget::~BrushWidget() | |
30 | { |
|
28 | { | |
31 |
|
29 | |||
32 | } |
|
30 | } | |
33 |
|
31 |
@@ -1,39 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef BRUSHWIDGET_H |
|
19 | #ifndef BRUSHWIDGET_H | |
22 | #define BRUSHWIDGET_H |
|
20 | #define BRUSHWIDGET_H | |
23 |
|
21 | |||
24 | #include <QtWidgets/QWidget> |
|
22 | #include <QtWidgets/QWidget> | |
25 |
|
23 | |||
26 | class BrushWidget: public QWidget |
|
24 | class BrushWidget: public QWidget | |
27 | { |
|
25 | { | |
28 | public: |
|
26 | public: | |
29 | explicit BrushWidget(QWidget *parent = 0); |
|
27 | explicit BrushWidget(QWidget *parent = 0); | |
30 | ~BrushWidget(); |
|
28 | ~BrushWidget(); | |
31 |
|
29 | |||
32 | QBrush brush() const { return m_brush; } |
|
30 | QBrush brush() const { return m_brush; } | |
33 | void setBrush(const QBrush &brush); |
|
31 | void setBrush(const QBrush &brush); | |
34 |
|
32 | |||
35 | private: |
|
33 | private: | |
36 | QBrush m_brush; |
|
34 | QBrush m_brush; | |
37 | }; |
|
35 | }; | |
38 |
|
36 | |||
39 | #endif /* BRUSHWIDGET_H */ |
|
37 | #endif /* BRUSHWIDGET_H */ |
@@ -1,343 +1,341 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 |
|
|
2 | ** | |
3 |
|
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 |
|
|
4 | ** All rights reserved. | |
5 |
|
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 |
|
|
6 | ** | |
7 |
|
|
7 | ** This file is part of the Qt Charts module. | |
8 |
|
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 |
|
|
13 | ** | |
15 |
|
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
|
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 |
|
|
16 | ** | |
19 |
|
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "engine.h" |
|
19 | #include "engine.h" | |
22 | #include <QtCore/QItemSelectionModel> |
|
20 | #include <QtCore/QItemSelectionModel> | |
23 | #include <QtGui/QStandardItemModel> |
|
21 | #include <QtGui/QStandardItemModel> | |
24 | #include <QtCharts/QVXYModelMapper> |
|
22 | #include <QtCharts/QVXYModelMapper> | |
25 | #include <QtCharts/QHBarModelMapper> |
|
23 | #include <QtCharts/QHBarModelMapper> | |
26 | #include <QtCharts/QVPieModelMapper> |
|
24 | #include <QtCharts/QVPieModelMapper> | |
27 | #include <QtCharts/QLineSeries> |
|
25 | #include <QtCharts/QLineSeries> | |
28 | #include <QtCharts/QSplineSeries> |
|
26 | #include <QtCharts/QSplineSeries> | |
29 | #include <QtCharts/QScatterSeries> |
|
27 | #include <QtCharts/QScatterSeries> | |
30 | #include <QtCharts/QBarSeries> |
|
28 | #include <QtCharts/QBarSeries> | |
31 | #include <QtCharts/QPercentBarSeries> |
|
29 | #include <QtCharts/QPercentBarSeries> | |
32 | #include <QtCharts/QStackedBarSeries> |
|
30 | #include <QtCharts/QStackedBarSeries> | |
33 | #include <QtCharts/QAreaSeries> |
|
31 | #include <QtCharts/QAreaSeries> | |
34 | #include <QtCharts/QPieSeries> |
|
32 | #include <QtCharts/QPieSeries> | |
35 | #include <QtCharts/QChart> |
|
33 | #include <QtCharts/QChart> | |
36 | #include <QtCharts/QBarSet> |
|
34 | #include <QtCharts/QBarSet> | |
37 |
|
35 | |||
38 |
|
36 | |||
39 | const qint32 MAGIC_NUMBER = 0x66666666; |
|
37 | const qint32 MAGIC_NUMBER = 0x66666666; | |
40 |
|
38 | |||
41 | Engine::Engine(QObject* parent) : |
|
39 | Engine::Engine(QObject* parent) : | |
42 | QObject(parent), m_count(10), m_chart(new QChart()), m_model(0), m_selection(0) |
|
40 | QObject(parent), m_count(10), m_chart(new QChart()), m_model(0), m_selection(0) | |
43 | { |
|
41 | { | |
44 | createModels(); |
|
42 | createModels(); | |
45 | } |
|
43 | } | |
46 |
|
44 | |||
47 | Engine::~Engine() |
|
45 | Engine::~Engine() | |
48 | { |
|
46 | { | |
49 | delete m_chart; |
|
47 | delete m_chart; | |
50 | delete m_selection; |
|
48 | delete m_selection; | |
51 | delete m_model; |
|
49 | delete m_model; | |
52 | } |
|
50 | } | |
53 |
|
51 | |||
54 | void Engine::createModels() |
|
52 | void Engine::createModels() | |
55 | { |
|
53 | { | |
56 | m_model = new QStandardItemModel(m_count, m_count); |
|
54 | m_model = new QStandardItemModel(m_count, m_count); | |
57 | m_model->setHorizontalHeaderLabels( |
|
55 | m_model->setHorizontalHeaderLabels( | |
58 | QStringList() << "A" << "B" << "C" << "D" << "E" << "F" << "G" << "H" << "I" << "J"); |
|
56 | QStringList() << "A" << "B" << "C" << "D" << "E" << "F" << "G" << "H" << "I" << "J"); | |
59 | m_model->setVerticalHeaderLabels( |
|
57 | m_model->setVerticalHeaderLabels( | |
60 | QStringList() << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10"); |
|
58 | QStringList() << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10"); | |
61 | m_selection = new QItemSelectionModel(m_model); |
|
59 | m_selection = new QItemSelectionModel(m_model); | |
62 |
|
60 | |||
63 | } |
|
61 | } | |
64 |
|
62 | |||
65 | QList<QAbstractSeries*> Engine::addSeries(QAbstractSeries::SeriesType type) |
|
63 | QList<QAbstractSeries*> Engine::addSeries(QAbstractSeries::SeriesType type) | |
66 | { |
|
64 | { | |
67 | const QModelIndexList& list = m_selection->selectedIndexes(); |
|
65 | const QModelIndexList& list = m_selection->selectedIndexes(); | |
68 |
|
66 | |||
69 | QMap<int, QModelIndex> columns; |
|
67 | QMap<int, QModelIndex> columns; | |
70 |
|
68 | |||
71 | foreach (const QModelIndex& index, list) { |
|
69 | foreach (const QModelIndex& index, list) { | |
72 | columns.insertMulti(index.column(), index); |
|
70 | columns.insertMulti(index.column(), index); | |
73 | } |
|
71 | } | |
74 |
|
72 | |||
75 | QList<int> keys = columns.uniqueKeys(); |
|
73 | QList<int> keys = columns.uniqueKeys(); | |
76 |
|
74 | |||
77 | QModelIndexList rows = columns.values(keys.first()); |
|
75 | QModelIndexList rows = columns.values(keys.first()); | |
78 |
|
76 | |||
79 | int minRow = m_count + 1; |
|
77 | int minRow = m_count + 1; | |
80 | int maxRow = -1; |
|
78 | int maxRow = -1; | |
81 |
|
79 | |||
82 | foreach (const QModelIndex& index, rows) { |
|
80 | foreach (const QModelIndex& index, rows) { | |
83 | minRow = qMin(index.row(), minRow); |
|
81 | minRow = qMin(index.row(), minRow); | |
84 | maxRow = qMax(index.row(), maxRow); |
|
82 | maxRow = qMax(index.row(), maxRow); | |
85 | } |
|
83 | } | |
86 |
|
84 | |||
87 | QList<QAbstractSeries*> result; |
|
85 | QList<QAbstractSeries*> result; | |
88 | QColor color; |
|
86 | QColor color; | |
89 |
|
87 | |||
90 | switch (type) { |
|
88 | switch (type) { | |
91 |
|
89 | |||
92 | case QAbstractSeries::SeriesTypeLine: |
|
90 | case QAbstractSeries::SeriesTypeLine: | |
93 | { |
|
91 | { | |
94 | for (int i = 1; i < keys.count(); ++i) { |
|
92 | for (int i = 1; i < keys.count(); ++i) { | |
95 | QLineSeries *line = new QLineSeries(); |
|
93 | QLineSeries *line = new QLineSeries(); | |
96 | setupXYSeries(line, keys, i, minRow, maxRow); |
|
94 | setupXYSeries(line, keys, i, minRow, maxRow); | |
97 | result << line; |
|
95 | result << line; | |
98 | } |
|
96 | } | |
99 | break; |
|
97 | break; | |
100 | } |
|
98 | } | |
101 | case QAbstractSeries::SeriesTypeSpline: |
|
99 | case QAbstractSeries::SeriesTypeSpline: | |
102 | { |
|
100 | { | |
103 | for (int i = 1; i < keys.count(); ++i) { |
|
101 | for (int i = 1; i < keys.count(); ++i) { | |
104 | QSplineSeries *line = new QSplineSeries(); |
|
102 | QSplineSeries *line = new QSplineSeries(); | |
105 | setupXYSeries(line, keys, i, minRow, maxRow); |
|
103 | setupXYSeries(line, keys, i, minRow, maxRow); | |
106 | result << line; |
|
104 | result << line; | |
107 | } |
|
105 | } | |
108 | break; |
|
106 | break; | |
109 | } |
|
107 | } | |
110 | case QAbstractSeries::SeriesTypeScatter: |
|
108 | case QAbstractSeries::SeriesTypeScatter: | |
111 | { |
|
109 | { | |
112 | for (int i = 1; i < keys.count(); ++i) { |
|
110 | for (int i = 1; i < keys.count(); ++i) { | |
113 | QScatterSeries *line = new QScatterSeries(); |
|
111 | QScatterSeries *line = new QScatterSeries(); | |
114 | setupXYSeries(line, keys, i, minRow, maxRow); |
|
112 | setupXYSeries(line, keys, i, minRow, maxRow); | |
115 | result << line; |
|
113 | result << line; | |
116 | } |
|
114 | } | |
117 | break; |
|
115 | break; | |
118 | } |
|
116 | } | |
119 | case QAbstractSeries::SeriesTypeBar: |
|
117 | case QAbstractSeries::SeriesTypeBar: | |
120 | { |
|
118 | { | |
121 | QBarSeries *bar = new QBarSeries(); |
|
119 | QBarSeries *bar = new QBarSeries(); | |
122 | setupBarSeries(bar,keys,minRow,maxRow); |
|
120 | setupBarSeries(bar,keys,minRow,maxRow); | |
123 | result << bar; |
|
121 | result << bar; | |
124 | break; |
|
122 | break; | |
125 | } |
|
123 | } | |
126 | case QAbstractSeries::SeriesTypePercentBar: |
|
124 | case QAbstractSeries::SeriesTypePercentBar: | |
127 | { |
|
125 | { | |
128 | QPercentBarSeries *bar = new QPercentBarSeries(); |
|
126 | QPercentBarSeries *bar = new QPercentBarSeries(); | |
129 | setupBarSeries(bar,keys,minRow,maxRow); |
|
127 | setupBarSeries(bar,keys,minRow,maxRow); | |
130 | result << bar; |
|
128 | result << bar; | |
131 | break; |
|
129 | break; | |
132 | } |
|
130 | } | |
133 | case QAbstractSeries::SeriesTypeStackedBar: |
|
131 | case QAbstractSeries::SeriesTypeStackedBar: | |
134 | { |
|
132 | { | |
135 | QStackedBarSeries *bar = new QStackedBarSeries(); |
|
133 | QStackedBarSeries *bar = new QStackedBarSeries(); | |
136 | setupBarSeries(bar,keys,minRow,maxRow); |
|
134 | setupBarSeries(bar,keys,minRow,maxRow); | |
137 | result << bar; |
|
135 | result << bar; | |
138 | break; |
|
136 | break; | |
139 | } |
|
137 | } | |
140 | case QAbstractSeries::SeriesTypePie: |
|
138 | case QAbstractSeries::SeriesTypePie: | |
141 | { |
|
139 | { | |
142 |
|
140 | |||
143 | QPieSeries *pie = new QPieSeries(); |
|
141 | QPieSeries *pie = new QPieSeries(); | |
144 | setupPieSeries(pie,keys,minRow,maxRow); |
|
142 | setupPieSeries(pie,keys,minRow,maxRow); | |
145 | result << pie; |
|
143 | result << pie; | |
146 | break; |
|
144 | break; | |
147 | } |
|
145 | } | |
148 | case QAbstractSeries::SeriesTypeArea: |
|
146 | case QAbstractSeries::SeriesTypeArea: | |
149 | { |
|
147 | { | |
150 | QAreaSeries *area = new QAreaSeries( new QLineSeries(), new QLineSeries()); |
|
148 | QAreaSeries *area = new QAreaSeries( new QLineSeries(), new QLineSeries()); | |
151 | setupAreaSeries(area,keys,minRow,maxRow); |
|
149 | setupAreaSeries(area,keys,minRow,maxRow); | |
152 | result << area; |
|
150 | result << area; | |
153 | break; |
|
151 | break; | |
154 | } |
|
152 | } | |
155 | } |
|
153 | } | |
156 |
|
154 | |||
157 | m_chart->createDefaultAxes(); |
|
155 | m_chart->createDefaultAxes(); | |
158 | return result; |
|
156 | return result; | |
159 | } |
|
157 | } | |
160 |
|
158 | |||
161 | void Engine::removeSeries(QAbstractSeries* series) |
|
159 | void Engine::removeSeries(QAbstractSeries* series) | |
162 | { |
|
160 | { | |
163 | m_chart->removeSeries(series); |
|
161 | m_chart->removeSeries(series); | |
164 |
|
162 | |||
165 | foreach (const QModelIndex& index, m_seriesModelIndex.value(series)) { |
|
163 | foreach (const QModelIndex& index, m_seriesModelIndex.value(series)) { | |
166 | m_model->setData(index, QColor(Qt::white), Qt::BackgroundRole); |
|
164 | m_model->setData(index, QColor(Qt::white), Qt::BackgroundRole); | |
167 | } |
|
165 | } | |
168 | } |
|
166 | } | |
169 |
|
167 | |||
170 | void Engine::clearModels() |
|
168 | void Engine::clearModels() | |
171 | { |
|
169 | { | |
172 | delete m_selection; |
|
170 | delete m_selection; | |
173 | m_selection = 0; |
|
171 | m_selection = 0; | |
174 | delete m_model; |
|
172 | delete m_model; | |
175 | m_model = 0; |
|
173 | m_model = 0; | |
176 | createModels(); |
|
174 | createModels(); | |
177 | } |
|
175 | } | |
178 |
|
176 | |||
179 | bool Engine::save(const QString &filename) const |
|
177 | bool Engine::save(const QString &filename) const | |
180 | { |
|
178 | { | |
181 | if (filename.isEmpty()) |
|
179 | if (filename.isEmpty()) | |
182 | return false; |
|
180 | return false; | |
183 |
|
181 | |||
184 | QFile file(filename); |
|
182 | QFile file(filename); | |
185 |
|
183 | |||
186 | if (!file.open(QIODevice::WriteOnly)) { |
|
184 | if (!file.open(QIODevice::WriteOnly)) { | |
187 | return false; |
|
185 | return false; | |
188 | } |
|
186 | } | |
189 |
|
187 | |||
190 | QDataStream out(&file); |
|
188 | QDataStream out(&file); | |
191 | out << MAGIC_NUMBER; |
|
189 | out << MAGIC_NUMBER; | |
192 | out.setVersion(QDataStream::Qt_4_8); |
|
190 | out.setVersion(QDataStream::Qt_4_8); | |
193 | out << m_model->rowCount(); |
|
191 | out << m_model->rowCount(); | |
194 | out << m_model->columnCount(); |
|
192 | out << m_model->columnCount(); | |
195 |
|
193 | |||
196 | for (int row = 0; row < m_model->rowCount(); ++row) { |
|
194 | for (int row = 0; row < m_model->rowCount(); ++row) { | |
197 | for (int column = 0; column < m_model->columnCount(); ++column) { |
|
195 | for (int column = 0; column < m_model->columnCount(); ++column) { | |
198 | QStandardItem *item = m_model->item(row, column); |
|
196 | QStandardItem *item = m_model->item(row, column); | |
199 | if (item) { |
|
197 | if (item) { | |
200 | out << row; |
|
198 | out << row; | |
201 | out << column; |
|
199 | out << column; | |
202 | out << item->data(Qt::EditRole).toString(); |
|
200 | out << item->data(Qt::EditRole).toString(); | |
203 | } |
|
201 | } | |
204 | } |
|
202 | } | |
205 | } |
|
203 | } | |
206 | return true; |
|
204 | return true; | |
207 | } |
|
205 | } | |
208 |
|
206 | |||
209 | bool Engine::load(const QString &filename) |
|
207 | bool Engine::load(const QString &filename) | |
210 | { |
|
208 | { | |
211 | clearModels(); |
|
209 | clearModels(); | |
212 |
|
210 | |||
213 | if (filename.isEmpty()) |
|
211 | if (filename.isEmpty()) | |
214 | return false; |
|
212 | return false; | |
215 |
|
213 | |||
216 | QFile file(filename); |
|
214 | QFile file(filename); | |
217 |
|
215 | |||
218 | if (!file.open(QIODevice::ReadOnly)) { |
|
216 | if (!file.open(QIODevice::ReadOnly)) { | |
219 | return false; |
|
217 | return false; | |
220 | } |
|
218 | } | |
221 |
|
219 | |||
222 | QDataStream in(&file); |
|
220 | QDataStream in(&file); | |
223 |
|
221 | |||
224 | qint32 magicNumber; |
|
222 | qint32 magicNumber; | |
225 | in >> magicNumber; |
|
223 | in >> magicNumber; | |
226 |
|
224 | |||
227 | if (magicNumber != MAGIC_NUMBER) |
|
225 | if (magicNumber != MAGIC_NUMBER) | |
228 | return false; |
|
226 | return false; | |
229 |
|
227 | |||
230 | in.setVersion(QDataStream::Qt_4_8); |
|
228 | in.setVersion(QDataStream::Qt_4_8); | |
231 |
|
229 | |||
232 | int rowCount; |
|
230 | int rowCount; | |
233 | in >> rowCount; |
|
231 | in >> rowCount; | |
234 |
|
232 | |||
235 | int columnCount; |
|
233 | int columnCount; | |
236 | in >> columnCount; |
|
234 | in >> columnCount; | |
237 |
|
235 | |||
238 | while (!in.atEnd()) { |
|
236 | while (!in.atEnd()) { | |
239 | int row; |
|
237 | int row; | |
240 | int column; |
|
238 | int column; | |
241 | QString value; |
|
239 | QString value; | |
242 | in >> row >> column >> value; |
|
240 | in >> row >> column >> value; | |
243 | QStandardItem *item = new QStandardItem(); |
|
241 | QStandardItem *item = new QStandardItem(); | |
244 | bool ok; |
|
242 | bool ok; | |
245 | double result = value.toDouble(&ok); |
|
243 | double result = value.toDouble(&ok); | |
246 | if(ok) |
|
244 | if(ok) | |
247 | item->setData(result, Qt::EditRole); |
|
245 | item->setData(result, Qt::EditRole); | |
248 | else |
|
246 | else | |
249 | item->setData(value, Qt::EditRole); |
|
247 | item->setData(value, Qt::EditRole); | |
250 | m_model->setItem(row, column, item); |
|
248 | m_model->setItem(row, column, item); | |
251 | } |
|
249 | } | |
252 |
|
250 | |||
253 | return true; |
|
251 | return true; | |
254 | } |
|
252 | } | |
255 |
|
253 | |||
256 | void Engine::setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int column, int minRow, int maxRow) |
|
254 | void Engine::setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int column, int minRow, int maxRow) | |
257 | { |
|
255 | { | |
258 | QVXYModelMapper* mapper = new QVXYModelMapper(xyseries); |
|
256 | QVXYModelMapper* mapper = new QVXYModelMapper(xyseries); | |
259 | mapper->setSeries(xyseries); |
|
257 | mapper->setSeries(xyseries); | |
260 | mapper->setModel(m_model); |
|
258 | mapper->setModel(m_model); | |
261 | mapper->setXColumn(columns.first()); |
|
259 | mapper->setXColumn(columns.first()); | |
262 | mapper->setYColumn(columns.at(column)); |
|
260 | mapper->setYColumn(columns.at(column)); | |
263 | mapper->setFirstRow(minRow); |
|
261 | mapper->setFirstRow(minRow); | |
264 | mapper->setRowCount(maxRow - minRow + 1); |
|
262 | mapper->setRowCount(maxRow - minRow + 1); | |
265 | m_chart->addSeries(xyseries); |
|
263 | m_chart->addSeries(xyseries); | |
266 | xyseries->setName(QString("Series %1").arg(m_chart->series().count())); |
|
264 | xyseries->setName(QString("Series %1").arg(m_chart->series().count())); | |
267 | QObject::connect(xyseries,SIGNAL(clicked(QPointF)),this,SIGNAL(selected())); |
|
265 | QObject::connect(xyseries,SIGNAL(clicked(QPointF)),this,SIGNAL(selected())); | |
268 | const QModelIndexList& list = m_selection->selectedIndexes(); |
|
266 | const QModelIndexList& list = m_selection->selectedIndexes(); | |
269 | QModelIndexList result; |
|
267 | QModelIndexList result; | |
270 | foreach (const QModelIndex& index, list) { |
|
268 | foreach (const QModelIndex& index, list) { | |
271 | if (index.column() ==columns.at(column)){ |
|
269 | if (index.column() ==columns.at(column)){ | |
272 | m_model->setData(index, xyseries->pen().color(), Qt::BackgroundRole); |
|
270 | m_model->setData(index, xyseries->pen().color(), Qt::BackgroundRole); | |
273 | result << index; |
|
271 | result << index; | |
274 | } |
|
272 | } | |
275 | } |
|
273 | } | |
276 | m_seriesModelIndex.insert(xyseries,result); |
|
274 | m_seriesModelIndex.insert(xyseries,result); | |
277 | } |
|
275 | } | |
278 |
|
276 | |||
279 | void Engine::setupBarSeries(QAbstractBarSeries *bar, const QList<int>& columns, int minRow, int maxRow) |
|
277 | void Engine::setupBarSeries(QAbstractBarSeries *bar, const QList<int>& columns, int minRow, int maxRow) | |
280 | { |
|
278 | { | |
281 | QHBarModelMapper* mapper = new QHBarModelMapper(bar); |
|
279 | QHBarModelMapper* mapper = new QHBarModelMapper(bar); | |
282 | mapper->setSeries(bar); |
|
280 | mapper->setSeries(bar); | |
283 | mapper->setModel(m_model); |
|
281 | mapper->setModel(m_model); | |
284 | mapper->setFirstColumn(minRow); |
|
282 | mapper->setFirstColumn(minRow); | |
285 | mapper->setColumnCount(maxRow - minRow + 1); |
|
283 | mapper->setColumnCount(maxRow - minRow + 1); | |
286 | mapper->setFirstBarSetRow(columns.at(1)); |
|
284 | mapper->setFirstBarSetRow(columns.at(1)); | |
287 | mapper->setLastBarSetRow(columns.last()); |
|
285 | mapper->setLastBarSetRow(columns.last()); | |
288 | m_chart->addSeries(bar); |
|
286 | m_chart->addSeries(bar); | |
289 | bar->setName(QString("Series %1").arg(m_chart->series().count())); |
|
287 | bar->setName(QString("Series %1").arg(m_chart->series().count())); | |
290 |
|
288 | |||
291 | const QModelIndexList& list = m_selection->selectedIndexes(); |
|
289 | const QModelIndexList& list = m_selection->selectedIndexes(); | |
292 | foreach (const QModelIndex& index, list) { |
|
290 | foreach (const QModelIndex& index, list) { | |
293 | if (index.column() >= columns.at(1) && index.column()<= columns.last()) { |
|
291 | if (index.column() >= columns.at(1) && index.column()<= columns.last()) { | |
294 | //m_model->setData(index, bar->barSets().at(index.column())->brush().color(), Qt::BackgroundRole); |
|
292 | //m_model->setData(index, bar->barSets().at(index.column())->brush().color(), Qt::BackgroundRole); | |
295 | } |
|
293 | } | |
296 | } |
|
294 | } | |
297 | } |
|
295 | } | |
298 |
|
296 | |||
299 | void Engine::setupPieSeries(QPieSeries *pie, const QList<int>& columns, int minRow, int maxRow) |
|
297 | void Engine::setupPieSeries(QPieSeries *pie, const QList<int>& columns, int minRow, int maxRow) | |
300 | { |
|
298 | { | |
301 | QVPieModelMapper* mapper = new QVPieModelMapper(pie); |
|
299 | QVPieModelMapper* mapper = new QVPieModelMapper(pie); | |
302 | mapper->setSeries(pie); |
|
300 | mapper->setSeries(pie); | |
303 | mapper->setModel(m_model); |
|
301 | mapper->setModel(m_model); | |
304 | mapper->setValuesColumn(columns.at(1)); |
|
302 | mapper->setValuesColumn(columns.at(1)); | |
305 | mapper->setLabelsColumn(columns.first()); |
|
303 | mapper->setLabelsColumn(columns.first()); | |
306 | mapper->setFirstRow(minRow); |
|
304 | mapper->setFirstRow(minRow); | |
307 | mapper->setRowCount(maxRow - minRow + 1); |
|
305 | mapper->setRowCount(maxRow - minRow + 1); | |
308 | m_chart->addSeries(pie); |
|
306 | m_chart->addSeries(pie); | |
309 | pie->setName(QString("Series %1").arg(m_chart->series().count())); |
|
307 | pie->setName(QString("Series %1").arg(m_chart->series().count())); | |
310 |
|
308 | |||
311 | const QModelIndexList& list = m_selection->selectedIndexes(); |
|
309 | const QModelIndexList& list = m_selection->selectedIndexes(); | |
312 | foreach (const QModelIndex& index, list) { |
|
310 | foreach (const QModelIndex& index, list) { | |
313 | // m_model->setData(index, bar->barSets()pen().color(), Qt::BackgroundRole); |
|
311 | // m_model->setData(index, bar->barSets()pen().color(), Qt::BackgroundRole); | |
314 | } |
|
312 | } | |
315 | } |
|
313 | } | |
316 |
|
314 | |||
317 | void Engine::setupAreaSeries(QAreaSeries *series, const QList<int>& columns, int minRow, int maxRow) |
|
315 | void Engine::setupAreaSeries(QAreaSeries *series, const QList<int>& columns, int minRow, int maxRow) | |
318 | { |
|
316 | { | |
319 | QVXYModelMapper* umapper = new QVXYModelMapper(series); |
|
317 | QVXYModelMapper* umapper = new QVXYModelMapper(series); | |
320 | umapper->setSeries(series->upperSeries()); |
|
318 | umapper->setSeries(series->upperSeries()); | |
321 | umapper->setModel(m_model); |
|
319 | umapper->setModel(m_model); | |
322 | umapper->setXColumn(columns.first()); |
|
320 | umapper->setXColumn(columns.first()); | |
323 | umapper->setYColumn(columns.at(1)); |
|
321 | umapper->setYColumn(columns.at(1)); | |
324 | umapper->setFirstRow(minRow); |
|
322 | umapper->setFirstRow(minRow); | |
325 | umapper->setRowCount(maxRow - minRow + 1); |
|
323 | umapper->setRowCount(maxRow - minRow + 1); | |
326 |
|
324 | |||
327 | QVXYModelMapper* lmapper = new QVXYModelMapper(series); |
|
325 | QVXYModelMapper* lmapper = new QVXYModelMapper(series); | |
328 | lmapper->setSeries(series->lowerSeries()); |
|
326 | lmapper->setSeries(series->lowerSeries()); | |
329 | lmapper->setModel(m_model); |
|
327 | lmapper->setModel(m_model); | |
330 | lmapper->setXColumn(columns.first()); |
|
328 | lmapper->setXColumn(columns.first()); | |
331 | lmapper->setYColumn(columns.at(2)); |
|
329 | lmapper->setYColumn(columns.at(2)); | |
332 | lmapper->setFirstRow(minRow); |
|
330 | lmapper->setFirstRow(minRow); | |
333 | lmapper->setRowCount(maxRow - minRow + 1); |
|
331 | lmapper->setRowCount(maxRow - minRow + 1); | |
334 |
|
332 | |||
335 | m_chart->addSeries(series); |
|
333 | m_chart->addSeries(series); | |
336 | series->setName(QString("Series %1").arg(m_chart->series().count())); |
|
334 | series->setName(QString("Series %1").arg(m_chart->series().count())); | |
337 |
|
335 | |||
338 | const QModelIndexList& list = m_selection->selectedIndexes(); |
|
336 | const QModelIndexList& list = m_selection->selectedIndexes(); | |
339 | foreach (const QModelIndex& index, list) { |
|
337 | foreach (const QModelIndex& index, list) { | |
340 | //if (index.column() ==columns.at(column)) |
|
338 | //if (index.column() ==columns.at(column)) | |
341 | // m_model->setData(index, xyseries->pen().color(), Qt::BackgroundRole); |
|
339 | // m_model->setData(index, xyseries->pen().color(), Qt::BackgroundRole); | |
342 | } |
|
340 | } | |
343 | } |
|
341 | } |
@@ -1,76 +1,74 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 |
|
|
2 | ** | |
3 |
|
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 |
|
|
4 | ** All rights reserved. | |
5 |
|
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 |
|
|
6 | ** | |
7 |
|
|
7 | ** This file is part of the Qt Charts module. | |
8 |
|
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 |
|
|
13 | ** | |
15 |
|
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
|
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 |
|
|
16 | ** | |
19 |
|
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef ENGINE_H |
|
19 | #ifndef ENGINE_H | |
22 | #define ENGINE_H |
|
20 | #define ENGINE_H | |
23 |
|
21 | |||
24 | #include <QtCore/QObject> |
|
22 | #include <QtCore/QObject> | |
25 | #include <QtCharts/QAbstractSeries> |
|
23 | #include <QtCharts/QAbstractSeries> | |
26 | #include <QtCore/QModelIndex> |
|
24 | #include <QtCore/QModelIndex> | |
27 |
|
25 | |||
28 | class QStandardItemModel; |
|
26 | class QStandardItemModel; | |
29 | class QItemSelectionModel; |
|
27 | class QItemSelectionModel; | |
30 |
|
28 | |||
31 |
|
29 | |||
32 | QT_CHARTS_BEGIN_NAMESPACE |
|
30 | QT_CHARTS_BEGIN_NAMESPACE | |
33 | class QChart; |
|
31 | class QChart; | |
34 | class QXYSeries; |
|
32 | class QXYSeries; | |
35 | class QAbstractBarSeries; |
|
33 | class QAbstractBarSeries; | |
36 | class QPieSeries; |
|
34 | class QPieSeries; | |
37 | class QAreaSeries; |
|
35 | class QAreaSeries; | |
38 | QT_CHARTS_END_NAMESPACE |
|
36 | QT_CHARTS_END_NAMESPACE | |
39 |
|
37 | |||
40 | QT_CHARTS_USE_NAMESPACE |
|
38 | QT_CHARTS_USE_NAMESPACE | |
41 |
|
39 | |||
42 | class Engine : public QObject |
|
40 | class Engine : public QObject | |
43 | { |
|
41 | { | |
44 | Q_OBJECT |
|
42 | Q_OBJECT | |
45 | public: |
|
43 | public: | |
46 | explicit Engine(QObject *parent = 0); |
|
44 | explicit Engine(QObject *parent = 0); | |
47 | ~Engine(); |
|
45 | ~Engine(); | |
48 |
|
46 | |||
49 | int modelCount() { return m_count; } |
|
47 | int modelCount() { return m_count; } | |
50 | QStandardItemModel *model() const { return m_model; } |
|
48 | QStandardItemModel *model() const { return m_model; } | |
51 | QItemSelectionModel *selectionModel() const { return m_selection; } |
|
49 | QItemSelectionModel *selectionModel() const { return m_selection; } | |
52 | QChart* chart() const { return m_chart; } |
|
50 | QChart* chart() const { return m_chart; } | |
53 | void clearModels(); |
|
51 | void clearModels(); | |
54 | QList<QAbstractSeries*> addSeries(QAbstractSeries::SeriesType type); |
|
52 | QList<QAbstractSeries*> addSeries(QAbstractSeries::SeriesType type); | |
55 | void removeSeries(QAbstractSeries* series); |
|
53 | void removeSeries(QAbstractSeries* series); | |
56 | bool save(const QString &filename) const; |
|
54 | bool save(const QString &filename) const; | |
57 | bool load(const QString &filename); |
|
55 | bool load(const QString &filename); | |
58 | signals: |
|
56 | signals: | |
59 | void selected(); |
|
57 | void selected(); | |
60 |
|
58 | |||
61 | private: |
|
59 | private: | |
62 | void createModels(); |
|
60 | void createModels(); | |
63 | void setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int column, int minRow, int maxRow); |
|
61 | void setupXYSeries(QXYSeries *xyseries, const QList<int>& columns, int column, int minRow, int maxRow); | |
64 | void setupBarSeries(QAbstractBarSeries *series, const QList<int>& columns, int minRow, int maxRow); |
|
62 | void setupBarSeries(QAbstractBarSeries *series, const QList<int>& columns, int minRow, int maxRow); | |
65 | void setupPieSeries(QPieSeries *pie, const QList<int>& columns, int minRow, int maxRow); |
|
63 | void setupPieSeries(QPieSeries *pie, const QList<int>& columns, int minRow, int maxRow); | |
66 | void setupAreaSeries(QAreaSeries *series, const QList<int>& columns, int minRow, int maxRow); |
|
64 | void setupAreaSeries(QAreaSeries *series, const QList<int>& columns, int minRow, int maxRow); | |
67 |
|
65 | |||
68 | private: |
|
66 | private: | |
69 | int m_count; |
|
67 | int m_count; | |
70 | QChart *m_chart; |
|
68 | QChart *m_chart; | |
71 | QStandardItemModel *m_model; |
|
69 | QStandardItemModel *m_model; | |
72 | QItemSelectionModel *m_selection; |
|
70 | QItemSelectionModel *m_selection; | |
73 | QMap<QAbstractSeries*, QList<QModelIndex> > m_seriesModelIndex; |
|
71 | QMap<QAbstractSeries*, QList<QModelIndex> > m_seriesModelIndex; | |
74 | }; |
|
72 | }; | |
75 |
|
73 | |||
76 | #endif /* ENGINE_H */ |
|
74 | #endif /* ENGINE_H */ |
@@ -1,32 +1,30 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "mainwindow.h" |
|
19 | #include "mainwindow.h" | |
22 | #include <QtWidgets/QApplication> |
|
20 | #include <QtWidgets/QApplication> | |
23 |
|
21 | |||
24 | int main(int argc, char *argv[]) |
|
22 | int main(int argc, char *argv[]) | |
25 | { |
|
23 | { | |
26 | QApplication a(argc, argv); |
|
24 | QApplication a(argc, argv); | |
27 |
|
25 | |||
28 | MainWindow window; |
|
26 | MainWindow window; | |
29 | window.resize(1000,600); |
|
27 | window.resize(1000,600); | |
30 | window.show(); |
|
28 | window.show(); | |
31 | return a.exec(); |
|
29 | return a.exec(); | |
32 | } |
|
30 | } |
@@ -1,423 +1,421 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 |
|
|
2 | ** | |
3 |
|
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 |
|
|
4 | ** All rights reserved. | |
5 |
|
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 |
|
|
6 | ** | |
7 |
|
|
7 | ** This file is part of the Qt Charts module. | |
8 |
|
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 |
|
|
13 | ** | |
15 |
|
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
|
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 |
|
|
16 | ** | |
19 |
|
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "mainwindow.h" |
|
19 | #include "mainwindow.h" | |
22 | #include "objectinspectorwidget.h" |
|
20 | #include "objectinspectorwidget.h" | |
23 | #include "penwidget.h" |
|
21 | #include "penwidget.h" | |
24 | #include "brushwidget.h" |
|
22 | #include "brushwidget.h" | |
25 | #include "engine.h" |
|
23 | #include "engine.h" | |
26 | #include <QtCore/QSettings> |
|
24 | #include <QtCore/QSettings> | |
27 | #include <QtCharts/QChartView> |
|
25 | #include <QtCharts/QChartView> | |
28 | #include <QtWidgets/QDockWidget> |
|
26 | #include <QtWidgets/QDockWidget> | |
29 | #include <QtWidgets/QMenuBar> |
|
27 | #include <QtWidgets/QMenuBar> | |
30 | #include <QtWidgets/QTableWidget> |
|
28 | #include <QtWidgets/QTableWidget> | |
31 | #include <QtWidgets/QSplitter> |
|
29 | #include <QtWidgets/QSplitter> | |
32 | #include <QtCore/QMetaEnum> |
|
30 | #include <QtCore/QMetaEnum> | |
33 | #include <QtGui/QStandardItemModel> |
|
31 | #include <QtGui/QStandardItemModel> | |
34 | #include <QtWidgets/QHeaderView> |
|
32 | #include <QtWidgets/QHeaderView> | |
35 | #include <QtCore/QDebug> |
|
33 | #include <QtCore/QDebug> | |
36 | #include <QtWidgets/QMessageBox> |
|
34 | #include <QtWidgets/QMessageBox> | |
37 |
|
35 | |||
38 | static const QString FILENAME_SETTING("filename"); |
|
36 | static const QString FILENAME_SETTING("filename"); | |
39 | static const QString GEOMETRY_SETTING("geometry"); |
|
37 | static const QString GEOMETRY_SETTING("geometry"); | |
40 |
|
38 | |||
41 | MainWindow::MainWindow() : |
|
39 | MainWindow::MainWindow() : | |
42 | m_engine(new Engine(this)), |
|
40 | m_engine(new Engine(this)), | |
43 | m_view(new QChartView(m_engine->chart())), |
|
41 | m_view(new QChartView(m_engine->chart())), | |
44 | m_scene(m_view->scene()), |
|
42 | m_scene(m_view->scene()), | |
45 | m_table(new QTableView()), |
|
43 | m_table(new QTableView()), | |
46 | m_addSeriesMenu(0), |
|
44 | m_addSeriesMenu(0), | |
47 | m_seriesMenu(0), |
|
45 | m_seriesMenu(0), | |
48 | m_chartMenu(0), |
|
46 | m_chartMenu(0), | |
49 | m_themeMenu(0), |
|
47 | m_themeMenu(0), | |
50 | m_animationMenu(0), |
|
48 | m_animationMenu(0), | |
51 | m_zoomMenu(0), |
|
49 | m_zoomMenu(0), | |
52 | m_removeAllAction(0), |
|
50 | m_removeAllAction(0), | |
53 | m_legendAction(0), |
|
51 | m_legendAction(0), | |
54 | m_antialiasingAction(0) |
|
52 | m_antialiasingAction(0) | |
55 | { |
|
53 | { | |
56 | createMenus(); |
|
54 | createMenus(); | |
57 | createDockWidgets(); |
|
55 | createDockWidgets(); | |
58 | createTable(); |
|
56 | createTable(); | |
59 | createLayout(); |
|
57 | createLayout(); | |
60 |
|
58 | |||
61 | QSettings settings; |
|
59 | QSettings settings; | |
62 | restoreGeometry(settings.value(GEOMETRY_SETTING).toByteArray()); |
|
60 | restoreGeometry(settings.value(GEOMETRY_SETTING).toByteArray()); | |
63 | m_filename = settings.value(FILENAME_SETTING).toString(); |
|
61 | m_filename = settings.value(FILENAME_SETTING).toString(); | |
64 | if (m_filename.isEmpty()) |
|
62 | if (m_filename.isEmpty()) | |
65 | m_filename = "untitled"; |
|
63 | m_filename = "untitled"; | |
66 |
|
64 | |||
67 | setWindowTitle(m_filename); |
|
65 | setWindowTitle(m_filename); | |
68 | updateUI(); |
|
66 | updateUI(); | |
69 | } |
|
67 | } | |
70 |
|
68 | |||
71 | MainWindow::~MainWindow() |
|
69 | MainWindow::~MainWindow() | |
72 | { |
|
70 | { | |
73 | delete m_engine; |
|
71 | delete m_engine; | |
74 | } |
|
72 | } | |
75 |
|
73 | |||
76 | void MainWindow::createMenus() |
|
74 | void MainWindow::createMenus() | |
77 | { |
|
75 | { | |
78 | QMenu *file = menuBar()->addMenu(tr("File")); |
|
76 | QMenu *file = menuBar()->addMenu(tr("File")); | |
79 | QMenu *edit = menuBar()->addMenu(tr("Edit")); |
|
77 | QMenu *edit = menuBar()->addMenu(tr("Edit")); | |
80 | m_seriesMenu = menuBar()->addMenu(tr("Series")); |
|
78 | m_seriesMenu = menuBar()->addMenu(tr("Series")); | |
81 | m_chartMenu = menuBar()->addMenu(tr("Chart")); |
|
79 | m_chartMenu = menuBar()->addMenu(tr("Chart")); | |
82 |
|
80 | |||
83 | m_addSeriesMenu = new QMenu(tr("Add series")); |
|
81 | m_addSeriesMenu = new QMenu(tr("Add series")); | |
84 | m_themeMenu = new QMenu(tr("Apply theme")); |
|
82 | m_themeMenu = new QMenu(tr("Apply theme")); | |
85 | m_animationMenu = new QMenu(tr("Animations")); |
|
83 | m_animationMenu = new QMenu(tr("Animations")); | |
86 | m_zoomMenu = new QMenu(tr("Zoom")); |
|
84 | m_zoomMenu = new QMenu(tr("Zoom")); | |
87 |
|
85 | |||
88 | file->addAction(tr("New"), this, SLOT(handleNewAction())); |
|
86 | file->addAction(tr("New"), this, SLOT(handleNewAction())); | |
89 | file->addAction(tr("Load"), this, SLOT(handleLoadAction())); |
|
87 | file->addAction(tr("Load"), this, SLOT(handleLoadAction())); | |
90 | file->addAction(tr("Save"), this, SLOT(handleSaveAction())); |
|
88 | file->addAction(tr("Save"), this, SLOT(handleSaveAction())); | |
91 | file->addAction(tr("Save As"), this, SLOT(handleSaveAsAction())); |
|
89 | file->addAction(tr("Save As"), this, SLOT(handleSaveAsAction())); | |
92 |
|
90 | |||
93 | //seriesMenu |
|
91 | //seriesMenu | |
94 | m_seriesMenu->addMenu(m_addSeriesMenu); |
|
92 | m_seriesMenu->addMenu(m_addSeriesMenu); | |
95 | m_removeAllAction = new QAction(tr("Remove all series"), this); |
|
93 | m_removeAllAction = new QAction(tr("Remove all series"), this); | |
96 | QObject::connect(m_removeAllAction, SIGNAL(triggered()), this, SLOT(handleRemoveAllSeriesAction())); |
|
94 | QObject::connect(m_removeAllAction, SIGNAL(triggered()), this, SLOT(handleRemoveAllSeriesAction())); | |
97 | m_seriesMenu->addAction(m_removeAllAction); |
|
95 | m_seriesMenu->addAction(m_removeAllAction); | |
98 | m_seriesMenu->addSeparator(); |
|
96 | m_seriesMenu->addSeparator(); | |
99 |
|
97 | |||
100 | //seriesMenu /addSeriesMenu |
|
98 | //seriesMenu /addSeriesMenu | |
101 | { |
|
99 | { | |
102 | int index = QAbstractSeries::staticMetaObject.indexOfEnumerator("SeriesType"); |
|
100 | int index = QAbstractSeries::staticMetaObject.indexOfEnumerator("SeriesType"); | |
103 | QMetaEnum metaEnum = QAbstractSeries::staticMetaObject.enumerator(index); |
|
101 | QMetaEnum metaEnum = QAbstractSeries::staticMetaObject.enumerator(index); | |
104 |
|
102 | |||
105 | int count = metaEnum.keyCount(); |
|
103 | int count = metaEnum.keyCount(); | |
106 |
|
104 | |||
107 | for (int i = 0; i < count; ++i) { |
|
105 | for (int i = 0; i < count; ++i) { | |
108 | QAction* action = new QAction(metaEnum.key(i), this); |
|
106 | QAction* action = new QAction(metaEnum.key(i), this); | |
109 | action->setData(metaEnum.value(i)); |
|
107 | action->setData(metaEnum.value(i)); | |
110 | m_addSeriesMenu->addAction(action); |
|
108 | m_addSeriesMenu->addAction(action); | |
111 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleAddSeriesMenu())); |
|
109 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleAddSeriesMenu())); | |
112 | } |
|
110 | } | |
113 | } |
|
111 | } | |
114 |
|
112 | |||
115 | //chartMenu / themeMenu |
|
113 | //chartMenu / themeMenu | |
116 | { |
|
114 | { | |
117 | m_chartMenu->addMenu(m_themeMenu); |
|
115 | m_chartMenu->addMenu(m_themeMenu); | |
118 | int index = QChart::staticMetaObject.indexOfEnumerator("ChartTheme"); |
|
116 | int index = QChart::staticMetaObject.indexOfEnumerator("ChartTheme"); | |
119 | QMetaEnum metaEnum = QChart::staticMetaObject.enumerator(index); |
|
117 | QMetaEnum metaEnum = QChart::staticMetaObject.enumerator(index); | |
120 |
|
118 | |||
121 | int count = metaEnum.keyCount(); |
|
119 | int count = metaEnum.keyCount(); | |
122 |
|
120 | |||
123 | for (int i = 0; i < count; ++i) { |
|
121 | for (int i = 0; i < count; ++i) { | |
124 | QAction* action = new QAction(metaEnum.key(i), this); |
|
122 | QAction* action = new QAction(metaEnum.key(i), this); | |
125 | action->setData(metaEnum.value(i)); |
|
123 | action->setData(metaEnum.value(i)); | |
126 | action->setCheckable(true); |
|
124 | action->setCheckable(true); | |
127 | m_themeMenu->addAction(action); |
|
125 | m_themeMenu->addAction(action); | |
128 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleThemeMenu())); |
|
126 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleThemeMenu())); | |
129 | } |
|
127 | } | |
130 | } |
|
128 | } | |
131 |
|
129 | |||
132 | //chartMenu / animationMenu |
|
130 | //chartMenu / animationMenu | |
133 | { |
|
131 | { | |
134 | m_chartMenu->addMenu(m_animationMenu); |
|
132 | m_chartMenu->addMenu(m_animationMenu); | |
135 | int index = QChart::staticMetaObject.indexOfEnumerator("AnimationOption"); |
|
133 | int index = QChart::staticMetaObject.indexOfEnumerator("AnimationOption"); | |
136 | QMetaEnum metaEnum = QChart::staticMetaObject.enumerator(index); |
|
134 | QMetaEnum metaEnum = QChart::staticMetaObject.enumerator(index); | |
137 |
|
135 | |||
138 | int count = metaEnum.keyCount(); |
|
136 | int count = metaEnum.keyCount(); | |
139 |
|
137 | |||
140 | for (int i = 0; i < count; ++i) { |
|
138 | for (int i = 0; i < count; ++i) { | |
141 | QAction* action = new QAction(metaEnum.key(i), this); |
|
139 | QAction* action = new QAction(metaEnum.key(i), this); | |
142 | action->setData(metaEnum.value(i)); |
|
140 | action->setData(metaEnum.value(i)); | |
143 | action->setCheckable(true); |
|
141 | action->setCheckable(true); | |
144 | m_animationMenu->addAction(action); |
|
142 | m_animationMenu->addAction(action); | |
145 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleAnimationMenu())); |
|
143 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleAnimationMenu())); | |
146 | } |
|
144 | } | |
147 | } |
|
145 | } | |
148 |
|
146 | |||
149 | //chartMenu / zoomMenu |
|
147 | //chartMenu / zoomMenu | |
150 | { |
|
148 | { | |
151 | m_chartMenu->addMenu(m_zoomMenu); |
|
149 | m_chartMenu->addMenu(m_zoomMenu); | |
152 | int index = QChartView::staticMetaObject.indexOfEnumerator("RubberBand"); |
|
150 | int index = QChartView::staticMetaObject.indexOfEnumerator("RubberBand"); | |
153 | QMetaEnum metaEnum = QChartView::staticMetaObject.enumerator(index); |
|
151 | QMetaEnum metaEnum = QChartView::staticMetaObject.enumerator(index); | |
154 |
|
152 | |||
155 | int count = metaEnum.keyCount(); |
|
153 | int count = metaEnum.keyCount(); | |
156 |
|
154 | |||
157 | for (int i = 0; i < count; ++i) { |
|
155 | for (int i = 0; i < count; ++i) { | |
158 | QAction* action = new QAction(metaEnum.key(i), this); |
|
156 | QAction* action = new QAction(metaEnum.key(i), this); | |
159 | action->setData(metaEnum.value(i)); |
|
157 | action->setData(metaEnum.value(i)); | |
160 | action->setCheckable(true); |
|
158 | action->setCheckable(true); | |
161 | m_zoomMenu->addAction(action); |
|
159 | m_zoomMenu->addAction(action); | |
162 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleZoomMenu())); |
|
160 | QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleZoomMenu())); | |
163 | } |
|
161 | } | |
164 | } |
|
162 | } | |
165 |
|
163 | |||
166 | //chartMenu / legend |
|
164 | //chartMenu / legend | |
167 | m_legendAction = new QAction(tr("Legend"), this); |
|
165 | m_legendAction = new QAction(tr("Legend"), this); | |
168 | m_legendAction->setCheckable(true); |
|
166 | m_legendAction->setCheckable(true); | |
169 | m_chartMenu->addAction(m_legendAction); |
|
167 | m_chartMenu->addAction(m_legendAction); | |
170 | QObject::connect(m_legendAction, SIGNAL(triggered()), this, SLOT(handleLegendAction())); |
|
168 | QObject::connect(m_legendAction, SIGNAL(triggered()), this, SLOT(handleLegendAction())); | |
171 |
|
169 | |||
172 | //chartMenu / Anti-aliasing |
|
170 | //chartMenu / Anti-aliasing | |
173 | m_antialiasingAction = new QAction(tr("Anti-aliasing"), this); |
|
171 | m_antialiasingAction = new QAction(tr("Anti-aliasing"), this); | |
174 | m_antialiasingAction->setCheckable(true); |
|
172 | m_antialiasingAction->setCheckable(true); | |
175 | m_chartMenu->addAction(m_antialiasingAction); |
|
173 | m_chartMenu->addAction(m_antialiasingAction); | |
176 | QObject::connect(m_antialiasingAction, SIGNAL(triggered()), this, SLOT(handleAntialiasingAction())); |
|
174 | QObject::connect(m_antialiasingAction, SIGNAL(triggered()), this, SLOT(handleAntialiasingAction())); | |
177 |
|
175 | |||
178 | } |
|
176 | } | |
179 |
|
177 | |||
180 | void MainWindow::createDockWidgets() |
|
178 | void MainWindow::createDockWidgets() | |
181 | { |
|
179 | { | |
182 | m_brushWidget = new BrushWidget(); |
|
180 | m_brushWidget = new BrushWidget(); | |
183 | QDockWidget *brushDockWidget = new QDockWidget(tr("Brush"), this); |
|
181 | QDockWidget *brushDockWidget = new QDockWidget(tr("Brush"), this); | |
184 | brushDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); |
|
182 | brushDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); | |
185 | brushDockWidget->setWidget(m_brushWidget); |
|
183 | brushDockWidget->setWidget(m_brushWidget); | |
186 | addDockWidget(Qt::RightDockWidgetArea, brushDockWidget); |
|
184 | addDockWidget(Qt::RightDockWidgetArea, brushDockWidget); | |
187 |
|
185 | |||
188 | m_penWidget = new PenWidget(); |
|
186 | m_penWidget = new PenWidget(); | |
189 | QDockWidget *penDockWidget = new QDockWidget(tr("Pen"), this); |
|
187 | QDockWidget *penDockWidget = new QDockWidget(tr("Pen"), this); | |
190 | penDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); |
|
188 | penDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); | |
191 | penDockWidget->setWidget(m_penWidget); |
|
189 | penDockWidget->setWidget(m_penWidget); | |
192 | addDockWidget(Qt::RightDockWidgetArea, penDockWidget); |
|
190 | addDockWidget(Qt::RightDockWidgetArea, penDockWidget); | |
193 |
|
191 | |||
194 | m_inspectorWidget = new InspectorWidget(); |
|
192 | m_inspectorWidget = new InspectorWidget(); | |
195 | QDockWidget *inspectorDockWidget = new QDockWidget(tr("Object Inspector"), this); |
|
193 | QDockWidget *inspectorDockWidget = new QDockWidget(tr("Object Inspector"), this); | |
196 | inspectorDockWidget->setFeatures( |
|
194 | inspectorDockWidget->setFeatures( | |
197 | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); |
|
195 | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); | |
198 | inspectorDockWidget->setWidget(m_inspectorWidget); |
|
196 | inspectorDockWidget->setWidget(m_inspectorWidget); | |
199 | addDockWidget(Qt::RightDockWidgetArea, inspectorDockWidget); |
|
197 | addDockWidget(Qt::RightDockWidgetArea, inspectorDockWidget); | |
200 |
|
198 | |||
201 | setDockOptions(QMainWindow::AnimatedDocks); |
|
199 | setDockOptions(QMainWindow::AnimatedDocks); | |
202 | } |
|
200 | } | |
203 |
|
201 | |||
204 | void MainWindow::createLayout() |
|
202 | void MainWindow::createLayout() | |
205 | { |
|
203 | { | |
206 | m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
|
204 | m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | |
207 |
|
205 | |||
208 | int rowHeight = m_table->rowHeight(0); |
|
206 | int rowHeight = m_table->rowHeight(0); | |
209 | int tableHeight = (m_engine->modelCount() * rowHeight) + m_table->horizontalHeader()->height() + 2 * m_table->frameWidth(); |
|
207 | int tableHeight = (m_engine->modelCount() * rowHeight) + m_table->horizontalHeader()->height() + 2 * m_table->frameWidth(); | |
210 |
|
208 | |||
211 | m_table->setMinimumHeight(tableHeight); |
|
209 | m_table->setMinimumHeight(tableHeight); | |
212 | m_table->setMaximumHeight(tableHeight); |
|
210 | m_table->setMaximumHeight(tableHeight); | |
213 |
|
211 | |||
214 | QSplitter *splitter = new QSplitter(this); |
|
212 | QSplitter *splitter = new QSplitter(this); | |
215 | splitter->setOrientation(Qt::Vertical); |
|
213 | splitter->setOrientation(Qt::Vertical); | |
216 | splitter->addWidget(m_table); |
|
214 | splitter->addWidget(m_table); | |
217 | splitter->addWidget(m_view); |
|
215 | splitter->addWidget(m_view); | |
218 | setCentralWidget(splitter); |
|
216 | setCentralWidget(splitter); | |
219 | m_view->hide(); |
|
217 | m_view->hide(); | |
220 | } |
|
218 | } | |
221 |
|
219 | |||
222 | void MainWindow::createTable() |
|
220 | void MainWindow::createTable() | |
223 | { |
|
221 | { | |
224 | m_table->setModel(m_engine->model()); |
|
222 | m_table->setModel(m_engine->model()); | |
225 | m_table->setSelectionModel(m_engine->selectionModel()); |
|
223 | m_table->setSelectionModel(m_engine->selectionModel()); | |
226 | QObject::connect(m_table->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,SLOT(updateUI())); |
|
224 | QObject::connect(m_table->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,SLOT(updateUI())); | |
227 | } |
|
225 | } | |
228 |
|
226 | |||
229 | void MainWindow::updateUI() |
|
227 | void MainWindow::updateUI() | |
230 | { |
|
228 | { | |
231 |
|
229 | |||
232 | QItemSelectionModel* selection = m_table->selectionModel(); |
|
230 | QItemSelectionModel* selection = m_table->selectionModel(); | |
233 | const QModelIndexList& list = selection->selectedIndexes(); |
|
231 | const QModelIndexList& list = selection->selectedIndexes(); | |
234 |
|
232 | |||
235 | QMap<int, QModelIndex> columns; |
|
233 | QMap<int, QModelIndex> columns; | |
236 |
|
234 | |||
237 | foreach (const QModelIndex& index, list) { |
|
235 | foreach (const QModelIndex& index, list) { | |
238 | columns.insertMulti(index.column(), index); |
|
236 | columns.insertMulti(index.column(), index); | |
239 | } |
|
237 | } | |
240 |
|
238 | |||
241 | QList<int> keys = columns.uniqueKeys(); |
|
239 | QList<int> keys = columns.uniqueKeys(); | |
242 |
|
240 | |||
243 | bool seriesEnabled = false; |
|
241 | bool seriesEnabled = false; | |
244 |
|
242 | |||
245 | foreach (QAction* action, m_addSeriesMenu->actions()) { |
|
243 | foreach (QAction* action, m_addSeriesMenu->actions()) { | |
246 | switch (action->data().toInt()) { |
|
244 | switch (action->data().toInt()) { | |
247 | case QAbstractSeries::SeriesTypeLine: |
|
245 | case QAbstractSeries::SeriesTypeLine: | |
248 | case QAbstractSeries::SeriesTypeSpline: |
|
246 | case QAbstractSeries::SeriesTypeSpline: | |
249 | case QAbstractSeries::SeriesTypeScatter: |
|
247 | case QAbstractSeries::SeriesTypeScatter: | |
250 | action->setEnabled(list.count() > 0 && keys.count() >= 2); |
|
248 | action->setEnabled(list.count() > 0 && keys.count() >= 2); | |
251 | seriesEnabled |= action->isEnabled(); |
|
249 | seriesEnabled |= action->isEnabled(); | |
252 | break; |
|
250 | break; | |
253 | case QAbstractSeries::SeriesTypeBar: |
|
251 | case QAbstractSeries::SeriesTypeBar: | |
254 | case QAbstractSeries::SeriesTypePercentBar: |
|
252 | case QAbstractSeries::SeriesTypePercentBar: | |
255 | case QAbstractSeries::SeriesTypeStackedBar: |
|
253 | case QAbstractSeries::SeriesTypeStackedBar: | |
256 | action->setEnabled(list.count() > 0 && keys.count() >= 2); |
|
254 | action->setEnabled(list.count() > 0 && keys.count() >= 2); | |
257 | seriesEnabled |= action->isEnabled(); |
|
255 | seriesEnabled |= action->isEnabled(); | |
258 | break; |
|
256 | break; | |
259 | case QAbstractSeries::SeriesTypePie: |
|
257 | case QAbstractSeries::SeriesTypePie: | |
260 | action->setEnabled(list.count() > 0 && keys.count() == 2); |
|
258 | action->setEnabled(list.count() > 0 && keys.count() == 2); | |
261 | seriesEnabled |= action->isEnabled(); |
|
259 | seriesEnabled |= action->isEnabled(); | |
262 | break; |
|
260 | break; | |
263 | case QAbstractSeries::SeriesTypeArea: |
|
261 | case QAbstractSeries::SeriesTypeArea: | |
264 | action->setEnabled(list.count() > 0 && keys.count() == 3); |
|
262 | action->setEnabled(list.count() > 0 && keys.count() == 3); | |
265 | seriesEnabled |= action->isEnabled(); |
|
263 | seriesEnabled |= action->isEnabled(); | |
266 | break; |
|
264 | break; | |
267 | } |
|
265 | } | |
268 | } |
|
266 | } | |
269 |
|
267 | |||
270 | m_chartMenu->setEnabled(m_engine->chart()->series().count() > 0); |
|
268 | m_chartMenu->setEnabled(m_engine->chart()->series().count() > 0); | |
271 | m_seriesMenu->setEnabled(seriesEnabled || m_engine->chart()->series().count() > 0); |
|
269 | m_seriesMenu->setEnabled(seriesEnabled || m_engine->chart()->series().count() > 0); | |
272 | m_removeAllAction->setEnabled(m_engine->chart()->series().count() > 0); |
|
270 | m_removeAllAction->setEnabled(m_engine->chart()->series().count() > 0); | |
273 |
|
271 | |||
274 | int theme = m_engine->chart()->theme(); |
|
272 | int theme = m_engine->chart()->theme(); | |
275 | foreach (QAction* action, m_themeMenu->actions()) { |
|
273 | foreach (QAction* action, m_themeMenu->actions()) { | |
276 | action->setChecked(action->data().toInt() == theme); |
|
274 | action->setChecked(action->data().toInt() == theme); | |
277 | } |
|
275 | } | |
278 |
|
276 | |||
279 | int animation = m_engine->chart()->animationOptions(); |
|
277 | int animation = m_engine->chart()->animationOptions(); | |
280 | foreach (QAction* action, m_animationMenu->actions()) { |
|
278 | foreach (QAction* action, m_animationMenu->actions()) { | |
281 | action->setChecked(action->data().toInt() == animation); |
|
279 | action->setChecked(action->data().toInt() == animation); | |
282 | } |
|
280 | } | |
283 |
|
281 | |||
284 | int zoom = m_view->rubberBand(); |
|
282 | int zoom = m_view->rubberBand(); | |
285 | foreach (QAction* action, m_zoomMenu->actions()) { |
|
283 | foreach (QAction* action, m_zoomMenu->actions()) { | |
286 | action->setChecked(action->data().toInt() == zoom); |
|
284 | action->setChecked(action->data().toInt() == zoom); | |
287 | } |
|
285 | } | |
288 |
|
286 | |||
289 | m_legendAction->setChecked(m_engine->chart()->legend()->isVisible()); |
|
287 | m_legendAction->setChecked(m_engine->chart()->legend()->isVisible()); | |
290 | m_antialiasingAction->setChecked(m_view->renderHints().testFlag(QPainter::Antialiasing)); |
|
288 | m_antialiasingAction->setChecked(m_view->renderHints().testFlag(QPainter::Antialiasing)); | |
291 |
|
289 | |||
292 | foreach (QAction *action, m_seriesMenu->actions()) { |
|
290 | foreach (QAction *action, m_seriesMenu->actions()) { | |
293 | //TODO: visibility handling |
|
291 | //TODO: visibility handling | |
294 | //if (m_series.value(action->text())) |
|
292 | //if (m_series.value(action->text())) | |
295 | // ; |
|
293 | // ; | |
296 | //action->setChecked(false); |
|
294 | //action->setChecked(false); | |
297 | } |
|
295 | } | |
298 | } |
|
296 | } | |
299 |
|
297 | |||
300 | void MainWindow::closeEvent(QCloseEvent *event) |
|
298 | void MainWindow::closeEvent(QCloseEvent *event) | |
301 | { |
|
299 | { | |
302 | QSettings settings; |
|
300 | QSettings settings; | |
303 | settings.setValue(GEOMETRY_SETTING, saveGeometry()); |
|
301 | settings.setValue(GEOMETRY_SETTING, saveGeometry()); | |
304 | settings.setValue(FILENAME_SETTING, m_filename); |
|
302 | settings.setValue(FILENAME_SETTING, m_filename); | |
305 | QMainWindow::closeEvent(event); |
|
303 | QMainWindow::closeEvent(event); | |
306 | } |
|
304 | } | |
307 |
|
305 | |||
308 | //handlers |
|
306 | //handlers | |
309 |
|
307 | |||
310 | void MainWindow::handleNewAction() |
|
308 | void MainWindow::handleNewAction() | |
311 | { |
|
309 | { | |
312 | m_engine->chart()->removeAllSeries(); |
|
310 | m_engine->chart()->removeAllSeries(); | |
313 | m_view->hide(); |
|
311 | m_view->hide(); | |
314 | m_engine->clearModels(); |
|
312 | m_engine->clearModels(); | |
315 | createTable(); |
|
313 | createTable(); | |
316 | m_filename = "untitled"; |
|
314 | m_filename = "untitled"; | |
317 | setWindowTitle(m_filename); |
|
315 | setWindowTitle(m_filename); | |
318 | updateUI(); |
|
316 | updateUI(); | |
319 | } |
|
317 | } | |
320 |
|
318 | |||
321 | void MainWindow::handleAddSeriesMenu() |
|
319 | void MainWindow::handleAddSeriesMenu() | |
322 | { |
|
320 | { | |
323 | m_view->show(); |
|
321 | m_view->show(); | |
324 | QAction* action = qobject_cast<QAction*>(sender()); |
|
322 | QAction* action = qobject_cast<QAction*>(sender()); | |
325 | QList<QAbstractSeries*> series = m_engine->addSeries(QAbstractSeries::SeriesType(action->data().toInt())); |
|
323 | QList<QAbstractSeries*> series = m_engine->addSeries(QAbstractSeries::SeriesType(action->data().toInt())); | |
326 |
|
324 | |||
327 | foreach (QAbstractSeries* s , series) |
|
325 | foreach (QAbstractSeries* s , series) | |
328 | { |
|
326 | { | |
329 | QAction *newAction = new QAction(s->name(),this); |
|
327 | QAction *newAction = new QAction(s->name(),this); | |
330 | //newAction->setCheckable(true); |
|
328 | //newAction->setCheckable(true); | |
331 | m_series.insert(s->name(),s); |
|
329 | m_series.insert(s->name(),s); | |
332 | m_seriesMenu->addAction(newAction); |
|
330 | m_seriesMenu->addAction(newAction); | |
333 | } |
|
331 | } | |
334 |
|
332 | |||
335 | updateUI(); |
|
333 | updateUI(); | |
336 | } |
|
334 | } | |
337 |
|
335 | |||
338 | void MainWindow::handleRemoveAllSeriesAction() |
|
336 | void MainWindow::handleRemoveAllSeriesAction() | |
339 | { |
|
337 | { | |
340 |
|
338 | |||
341 | foreach (QAction* action, m_seriesMenu->actions()){ |
|
339 | foreach (QAction* action, m_seriesMenu->actions()){ | |
342 | if(m_series.contains(action->text())){ |
|
340 | if(m_series.contains(action->text())){ | |
343 | m_seriesMenu->removeAction(action); |
|
341 | m_seriesMenu->removeAction(action); | |
344 | m_engine->removeSeries(m_series.value(action->text())); |
|
342 | m_engine->removeSeries(m_series.value(action->text())); | |
345 | delete action; |
|
343 | delete action; | |
346 | } |
|
344 | } | |
347 | } |
|
345 | } | |
348 |
|
346 | |||
349 | m_series.clear(); |
|
347 | m_series.clear(); | |
350 |
|
348 | |||
351 | m_view->hide(); |
|
349 | m_view->hide(); | |
352 | updateUI(); |
|
350 | updateUI(); | |
353 | } |
|
351 | } | |
354 |
|
352 | |||
355 | void MainWindow::handleThemeMenu() |
|
353 | void MainWindow::handleThemeMenu() | |
356 | { |
|
354 | { | |
357 | QAction* action = qobject_cast<QAction*>(sender()); |
|
355 | QAction* action = qobject_cast<QAction*>(sender()); | |
358 | m_engine->chart()->setTheme(QChart::ChartTheme(action->data().toInt())); |
|
356 | m_engine->chart()->setTheme(QChart::ChartTheme(action->data().toInt())); | |
359 | updateUI(); |
|
357 | updateUI(); | |
360 | } |
|
358 | } | |
361 |
|
359 | |||
362 | void MainWindow::handleAnimationMenu() |
|
360 | void MainWindow::handleAnimationMenu() | |
363 | { |
|
361 | { | |
364 | QAction* action = qobject_cast<QAction*>(sender()); |
|
362 | QAction* action = qobject_cast<QAction*>(sender()); | |
365 | m_engine->chart()->setAnimationOptions(QChart::AnimationOption(action->data().toInt())); |
|
363 | m_engine->chart()->setAnimationOptions(QChart::AnimationOption(action->data().toInt())); | |
366 | updateUI(); |
|
364 | updateUI(); | |
367 | } |
|
365 | } | |
368 |
|
366 | |||
369 | void MainWindow::handleZoomMenu() |
|
367 | void MainWindow::handleZoomMenu() | |
370 | { |
|
368 | { | |
371 | QAction* action = qobject_cast<QAction*>(sender()); |
|
369 | QAction* action = qobject_cast<QAction*>(sender()); | |
372 | m_view->setRubberBand(QChartView::RubberBand(action->data().toInt())); |
|
370 | m_view->setRubberBand(QChartView::RubberBand(action->data().toInt())); | |
373 | updateUI(); |
|
371 | updateUI(); | |
374 | } |
|
372 | } | |
375 |
|
373 | |||
376 | void MainWindow::handleAntialiasingAction() |
|
374 | void MainWindow::handleAntialiasingAction() | |
377 | { |
|
375 | { | |
378 | QAction* action = qobject_cast<QAction*>(sender()); |
|
376 | QAction* action = qobject_cast<QAction*>(sender()); | |
379 | if (action->isChecked()) { |
|
377 | if (action->isChecked()) { | |
380 | m_view->setRenderHint(QPainter::Antialiasing, true); |
|
378 | m_view->setRenderHint(QPainter::Antialiasing, true); | |
381 | } |
|
379 | } | |
382 | else { |
|
380 | else { | |
383 | m_view->setRenderHint(QPainter::Antialiasing, false); |
|
381 | m_view->setRenderHint(QPainter::Antialiasing, false); | |
384 | } |
|
382 | } | |
385 | } |
|
383 | } | |
386 |
|
384 | |||
387 | void MainWindow::handleLegendAction() |
|
385 | void MainWindow::handleLegendAction() | |
388 | { |
|
386 | { | |
389 | QAction* action = qobject_cast<QAction*>(sender()); |
|
387 | QAction* action = qobject_cast<QAction*>(sender()); | |
390 | if (action->isChecked()) { |
|
388 | if (action->isChecked()) { | |
391 | m_engine->chart()->legend()->setVisible(true); |
|
389 | m_engine->chart()->legend()->setVisible(true); | |
392 | } |
|
390 | } | |
393 | else { |
|
391 | else { | |
394 | m_engine->chart()->legend()->setVisible(false); |
|
392 | m_engine->chart()->legend()->setVisible(false); | |
395 | } |
|
393 | } | |
396 | } |
|
394 | } | |
397 |
|
395 | |||
398 | void MainWindow::handleSaveAction() |
|
396 | void MainWindow::handleSaveAction() | |
399 | { |
|
397 | { | |
400 | if(!m_engine->save(m_filename)) { |
|
398 | if(!m_engine->save(m_filename)) { | |
401 |
|
399 | |||
402 | QScopedPointer<QMessageBox> messageBox(new QMessageBox(this)); |
|
400 | QScopedPointer<QMessageBox> messageBox(new QMessageBox(this)); | |
403 | messageBox->setIcon(QMessageBox::Warning); |
|
401 | messageBox->setIcon(QMessageBox::Warning); | |
404 | messageBox->setWindowModality(Qt::WindowModal); |
|
402 | messageBox->setWindowModality(Qt::WindowModal); | |
405 | messageBox->setWindowTitle(QString(tr("Error"))); |
|
403 | messageBox->setWindowTitle(QString(tr("Error"))); | |
406 | messageBox->setText(tr("Could not write to ") + m_filename); |
|
404 | messageBox->setText(tr("Could not write to ") + m_filename); | |
407 | messageBox->exec(); |
|
405 | messageBox->exec(); | |
408 | } |
|
406 | } | |
409 | } |
|
407 | } | |
410 |
|
408 | |||
411 | void MainWindow::handleLoadAction() |
|
409 | void MainWindow::handleLoadAction() | |
412 | { |
|
410 | { | |
413 | if(!m_engine->load(m_filename)) { |
|
411 | if(!m_engine->load(m_filename)) { | |
414 |
|
412 | |||
415 | QScopedPointer<QMessageBox> messageBox(new QMessageBox(this)); |
|
413 | QScopedPointer<QMessageBox> messageBox(new QMessageBox(this)); | |
416 | messageBox->setIcon(QMessageBox::Warning); |
|
414 | messageBox->setIcon(QMessageBox::Warning); | |
417 | messageBox->setWindowModality(Qt::WindowModal); |
|
415 | messageBox->setWindowModality(Qt::WindowModal); | |
418 | messageBox->setWindowTitle(QString(tr("Error"))); |
|
416 | messageBox->setWindowTitle(QString(tr("Error"))); | |
419 | messageBox->setText(tr("Could not open ") + m_filename); |
|
417 | messageBox->setText(tr("Could not open ") + m_filename); | |
420 | messageBox->exec(); |
|
418 | messageBox->exec(); | |
421 |
|
419 | |||
422 | }else createTable(); |
|
420 | }else createTable(); | |
423 | } |
|
421 | } |
@@ -1,97 +1,95 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef MAINWINDOW_H |
|
19 | #ifndef MAINWINDOW_H | |
22 | #define MAINWINDOW_H |
|
20 | #define MAINWINDOW_H | |
23 |
|
21 | |||
24 | #include <QtWidgets/QMainWindow> |
|
22 | #include <QtWidgets/QMainWindow> | |
25 | #include <QtCharts/QChartGlobal> |
|
23 | #include <QtCharts/QChartGlobal> | |
26 | #include <QtCore/QMap> |
|
24 | #include <QtCore/QMap> | |
27 |
|
25 | |||
28 |
|
26 | |||
29 | QT_CHARTS_BEGIN_NAMESPACE |
|
27 | QT_CHARTS_BEGIN_NAMESPACE | |
30 | class QChartView; |
|
28 | class QChartView; | |
31 | class QAbstractSeries; |
|
29 | class QAbstractSeries; | |
32 | QT_CHARTS_END_NAMESPACE |
|
30 | QT_CHARTS_END_NAMESPACE | |
33 |
|
31 | |||
34 | class QGraphicsScene; |
|
32 | class QGraphicsScene; | |
35 | class InspectorWidget; |
|
33 | class InspectorWidget; | |
36 | class BrushWidget; |
|
34 | class BrushWidget; | |
37 | class PenWidget; |
|
35 | class PenWidget; | |
38 | class QTableView; |
|
36 | class QTableView; | |
39 | class Engine; |
|
37 | class Engine; | |
40 |
|
38 | |||
41 | QT_CHARTS_USE_NAMESPACE |
|
39 | QT_CHARTS_USE_NAMESPACE | |
42 |
|
40 | |||
43 | class MainWindow : public QMainWindow |
|
41 | class MainWindow : public QMainWindow | |
44 | { |
|
42 | { | |
45 | Q_OBJECT |
|
43 | Q_OBJECT | |
46 | public: |
|
44 | public: | |
47 | MainWindow(); |
|
45 | MainWindow(); | |
48 | ~MainWindow(); |
|
46 | ~MainWindow(); | |
49 |
|
47 | |||
50 | private slots: |
|
48 | private slots: | |
51 | void handleNewAction(); |
|
49 | void handleNewAction(); | |
52 | void handleAddSeriesMenu(); |
|
50 | void handleAddSeriesMenu(); | |
53 | void handleRemoveAllSeriesAction(); |
|
51 | void handleRemoveAllSeriesAction(); | |
54 | void updateUI(); |
|
52 | void updateUI(); | |
55 | void handleThemeMenu(); |
|
53 | void handleThemeMenu(); | |
56 | void handleAnimationMenu(); |
|
54 | void handleAnimationMenu(); | |
57 | void handleZoomMenu(); |
|
55 | void handleZoomMenu(); | |
58 | void handleAntialiasingAction(); |
|
56 | void handleAntialiasingAction(); | |
59 | void handleLegendAction(); |
|
57 | void handleLegendAction(); | |
60 | void handleSaveAction(); |
|
58 | void handleSaveAction(); | |
61 | void handleLoadAction(); |
|
59 | void handleLoadAction(); | |
62 |
|
60 | |||
63 | protected: |
|
61 | protected: | |
64 | void closeEvent(QCloseEvent *event); |
|
62 | void closeEvent(QCloseEvent *event); | |
65 |
|
63 | |||
66 | private: |
|
64 | private: | |
67 | void createMenus(); |
|
65 | void createMenus(); | |
68 | void createDockWidgets(); |
|
66 | void createDockWidgets(); | |
69 | void createModel(); |
|
67 | void createModel(); | |
70 | void createLayout(); |
|
68 | void createLayout(); | |
71 | void createTable(); |
|
69 | void createTable(); | |
72 |
|
70 | |||
73 | private: |
|
71 | private: | |
74 | Engine *m_engine; |
|
72 | Engine *m_engine; | |
75 | QChartView *m_view; |
|
73 | QChartView *m_view; | |
76 | QGraphicsScene *m_scene; |
|
74 | QGraphicsScene *m_scene; | |
77 | QTableView *m_table; |
|
75 | QTableView *m_table; | |
78 | InspectorWidget *m_inspectorWidget; |
|
76 | InspectorWidget *m_inspectorWidget; | |
79 | PenWidget *m_penWidget; |
|
77 | PenWidget *m_penWidget; | |
80 | BrushWidget *m_brushWidget; |
|
78 | BrushWidget *m_brushWidget; | |
81 | QMenu *m_addSeriesMenu; |
|
79 | QMenu *m_addSeriesMenu; | |
82 | QMenu *m_seriesMenu; |
|
80 | QMenu *m_seriesMenu; | |
83 | QMenu *m_chartMenu; |
|
81 | QMenu *m_chartMenu; | |
84 | QMenu *m_themeMenu; |
|
82 | QMenu *m_themeMenu; | |
85 | QMenu *m_animationMenu; |
|
83 | QMenu *m_animationMenu; | |
86 | QMenu *m_zoomMenu; |
|
84 | QMenu *m_zoomMenu; | |
87 |
|
85 | |||
88 | QAction *m_removeAllAction; |
|
86 | QAction *m_removeAllAction; | |
89 | QAction *m_legendAction; |
|
87 | QAction *m_legendAction; | |
90 | QAction *m_antialiasingAction; |
|
88 | QAction *m_antialiasingAction; | |
91 | QString m_filename; |
|
89 | QString m_filename; | |
92 |
|
90 | |||
93 | QMap<QString,QAbstractSeries*> m_series; |
|
91 | QMap<QString,QAbstractSeries*> m_series; | |
94 |
|
92 | |||
95 | }; |
|
93 | }; | |
96 |
|
94 | |||
97 | #endif /* MAINWINDOW_H */ |
|
95 | #endif /* MAINWINDOW_H */ |
@@ -1,51 +1,49 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "objectinspectorwidget.h" |
|
19 | #include "objectinspectorwidget.h" | |
22 | #include <QtGui/QIcon> |
|
20 | #include <QtGui/QIcon> | |
23 | #include <QtGui/QPainter> |
|
21 | #include <QtGui/QPainter> | |
24 | #include <QtGui/QPixmapCache> |
|
22 | #include <QtGui/QPixmapCache> | |
25 |
|
23 | |||
26 | InspectorWidget::InspectorWidget() |
|
24 | InspectorWidget::InspectorWidget() | |
27 | { |
|
25 | { | |
28 |
|
26 | |||
29 | } |
|
27 | } | |
30 |
|
28 | |||
31 | InspectorWidget::~InspectorWidget() |
|
29 | InspectorWidget::~InspectorWidget() | |
32 | { |
|
30 | { | |
33 |
|
31 | |||
34 | } |
|
32 | } | |
35 |
|
33 | |||
36 | QIcon InspectorWidget::getColorIcon(const QColor& color,const QSize &size) const |
|
34 | QIcon InspectorWidget::getColorIcon(const QColor& color,const QSize &size) const | |
37 | { |
|
35 | { | |
38 |
|
36 | |||
39 | QString key = QString("COLOR_ICON=%1:%2x%3").arg(color.name()).arg(size.width()).arg(size.height()); |
|
37 | QString key = QString("COLOR_ICON=%1:%2x%3").arg(color.name()).arg(size.width()).arg(size.height()); | |
40 |
|
38 | |||
41 | QPixmap pixmap(size); |
|
39 | QPixmap pixmap(size); | |
42 |
|
40 | |||
43 | if (!QPixmapCache::find(key, &pixmap)) { |
|
41 | if (!QPixmapCache::find(key, &pixmap)) { | |
44 | pixmap.fill(Qt::white); |
|
42 | pixmap.fill(Qt::white); | |
45 | QPainter painter(&pixmap); |
|
43 | QPainter painter(&pixmap); | |
46 | painter.fillRect(2, 2, 46, 46, color); |
|
44 | painter.fillRect(2, 2, 46, 46, color); | |
47 | QPixmapCache::insert(key, pixmap); |
|
45 | QPixmapCache::insert(key, pixmap); | |
48 | } |
|
46 | } | |
49 |
|
47 | |||
50 | return QIcon(pixmap); |
|
48 | return QIcon(pixmap); | |
51 | } |
|
49 | } |
@@ -1,37 +1,35 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef INSPECTORWIDGET_H |
|
19 | #ifndef INSPECTORWIDGET_H | |
22 | #define INSPECTORWIDGET_H |
|
20 | #define INSPECTORWIDGET_H | |
23 |
|
21 | |||
24 | #include <QtWidgets/QWidget> |
|
22 | #include <QtWidgets/QWidget> | |
25 |
|
23 | |||
26 | class InspectorWidget : public QWidget |
|
24 | class InspectorWidget : public QWidget | |
27 | { |
|
25 | { | |
28 | public: |
|
26 | public: | |
29 | InspectorWidget(); |
|
27 | InspectorWidget(); | |
30 | ~InspectorWidget(); |
|
28 | ~InspectorWidget(); | |
31 |
|
29 | |||
32 | private: |
|
30 | private: | |
33 | QIcon getColorIcon(const QColor& color,const QSize &size) const; |
|
31 | QIcon getColorIcon(const QColor& color,const QSize &size) const; | |
34 |
|
32 | |||
35 | }; |
|
33 | }; | |
36 |
|
34 | |||
37 | #endif |
|
35 | #endif |
@@ -1,56 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "penwidget.h" |
|
19 | #include "penwidget.h" | |
22 | #include <QtWidgets/QFormLayout> |
|
20 | #include <QtWidgets/QFormLayout> | |
23 | #include <QtWidgets/QComboBox> |
|
21 | #include <QtWidgets/QComboBox> | |
24 | #include <QtWidgets/QSpinBox> |
|
22 | #include <QtWidgets/QSpinBox> | |
25 |
|
23 | |||
26 | PenWidget::PenWidget(QWidget *parent):QWidget(parent), |
|
24 | PenWidget::PenWidget(QWidget *parent):QWidget(parent), | |
27 | m_colorComboBox(0), |
|
25 | m_colorComboBox(0), | |
28 | m_lineStyleComboBox(0), |
|
26 | m_lineStyleComboBox(0), | |
29 | m_widthSpinBox(0) |
|
27 | m_widthSpinBox(0) | |
30 | { |
|
28 | { | |
31 | createContent(); |
|
29 | createContent(); | |
32 | createLayout(); |
|
30 | createLayout(); | |
33 | setFixedSize(minimumSizeHint()); |
|
31 | setFixedSize(minimumSizeHint()); | |
34 | } |
|
32 | } | |
35 |
|
33 | |||
36 | PenWidget::~PenWidget() |
|
34 | PenWidget::~PenWidget() | |
37 | { |
|
35 | { | |
38 |
|
36 | |||
39 | } |
|
37 | } | |
40 |
|
38 | |||
41 | void PenWidget::createContent() |
|
39 | void PenWidget::createContent() | |
42 | { |
|
40 | { | |
43 | m_colorComboBox = new QComboBox(this); |
|
41 | m_colorComboBox = new QComboBox(this); | |
44 | m_lineStyleComboBox = new QComboBox(this); |
|
42 | m_lineStyleComboBox = new QComboBox(this); | |
45 | m_widthSpinBox = new QSpinBox(this); |
|
43 | m_widthSpinBox = new QSpinBox(this); | |
46 | } |
|
44 | } | |
47 |
|
45 | |||
48 | void PenWidget::createLayout() |
|
46 | void PenWidget::createLayout() | |
49 | { |
|
47 | { | |
50 | QFormLayout *layout = new QFormLayout(); |
|
48 | QFormLayout *layout = new QFormLayout(); | |
51 | layout->addRow(tr("Color"), m_colorComboBox); |
|
49 | layout->addRow(tr("Color"), m_colorComboBox); | |
52 | layout->addRow(tr("Style"), m_lineStyleComboBox); |
|
50 | layout->addRow(tr("Style"), m_lineStyleComboBox); | |
53 | layout->addRow(tr("Width"), m_widthSpinBox); |
|
51 | layout->addRow(tr("Width"), m_widthSpinBox); | |
54 | setLayout(layout); |
|
52 | setLayout(layout); | |
55 | } |
|
53 | } | |
56 |
|
54 |
@@ -1,48 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef PENWIDGET_H |
|
19 | #ifndef PENWIDGET_H | |
22 | #define PENWIDGET_H |
|
20 | #define PENWIDGET_H | |
23 |
|
21 | |||
24 | #include <QtWidgets/QWidget> |
|
22 | #include <QtWidgets/QWidget> | |
25 | #include <QtWidgets/QPen> |
|
23 | #include <QtWidgets/QPen> | |
26 |
|
24 | |||
27 | class QComboBox; |
|
25 | class QComboBox; | |
28 | class QSpinBox; |
|
26 | class QSpinBox; | |
29 |
|
27 | |||
30 | class PenWidget : public QWidget |
|
28 | class PenWidget : public QWidget | |
31 | { |
|
29 | { | |
32 | public: |
|
30 | public: | |
33 | explicit PenWidget(QWidget* parent = 0); |
|
31 | explicit PenWidget(QWidget* parent = 0); | |
34 | ~PenWidget(); |
|
32 | ~PenWidget(); | |
35 |
|
33 | |||
36 | QPen pen() const { return m_pen; } |
|
34 | QPen pen() const { return m_pen; } | |
37 | private: |
|
35 | private: | |
38 | void createContent(); |
|
36 | void createContent(); | |
39 | void createLayout(); |
|
37 | void createLayout(); | |
40 |
|
38 | |||
41 | private: |
|
39 | private: | |
42 | QPen m_pen; |
|
40 | QPen m_pen; | |
43 | QComboBox *m_colorComboBox; |
|
41 | QComboBox *m_colorComboBox; | |
44 | QComboBox *m_lineStyleComboBox; |
|
42 | QComboBox *m_lineStyleComboBox; | |
45 | QSpinBox *m_widthSpinBox; |
|
43 | QSpinBox *m_widthSpinBox; | |
46 | }; |
|
44 | }; | |
47 |
|
45 | |||
48 | #endif /* PENWIDGET_H */ |
|
46 | #endif /* PENWIDGET_H */ |
@@ -1,59 +1,57 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "graphicsbutton.h" |
|
19 | #include "graphicsbutton.h" | |
22 | #include <QPainter> |
|
20 | #include <QPainter> | |
23 | #include <QProcess> |
|
21 | #include <QProcess> | |
24 | #include <QMouseEvent> |
|
22 | #include <QMouseEvent> | |
25 |
|
23 | |||
26 | GraphicsButton::GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent) : |
|
24 | GraphicsButton::GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent) : | |
27 | QWidget(parent), |
|
25 | QWidget(parent), | |
28 | m_path(path), |
|
26 | m_path(path), | |
29 | m_appFolder(appFolder), |
|
27 | m_appFolder(appFolder), | |
30 | m_app(app), |
|
28 | m_app(app), | |
31 | m_demoApp(0) |
|
29 | m_demoApp(0) | |
32 | { |
|
30 | { | |
33 | m_pixmap = QPixmap(path); |
|
31 | m_pixmap = QPixmap(path); | |
34 | } |
|
32 | } | |
35 |
|
33 | |||
36 | GraphicsButton::~GraphicsButton() |
|
34 | GraphicsButton::~GraphicsButton() | |
37 | { |
|
35 | { | |
38 | if (m_demoApp) |
|
36 | if (m_demoApp) | |
39 | m_demoApp->close(); |
|
37 | m_demoApp->close(); | |
40 | } |
|
38 | } | |
41 |
|
39 | |||
42 | void GraphicsButton::mousePressEvent(QMouseEvent *event) |
|
40 | void GraphicsButton::mousePressEvent(QMouseEvent *event) | |
43 | { |
|
41 | { | |
44 | QString program = m_appFolder.absolutePath() + QDir::separator() + m_app; |
|
42 | QString program = m_appFolder.absolutePath() + QDir::separator() + m_app; | |
45 | if (m_demoApp) { |
|
43 | if (m_demoApp) { | |
46 | m_demoApp->close(); |
|
44 | m_demoApp->close(); | |
47 | delete m_demoApp; |
|
45 | delete m_demoApp; | |
48 | } |
|
46 | } | |
49 | m_demoApp = new QProcess(this); |
|
47 | m_demoApp = new QProcess(this); | |
50 | m_demoApp->start(program); |
|
48 | m_demoApp->start(program); | |
51 | event->accept(); |
|
49 | event->accept(); | |
52 | } |
|
50 | } | |
53 |
|
51 | |||
54 | void GraphicsButton::paintEvent(QPaintEvent *event) |
|
52 | void GraphicsButton::paintEvent(QPaintEvent *event) | |
55 | { |
|
53 | { | |
56 | QPainter painter(this); |
|
54 | QPainter painter(this); | |
57 | painter.drawPixmap(0, 0, this->width(), this->height(), m_pixmap); |
|
55 | painter.drawPixmap(0, 0, this->width(), this->height(), m_pixmap); | |
58 | QWidget::paintEvent(event); |
|
56 | QWidget::paintEvent(event); | |
59 | } |
|
57 | } |
@@ -1,48 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef GRAPHICSBUTTON_H |
|
19 | #ifndef GRAPHICSBUTTON_H | |
22 | #define GRAPHICSBUTTON_H |
|
20 | #define GRAPHICSBUTTON_H | |
23 |
|
21 | |||
24 | #include <QWidget> |
|
22 | #include <QWidget> | |
25 | #include <QDir> |
|
23 | #include <QDir> | |
26 |
|
24 | |||
27 | class QProcess; |
|
25 | class QProcess; | |
28 |
|
26 | |||
29 | class GraphicsButton : public QWidget |
|
27 | class GraphicsButton : public QWidget | |
30 | { |
|
28 | { | |
31 | Q_OBJECT |
|
29 | Q_OBJECT | |
32 | public: |
|
30 | public: | |
33 | explicit GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent = 0); |
|
31 | explicit GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent = 0); | |
34 | ~GraphicsButton(); |
|
32 | ~GraphicsButton(); | |
35 |
|
33 | |||
36 | protected: |
|
34 | protected: | |
37 | void mousePressEvent(QMouseEvent *event); |
|
35 | void mousePressEvent(QMouseEvent *event); | |
38 | void paintEvent(QPaintEvent *event); |
|
36 | void paintEvent(QPaintEvent *event); | |
39 |
|
37 | |||
40 | private: |
|
38 | private: | |
41 | QPixmap m_pixmap; |
|
39 | QPixmap m_pixmap; | |
42 | QString m_path; |
|
40 | QString m_path; | |
43 | QDir m_appFolder; |
|
41 | QDir m_appFolder; | |
44 | QString m_app; |
|
42 | QString m_app; | |
45 | QProcess *m_demoApp; |
|
43 | QProcess *m_demoApp; | |
46 | }; |
|
44 | }; | |
47 |
|
45 | |||
48 | #endif // GRAPHICSBUTTON_H |
|
46 | #endif // GRAPHICSBUTTON_H |
@@ -1,31 +1,29 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include <QApplication> |
|
19 | #include <QApplication> | |
22 | #include "widget.h" |
|
20 | #include "widget.h" | |
23 |
|
21 | |||
24 | int main(int argc, char *argv[]) |
|
22 | int main(int argc, char *argv[]) | |
25 | { |
|
23 | { | |
26 | QApplication a(argc, argv); |
|
24 | QApplication a(argc, argv); | |
27 | Widget w; |
|
25 | Widget w; | |
28 | w.show(); |
|
26 | w.show(); | |
29 |
|
27 | |||
30 | return a.exec(); |
|
28 | return a.exec(); | |
31 | } |
|
29 | } |
@@ -1,81 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #include "widget.h" |
|
19 | #include "widget.h" | |
22 | #include <QDir> |
|
20 | #include <QDir> | |
23 | #include <QGridLayout> |
|
21 | #include <QGridLayout> | |
24 | #include <QApplication> |
|
22 | #include <QApplication> | |
25 | #include "graphicsbutton.h" |
|
23 | #include "graphicsbutton.h" | |
26 |
|
24 | |||
27 | Widget::Widget(QWidget *parent) |
|
25 | Widget::Widget(QWidget *parent) | |
28 | : QWidget(parent) |
|
26 | : QWidget(parent) | |
29 | { |
|
27 | { | |
30 | setMinimumSize(800, 600); |
|
28 | setMinimumSize(800, 600); | |
31 |
|
29 | |||
32 | m_appFolder = QDir(QApplication::applicationDirPath()); |
|
30 | m_appFolder = QDir(QApplication::applicationDirPath()); | |
33 | #ifdef Q_OS_MAC |
|
31 | #ifdef Q_OS_MAC | |
34 | // The executable is inside an application bundle (a folder) on OSX |
|
32 | // The executable is inside an application bundle (a folder) on OSX | |
35 | m_appFolder.cdUp(); |
|
33 | m_appFolder.cdUp(); | |
36 | m_appFolder.cdUp(); |
|
34 | m_appFolder.cdUp(); | |
37 | m_appFolder.cdUp(); |
|
35 | m_appFolder.cdUp(); | |
38 | #endif |
|
36 | #endif | |
39 |
|
37 | |||
40 | QDir imageFolder = m_appFolder; |
|
38 | QDir imageFolder = m_appFolder; | |
41 | imageFolder.cdUp(); |
|
39 | imageFolder.cdUp(); | |
42 | imageFolder.cdUp(); |
|
40 | imageFolder.cdUp(); | |
43 | imageFolder.cd("doc"); |
|
41 | imageFolder.cd("doc"); | |
44 | imageFolder.cd("images"); |
|
42 | imageFolder.cd("images"); | |
45 |
|
43 | |||
46 | // Create push buttons for starting the executables |
|
44 | // Create push buttons for starting the executables | |
47 | QGridLayout* demosLayout = new QGridLayout; |
|
45 | QGridLayout* demosLayout = new QGridLayout; | |
48 |
|
46 | |||
49 | GraphicsButton *button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() + "examples_audio.png", m_appFolder, "audio", this); |
|
47 | GraphicsButton *button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() + "examples_audio.png", m_appFolder, "audio", this); | |
50 | demosLayout->addWidget(button, 0, 0); |
|
48 | demosLayout->addWidget(button, 0, 0); | |
51 |
|
49 | |||
52 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_callout.png", m_appFolder, "callout", this); |
|
50 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_callout.png", m_appFolder, "callout", this); | |
53 | demosLayout->addWidget(button, 0, 1); |
|
51 | demosLayout->addWidget(button, 0, 1); | |
54 |
|
52 | |||
55 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"demo_chartthemes_blue_cerulean.png", m_appFolder, "chartthemes", this); |
|
53 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"demo_chartthemes_blue_cerulean.png", m_appFolder, "chartthemes", this); | |
56 | demosLayout->addWidget(button, 0, 2); |
|
54 | demosLayout->addWidget(button, 0, 2); | |
57 |
|
55 | |||
58 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_nesteddonuts.png", m_appFolder, "nesteddonuts", this); |
|
56 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_nesteddonuts.png", m_appFolder, "nesteddonuts", this); | |
59 | demosLayout->addWidget(button, 1, 0); |
|
57 | demosLayout->addWidget(button, 1, 0); | |
60 |
|
58 | |||
61 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_zoomlinechart1.png", m_appFolder, "zoomlinechart", this); |
|
59 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_zoomlinechart1.png", m_appFolder, "zoomlinechart", this); | |
62 | demosLayout->addWidget(button, 1, 1); |
|
60 | demosLayout->addWidget(button, 1, 1); | |
63 |
|
61 | |||
64 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_stackedbarchartdrilldown1.png", m_appFolder, "stackedbarchartdrilldown", this); |
|
62 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_stackedbarchartdrilldown1.png", m_appFolder, "stackedbarchartdrilldown", this); | |
65 | demosLayout->addWidget(button, 1, 2); |
|
63 | demosLayout->addWidget(button, 1, 2); | |
66 |
|
64 | |||
67 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"piechart_customization.png", m_appFolder, "piechartcustomization", this); |
|
65 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"piechart_customization.png", m_appFolder, "piechartcustomization", this); | |
68 | demosLayout->addWidget(button, 2, 0); |
|
66 | demosLayout->addWidget(button, 2, 0); | |
69 |
|
67 | |||
70 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_datetimeaxis.png", m_appFolder, "datetimeaxis", this); |
|
68 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_datetimeaxis.png", m_appFolder, "datetimeaxis", this); | |
71 | demosLayout->addWidget(button, 2, 1); |
|
69 | demosLayout->addWidget(button, 2, 1); | |
72 |
|
70 | |||
73 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_donutbreakdown.png", m_appFolder, "donutbreakdown", this); |
|
71 | button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_donutbreakdown.png", m_appFolder, "donutbreakdown", this); | |
74 | demosLayout->addWidget(button, 2, 2); |
|
72 | demosLayout->addWidget(button, 2, 2); | |
75 |
|
73 | |||
76 | setLayout(demosLayout); |
|
74 | setLayout(demosLayout); | |
77 | } |
|
75 | } | |
78 |
|
76 | |||
79 | Widget::~Widget() |
|
77 | Widget::~Widget() | |
80 | { |
|
78 | { | |
81 | } |
|
79 | } |
@@ -1,39 +1,37 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 |
** For any questions to Digia, please use contact form at http://qt. |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 |
** This file is part of the Qt |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** agreement between you and Digia. | |
13 | ** a written agreement between you and Digia. |
|
|||
14 | ** |
|
13 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
16 |
** contact form at http://qt. |
|
15 | ** contact form at http://qt.io | |
17 | ** $QT_END_LICENSE$ |
|
|||
18 | ** |
|
16 | ** | |
19 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
20 |
|
18 | |||
21 | #ifndef WIDGET_H |
|
19 | #ifndef WIDGET_H | |
22 | #define WIDGET_H |
|
20 | #define WIDGET_H | |
23 |
|
21 | |||
24 | #include <QWidget> |
|
22 | #include <QWidget> | |
25 | #include <QDir> |
|
23 | #include <QDir> | |
26 |
|
24 | |||
27 | class Widget : public QWidget |
|
25 | class Widget : public QWidget | |
28 | { |
|
26 | { | |
29 | Q_OBJECT |
|
27 | Q_OBJECT | |
30 |
|
28 | |||
31 | public: |
|
29 | public: | |
32 | Widget(QWidget *parent = 0); |
|
30 | Widget(QWidget *parent = 0); | |
33 | ~Widget(); |
|
31 | ~Widget(); | |
34 |
|
32 | |||
35 | private: |
|
33 | private: | |
36 | QDir m_appFolder; |
|
34 | QDir m_appFolder; | |
37 | }; |
|
35 | }; | |
38 |
|
36 | |||
39 | #endif // WIDGET_H |
|
37 | #endif // WIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now