@@ -0,0 +1,32 | |||
|
1 | #include "qhxymodelmapper.h" | |
|
2 | ||
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
4 | ||
|
5 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : | |
|
6 | QXYModelMapper(parent) | |
|
7 | { | |
|
8 | } | |
|
9 | ||
|
10 | int QHXYModelMapper::xRow() const | |
|
11 | { | |
|
12 | return QXYModelMapper::xSection(); | |
|
13 | } | |
|
14 | ||
|
15 | void QHXYModelMapper::setXRow(int xRow) | |
|
16 | { | |
|
17 | return QXYModelMapper::setXSection(xRow); | |
|
18 | } | |
|
19 | ||
|
20 | int QHXYModelMapper::yRow() const | |
|
21 | { | |
|
22 | return QXYModelMapper::ySection(); | |
|
23 | } | |
|
24 | ||
|
25 | void QHXYModelMapper::setYRow(int yRow) | |
|
26 | { | |
|
27 | return QXYModelMapper::setYSection(yRow); | |
|
28 | } | |
|
29 | ||
|
30 | #include "moc_qhxymodelmapper.cpp" | |
|
31 | ||
|
32 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,27 | |||
|
1 | #ifndef QHXYMODELMAPPER_H | |
|
2 | #define QHXYMODELMAPPER_H | |
|
3 | ||
|
4 | #include <QXYModelMapper> | |
|
5 | ||
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
7 | ||
|
8 | class QTCOMMERCIALCHART_EXPORT QHXYModelMapper : public QXYModelMapper | |
|
9 | { | |
|
10 | Q_OBJECT | |
|
11 | Q_PROPERTY(int xRow READ xRow WRITE setXRow) | |
|
12 | Q_PROPERTY(int yRow READ yRow WRITE setYRow) | |
|
13 | ||
|
14 | public: | |
|
15 | explicit QHXYModelMapper(QObject *parent = 0); | |
|
16 | ||
|
17 | int xRow() const; | |
|
18 | void setXRow(int xRow); | |
|
19 | ||
|
20 | int yRow() const; | |
|
21 | void setYRow(int yRow); | |
|
22 | ||
|
23 | }; | |
|
24 | ||
|
25 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
26 | ||
|
27 | #endif // QHXYMODELMAPPER_H |
@@ -0,0 +1,32 | |||
|
1 | #include "qvxymodelmapper.h" | |
|
2 | ||
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
4 | ||
|
5 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : | |
|
6 | QXYModelMapper(parent) | |
|
7 | { | |
|
8 | } | |
|
9 | ||
|
10 | int QVXYModelMapper::xColumn() const | |
|
11 | { | |
|
12 | return QXYModelMapper::xSection(); | |
|
13 | } | |
|
14 | ||
|
15 | void QVXYModelMapper::setXColumn(int xColumn) | |
|
16 | { | |
|
17 | return QXYModelMapper::setXSection(xColumn); | |
|
18 | } | |
|
19 | ||
|
20 | int QVXYModelMapper::yColumn() const | |
|
21 | { | |
|
22 | return QXYModelMapper::ySection(); | |
|
23 | } | |
|
24 | ||
|
25 | void QVXYModelMapper::setYColumn(int yColumn) | |
|
26 | { | |
|
27 | return QXYModelMapper::setYSection(yColumn); | |
|
28 | } | |
|
29 | ||
|
30 | #include "moc_qvxymodelmapper.cpp" | |
|
31 | ||
|
32 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,27 | |||
|
1 | #ifndef QVXYMODELMAPPER_H | |
|
2 | #define QVXYMODELMAPPER_H | |
|
3 | ||
|
4 | #include <QXYModelMapper> | |
|
5 | ||
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
7 | ||
|
8 | class QTCOMMERCIALCHART_EXPORT QVXYModelMapper : public QXYModelMapper | |
|
9 | { | |
|
10 | Q_OBJECT | |
|
11 | Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn) | |
|
12 | Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn) | |
|
13 | ||
|
14 | public: | |
|
15 | explicit QVXYModelMapper(QObject *parent = 0); | |
|
16 | ||
|
17 | int xColumn() const; | |
|
18 | void setXColumn(int xColumn); | |
|
19 | ||
|
20 | int yColumn() const; | |
|
21 | void setYColumn(int yColumn); | |
|
22 | ||
|
23 | }; | |
|
24 | ||
|
25 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
26 | ||
|
27 | #endif // QVXYMODELMAPPER_H |
@@ -101,8 +101,9 void DeclarativeTableModel::appendPoint(QXYModelMapper *mapper, DeclarativeXyPoi | |||
|
101 | 101 | { |
|
102 | 102 | // qDebug() << "DeclarativeTableModel::appendPoint:" << point; |
|
103 | 103 | QVariantList values; |
|
104 | values.insert(mapper->mapX(), point->x()); | |
|
105 |
values.insert(mapper->map |
|
|
104 | // TODO: XYModelMapper implementation has change, this code has to be updated. | |
|
105 | // values.insert(mapper->mapX(), point->x()); | |
|
106 | // values.insert(mapper->mapY(), point->y()); | |
|
106 | 107 | append(values); |
|
107 | 108 | } |
|
108 | 109 |
@@ -29,15 +29,17 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
29 | 29 | |
|
30 | 30 | DeclarativeXySeries::DeclarativeXySeries() |
|
31 | 31 | { |
|
32 | // TODO: XYModelMapper implementation has changed, this code has to be updated | |
|
33 | ||
|
32 | 34 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
33 | QXYSeries *series = reinterpret_cast<QXYSeries *>(this); | |
|
34 | // TODO: mapper should be available on the series by default | |
|
35 | QXYModelMapper *mapper = new QXYModelMapper(series); | |
|
36 | mapper->setMapX(0); | |
|
37 | mapper->setMapY(1); | |
|
38 | mapper->setFirst(0); | |
|
39 | mapper->setCount(-1); | |
|
40 | mapper->setOrientation(Qt::Vertical); | |
|
35 | // QXYSeries *series = reinterpret_cast<QXYSeries *>(this); | |
|
36 | // // TODO: mapper should be available on the series by default | |
|
37 | // QXYModelMapper *mapper = new QXYModelMapper(series); | |
|
38 | // mapper->setMapX(0); | |
|
39 | // mapper->setMapY(1); | |
|
40 | // mapper->setFirst(0); | |
|
41 | // mapper->setCount(-1); | |
|
42 | // mapper->setOrientation(Qt::Vertical); | |
|
41 | 43 | // series->setModelMapper(mapper); |
|
42 | 44 | } |
|
43 | 45 |
@@ -46,20 +46,19 QPieSeries* QPieModelMapper::series() const | |||
|
46 | 46 | |
|
47 | 47 | void QPieModelMapper::setSeries(QPieSeries *series) |
|
48 | 48 | { |
|
49 | if (series == 0) | |
|
50 | return; | |
|
51 | ||
|
52 | 49 | Q_D(QPieModelMapper); |
|
53 | 50 | if (d->m_series) { |
|
54 | 51 | disconnect(d->m_series, 0, d, 0); |
|
55 | 52 | } |
|
56 | 53 | |
|
54 | if (series == 0) | |
|
55 | return; | |
|
56 | ||
|
57 | 57 | d->m_series = series; |
|
58 | 58 | d->initializePieFromModel(); |
|
59 | 59 | // connect the signals from the series |
|
60 | 60 | connect(d->m_series, SIGNAL(added(QList<QPieSlice*>)), d, SLOT(slicesAdded(QList<QPieSlice*>))); |
|
61 | 61 | connect(d->m_series, SIGNAL(removed(QList<QPieSlice*>)), d, SLOT(slicesRemoved(QList<QPieSlice*>))); |
|
62 | // connect(d->m_model, SIGNAL(), d, SLOT()); | |
|
63 | 62 | } |
|
64 | 63 | |
|
65 | 64 | int QPieModelMapper::first() const |
@@ -7,8 +7,8 QXYModelMapper::QXYModelMapper(QObject *parent): | |||
|
7 | 7 | m_first(0), |
|
8 | 8 | m_count(-1), |
|
9 | 9 | m_orientation(Qt::Vertical), |
|
10 |
m_ |
|
|
11 |
m_ |
|
|
10 | m_xSection(-1), | |
|
11 | m_ySection(-1) | |
|
12 | 12 | { |
|
13 | 13 | } |
|
14 | 14 | |
@@ -20,7 +20,7 int QXYModelMapper::first() const | |||
|
20 | 20 | void QXYModelMapper::setFirst(int first) |
|
21 | 21 | { |
|
22 | 22 | m_first = qMax(first, 0); |
|
23 | emit updated(); | |
|
23 | // emit updated(); | |
|
24 | 24 | } |
|
25 | 25 | |
|
26 | 26 | int QXYModelMapper::count() const |
@@ -31,7 +31,7 int QXYModelMapper::count() const | |||
|
31 | 31 | void QXYModelMapper::setCount(int count) |
|
32 | 32 | { |
|
33 | 33 | m_count = qMax(count, -1); |
|
34 | emit updated(); | |
|
34 | // emit updated(); | |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | Qt::Orientation QXYModelMapper::orientation() const |
@@ -42,29 +42,29 Qt::Orientation QXYModelMapper::orientation() const | |||
|
42 | 42 | void QXYModelMapper::setOrientation(Qt::Orientation orientation) |
|
43 | 43 | { |
|
44 | 44 | m_orientation = orientation; |
|
45 | emit updated(); | |
|
45 | // emit updated(); | |
|
46 | 46 | } |
|
47 | 47 | |
|
48 |
int QXYModelMapper:: |
|
|
48 | int QXYModelMapper::xSection() const | |
|
49 | 49 | { |
|
50 |
return m_ |
|
|
50 | return m_xSection; | |
|
51 | 51 | } |
|
52 | 52 | |
|
53 |
void QXYModelMapper::set |
|
|
53 | void QXYModelMapper::setXSection(int xSection) | |
|
54 | 54 | { |
|
55 | m_mapX = mapX; | |
|
56 | emit updated(); | |
|
55 | m_xSection = xSection; | |
|
56 | // emit updated(); | |
|
57 | 57 | } |
|
58 | 58 | |
|
59 |
int QXYModelMapper:: |
|
|
59 | int QXYModelMapper::ySection() const | |
|
60 | 60 | { |
|
61 |
return m_ |
|
|
61 | return m_ySection; | |
|
62 | 62 | } |
|
63 | 63 | |
|
64 |
void QXYModelMapper::set |
|
|
64 | void QXYModelMapper::setYSection(int ySection) | |
|
65 | 65 | { |
|
66 | m_mapY = mapY; | |
|
67 | emit updated(); | |
|
66 | m_ySection = ySection; | |
|
67 | // emit updated(); | |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | void QXYModelMapper::reset() |
@@ -72,8 +72,8 void QXYModelMapper::reset() | |||
|
72 | 72 | m_first = 0; |
|
73 | 73 | m_count = -1; |
|
74 | 74 | m_orientation = Qt::Vertical; |
|
75 |
m_ |
|
|
76 |
m_ |
|
|
75 | m_xSection = -1; | |
|
76 | m_ySection = -1; | |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | #include "moc_qxymodelmapper.cpp" |
@@ -9,30 +9,31 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
9 | 9 | class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject |
|
10 | 10 | { |
|
11 | 11 | Q_OBJECT |
|
12 |
Q_PROPERTY(int |
|
|
13 |
Q_PROPERTY(int |
|
|
12 | Q_PROPERTY(int xSection READ xSection WRITE setXSection) | |
|
13 | Q_PROPERTY(int ySection READ ySection WRITE setYSection) | |
|
14 | 14 | Q_PROPERTY(int first READ first WRITE setFirst) |
|
15 | 15 | Q_PROPERTY(int count READ count WRITE setCount) |
|
16 | 16 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) |
|
17 | 17 | Q_ENUMS(Qt::Orientation) |
|
18 | 18 | |
|
19 | 19 | public: |
|
20 | explicit QXYModelMapper(QObject *parent = 0); | |
|
21 | ||
|
22 | 20 | int first() const; |
|
23 | 21 | void setFirst(int first); |
|
24 | 22 | |
|
25 | 23 | int count() const; |
|
26 | 24 | void setCount(int count); |
|
27 | 25 | |
|
26 | protected: | |
|
27 | explicit QXYModelMapper(QObject *parent = 0); | |
|
28 | ||
|
28 | 29 | Qt::Orientation orientation() const; |
|
29 | 30 | void setOrientation(Qt::Orientation orientation); |
|
30 | 31 | |
|
31 |
int |
|
|
32 |
void set |
|
|
32 | int xSection() const; | |
|
33 | void setXSection(int xSection); | |
|
33 | 34 | |
|
34 |
int |
|
|
35 |
void set |
|
|
35 | int ySection() const; | |
|
36 | void setYSection(int ySection); | |
|
36 | 37 | |
|
37 | 38 | void reset(); |
|
38 | 39 | |
@@ -43,8 +44,8 private: | |||
|
43 | 44 | int m_first; |
|
44 | 45 | int m_count; |
|
45 | 46 | Qt::Orientation m_orientation; |
|
46 |
int m_ |
|
|
47 |
int m_ |
|
|
47 | int m_xSection; | |
|
48 | int m_ySection; | |
|
48 | 49 | }; |
|
49 | 50 | |
|
50 | 51 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -4,7 +4,9 DEPENDPATH += $$PWD | |||
|
4 | 4 | SOURCES += \ |
|
5 | 5 | $$PWD/xychart.cpp \ |
|
6 | 6 | $$PWD/qxyseries.cpp \ |
|
7 | $$PWD/qxymodelmapper.cpp | |
|
7 | $$PWD/qxymodelmapper.cpp \ | |
|
8 | $$PWD/qvxymodelmapper.cpp \ | |
|
9 | $$PWD/qhxymodelmapper.cpp | |
|
8 | 10 | |
|
9 | 11 | PRIVATE_HEADERS += \ |
|
10 | 12 | $$PWD/xychart_p.h \ |
@@ -13,4 +15,7 PRIVATE_HEADERS += \ | |||
|
13 | 15 | |
|
14 | 16 | PUBLIC_HEADERS += \ |
|
15 | 17 | $$PWD/qxyseries.h \ |
|
16 | $$PWD/qxymodelmapper.h | |
|
18 | $$PWD/qxymodelmapper.h \ | |
|
19 | $$PWD/qvxymodelmapper.h \ | |
|
20 | $$PWD/qhxymodelmapper.h | |
|
21 |
@@ -253,12 +253,15 void tst_piemodelmapper::seriesUpdated() | |||
|
253 | 253 | mapper->setModel(otherModel); |
|
254 | 254 | mapper->setSeries(m_series); |
|
255 | 255 | QCOMPARE(m_series->count(), m_modelRowCount); |
|
256 | QCOMPARE(mapper->count(), -1); | |
|
256 | 257 | |
|
257 | 258 | m_series->append("1000", 1000); |
|
258 | 259 | QCOMPARE(m_series->count(), m_modelRowCount + 1); |
|
260 | QCOMPARE(mapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model | |
|
259 | 261 | |
|
260 | 262 | m_series->remove(m_series->slices().last()); |
|
261 | 263 | QCOMPARE(m_series->count(), m_modelRowCount); |
|
264 | QCOMPARE(mapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model | |
|
262 | 265 | |
|
263 | 266 | otherModel->clear(); |
|
264 | 267 | delete otherModel; |
General Comments 0
You need to be logged in to leave comments.
Login now