##// END OF EJS Templates
Added Vertical and Horizontal PieModelMapper
Marek Rosa -
r1237:64e92d4f2959
parent child
Show More
@@ -0,0 +1,33
1 #include "qhpiemodelmapper.h"
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
5 QHPieModelMapper::QHPieModelMapper(QObject *parent) :
6 QPieModelMapper(parent)
7 {
8 QPieModelMapper::setOrientation(Qt::Horizontal);
9 }
10
11 int QHPieModelMapper::valuesRow() const
12 {
13 return QPieModelMapper::valuesIndex();
14 }
15
16 void QHPieModelMapper::setValuesRow(int valuesRow)
17 {
18 QPieModelMapper::setValuesIndex(valuesRow);
19 }
20
21 int QHPieModelMapper::labelsRow() const
22 {
23 return QPieModelMapper::labelsIndex();
24 }
25
26 void QHPieModelMapper::setLabelsRow(int labelsRow)
27 {
28 QPieModelMapper::setLabelsIndex(labelsRow);
29 }
30
31 #include "moc_qhpiemodelmapper.cpp"
32
33 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,27
1 #ifndef QHPIEMODELMAPPER_H
2 #define QHPIEMODELMAPPER_H
3
4 #include "qpiemodelmapper.h"
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
8 class QTCOMMERCIALCHART_EXPORT QHPieModelMapper : public QPieModelMapper
9 {
10 Q_OBJECT
11 Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow)
12 Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow)
13
14 public:
15 QHPieModelMapper(QObject *parent = 0);
16
17 int valuesRow() const;
18 void setValuesRow(int valuesRow);
19
20 int labelsRow() const;
21 void setLabelsRow(int labelsRow);
22
23 };
24
25 QTCOMMERCIALCHART_END_NAMESPACE
26
27 #endif // QHPIEMODELMAPPER_H
@@ -0,0 +1,34
1 #include "qpiemodelmapper_p.h"
2 #include "qvpiemodelmapper.h"
3
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5
6 QVPieModelMapper::QVPieModelMapper(QObject *parent) :
7 QPieModelMapper(parent)
8 {
9 QPieModelMapper::setOrientation(Qt::Vertical);
10 }
11
12 int QVPieModelMapper::valuesColumn() const
13 {
14 return QPieModelMapper::valuesIndex();
15 }
16
17 void QVPieModelMapper::setValuesColumn(int valuesColumn)
18 {
19 QPieModelMapper::setValuesIndex(valuesColumn);
20 }
21
22 int QVPieModelMapper::labelsColumn() const
23 {
24 return QPieModelMapper::labelsIndex();
25 }
26
27 void QVPieModelMapper::setLabelsColumn(int labelsColumn)
28 {
29 QPieModelMapper::setLabelsIndex(labelsColumn);
30 }
31
32 #include "moc_qvpiemodelmapper.cpp"
33
34 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,26
1 #ifndef QVPIEMODELMAPPER_H
2 #define QVPIEMODELMAPPER_H
3
4 #include "qpiemodelmapper.h"
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
8 class QTCOMMERCIALCHART_EXPORT QVPieModelMapper : public QPieModelMapper
9 {
10 Q_OBJECT
11 Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn)
12 Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn)
13
14 public:
15 explicit QVPieModelMapper(QObject *parent = 0);
16
17 int valuesColumn() const;
18 void setValuesColumn(int valuesColumn);
19
20 int labelsColumn() const;
21 void setLabelsColumn(int labelsColumn);
22 };
23
24 QTCOMMERCIALCHART_END_NAMESPACE
25
26 #endif // QVPIEMODELMAPPER_H
@@ -1,21 +1,25
1 INCLUDEPATH += $$PWD
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
2 DEPENDPATH += $$PWD
3
3
4 SOURCES += \
4 SOURCES += \
5 $$PWD/qpieseries.cpp \
5 $$PWD/qpieseries.cpp \
6 $$PWD/piesliceitem.cpp \
6 $$PWD/piesliceitem.cpp \
7 $$PWD/piechartitem.cpp \
7 $$PWD/piechartitem.cpp \
8 $$PWD/qpieslice.cpp \
8 $$PWD/qpieslice.cpp \
9 $$PWD/qpiemodelmapper.cpp
9 $$PWD/qpiemodelmapper.cpp \
10 $$PWD/qvpiemodelmapper.cpp \
11 $$PWD/qhpiemodelmapper.cpp
10
12
11 PRIVATE_HEADERS += \
13 PRIVATE_HEADERS += \
12 $$PWD/pieslicedata_p.h \
14 $$PWD/pieslicedata_p.h \
13 $$PWD/piechartitem_p.h \
15 $$PWD/piechartitem_p.h \
14 $$PWD/piesliceitem_p.h \
16 $$PWD/piesliceitem_p.h \
15 $$PWD/qpieseries_p.h \
17 $$PWD/qpieseries_p.h \
16 $$PWD/qpiemodelmapper_p.h
18 $$PWD/qpiemodelmapper_p.h
17
19
18 PUBLIC_HEADERS += \
20 PUBLIC_HEADERS += \
19 $$PWD/qpieseries.h \
21 $$PWD/qpieseries.h \
20 $$PWD/qpieslice.h \
22 $$PWD/qpieslice.h \
21 $$PWD/qpiemodelmapper.h
23 $$PWD/qpiemodelmapper.h \
24 $$PWD/qvpiemodelmapper.h \
25 $$PWD/qhpiemodelmapper.h
@@ -1,57 +1,76
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 #ifndef QPIEMODELMAPPER_H
21 #ifndef QPIEMODELMAPPER_H
2 #define QPIEMODELMAPPER_H
22 #define QPIEMODELMAPPER_H
3
23
4 #include "qchartglobal.h"
24 #include "qchartglobal.h"
5 #include <QObject>
25 #include <QObject>
6
26
7 class QAbstractItemModel;
27 class QAbstractItemModel;
8
28
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
30
11 class QPieModelMapperPrivate;
31 class QPieModelMapperPrivate;
12 class QPieSeries;
32 class QPieSeries;
13
33
14 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
34 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
15 {
35 {
16 Q_OBJECT
36 Q_OBJECT
17 Q_PROPERTY(int valuesIndex READ valuesIndex WRITE setValuesIndex)
18 Q_PROPERTY(int labelsIndex READ labelsIndex WRITE setLabelsIndex)
19 Q_PROPERTY(int first READ first WRITE setFirst)
37 Q_PROPERTY(int first READ first WRITE setFirst)
20 Q_PROPERTY(int count READ count WRITE setCount)
38 Q_PROPERTY(int count READ count WRITE setCount)
21 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
22 Q_ENUMS(Qt::Orientation)
39 Q_ENUMS(Qt::Orientation)
23
40
24 public:
41 protected:
25 QPieModelMapper(QObject *parent = 0);
42 QPieModelMapper(QObject *parent = 0);
26
43
44 public:
27 QAbstractItemModel* model() const;
45 QAbstractItemModel* model() const;
28 void setModel(QAbstractItemModel *model);
46 void setModel(QAbstractItemModel *model);
29
47
30 QPieSeries* series() const;
48 QPieSeries* series() const;
31 void setSeries(QPieSeries *series);
49 void setSeries(QPieSeries *series);
32
50
33 int first() const;
51 int first() const;
34 void setFirst(int first);
52 void setFirst(int first);
35
53
36 int count() const;
54 int count() const;
37 void setCount(int count);
55 void setCount(int count);
38
56
39 Qt::Orientation orientation() const;
57 void reset();
40 void setOrientation(Qt::Orientation orientation);
41
58
59 protected:
42 int valuesIndex() const;
60 int valuesIndex() const;
43 void setValuesIndex(int valuesIndex);
61 void setValuesIndex(int valuesIndex);
44
62
45 int labelsIndex() const;
63 int labelsIndex() const;
46 void setLabelsIndex(int labelsIndex);
64 void setLabelsIndex(int labelsIndex);
47
65
48 void reset();
66 Qt::Orientation orientation() const;
67 void setOrientation(Qt::Orientation orientation);
49
68
50 protected:
69 protected:
51 QPieModelMapperPrivate * const d_ptr;
70 QPieModelMapperPrivate * const d_ptr;
52 Q_DECLARE_PRIVATE(QPieModelMapper)
71 Q_DECLARE_PRIVATE(QPieModelMapper)
53 };
72 };
54
73
55 QTCOMMERCIALCHART_END_NAMESPACE
74 QTCOMMERCIALCHART_END_NAMESPACE
56
75
57 #endif // QPIEMODELMAPPER_H
76 #endif // QPIEMODELMAPPER_H
@@ -1,519 +1,519
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "tablewidget.h"
21 #include "tablewidget.h"
22 #include <QGridLayout>
22 #include <QGridLayout>
23 #include <QTableView>
23 #include <QTableView>
24 #include <QChart>
24 #include <QChart>
25 #include <QStyledItemDelegate>
25 #include <QStyledItemDelegate>
26 #include <QLineSeries>
26 #include <QLineSeries>
27 #include <QSplineSeries>
27 #include <QSplineSeries>
28 #include <QScatterSeries>
28 #include <QScatterSeries>
29 #include <QXYModelMapper>
29 #include <QXYModelMapper>
30 #include "customtablemodel.h"
30 #include "customtablemodel.h"
31 #include <QPieSeries>
31 #include <QPieSeries>
32 #include <QPieModelMapper>
32 #include <QVPieModelMapper>
33 #include <QPieSlice>
33 #include <QPieSlice>
34 #include <QAreaSeries>
34 #include <QAreaSeries>
35 #include <QBarSeries>
35 #include <QBarSeries>
36 #include <QGroupedBarSeries>
36 #include <QGroupedBarSeries>
37 #include <QBarSet>
37 #include <QBarSet>
38 #include <QBarModelMapper>
38 #include <QBarModelMapper>
39 #include <QPushButton>
39 #include <QPushButton>
40 #include <QRadioButton>
40 #include <QRadioButton>
41 #include <QLabel>
41 #include <QLabel>
42 #include <QSpinBox>
42 #include <QSpinBox>
43 #include <QTime>
43 #include <QTime>
44 #include <QHeaderView>
44 #include <QHeaderView>
45
45
46 TableWidget::TableWidget(QWidget *parent)
46 TableWidget::TableWidget(QWidget *parent)
47 : QWidget(parent)
47 : QWidget(parent)
48 // specialPie(0)
48 // specialPie(0)
49 {
49 {
50 setGeometry(1900, 100, 1000, 600);
50 setGeometry(1900, 100, 1000, 600);
51 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
51 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
52 // create simple model for storing data
52 // create simple model for storing data
53 // user's table data model
53 // user's table data model
54 m_model = new CustomTableModel;
54 m_model = new CustomTableModel;
55 m_tableView = new QTableView;
55 m_tableView = new QTableView;
56 m_tableView->setModel(m_model);
56 m_tableView->setModel(m_model);
57 // m_tableView->setMinimumHeight(300);
57 // m_tableView->setMinimumHeight(300);
58 m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
58 m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
59 m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
59 m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
60
60
61 m_chart = new QChart;
61 m_chart = new QChart;
62 m_chart->legend()->setVisible(true);
62 m_chart->legend()->setVisible(true);
63 m_chart->setAnimationOptions(QChart::SeriesAnimations);
63 m_chart->setAnimationOptions(QChart::SeriesAnimations);
64 m_chartView = new QChartView(m_chart);
64 m_chartView = new QChartView(m_chart);
65 m_chartView->setRenderHint(QPainter::Antialiasing);
65 m_chartView->setRenderHint(QPainter::Antialiasing);
66 m_chartView->setMinimumSize(640, 480);
66 m_chartView->setMinimumSize(640, 480);
67
67
68 // add, remove data buttons
68 // add, remove data buttons
69 QPushButton* addRowAboveButton = new QPushButton("Add row above");
69 QPushButton* addRowAboveButton = new QPushButton("Add row above");
70 connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
70 connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
71
71
72 QPushButton* addRowBelowButton = new QPushButton("Add row below");
72 QPushButton* addRowBelowButton = new QPushButton("Add row below");
73 connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
73 connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
74
74
75 QPushButton* removeRowButton = new QPushButton("Remove row");
75 QPushButton* removeRowButton = new QPushButton("Remove row");
76 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
76 connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
77
77
78 QPushButton* addColumnRightButton = new QPushButton("Add column to the right");
78 QPushButton* addColumnRightButton = new QPushButton("Add column to the right");
79 connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight()));
79 connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight()));
80
80
81 QPushButton* removeColumnButton = new QPushButton("Remove column");
81 QPushButton* removeColumnButton = new QPushButton("Remove column");
82 connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn()));
82 connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn()));
83
83
84 QPushButton* specialPieButton = new QPushButton("Add slices from series");
84 QPushButton* specialPieButton = new QPushButton("Add slices from series");
85 connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie()));
85 connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie()));
86
86
87 QPushButton* specialPieButton2 = new QPushButton("Remove slices from series");
87 QPushButton* specialPieButton2 = new QPushButton("Remove slices from series");
88 connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2()));
88 connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2()));
89
89
90 QPushButton* specialPieButton3 = new QPushButton("Remove slices from series");
90 QPushButton* specialPieButton3 = new QPushButton("Remove slices from series");
91 connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3()));
91 connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3()));
92
92
93
93
94 // QLabel *spinBoxLabel = new QLabel("Rows affected:");
94 // QLabel *spinBoxLabel = new QLabel("Rows affected:");
95
95
96 // spin box for setting number of affected items (add, remove)
96 // spin box for setting number of affected items (add, remove)
97 m_linesCountSpinBox = new QSpinBox;
97 m_linesCountSpinBox = new QSpinBox;
98 m_linesCountSpinBox->setRange(1, 10);
98 m_linesCountSpinBox->setRange(1, 10);
99 m_linesCountSpinBox->setValue(1);
99 m_linesCountSpinBox->setValue(1);
100
100
101 // buttons layout
101 // buttons layout
102 QVBoxLayout* buttonsLayout = new QVBoxLayout;
102 QVBoxLayout* buttonsLayout = new QVBoxLayout;
103 // buttonsLayout->addWidget(spinBoxLabel);
103 // buttonsLayout->addWidget(spinBoxLabel);
104 // buttonsLayout->addWidget(m_linesCountSpinBox);
104 // buttonsLayout->addWidget(m_linesCountSpinBox);
105 // buttonsLayout->addWidget(addRowAboveButton);
105 // buttonsLayout->addWidget(addRowAboveButton);
106 buttonsLayout->addWidget(addRowBelowButton);
106 buttonsLayout->addWidget(addRowBelowButton);
107 buttonsLayout->addWidget(removeRowButton);
107 buttonsLayout->addWidget(removeRowButton);
108 // buttonsLayout->addWidget(addColumnRightButton);
108 // buttonsLayout->addWidget(addColumnRightButton);
109 // buttonsLayout->addWidget(removeColumnButton);
109 // buttonsLayout->addWidget(removeColumnButton);
110 buttonsLayout->addWidget(specialPieButton);
110 buttonsLayout->addWidget(specialPieButton);
111 buttonsLayout->addWidget(specialPieButton2);
111 buttonsLayout->addWidget(specialPieButton2);
112 buttonsLayout->addWidget(specialPieButton3);
112 buttonsLayout->addWidget(specialPieButton3);
113 buttonsLayout->addStretch();
113 buttonsLayout->addStretch();
114
114
115 // chart type radio buttons
115 // chart type radio buttons
116 m_lineRadioButton = new QRadioButton("Line");
116 m_lineRadioButton = new QRadioButton("Line");
117 m_splineRadioButton = new QRadioButton("Spline");
117 m_splineRadioButton = new QRadioButton("Spline");
118 m_scatterRadioButton = new QRadioButton("Scatter");
118 m_scatterRadioButton = new QRadioButton("Scatter");
119 m_pieRadioButton = new QRadioButton("Pie");
119 m_pieRadioButton = new QRadioButton("Pie");
120 m_areaRadioButton = new QRadioButton("Area");
120 m_areaRadioButton = new QRadioButton("Area");
121 m_barRadioButton = new QRadioButton("Bar");
121 m_barRadioButton = new QRadioButton("Bar");
122
122
123 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
123 connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
124 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
124 connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
125 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
125 connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
126 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
126 connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
127 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
127 connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
128 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
128 connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
129 m_lineRadioButton->setChecked(true);
129 m_lineRadioButton->setChecked(true);
130
130
131 // radio buttons layout
131 // radio buttons layout
132 QVBoxLayout* radioLayout = new QVBoxLayout;
132 QVBoxLayout* radioLayout = new QVBoxLayout;
133 radioLayout->addWidget(m_lineRadioButton);
133 radioLayout->addWidget(m_lineRadioButton);
134 radioLayout->addWidget(m_splineRadioButton);
134 radioLayout->addWidget(m_splineRadioButton);
135 // radioLayout->addWidget(m_scatterRadioButton);
135 // radioLayout->addWidget(m_scatterRadioButton);
136 radioLayout->addWidget(m_pieRadioButton);
136 radioLayout->addWidget(m_pieRadioButton);
137 // radioLayout->addWidget(m_areaRadioButton);
137 // radioLayout->addWidget(m_areaRadioButton);
138 radioLayout->addWidget(m_barRadioButton);
138 radioLayout->addWidget(m_barRadioButton);
139 radioLayout->addStretch();
139 radioLayout->addStretch();
140
140
141 // create main layout
141 // create main layout
142 QGridLayout* mainLayout = new QGridLayout;
142 QGridLayout* mainLayout = new QGridLayout;
143 mainLayout->addLayout(buttonsLayout, 2, 0);
143 mainLayout->addLayout(buttonsLayout, 2, 0);
144 mainLayout->addLayout(radioLayout, 3, 0);
144 mainLayout->addLayout(radioLayout, 3, 0);
145 mainLayout->addWidget(m_tableView, 1, 0);
145 mainLayout->addWidget(m_tableView, 1, 0);
146 mainLayout->addWidget(m_chartView, 1, 1, 2, 1);
146 mainLayout->addWidget(m_chartView, 1, 1, 2, 1);
147 setLayout(mainLayout);
147 setLayout(mainLayout);
148 m_lineRadioButton->setFocus();
148 m_lineRadioButton->setFocus();
149 }
149 }
150
150
151 void TableWidget::addRowAbove()
151 void TableWidget::addRowAbove()
152 {
152 {
153 m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value());
153 m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value());
154
154
155 }
155 }
156
156
157 void TableWidget::addRowBelow()
157 void TableWidget::addRowBelow()
158 {
158 {
159 m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value());
159 m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value());
160
160
161 }
161 }
162
162
163 void TableWidget::removeRow()
163 void TableWidget::removeRow()
164 {
164 {
165 m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
165 m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
166 }
166 }
167
167
168 void TableWidget::addColumnRight()
168 void TableWidget::addColumnRight()
169 {
169 {
170 m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value());
170 m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value());
171 }
171 }
172
172
173 void TableWidget::removeColumn()
173 void TableWidget::removeColumn()
174 {
174 {
175 m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value()));
175 m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value()));
176 }
176 }
177
177
178 void TableWidget::updateChartType(bool toggle)
178 void TableWidget::updateChartType(bool toggle)
179 {
179 {
180 // this if is needed, so that the function is only called once.
180 // this if is needed, so that the function is only called once.
181 // For the radioButton that was enabled.
181 // For the radioButton that was enabled.
182 if (toggle) {
182 if (toggle) {
183 // specialPie = 0;
183 // specialPie = 0;
184 m_chart->removeAllSeries();
184 m_chart->removeAllSeries();
185 // m_chart->axisX()->setNiceNumbersEnabled(false);
185 // m_chart->axisX()->setNiceNumbersEnabled(false);
186 // m_chart->axisY()->setNiceNumbersEnabled(false);
186 // m_chart->axisY()->setNiceNumbersEnabled(false);
187
187
188 // // renable axes of the chart (pie hides them)
188 // // renable axes of the chart (pie hides them)
189 // // x axis
189 // // x axis
190 // QAxis *axis = m_chart->axisX();
190 // QAxis *axis = m_chart->axisX();
191 // axis->setAxisVisible(true);
191 // axis->setAxisVisible(true);
192 // axis->setGridLineVisible(true);
192 // axis->setGridLineVisible(true);
193 // axis->setLabelsVisible(true);
193 // axis->setLabelsVisible(true);
194
194
195 // // y axis
195 // // y axis
196 // axis = m_chart->axisY();
196 // axis = m_chart->axisY();
197 // axis->setAxisVisible(true);
197 // axis->setAxisVisible(true);
198 // axis->setGridLineVisible(true);
198 // axis->setGridLineVisible(true);
199 // axis->setLabelsVisible(true);
199 // axis->setLabelsVisible(true);
200
200
201 // m_model->clearMapping();
201 // m_model->clearMapping();
202
202
203 QString seriesColorHex = "#000000";
203 QString seriesColorHex = "#000000";
204 // QPen pen;
204 // QPen pen;
205 // pen.setWidth(2);
205 // pen.setWidth(2);
206
206
207 if (m_lineRadioButton->isChecked())
207 if (m_lineRadioButton->isChecked())
208 {
208 {
209 // m_chart->setAnimationOptions(QChart::NoAnimation);
209 // m_chart->setAnimationOptions(QChart::NoAnimation);
210
210
211 // // series 1
211 // // series 1
212 // m_series = new QLineSeries;
212 // m_series = new QLineSeries;
213 // m_series->setModel(m_model);
213 // m_series->setModel(m_model);
214
214
215 // QXYModelMapper *mapper = new QXYModelMapper;
215 // QXYModelMapper *mapper = new QXYModelMapper;
216 // mapper->setMapX(0);
216 // mapper->setMapX(0);
217 // mapper->setMapY(1);
217 // mapper->setMapY(1);
218 // mapper->setFirst(3);
218 // mapper->setFirst(3);
219 // mapper->setCount(4);
219 // mapper->setCount(4);
220 // m_series->setModelMapper(mapper);
220 // m_series->setModelMapper(mapper);
221 // // m_series->setModelMapping(0,1, Qt::Vertical);
221 // // m_series->setModelMapping(0,1, Qt::Vertical);
222 // // m_series->setModelMappingRange(3, 4);
222 // // m_series->setModelMappingRange(3, 4);
223 // m_chart->addSeries(m_series);
223 // m_chart->addSeries(m_series);
224 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
224 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
225 // m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4));
225 // m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4));
226
226
227 // // series 2
227 // // series 2
228 // m_series = new QLineSeries;
228 // m_series = new QLineSeries;
229 // m_series->setModel(m_model);
229 // m_series->setModel(m_model);
230
230
231 // mapper = new QXYModelMapper;
231 // mapper = new QXYModelMapper;
232 // mapper->setMapX(3);
232 // mapper->setMapX(3);
233 // mapper->setMapY(4);
233 // mapper->setMapY(4);
234 // // mapper->setFirst(3);
234 // // mapper->setFirst(3);
235 // // mapper->setCount(4);
235 // // mapper->setCount(4);
236 // m_series->setModelMapper(mapper);
236 // m_series->setModelMapper(mapper);
237 // // m_series->setModelMapping(2,3, Qt::Vertical);
237 // // m_series->setModelMapping(2,3, Qt::Vertical);
238 // m_chart->addSeries(m_series);
238 // m_chart->addSeries(m_series);
239 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
239 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
240 // m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000));
240 // m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000));
241
241
242 // // series 3
242 // // series 3
243 // m_series = new QLineSeries;
243 // m_series = new QLineSeries;
244 // m_series->setModel(m_model);
244 // m_series->setModel(m_model);
245
245
246 // mapper = new QXYModelMapper;
246 // mapper = new QXYModelMapper;
247 // mapper->setMapX(5);
247 // mapper->setMapX(5);
248 // mapper->setMapY(6);
248 // mapper->setMapY(6);
249 // mapper->setFirst(2);
249 // mapper->setFirst(2);
250 // mapper->setCount(-1);
250 // mapper->setCount(-1);
251 // m_series->setModelMapper(mapper);
251 // m_series->setModelMapper(mapper);
252 // // m_series->setModelMapping(4,5, Qt::Vertical);
252 // // m_series->setModelMapping(4,5, Qt::Vertical);
253 // // m_series->setModelMappingRange(2, -1);
253 // // m_series->setModelMappingRange(2, -1);
254 // m_chart->addSeries(m_series);
254 // m_chart->addSeries(m_series);
255 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
255 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
256 // m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000));
256 // m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000));
257 }
257 }
258 else if (m_splineRadioButton->isChecked())
258 else if (m_splineRadioButton->isChecked())
259 {
259 {
260 // m_chart->setAnimationOptions(QChart::NoAnimation);
260 // m_chart->setAnimationOptions(QChart::NoAnimation);
261
261
262 // // series 1
262 // // series 1
263 // m_series = new QSplineSeries;
263 // m_series = new QSplineSeries;
264 // m_series->setModel(m_model);
264 // m_series->setModel(m_model);
265
265
266 // QXYModelMapper *mapper = new QXYModelMapper;
266 // QXYModelMapper *mapper = new QXYModelMapper;
267 // mapper->setMapX(0);
267 // mapper->setMapX(0);
268 // mapper->setMapY(1);
268 // mapper->setMapY(1);
269 // mapper->setFirst(0);
269 // mapper->setFirst(0);
270 // mapper->setCount(-1);
270 // mapper->setCount(-1);
271
271
272 // m_series->setModelMapper(mapper);
272 // m_series->setModelMapper(mapper);
273
273
274 // m_chart->addSeries(m_series);
274 // m_chart->addSeries(m_series);
275 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
275 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
276 // m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000));
276 // m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000));
277
277
278 // // series 2
278 // // series 2
279 // m_series = new QSplineSeries;
279 // m_series = new QSplineSeries;
280 // m_series->setModel(m_model);
280 // m_series->setModel(m_model);
281
281
282 // mapper = new QXYModelMapper;
282 // mapper = new QXYModelMapper;
283 // mapper->setMapX(2);
283 // mapper->setMapX(2);
284 // mapper->setMapY(3);
284 // mapper->setMapY(3);
285 // mapper->setFirst(2);
285 // mapper->setFirst(2);
286 // mapper->setCount(4);
286 // mapper->setCount(4);
287
287
288 // m_series->setModelMapper(mapper);
288 // m_series->setModelMapper(mapper);
289
289
290 // m_chart->addSeries(m_series);
290 // m_chart->addSeries(m_series);
291 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
291 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
292 // m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4));
292 // m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4));
293
293
294 // // series 3
294 // // series 3
295 // m_series = new QSplineSeries;
295 // m_series = new QSplineSeries;
296 // m_series->setModel(m_model);
296 // m_series->setModel(m_model);
297
297
298 // mapper = new QXYModelMapper;
298 // mapper = new QXYModelMapper;
299 // mapper->setMapX(4);
299 // mapper->setMapX(4);
300 // mapper->setMapY(5);
300 // mapper->setMapY(5);
301 // mapper->setFirst(2);
301 // mapper->setFirst(2);
302 // mapper->setCount(-1);
302 // mapper->setCount(-1);
303
303
304 // m_series->setModelMapper(mapper);
304 // m_series->setModelMapper(mapper);
305
305
306 // m_chart->addSeries(m_series);
306 // m_chart->addSeries(m_series);
307 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
307 // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
308 // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000));
308 // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000));
309 }
309 }
310 // else if (m_scatterRadioButton->isChecked())
310 // else if (m_scatterRadioButton->isChecked())
311 // {
311 // {
312 // m_chart->setAnimationOptions(QChart::NoAnimation);
312 // m_chart->setAnimationOptions(QChart::NoAnimation);
313
313
314 // // series 1
314 // // series 1
315 // m_series = new QScatterSeries;
315 // m_series = new QScatterSeries;
316 // m_series->setModel(m_model);
316 // m_series->setModel(m_model);
317 // m_series->setModelMapping(0,1, Qt::Vertical);
317 // m_series->setModelMapping(0,1, Qt::Vertical);
318 // // m_series->setModelMappingRange(2, 0);
318 // // m_series->setModelMappingRange(2, 0);
319 // // series->setModelMapping(0,1, Qt::Horizontal);
319 // // series->setModelMapping(0,1, Qt::Horizontal);
320 // m_chart->addSeries(m_series);
320 // m_chart->addSeries(m_series);
321
321
322 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
322 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
323 // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000));
323 // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000));
324
324
325 // // series 2
325 // // series 2
326 // m_series = new QScatterSeries;
326 // m_series = new QScatterSeries;
327 // m_series->setModel(m_model);
327 // m_series->setModel(m_model);
328 // m_series->setModelMapping(2,3, Qt::Vertical);
328 // m_series->setModelMapping(2,3, Qt::Vertical);
329 // // m_series->setModelMappingRange(1, 6);
329 // // m_series->setModelMappingRange(1, 6);
330 // // series->setModelMapping(2,3, Qt::Horizontal);
330 // // series->setModelMapping(2,3, Qt::Horizontal);
331 // m_chart->addSeries(m_series);
331 // m_chart->addSeries(m_series);
332
332
333 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
333 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
334 // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6));
334 // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6));
335
335
336 // // series 3
336 // // series 3
337 // m_series = new QScatterSeries;
337 // m_series = new QScatterSeries;
338 // m_series->setModel(m_model);
338 // m_series->setModel(m_model);
339 // m_series->setModelMapping(4,5, Qt::Vertical);
339 // m_series->setModelMapping(4,5, Qt::Vertical);
340 // // series->setModelMapping(4,5, Qt::Horizontal);
340 // // series->setModelMapping(4,5, Qt::Horizontal);
341 // m_chart->addSeries(m_series);
341 // m_chart->addSeries(m_series);
342 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
342 // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
343 // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000));
343 // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000));
344 // }
344 // }
345 else if (m_pieRadioButton->isChecked())
345 else if (m_pieRadioButton->isChecked())
346 {
346 {
347 m_chart->setAnimationOptions(QChart::SeriesAnimations);
347 m_chart->setAnimationOptions(QChart::SeriesAnimations);
348
348
349 // pie 1
349 // pie 1
350 m_pieSeries = new QPieSeries;
350 m_pieSeries = new QPieSeries;
351
351
352 m_pieMapper = new QPieModelMapper;
352 m_pieMapper = new QVPieModelMapper;
353 m_pieMapper->setValuesIndex(1);
353 m_pieMapper->setValuesColumn(1);
354 m_pieMapper->setLabelsIndex(7);
354 m_pieMapper->setLabelsColumn(7);
355 m_pieMapper->setSeries(m_pieSeries);
355 m_pieMapper->setSeries(m_pieSeries);
356 m_pieMapper->setModel(m_model);
356 m_pieMapper->setModel(m_model);
357 m_pieMapper->setFirst(2);
357 m_pieMapper->setFirst(2);
358 m_pieMapper->setCount(5);
358 m_pieMapper->setCount(5);
359 // pieSeries->setModelMapper(mapper);
359 // pieSeries->setModelMapper(mapper);
360
360
361 m_pieSeries->setLabelsVisible(true);
361 m_pieSeries->setLabelsVisible(true);
362 m_pieSeries->setPieSize(0.75);
362 m_pieSeries->setPieSize(0.75);
363 // pieSeries->setHorizontalPosition(0.2);
363 // pieSeries->setHorizontalPosition(0.2);
364 // pieSeries->setVerticalPosition(0.3);
364 // pieSeries->setVerticalPosition(0.3);
365
365
366 m_chart->addSeries(m_pieSeries);
366 m_chart->addSeries(m_pieSeries);
367 seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
367 seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
368 m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5));
368 m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5));
369
369
370
370
371 // pieSeries->slices().at(0)->setValue(400);
371 // pieSeries->slices().at(0)->setValue(400);
372 // pieSeries->slices().at(0)->setLabel(QString("36"));
372 // pieSeries->slices().at(0)->setLabel(QString("36"));
373
373
374 // // pie 2
374 // // pie 2
375 // pieSeries = new QPieSeries;
375 // pieSeries = new QPieSeries;
376 // pieSeries->setModel(m_model);
376 // pieSeries->setModel(m_model);
377
377
378 // pieSeries->setModelMapping(1,1, Qt::Vertical);
378 // pieSeries->setModelMapping(1,1, Qt::Vertical);
379 // pieSeries->setModelMappingRange(2, -1);
379 // pieSeries->setModelMappingRange(2, -1);
380 // pieSeries->setLabelsVisible(true);
380 // pieSeries->setLabelsVisible(true);
381 // pieSeries->setPieSize(0.35);
381 // pieSeries->setPieSize(0.35);
382 // pieSeries->setHorizontalPosition(0.8);
382 // pieSeries->setHorizontalPosition(0.8);
383 // pieSeries->setVerticalPosition(0.3);
383 // pieSeries->setVerticalPosition(0.3);
384 // m_chart->addSeries(pieSeries);
384 // m_chart->addSeries(pieSeries);
385 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
385 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
386 // m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000));
386 // m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000));
387
387
388 // // pie 3
388 // // pie 3
389 // pieSeries = new QPieSeries;
389 // pieSeries = new QPieSeries;
390 // pieSeries->setModel(m_model);
390 // pieSeries->setModel(m_model);
391 // pieSeries->setModelMapping(2,2, Qt::Vertical);
391 // pieSeries->setModelMapping(2,2, Qt::Vertical);
392 // pieSeries->setLabelsVisible(true);
392 // pieSeries->setLabelsVisible(true);
393 // pieSeries->setPieSize(0.35);
393 // pieSeries->setPieSize(0.35);
394 // pieSeries->setHorizontalPosition(0.5);
394 // pieSeries->setHorizontalPosition(0.5);
395 // pieSeries->setVerticalPosition(0.75);
395 // pieSeries->setVerticalPosition(0.75);
396 // m_chart->addSeries(pieSeries);
396 // m_chart->addSeries(pieSeries);
397 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
397 // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
398 // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000));
398 // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000));
399
399
400 // // special pie
400 // // special pie
401 // specialPie = new QPieSeries;
401 // specialPie = new QPieSeries;
402 // specialPie->append(17, "1");
402 // specialPie->append(17, "1");
403 // specialPie->append(45, "2");
403 // specialPie->append(45, "2");
404 // specialPie->append(77, "3");
404 // specialPie->append(77, "3");
405 // specialPie->append(37, "4");
405 // specialPie->append(37, "4");
406 // specialPie->append(27, "5");
406 // specialPie->append(27, "5");
407 // specialPie->append(47, "6");
407 // specialPie->append(47, "6");
408 // specialPie->setPieSize(0.35);
408 // specialPie->setPieSize(0.35);
409 // specialPie->setHorizontalPosition(0.8);
409 // specialPie->setHorizontalPosition(0.8);
410 // specialPie->setVerticalPosition(0.75);
410 // specialPie->setVerticalPosition(0.75);
411 // specialPie->setLabelsVisible(true);
411 // specialPie->setLabelsVisible(true);
412 // m_chart->addSeries(specialPie);
412 // m_chart->addSeries(specialPie);
413 }
413 }
414 // else if (m_areaRadioButton->isChecked())
414 // else if (m_areaRadioButton->isChecked())
415 // {
415 // {
416 // m_chart->setAnimationOptions(QChart::NoAnimation);
416 // m_chart->setAnimationOptions(QChart::NoAnimation);
417
417
418 // QLineSeries* upperLineSeries = new QLineSeries;
418 // QLineSeries* upperLineSeries = new QLineSeries;
419 // upperLineSeries->setModel(m_model);
419 // upperLineSeries->setModel(m_model);
420 // upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
420 // upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
421 // // upperLineSeries->setModelMappingRange(1, 5);
421 // // upperLineSeries->setModelMappingRange(1, 5);
422 // QLineSeries* lowerLineSeries = new QLineSeries;
422 // QLineSeries* lowerLineSeries = new QLineSeries;
423 // lowerLineSeries->setModel(m_model);
423 // lowerLineSeries->setModel(m_model);
424 // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
424 // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
425 // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
425 // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
426 // m_chart->addSeries(areaSeries);
426 // m_chart->addSeries(areaSeries);
427 // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper();
427 // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper();
428 // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5));
428 // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5));
429 // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000));
429 // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000));
430 // }
430 // }
431 else if (m_barRadioButton->isChecked())
431 else if (m_barRadioButton->isChecked())
432 {
432 {
433 // m_chart->setAnimationOptions(QChart::SeriesAnimations);
433 // m_chart->setAnimationOptions(QChart::SeriesAnimations);
434
434
435 // QGroupedBarSeries* barSeries = new QGroupedBarSeries();
435 // QGroupedBarSeries* barSeries = new QGroupedBarSeries();
436 // barSeries->setCategories(QStringList());
436 // barSeries->setCategories(QStringList());
437 // barSeries->setModel(m_model);
437 // barSeries->setModel(m_model);
438 // // barSeries->setModelMappingRange(2, 5);
438 // // barSeries->setModelMappingRange(2, 5);
439 //// barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
439 //// barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
440
440
441 // QBarModelMapper *mapper = new QBarModelMapper;
441 // QBarModelMapper *mapper = new QBarModelMapper;
442 // mapper->setMapCategories(5);
442 // mapper->setMapCategories(5);
443 // mapper->setMapBarBottom(2);
443 // mapper->setMapBarBottom(2);
444 // mapper->setMapBarTop(4);
444 // mapper->setMapBarTop(4);
445 // barSeries->setModelMapper(mapper);
445 // barSeries->setModelMapper(mapper);
446 // m_chart->addSeries(barSeries);
446 // m_chart->addSeries(barSeries);
447 // QList<QBarSet*> barsets = barSeries->barSets();
447 // QList<QBarSet*> barsets = barSeries->barSets();
448 // for (int i = 0; i < barsets.count(); i++) {
448 // for (int i = 0; i < barsets.count(); i++) {
449 // seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
449 // seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
450 // m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000));
450 // m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000));
451 // }
451 // }
452 }
452 }
453
453
454
454
455 if (!m_barRadioButton->isChecked()) {
455 if (!m_barRadioButton->isChecked()) {
456 m_chart->axisX()->setRange(0, 500);
456 m_chart->axisX()->setRange(0, 500);
457 m_chart->axisY()->setRange(0, 220);
457 m_chart->axisY()->setRange(0, 220);
458 }
458 }
459 m_chart->legend()->setVisible(true);
459 m_chart->legend()->setVisible(true);
460
460
461 // repaint table view colors
461 // repaint table view colors
462 m_tableView->repaint();
462 m_tableView->repaint();
463 m_tableView->setFocus();
463 m_tableView->setFocus();
464 }
464 }
465 }
465 }
466
466
467 void TableWidget::testPie()
467 void TableWidget::testPie()
468 {
468 {
469 // m_pieMapper->setCount(-1);
469 // m_pieMapper->setCount(-1);
470 QPieSlice *slice = new QPieSlice("Hehe", 145);
470 QPieSlice *slice = new QPieSlice("Hehe", 145);
471 slice->setLabelVisible();
471 slice->setLabelVisible();
472 m_pieSeries->append(slice);
472 m_pieSeries->append(slice);
473
473
474 slice = new QPieSlice("Hoho", 34);
474 slice = new QPieSlice("Hoho", 34);
475 slice->setLabelVisible();
475 slice->setLabelVisible();
476 m_pieSeries->append(slice);
476 m_pieSeries->append(slice);
477 // m_series->modelMapper()->setMapX(4);
477 // m_series->modelMapper()->setMapX(4);
478 // m_tableView->setColumnWidth(10, 250);
478 // m_tableView->setColumnWidth(10, 250);
479 // if (specialPie) {
479 // if (specialPie) {
480 // specialPie->remove(specialPie->slices().at(2));
480 // specialPie->remove(specialPie->slices().at(2));
481 // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2));
481 // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2));
482 // specialPie->append(4, "heloo");
482 // specialPie->append(4, "heloo");
483 // }
483 // }
484 }
484 }
485
485
486 void TableWidget::testPie2()
486 void TableWidget::testPie2()
487 {
487 {
488 QPieSlice *slice;
488 QPieSlice *slice;
489 if (m_pieSeries->count() > 0) {
489 if (m_pieSeries->count() > 0) {
490 slice = m_pieSeries->slices().last();
490 slice = m_pieSeries->slices().last();
491 m_pieSeries->remove(slice);
491 m_pieSeries->remove(slice);
492 }
492 }
493
493
494 if (m_pieSeries->count() > 0) {
494 if (m_pieSeries->count() > 0) {
495 slice = m_pieSeries->slices().first();
495 slice = m_pieSeries->slices().first();
496 m_pieSeries->remove(slice);
496 m_pieSeries->remove(slice);
497 }
497 }
498 }
498 }
499
499
500 void TableWidget::testPie3()
500 void TableWidget::testPie3()
501 {
501 {
502 QPieSlice *slice;
502 QPieSlice *slice;
503 if (m_pieSeries->count() > 0) {
503 if (m_pieSeries->count() > 0) {
504 slice = m_pieSeries->slices().last();
504 slice = m_pieSeries->slices().last();
505 slice->setLabel("Dalej");
505 slice->setLabel("Dalej");
506 slice->setValue(222);
506 slice->setValue(222);
507 }
507 }
508
508
509 if (m_pieSeries->count() > 0) {
509 if (m_pieSeries->count() > 0) {
510 slice = m_pieSeries->slices().first();
510 slice = m_pieSeries->slices().first();
511 slice->setLabel("Prawie");
511 slice->setLabel("Prawie");
512 slice->setValue(111);
512 slice->setValue(111);
513 }
513 }
514 }
514 }
515
515
516 TableWidget::~TableWidget()
516 TableWidget::~TableWidget()
517 {
517 {
518
518
519 }
519 }
@@ -1,76 +1,76
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef TABLEWIDGET_H
21 #ifndef TABLEWIDGET_H
22 #define TABLEWIDGET_H
22 #define TABLEWIDGET_H
23
23
24 #include <QtGui/QWidget>
24 #include <QtGui/QWidget>
25 //#include <QChartGlobal>
25 //#include <QChartGlobal>
26 #include "qchartview.h"
26 #include "qchartview.h"
27 //#include "qxyseries.h"
27 //#include "qxyseries.h"
28 #include <QPieSeries>
28 #include <QPieSeries>
29 #include <QPieModelMapper>
29 #include <QVPieModelMapper>
30
30
31 class CustomTableModel;
31 class CustomTableModel;
32 class QTableView;
32 class QTableView;
33 class QRadioButton;
33 class QRadioButton;
34 class QSpinBox;
34 class QSpinBox;
35
35
36 QTCOMMERCIALCHART_USE_NAMESPACE
36 QTCOMMERCIALCHART_USE_NAMESPACE
37
37
38 class TableWidget : public QWidget
38 class TableWidget : public QWidget
39 {
39 {
40 Q_OBJECT
40 Q_OBJECT
41
41
42 public:
42 public:
43 TableWidget(QWidget *parent = 0);
43 TableWidget(QWidget *parent = 0);
44 ~TableWidget();
44 ~TableWidget();
45
45
46
46
47 public slots:
47 public slots:
48 void addRowAbove();
48 void addRowAbove();
49 void addRowBelow();
49 void addRowBelow();
50 void removeRow();
50 void removeRow();
51 void addColumnRight();
51 void addColumnRight();
52 void removeColumn();
52 void removeColumn();
53 void updateChartType(bool toggle);
53 void updateChartType(bool toggle);
54 void testPie();
54 void testPie();
55 void testPie2();
55 void testPie2();
56 void testPie3();
56 void testPie3();
57
57
58 private:
58 private:
59 QChartView* m_chartView;
59 QChartView* m_chartView;
60 QChart* m_chart;
60 QChart* m_chart;
61 QXYSeries* m_series;
61 QXYSeries* m_series;
62 CustomTableModel* m_model;
62 CustomTableModel* m_model;
63 QTableView* m_tableView;
63 QTableView* m_tableView;
64 QRadioButton* m_lineRadioButton;
64 QRadioButton* m_lineRadioButton;
65 QRadioButton* m_splineRadioButton;
65 QRadioButton* m_splineRadioButton;
66 QRadioButton* m_scatterRadioButton;
66 QRadioButton* m_scatterRadioButton;
67 QRadioButton* m_pieRadioButton;
67 QRadioButton* m_pieRadioButton;
68 QRadioButton* m_areaRadioButton;
68 QRadioButton* m_areaRadioButton;
69 QRadioButton* m_barRadioButton;
69 QRadioButton* m_barRadioButton;
70 QSpinBox* m_linesCountSpinBox;
70 QSpinBox* m_linesCountSpinBox;
71 QPieModelMapper *m_pieMapper;
71 QVPieModelMapper *m_pieMapper;
72 QPieSeries* m_pieSeries;
72 QPieSeries* m_pieSeries;
73 // QPieSeries* specialPie;
73 // QPieSeries* specialPie;
74 };
74 };
75
75
76 #endif // TABLEWIDGET_H
76 #endif // TABLEWIDGET_H
General Comments 0
You need to be logged in to leave comments. Login now