##// 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
@@ -6,7 +6,9 SOURCES += \
6 6 $$PWD/piesliceitem.cpp \
7 7 $$PWD/piechartitem.cpp \
8 8 $$PWD/qpieslice.cpp \
9 $$PWD/qpiemodelmapper.cpp
9 $$PWD/qpiemodelmapper.cpp \
10 $$PWD/qvpiemodelmapper.cpp \
11 $$PWD/qhpiemodelmapper.cpp
10 12
11 13 PRIVATE_HEADERS += \
12 14 $$PWD/pieslicedata_p.h \
@@ -18,4 +20,6 PRIVATE_HEADERS += \
18 20 PUBLIC_HEADERS += \
19 21 $$PWD/qpieseries.h \
20 22 $$PWD/qpieslice.h \
21 $$PWD/qpiemodelmapper.h
23 $$PWD/qpiemodelmapper.h \
24 $$PWD/qvpiemodelmapper.h \
25 $$PWD/qhpiemodelmapper.h
@@ -1,3 +1,23
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 21 #ifndef QPIEMODELMAPPER_H
2 22 #define QPIEMODELMAPPER_H
3 23
@@ -14,16 +34,14 class QPieSeries;
14 34 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
15 35 {
16 36 Q_OBJECT
17 Q_PROPERTY(int valuesIndex READ valuesIndex WRITE setValuesIndex)
18 Q_PROPERTY(int labelsIndex READ labelsIndex WRITE setLabelsIndex)
19 37 Q_PROPERTY(int first READ first WRITE setFirst)
20 38 Q_PROPERTY(int count READ count WRITE setCount)
21 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
22 39 Q_ENUMS(Qt::Orientation)
23 40
24 public:
41 protected:
25 42 QPieModelMapper(QObject *parent = 0);
26 43
44 public:
27 45 QAbstractItemModel* model() const;
28 46 void setModel(QAbstractItemModel *model);
29 47
@@ -36,16 +54,17 public:
36 54 int count() const;
37 55 void setCount(int count);
38 56
39 Qt::Orientation orientation() const;
40 void setOrientation(Qt::Orientation orientation);
57 void reset();
41 58
59 protected:
42 60 int valuesIndex() const;
43 61 void setValuesIndex(int valuesIndex);
44 62
45 63 int labelsIndex() const;
46 64 void setLabelsIndex(int labelsIndex);
47 65
48 void reset();
66 Qt::Orientation orientation() const;
67 void setOrientation(Qt::Orientation orientation);
49 68
50 69 protected:
51 70 QPieModelMapperPrivate * const d_ptr;
@@ -29,7 +29,7
29 29 #include <QXYModelMapper>
30 30 #include "customtablemodel.h"
31 31 #include <QPieSeries>
32 #include <QPieModelMapper>
32 #include <QVPieModelMapper>
33 33 #include <QPieSlice>
34 34 #include <QAreaSeries>
35 35 #include <QBarSeries>
@@ -349,9 +349,9 void TableWidget::updateChartType(bool toggle)
349 349 // pie 1
350 350 m_pieSeries = new QPieSeries;
351 351
352 m_pieMapper = new QPieModelMapper;
353 m_pieMapper->setValuesIndex(1);
354 m_pieMapper->setLabelsIndex(7);
352 m_pieMapper = new QVPieModelMapper;
353 m_pieMapper->setValuesColumn(1);
354 m_pieMapper->setLabelsColumn(7);
355 355 m_pieMapper->setSeries(m_pieSeries);
356 356 m_pieMapper->setModel(m_model);
357 357 m_pieMapper->setFirst(2);
@@ -26,7 +26,7
26 26 #include "qchartview.h"
27 27 //#include "qxyseries.h"
28 28 #include <QPieSeries>
29 #include <QPieModelMapper>
29 #include <QVPieModelMapper>
30 30
31 31 class CustomTableModel;
32 32 class QTableView;
@@ -68,7 +68,7 public:
68 68 QRadioButton* m_areaRadioButton;
69 69 QRadioButton* m_barRadioButton;
70 70 QSpinBox* m_linesCountSpinBox;
71 QPieModelMapper *m_pieMapper;
71 QVPieModelMapper *m_pieMapper;
72 72 QPieSeries* m_pieSeries;
73 73 // QPieSeries* specialPie;
74 74 };
General Comments 0
You need to be logged in to leave comments. Login now