@@ -1,58 +1,58 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "drilldownchart.h" |
|
22 | 22 | #include <QCategoriesAxis> |
|
23 | 23 | |
|
24 | 24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | 25 | |
|
26 | 26 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
27 | 27 | : QChart(parent, wFlags) |
|
28 | 28 | ,m_currentSeries(0) |
|
29 | 29 | { |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | void DrilldownChart::changeSeries(DrilldownBarSeries *series) |
|
33 | 33 | { |
|
34 | 34 | if (m_currentSeries) { |
|
35 | 35 | removeSeries(m_currentSeries); |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | m_currentSeries = series; |
|
39 | 39 | |
|
40 | 40 | // Reset axis |
|
41 | 41 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
42 | 42 | axis->append(m_currentSeries->categories()); |
|
43 | 43 | |
|
44 | 44 | addSeries(series); |
|
45 | 45 | |
|
46 | 46 | setAxisX(series,axis); |
|
47 | 47 | |
|
48 | 48 | setTitle(series->name()); |
|
49 | 49 | } |
|
50 | 50 | |
|
51 |
void DrilldownChart::handleClicked(QBarSet *barset |
|
|
51 | void DrilldownChart::handleClicked(int index, QBarSet *barset) | |
|
52 | 52 | { |
|
53 | 53 | Q_UNUSED(barset) |
|
54 | 54 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); |
|
55 | 55 | changeSeries(series->drilldownSeries(index)); |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | #include "moc_drilldownchart.cpp" |
@@ -1,46 +1,46 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef DRILLDOWNCHART_H |
|
22 | 22 | #define DRILLDOWNCHART_H |
|
23 | 23 | |
|
24 | 24 | #include <QChart> |
|
25 | 25 | #include "drilldownseries.h" |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | //! [1] |
|
30 | 30 | class DrilldownChart : public QChart |
|
31 | 31 | { |
|
32 | 32 | Q_OBJECT |
|
33 | 33 | public: |
|
34 | 34 | explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
35 | 35 | |
|
36 | 36 | void changeSeries(DrilldownBarSeries *series); |
|
37 | 37 | |
|
38 | 38 | public Q_SLOTS: |
|
39 |
void handleClicked(QBarSet *barset |
|
|
39 | void handleClicked(int index, QBarSet *barset); | |
|
40 | 40 | |
|
41 | 41 | private: |
|
42 | 42 | DrilldownBarSeries* m_currentSeries; |
|
43 | 43 | }; |
|
44 | 44 | //! [1] |
|
45 | 45 | |
|
46 | 46 | #endif // DRILLDOWNCHART_H |
@@ -1,115 +1,115 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtGui/QApplication> |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QBarSet> |
|
25 | 25 | #include <QLegend> |
|
26 | 26 | #include "drilldownseries.h" |
|
27 | 27 | #include "drilldownchart.h" |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | int main(int argc, char *argv[]) |
|
32 | 32 | { |
|
33 | 33 | QApplication a(argc, argv); |
|
34 | 34 | QMainWindow window; |
|
35 | 35 | |
|
36 | 36 | //! [1] |
|
37 | 37 | DrilldownChart* drilldownChart = new DrilldownChart(); |
|
38 | 38 | drilldownChart->setTheme(QChart::ChartThemeBlueIcy); |
|
39 | 39 | drilldownChart->setAnimationOptions(QChart::SeriesAnimations); |
|
40 | 40 | //! [1] |
|
41 | 41 | |
|
42 | 42 | //! [2] |
|
43 | 43 | // Define categories |
|
44 | 44 | QStringList months; |
|
45 | 45 | months << "May" << "Jun" << "Jul" << "Aug" << "Sep"; |
|
46 | 46 | QStringList weeks; |
|
47 | 47 | weeks << "week 1" << "week 2" << "week 3" << "week 4"; |
|
48 | 48 | QStringList plants; |
|
49 | 49 | plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo"; |
|
50 | 50 | //! [2] |
|
51 | 51 | |
|
52 | 52 | //! [3] |
|
53 | 53 | // Create drilldown structure |
|
54 | 54 | DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart); |
|
55 | 55 | seasonSeries->setName("Crop by month - Season"); |
|
56 | 56 | |
|
57 | 57 | // Each month in season series has drilldown series for weekly data |
|
58 | 58 | for (int month=0; month < months.count(); month++) { |
|
59 | 59 | |
|
60 | 60 | // Create drilldown series for every week |
|
61 | 61 | DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart); |
|
62 | 62 | seasonSeries->mapDrilldownSeries(month, weeklySeries); |
|
63 | 63 | |
|
64 | 64 | // Drilling down from weekly data brings us back to season data. |
|
65 | 65 | for (int week=0; week < weeks.count(); week++) { |
|
66 | 66 | weeklySeries->mapDrilldownSeries(week, seasonSeries); |
|
67 | 67 | weeklySeries->setName(QString("Crop by week - " + months.at(month))); |
|
68 | 68 | } |
|
69 | 69 | |
|
70 |
// Use |
|
|
71 |
QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet* |
|
|
70 | // Use clicked signal to implement drilldown | |
|
71 | QObject::connect(weeklySeries, SIGNAL(clicked(int, QBarSet*)), drilldownChart, SLOT(handleClicked(int, QBarSet*))); | |
|
72 | 72 | } |
|
73 | 73 | |
|
74 |
// Enable drilldown from season series using |
|
|
75 |
QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet* |
|
|
74 | // Enable drilldown from season series using clicked signal | |
|
75 | QObject::connect(seasonSeries, SIGNAL(clicked(int, QBarSet*)), drilldownChart, SLOT(handleClicked(int, QBarSet*))); | |
|
76 | 76 | //! [3] |
|
77 | 77 | |
|
78 | 78 | //! [4] |
|
79 | 79 | // Fill monthly and weekly series with data |
|
80 | 80 | foreach (QString plant, plants) { |
|
81 | 81 | QBarSet* monthlyCrop = new QBarSet(plant); |
|
82 | 82 | for (int month=0; month<months.count(); month++) { |
|
83 | 83 | QBarSet* weeklyCrop = new QBarSet(plant); |
|
84 | 84 | for (int week=0; week<weeks.count(); week++) { |
|
85 | 85 | *weeklyCrop << (qrand() % 20); |
|
86 | 86 | } |
|
87 | 87 | // Get the drilldown series from season series and add crop to it. |
|
88 | 88 | seasonSeries->drilldownSeries(month)->append(weeklyCrop); |
|
89 | 89 | *monthlyCrop << weeklyCrop->sum(); |
|
90 | 90 | } |
|
91 | 91 | seasonSeries->append(monthlyCrop); |
|
92 | 92 | } |
|
93 | 93 | //! [4] |
|
94 | 94 | |
|
95 | 95 | //! [5] |
|
96 | 96 | // Show season series in initial view |
|
97 | 97 | drilldownChart->changeSeries(seasonSeries); |
|
98 | 98 | drilldownChart->setTitle(seasonSeries->name()); |
|
99 | 99 | //! [5] |
|
100 | 100 | |
|
101 | 101 | //! [6] |
|
102 | 102 | drilldownChart->axisX()->setGridLineVisible(false); |
|
103 | 103 | //TODO: drilldownChart->axisY()->setNiceNumbersEnabled(true); |
|
104 | 104 | drilldownChart->legend()->setVisible(true); |
|
105 | 105 | drilldownChart->legend()->setAlignment(Qt::AlignBottom); |
|
106 | 106 | //! [6] |
|
107 | 107 | |
|
108 | 108 | QChartView *chartView = new QChartView(drilldownChart); |
|
109 | 109 | window.setCentralWidget(chartView); |
|
110 | 110 | window.resize(400, 300); |
|
111 | 111 | window.show(); |
|
112 | 112 | |
|
113 | 113 | return a.exec(); |
|
114 | 114 | } |
|
115 | 115 |
@@ -1,58 +1,66 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "bar_p.h" |
|
22 | 22 | #include <QPainter> |
|
23 | 23 | #include <QGraphicsSceneEvent> |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | Bar::Bar(QBarSet *barset, int index, QGraphicsItem *parent) : QGraphicsRectItem(parent), |
|
28 | 28 | m_index(index), |
|
29 | m_barset(barset) | |
|
29 | m_barset(barset), | |
|
30 | m_hovering(false) | |
|
30 | 31 | { |
|
31 | 32 | setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); |
|
32 | 33 | setAcceptHoverEvents(true); |
|
33 | 34 | } |
|
34 | 35 | |
|
36 | Bar::~Bar() | |
|
37 | { | |
|
38 | // End hover event, if bar is deleted during it | |
|
39 | if (m_hovering) { | |
|
40 | emit hovered(false, m_barset); | |
|
41 | } | |
|
42 | } | |
|
43 | ||
|
35 | 44 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
36 | 45 | { |
|
37 | 46 | Q_UNUSED(event) |
|
38 |
emit clicked(m_ |
|
|
39 | emit clicked(m_index); | |
|
47 | emit clicked(m_index, m_barset); | |
|
40 | 48 | } |
|
41 | 49 | |
|
42 | 50 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
43 | 51 | { |
|
44 | 52 | Q_UNUSED(event) |
|
45 | emit hovered(m_barset, true); | |
|
46 | emit hovered(true); | |
|
53 | m_hovering = true; | |
|
54 | emit hovered(true, m_barset); | |
|
47 | 55 | } |
|
48 | 56 | |
|
49 | 57 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
50 | 58 | { |
|
51 | 59 | Q_UNUSED(event) |
|
52 | emit hovered(m_barset, false); | |
|
53 | emit hovered(false); | |
|
60 | m_hovering = false; | |
|
61 | emit hovered(false, m_barset); | |
|
54 | 62 | } |
|
55 | 63 | |
|
56 | 64 | #include "moc_bar_p.cpp" |
|
57 | 65 | |
|
58 | 66 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,65 +1,65 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef BAR_H |
|
31 | 31 | #define BAR_H |
|
32 | 32 | |
|
33 | 33 | #include "qchartglobal.h" |
|
34 | 34 | #include <QGraphicsRectItem> |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | class QBarSet; |
|
39 | 39 | |
|
40 | 40 | // Single visual bar item of chart |
|
41 | 41 | class Bar : public QObject, public QGraphicsRectItem |
|
42 | 42 | { |
|
43 | 43 | Q_OBJECT |
|
44 | 44 | public: |
|
45 | 45 | Bar(QBarSet *barset, int index, QGraphicsItem *parent = 0); |
|
46 | ~Bar(); | |
|
46 | 47 | |
|
47 | 48 | public: |
|
48 | 49 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
49 | 50 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
|
50 | 51 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
|
51 | 52 | |
|
52 | 53 | Q_SIGNALS: |
|
53 |
void clicked(QBarSet *barset |
|
|
54 |
void hovered(QBarSet *barset |
|
|
55 | void clicked(int index); | |
|
56 | void hovered(bool status); | |
|
54 | void clicked(int index, QBarSet *barset); | |
|
55 | void hovered(bool status, QBarSet *barset); | |
|
57 | 56 | |
|
58 | 57 | private: |
|
59 | 58 | int m_index; |
|
59 | bool m_hovering; | |
|
60 | 60 | QBarSet *m_barset; |
|
61 | 61 | }; |
|
62 | 62 | |
|
63 | 63 | QTCOMMERCIALCHART_END_NAMESPACE |
|
64 | 64 | |
|
65 | 65 | #endif // BAR_H |
@@ -1,226 +1,226 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "barchartitem_p.h" |
|
22 | 22 | #include "bar_p.h" |
|
23 | 23 | #include "qbarset.h" |
|
24 | 24 | #include "qbarset_p.h" |
|
25 | 25 | #include "qbarseries.h" |
|
26 | 26 | #include "qbarseries_p.h" |
|
27 | 27 | #include "qchart.h" |
|
28 | 28 | #include "chartpresenter_p.h" |
|
29 | 29 | #include "chartanimator_p.h" |
|
30 | 30 | #include "chartdataset_p.h" |
|
31 | 31 | #include <QPainter> |
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 | 35 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : |
|
36 | 36 | ChartItem(presenter), |
|
37 | 37 | m_series(series) |
|
38 | 38 | { |
|
39 | 39 | setFlag(ItemClipsChildrenToShape); |
|
40 | 40 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
41 | 41 | connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(handleLabelsVisibleChanged(bool))); |
|
42 | 42 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged())); |
|
43 | 43 | connect(series, SIGNAL(visibleChanged()), this, SLOT(handleVisibleChanged())); |
|
44 | 44 | setZValue(ChartPresenter::BarSeriesZValue); |
|
45 | 45 | handleDataStructureChanged(); |
|
46 | 46 | } |
|
47 | 47 | |
|
48 | 48 | BarChartItem::~BarChartItem() |
|
49 | 49 | { |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
53 | 53 | { |
|
54 | 54 | Q_UNUSED(painter); |
|
55 | 55 | Q_UNUSED(option); |
|
56 | 56 | Q_UNUSED(widget); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | QRectF BarChartItem::boundingRect() const |
|
60 | 60 | { |
|
61 | 61 | return m_rect; |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | QVector<QRectF> BarChartItem::calculateLayout() |
|
65 | 65 | { |
|
66 | 66 | QVector<QRectF> layout; |
|
67 | 67 | |
|
68 | 68 | // Use temporary qreals for accuracy |
|
69 | 69 | qreal categoryCount = m_series->d_func()->categoryCount(); |
|
70 | 70 | qreal setCount = m_series->count(); |
|
71 | 71 | bool barsVisible = m_series->isVisible(); |
|
72 | 72 | |
|
73 | 73 | // Domain: |
|
74 | 74 | qreal width = geometry().width(); |
|
75 | 75 | qreal height = geometry().height(); |
|
76 | 76 | qreal rangeY = m_domainMaxY - m_domainMinY; |
|
77 | 77 | qreal rangeX = m_domainMaxX - m_domainMinX; |
|
78 | 78 | qreal scaleY = (height / rangeY); |
|
79 | 79 | qreal scaleX = (width / rangeX); |
|
80 | 80 | qreal barWidth = scaleX * m_series->d_func()->barWidth(); |
|
81 | 81 | |
|
82 | 82 | int itemIndex(0); |
|
83 | 83 | for (int category = 0; category < categoryCount; category++) { |
|
84 | 84 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
85 | 85 | for (int set = 0; set < setCount; set++) { |
|
86 | 86 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
87 | 87 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; |
|
88 | 88 | qreal barHeight = barSet->at(category).y() * scaleY; |
|
89 | 89 | |
|
90 | 90 | Bar* bar = m_bars.at(itemIndex); |
|
91 | 91 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
92 | 92 | |
|
93 | 93 | layout.append(rect); |
|
94 | 94 | bar->setPen(barSet->pen()); |
|
95 | 95 | bar->setBrush(barSet->brush()); |
|
96 | 96 | bar->setVisible(barsVisible); |
|
97 | 97 | |
|
98 | 98 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
99 | 99 | |
|
100 | 100 | if (!qFuzzyIsNull(barSet->at(category).y())) { |
|
101 | 101 | label->setText(QString::number(barSet->at(category).y())); |
|
102 | 102 | } else { |
|
103 | 103 | label->setText(QString("")); |
|
104 | 104 | } |
|
105 | 105 | |
|
106 | 106 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
107 | 107 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
108 | 108 | label->setFont(barSet->labelFont()); |
|
109 | 109 | label->setBrush(barSet->labelBrush()); |
|
110 | 110 | |
|
111 | 111 | itemIndex++; |
|
112 | 112 | } |
|
113 | 113 | } |
|
114 | 114 | |
|
115 | 115 | return layout; |
|
116 | 116 | } |
|
117 | 117 | |
|
118 | 118 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) |
|
119 | 119 | { |
|
120 | 120 | if (animator()) { |
|
121 | 121 | animator()->updateLayout(this, m_layout, layout); |
|
122 | 122 | } else { |
|
123 | 123 | setLayout(layout); |
|
124 | 124 | update(); |
|
125 | 125 | } |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | void BarChartItem::setLayout(const QVector<QRectF> &layout) |
|
129 | 129 | { |
|
130 | 130 | if (layout.count() != m_bars.count()) |
|
131 | 131 | return; |
|
132 | 132 | |
|
133 | 133 | m_layout = layout; |
|
134 | 134 | |
|
135 | 135 | for (int i=0; i < m_bars.count(); i++) { |
|
136 | 136 | m_bars.at(i)->setRect(layout.at(i)); |
|
137 | 137 | } |
|
138 | 138 | } |
|
139 | 139 | //handlers |
|
140 | 140 | |
|
141 | 141 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
142 | 142 | { |
|
143 | 143 | m_domainMinX = minX; |
|
144 | 144 | m_domainMaxX = maxX; |
|
145 | 145 | m_domainMinY = minY; |
|
146 | 146 | m_domainMaxY = maxY; |
|
147 | 147 | handleLayoutChanged(); |
|
148 | 148 | } |
|
149 | 149 | |
|
150 | 150 | void BarChartItem::handleGeometryChanged(const QRectF &rect) |
|
151 | 151 | { |
|
152 | 152 | prepareGeometryChange(); |
|
153 | 153 | m_rect = rect; |
|
154 | 154 | handleLayoutChanged(); |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | void BarChartItem::handleLayoutChanged() |
|
158 | 158 | { |
|
159 | 159 | if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) { |
|
160 | 160 | // rect size zero. |
|
161 | 161 | return; |
|
162 | 162 | } |
|
163 | 163 | QVector<QRectF> layout = calculateLayout(); |
|
164 | 164 | applyLayout(layout); |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | |
|
168 | 168 | |
|
169 | 169 | void BarChartItem::handleLabelsVisibleChanged(bool visible) |
|
170 | 170 | { |
|
171 | 171 | foreach (QGraphicsSimpleTextItem* label, m_labels) { |
|
172 | 172 | label->setVisible(visible); |
|
173 | 173 | } |
|
174 | 174 | update(); |
|
175 | 175 | } |
|
176 | 176 | |
|
177 | 177 | void BarChartItem::handleDataStructureChanged() |
|
178 | 178 | { |
|
179 | 179 | foreach(QGraphicsItem *item, childItems()) { |
|
180 | 180 | delete item; |
|
181 | 181 | } |
|
182 | 182 | |
|
183 | 183 | m_bars.clear(); |
|
184 | 184 | m_labels.clear(); |
|
185 | 185 | m_layout.clear(); |
|
186 | 186 | |
|
187 | 187 | bool labelsVisible = m_series->isLabelsVisible(); |
|
188 | 188 | |
|
189 | 189 | // Create new graphic items for bars |
|
190 | 190 | for (int c = 0; c < m_series->d_func()->categoryCount(); c++) { |
|
191 | 191 | for (int s = 0; s < m_series->count(); s++) { |
|
192 | 192 | QBarSet *set = m_series->d_func()->barsetAt(s); |
|
193 | 193 | |
|
194 | 194 | // Bars |
|
195 | 195 | Bar *bar = new Bar(set,c,this); |
|
196 | 196 | m_bars.append(bar); |
|
197 |
connect(bar, SIGNAL(clicked(QBarSet* |
|
|
198 |
connect(bar, SIGNAL(hovered(QBarSet* |
|
|
199 | connect(bar, SIGNAL(clicked(int)), set, SIGNAL(clicked(int))); | |
|
200 | connect(bar, SIGNAL(hovered(bool)), set, SIGNAL(hovered(bool))); | |
|
197 | connect(bar, SIGNAL(clicked(int, QBarSet*)), m_series, SIGNAL(clicked(int, QBarSet*))); | |
|
198 | connect(bar, SIGNAL(hovered(bool, QBarSet*)), m_series, SIGNAL(hovered(bool, QBarSet*))); | |
|
199 | connect(bar, SIGNAL(clicked(int, QBarSet*)), set, SIGNAL(clicked(int))); | |
|
200 | connect(bar, SIGNAL(hovered(bool, QBarSet*)), set, SIGNAL(hovered(bool))); | |
|
201 | 201 | m_layout.append(QRectF(0, 0, 0, 0)); |
|
202 | 202 | |
|
203 | 203 | // Labels |
|
204 | 204 | QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this); |
|
205 | 205 | label->setVisible(labelsVisible); |
|
206 | 206 | m_labels.append(label); |
|
207 | 207 | } |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | // TODO: Is this the right place to call it? |
|
211 | 211 | presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); |
|
212 | 212 | handleLayoutChanged(); |
|
213 | 213 | } |
|
214 | 214 | |
|
215 | 215 | void BarChartItem::handleVisibleChanged() |
|
216 | 216 | { |
|
217 | 217 | bool visible = m_series->isVisible(); |
|
218 | 218 | handleLabelsVisibleChanged(visible); |
|
219 | 219 | foreach(QGraphicsItem *item, childItems()) { |
|
220 | 220 | item->setVisible(visible); |
|
221 | 221 | } |
|
222 | 222 | } |
|
223 | 223 | |
|
224 | 224 | #include "moc_barchartitem_p.cpp" |
|
225 | 225 | |
|
226 | 226 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,731 +1,731 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qbarseries.h" |
|
22 | 22 | #include "qbarseries_p.h" |
|
23 | 23 | #include "qbarset.h" |
|
24 | 24 | #include "qbarset_p.h" |
|
25 | 25 | #include "domain_p.h" |
|
26 | 26 | #include "legendmarker_p.h" |
|
27 | 27 | #include "chartdataset_p.h" |
|
28 | 28 | #include "charttheme_p.h" |
|
29 | 29 | #include "chartanimator_p.h" |
|
30 | 30 | #include "qvaluesaxis.h" |
|
31 | 31 | |
|
32 | 32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | 33 | |
|
34 | 34 | /*! |
|
35 | 35 | \class QBarSeries |
|
36 | 36 | \brief Series for creating a bar chart |
|
37 | 37 | \mainclass |
|
38 | 38 | |
|
39 | 39 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to |
|
40 | 40 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar |
|
41 | 41 | and y-value is the height of the bar. The category names are ignored with this series and x-axis |
|
42 | 42 | shows the x-values. |
|
43 | 43 | |
|
44 | 44 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. |
|
45 | 45 | \image examples_barchart.png |
|
46 | 46 | |
|
47 | 47 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries |
|
48 | 48 | */ |
|
49 | 49 | /*! |
|
50 | 50 | \qmlclass BarSeries QBarSeries |
|
51 | 51 | \inherits AbstractSeries |
|
52 | 52 | |
|
53 | 53 | The following QML shows how to create a simple bar chart: |
|
54 | 54 | \snippet ../demos/qmlchart/qml/qmlchart/View6.qml 1 |
|
55 | 55 | |
|
56 | 56 | \beginfloatleft |
|
57 | 57 | \image demos_qmlchart6.png |
|
58 | 58 | \endfloat |
|
59 | 59 | \clearfloat |
|
60 | 60 | */ |
|
61 | 61 | |
|
62 | 62 | /*! |
|
63 | 63 | \property QBarSeries::barWidth |
|
64 | 64 | The width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
65 | 65 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
66 | 66 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
67 | 67 | Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. |
|
68 | 68 | \sa QGroupedBarSeries |
|
69 | 69 | */ |
|
70 | 70 | /*! |
|
71 | 71 | \qmlproperty real BarSeries::barWidth |
|
72 | 72 | The width of the bars of the series. The unit of width is the unit of x-axis. The minimum width for bars |
|
73 | 73 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
74 | 74 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
75 | 75 | Note that with QGroupedBarSeries this value means the width of one group of bars instead of just one bar. |
|
76 | 76 | */ |
|
77 | 77 | |
|
78 | 78 | /*! |
|
79 | 79 | \property QBarSeries::count |
|
80 | 80 | Holds the number of sets in series. |
|
81 | 81 | */ |
|
82 | 82 | /*! |
|
83 | 83 | \qmlproperty int BarSeries::count |
|
84 | 84 | Holds the number of sets in series. |
|
85 | 85 | */ |
|
86 | 86 | |
|
87 | 87 | /*! |
|
88 | 88 | \property QBarSeries::labelsVisible |
|
89 | 89 | Defines the visibility of the labels in series |
|
90 | 90 | */ |
|
91 | 91 | /*! |
|
92 | 92 | \qmlproperty bool BarSeries::labelsVisible |
|
93 | 93 | Defines the visibility of the labels in series |
|
94 | 94 | */ |
|
95 | 95 | |
|
96 | 96 | /*! |
|
97 |
\fn void QBarSeries::clicked(QBarSet *barset |
|
|
97 | \fn void QBarSeries::clicked(int index, QBarSet *barset) | |
|
98 | 98 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset. |
|
99 | 99 | Clicked bar inside set is indexed by \a index |
|
100 | 100 | */ |
|
101 | 101 | /*! |
|
102 |
\qmlsignal BarSeries::onClicked(BarSet barset |
|
|
102 | \qmlsignal BarSeries::onClicked(int index, BarSet barset) | |
|
103 | 103 | The signal is emitted if the user clicks with a mouse on top of BarSet. |
|
104 | 104 | Clicked bar inside set is indexed by \a index |
|
105 | 105 | */ |
|
106 | 106 | |
|
107 | 107 | /*! |
|
108 |
\fn void QBarSeries::hovered(QBarSet* barset |
|
|
108 | \fn void QBarSeries::hovered(bool status, QBarSet* barset) | |
|
109 | 109 | |
|
110 | 110 | The signal is emitted if mouse is hovered on top of series. |
|
111 | 111 | Parameter \a barset is the pointer of barset, where hover happened. |
|
112 | 112 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
113 | 113 | */ |
|
114 | 114 | /*! |
|
115 |
\qmlsignal BarSeries::onHovered(BarSet barset |
|
|
115 | \qmlsignal BarSeries::onHovered(bool status, BarSet barset) | |
|
116 | 116 | |
|
117 | 117 | The signal is emitted if mouse is hovered on top of series. |
|
118 | 118 | Parameter \a barset is the pointer of barset, where hover happened. |
|
119 | 119 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
120 | 120 | */ |
|
121 | 121 | |
|
122 | 122 | /*! |
|
123 | 123 | \fn void QBarSeries::countChanged() |
|
124 | 124 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
125 | 125 | */ |
|
126 | 126 | /*! |
|
127 | 127 | \qmlsignal BarSeries::onCountChanged() |
|
128 | 128 | This signal is emitted when barset count has been changed, for example by append or remove. |
|
129 | 129 | */ |
|
130 | 130 | |
|
131 | 131 | /*! |
|
132 | 132 | \fn void QBarSeries::labelsVisibleChanged() |
|
133 | 133 | This signal is emitted when labels visibility have changed. |
|
134 | 134 | \sa isLabelsVisible(), setLabelsVisible() |
|
135 | 135 | */ |
|
136 | 136 | |
|
137 | 137 | /*! |
|
138 | 138 | \fn void QBarSeries::barsetsAdded(QList<QBarSet*> sets) |
|
139 | 139 | This signal is emitted when \a sets have been added to the series. |
|
140 | 140 | \sa append(), insert() |
|
141 | 141 | */ |
|
142 | 142 | /*! |
|
143 | 143 | \qmlsignal BarSeries::onAdded(BarSet barset) |
|
144 | 144 | Emitted when \a barset has been added to the series. |
|
145 | 145 | */ |
|
146 | 146 | |
|
147 | 147 | /*! |
|
148 | 148 | \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets) |
|
149 | 149 | This signal is emitted when \a sets have been removed from the series. |
|
150 | 150 | \sa remove() |
|
151 | 151 | */ |
|
152 | 152 | /*! |
|
153 | 153 | \qmlsignal BarSeries::onRemoved(BarSet barset) |
|
154 | 154 | Emitted when \a barset has been removed from the series. |
|
155 | 155 | */ |
|
156 | 156 | |
|
157 | 157 | /*! |
|
158 | 158 | \qmlmethod BarSet BarSeries::at(int index) |
|
159 | 159 | Returns bar set at \a index. Returns null if the index is not valid. |
|
160 | 160 | */ |
|
161 | 161 | |
|
162 | 162 | /*! |
|
163 | 163 | \qmlmethod BarSet BarSeries::append(string label, VariantList values) |
|
164 | 164 | Adds a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
165 | 165 | For example: |
|
166 | 166 | \code |
|
167 | 167 | myBarSeries.append("set 1", [0, 0.2, 0.2, 0.5, 0.4, 1.5, 0.9]); |
|
168 | 168 | myBarSeries.append("set 2", [Qt.point(0, 1), Qt.point(2, 2.5), Qt.point(3.5, 2.2)]); |
|
169 | 169 | \endcode |
|
170 | 170 | */ |
|
171 | 171 | |
|
172 | 172 | /*! |
|
173 | 173 | \qmlmethod BarSet BarSeries::insert(int index, string label, VariantList values) |
|
174 | 174 | Inserts a new bar set with \a label and \a values to \a index. Values can be a list of reals or a list of XYPoints. |
|
175 | 175 | If index is zero or smaller, the new barset is prepended. If the index is count or bigger, the new barset is |
|
176 | 176 | appended. |
|
177 | 177 | \sa BarSeries::append() |
|
178 | 178 | */ |
|
179 | 179 | |
|
180 | 180 | /*! |
|
181 | 181 | \qmlmethod bool BarSeries::remove(BarSet barset) |
|
182 | 182 | Removes the barset from the series. Returns true if successfull, false otherwise. |
|
183 | 183 | */ |
|
184 | 184 | |
|
185 | 185 | /*! |
|
186 | 186 | \qmlmethod BarSeries::clear() |
|
187 | 187 | Removes all barsets from the series. |
|
188 | 188 | */ |
|
189 | 189 | |
|
190 | 190 | /*! |
|
191 | 191 | Constructs empty QBarSeries. |
|
192 | 192 | QBarSeries is QObject which is a child of a \a parent. |
|
193 | 193 | */ |
|
194 | 194 | QBarSeries::QBarSeries(QObject *parent) : |
|
195 | 195 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) |
|
196 | 196 | { |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | 199 | /*! |
|
200 | 200 | Destructs barseries and owned barsets. |
|
201 | 201 | */ |
|
202 | 202 | QBarSeries::~QBarSeries() |
|
203 | 203 | { |
|
204 | 204 | Q_D(QBarSeries); |
|
205 | 205 | if(d->m_dataset){ |
|
206 | 206 | d->m_dataset->removeSeries(this); |
|
207 | 207 | } |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | /*! |
|
211 | 211 | \internal |
|
212 | 212 | */ |
|
213 | 213 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : |
|
214 | 214 | QAbstractSeries(d,parent) |
|
215 | 215 | { |
|
216 | 216 | } |
|
217 | 217 | |
|
218 | 218 | /*! |
|
219 | 219 | Returns the type of series. Derived classes override this. |
|
220 | 220 | */ |
|
221 | 221 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
222 | 222 | { |
|
223 | 223 | return QAbstractSeries::SeriesTypeBar; |
|
224 | 224 | } |
|
225 | 225 | |
|
226 | 226 | /*! |
|
227 | 227 | Sets the width of the bars of the series. The unit of \a width is the unit of x-axis. The minimum width for bars |
|
228 | 228 | is zero and negative values are treated as zero. Setting the width to zero means that width of the bar on screen |
|
229 | 229 | is one pixel no matter what the scale of x-axis is. Bars wider than zero are scaled with x-axis. |
|
230 | 230 | Note that with \link QGroupedBarSeries \endlink this value means the width of one group of bars instead of just one bar. |
|
231 | 231 | */ |
|
232 | 232 | void QBarSeries::setBarWidth(qreal width) |
|
233 | 233 | { |
|
234 | 234 | Q_D(QBarSeries); |
|
235 | 235 | d->setBarWidth(width); |
|
236 | 236 | } |
|
237 | 237 | |
|
238 | 238 | /*! |
|
239 | 239 | Returns the width of the bars of the series. |
|
240 | 240 | \sa setBarWidth() |
|
241 | 241 | */ |
|
242 | 242 | qreal QBarSeries::barWidth() const |
|
243 | 243 | { |
|
244 | 244 | Q_D(const QBarSeries); |
|
245 | 245 | return d->barWidth(); |
|
246 | 246 | } |
|
247 | 247 | |
|
248 | 248 | /*! |
|
249 | 249 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
250 | 250 | Returns true, if appending succeeded. |
|
251 | 251 | */ |
|
252 | 252 | bool QBarSeries::append(QBarSet *set) |
|
253 | 253 | { |
|
254 | 254 | Q_D(QBarSeries); |
|
255 | 255 | bool success = d->append(set); |
|
256 | 256 | if (success) { |
|
257 | 257 | QList<QBarSet*> sets; |
|
258 | 258 | sets.append(set); |
|
259 | 259 | emit barsetsAdded(sets); |
|
260 | 260 | emit countChanged(); |
|
261 | 261 | } |
|
262 | 262 | return success; |
|
263 | 263 | } |
|
264 | 264 | |
|
265 | 265 | /*! |
|
266 | 266 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
267 | 267 | Returns true, if set was removed. |
|
268 | 268 | */ |
|
269 | 269 | bool QBarSeries::remove(QBarSet *set) |
|
270 | 270 | { |
|
271 | 271 | Q_D(QBarSeries); |
|
272 | 272 | bool success = d->remove(set); |
|
273 | 273 | if (success) { |
|
274 | 274 | QList<QBarSet*> sets; |
|
275 | 275 | sets.append(set); |
|
276 | 276 | emit barsetsRemoved(sets); |
|
277 | 277 | emit countChanged(); |
|
278 | 278 | } |
|
279 | 279 | return success; |
|
280 | 280 | } |
|
281 | 281 | |
|
282 | 282 | /*! |
|
283 | 283 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
284 | 284 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, |
|
285 | 285 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended |
|
286 | 286 | and function returns false. |
|
287 | 287 | */ |
|
288 | 288 | bool QBarSeries::append(QList<QBarSet* > sets) |
|
289 | 289 | { |
|
290 | 290 | Q_D(QBarSeries); |
|
291 | 291 | bool success = d->append(sets); |
|
292 | 292 | if (success) { |
|
293 | 293 | emit barsetsAdded(sets); |
|
294 | 294 | emit countChanged(); |
|
295 | 295 | } |
|
296 | 296 | return success; |
|
297 | 297 | } |
|
298 | 298 | |
|
299 | 299 | /*! |
|
300 | 300 | Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
301 | 301 | Returns true, if inserting succeeded. |
|
302 | 302 | |
|
303 | 303 | */ |
|
304 | 304 | bool QBarSeries::insert(int index, QBarSet *set) |
|
305 | 305 | { |
|
306 | 306 | Q_D(QBarSeries); |
|
307 | 307 | bool success = d->insert(index, set); |
|
308 | 308 | if (success) { |
|
309 | 309 | QList<QBarSet*> sets; |
|
310 | 310 | sets.append(set); |
|
311 | 311 | emit barsetsAdded(sets); |
|
312 | 312 | emit countChanged(); |
|
313 | 313 | } |
|
314 | 314 | return success; |
|
315 | 315 | } |
|
316 | 316 | |
|
317 | 317 | /*! |
|
318 | 318 | Removes all of the bar sets from the series |
|
319 | 319 | */ |
|
320 | 320 | void QBarSeries::clear() |
|
321 | 321 | { |
|
322 | 322 | Q_D(QBarSeries); |
|
323 | 323 | QList<QBarSet *> sets = barSets(); |
|
324 | 324 | bool success = d->remove(sets); |
|
325 | 325 | if (success) { |
|
326 | 326 | emit barsetsRemoved(sets); |
|
327 | 327 | emit countChanged(); |
|
328 | 328 | } |
|
329 | 329 | } |
|
330 | 330 | |
|
331 | 331 | /*! |
|
332 | 332 | Returns number of sets in series. |
|
333 | 333 | */ |
|
334 | 334 | int QBarSeries::count() const |
|
335 | 335 | { |
|
336 | 336 | Q_D(const QBarSeries); |
|
337 | 337 | return d->m_barSets.count(); |
|
338 | 338 | } |
|
339 | 339 | |
|
340 | 340 | /*! |
|
341 | 341 | Returns a list of sets in series. Keeps ownership of sets. |
|
342 | 342 | */ |
|
343 | 343 | QList<QBarSet*> QBarSeries::barSets() const |
|
344 | 344 | { |
|
345 | 345 | Q_D(const QBarSeries); |
|
346 | 346 | return d->m_barSets; |
|
347 | 347 | } |
|
348 | 348 | |
|
349 | 349 | /*! |
|
350 | 350 | Sets the visibility of labels in series to \a visible |
|
351 | 351 | */ |
|
352 | 352 | void QBarSeries::setLabelsVisible(bool visible) |
|
353 | 353 | { |
|
354 | 354 | Q_D(QBarSeries); |
|
355 | 355 | if (d->m_labelsVisible != visible) { |
|
356 | 356 | d->setLabelsVisible(visible); |
|
357 | 357 | emit labelsVisibleChanged(); |
|
358 | 358 | } |
|
359 | 359 | } |
|
360 | 360 | |
|
361 | 361 | /*! |
|
362 | 362 | Returns the visibility of labels |
|
363 | 363 | */ |
|
364 | 364 | bool QBarSeries::isLabelsVisible() const |
|
365 | 365 | { |
|
366 | 366 | Q_D(const QBarSeries); |
|
367 | 367 | return d->m_labelsVisible; |
|
368 | 368 | } |
|
369 | 369 | |
|
370 | 370 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
371 | 371 | |
|
372 | 372 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : |
|
373 | 373 | QAbstractSeriesPrivate(q), |
|
374 | 374 | m_barWidth(0.5), // Default value is 50% of category width |
|
375 | 375 | m_labelsVisible(false), |
|
376 | 376 | m_visible(true) |
|
377 | 377 | { |
|
378 | 378 | } |
|
379 | 379 | |
|
380 | 380 | int QBarSeriesPrivate::categoryCount() const |
|
381 | 381 | { |
|
382 | 382 | // No categories defined. return count of longest set. |
|
383 | 383 | int count = 0; |
|
384 | 384 | for (int i=0; i<m_barSets.count(); i++) { |
|
385 | 385 | if (m_barSets.at(i)->count() > count) { |
|
386 | 386 | count = m_barSets.at(i)->count(); |
|
387 | 387 | } |
|
388 | 388 | } |
|
389 | 389 | |
|
390 | 390 | return count; |
|
391 | 391 | } |
|
392 | 392 | |
|
393 | 393 | void QBarSeriesPrivate::setBarWidth(qreal width) |
|
394 | 394 | { |
|
395 | 395 | if (width < 0.0) { |
|
396 | 396 | width = 0.0; |
|
397 | 397 | } |
|
398 | 398 | m_barWidth = width; |
|
399 | 399 | emit updatedBars(); |
|
400 | 400 | } |
|
401 | 401 | |
|
402 | 402 | qreal QBarSeriesPrivate::barWidth() const |
|
403 | 403 | { |
|
404 | 404 | return m_barWidth; |
|
405 | 405 | } |
|
406 | 406 | |
|
407 | 407 | QBarSet* QBarSeriesPrivate::barsetAt(int index) |
|
408 | 408 | { |
|
409 | 409 | return m_barSets.at(index); |
|
410 | 410 | } |
|
411 | 411 | |
|
412 | 412 | void QBarSeriesPrivate::setVisible(bool visible) |
|
413 | 413 | { |
|
414 | 414 | m_visible = visible; |
|
415 | 415 | emit updatedBars(); |
|
416 | 416 | } |
|
417 | 417 | |
|
418 | 418 | void QBarSeriesPrivate::setLabelsVisible(bool visible) |
|
419 | 419 | { |
|
420 | 420 | m_labelsVisible = visible; |
|
421 | 421 | emit labelsVisibleChanged(visible); |
|
422 | 422 | } |
|
423 | 423 | |
|
424 | 424 | qreal QBarSeriesPrivate::min() |
|
425 | 425 | { |
|
426 | 426 | if (m_barSets.count() <= 0) { |
|
427 | 427 | return 0; |
|
428 | 428 | } |
|
429 | 429 | qreal min = INT_MAX; |
|
430 | 430 | |
|
431 | 431 | for (int i = 0; i < m_barSets.count(); i++) { |
|
432 | 432 | int categoryCount = m_barSets.at(i)->count(); |
|
433 | 433 | for (int j = 0; j < categoryCount; j++) { |
|
434 | 434 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
435 | 435 | if (temp < min) |
|
436 | 436 | min = temp; |
|
437 | 437 | } |
|
438 | 438 | } |
|
439 | 439 | return min; |
|
440 | 440 | } |
|
441 | 441 | |
|
442 | 442 | qreal QBarSeriesPrivate::max() |
|
443 | 443 | { |
|
444 | 444 | if (m_barSets.count() <= 0) { |
|
445 | 445 | return 0; |
|
446 | 446 | } |
|
447 | 447 | qreal max = INT_MIN; |
|
448 | 448 | |
|
449 | 449 | for (int i = 0; i < m_barSets.count(); i++) { |
|
450 | 450 | int categoryCount = m_barSets.at(i)->count(); |
|
451 | 451 | for (int j = 0; j < categoryCount; j++) { |
|
452 | 452 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
453 | 453 | if (temp > max) |
|
454 | 454 | max = temp; |
|
455 | 455 | } |
|
456 | 456 | } |
|
457 | 457 | |
|
458 | 458 | return max; |
|
459 | 459 | } |
|
460 | 460 | |
|
461 | 461 | qreal QBarSeriesPrivate::valueAt(int set, int category) |
|
462 | 462 | { |
|
463 | 463 | if ((set < 0) || (set >= m_barSets.count())) { |
|
464 | 464 | // No set, no value. |
|
465 | 465 | return 0; |
|
466 | 466 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
467 | 467 | // No category, no value. |
|
468 | 468 | return 0; |
|
469 | 469 | } |
|
470 | 470 | |
|
471 | 471 | return m_barSets.at(set)->at(category).y(); |
|
472 | 472 | } |
|
473 | 473 | |
|
474 | 474 | qreal QBarSeriesPrivate::percentageAt(int set, int category) |
|
475 | 475 | { |
|
476 | 476 | if ((set < 0) || (set >= m_barSets.count())) { |
|
477 | 477 | // No set, no value. |
|
478 | 478 | return 0; |
|
479 | 479 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
480 | 480 | // No category, no value. |
|
481 | 481 | return 0; |
|
482 | 482 | } |
|
483 | 483 | |
|
484 | 484 | qreal value = m_barSets.at(set)->at(category).y(); |
|
485 | 485 | qreal sum = categorySum(category); |
|
486 | 486 | if ( qFuzzyIsNull(sum) ) { |
|
487 | 487 | return 0; |
|
488 | 488 | } |
|
489 | 489 | |
|
490 | 490 | return value / sum; |
|
491 | 491 | } |
|
492 | 492 | |
|
493 | 493 | qreal QBarSeriesPrivate::categorySum(int category) |
|
494 | 494 | { |
|
495 | 495 | qreal sum(0); |
|
496 | 496 | int count = m_barSets.count(); // Count sets |
|
497 | 497 | for (int set = 0; set < count; set++) { |
|
498 | 498 | if (category < m_barSets.at(set)->count()) |
|
499 | 499 | sum += m_barSets.at(set)->at(category).y(); |
|
500 | 500 | } |
|
501 | 501 | return sum; |
|
502 | 502 | } |
|
503 | 503 | |
|
504 | 504 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) |
|
505 | 505 | { |
|
506 | 506 | qreal sum(0); |
|
507 | 507 | int count = m_barSets.count(); // Count sets |
|
508 | 508 | for (int set = 0; set < count; set++) { |
|
509 | 509 | if (category < m_barSets.at(set)->count()) |
|
510 | 510 | sum += qAbs(m_barSets.at(set)->at(category).y()); |
|
511 | 511 | } |
|
512 | 512 | return sum; |
|
513 | 513 | } |
|
514 | 514 | |
|
515 | 515 | qreal QBarSeriesPrivate::maxCategorySum() |
|
516 | 516 | { |
|
517 | 517 | qreal max = INT_MIN; |
|
518 | 518 | int count = categoryCount(); |
|
519 | 519 | for (int i = 0; i < count; i++) { |
|
520 | 520 | qreal sum = categorySum(i); |
|
521 | 521 | if (sum > max) |
|
522 | 522 | max = sum; |
|
523 | 523 | } |
|
524 | 524 | return max; |
|
525 | 525 | } |
|
526 | 526 | |
|
527 | 527 | qreal QBarSeriesPrivate::minX() |
|
528 | 528 | { |
|
529 | 529 | if (m_barSets.count() <= 0) { |
|
530 | 530 | return 0; |
|
531 | 531 | } |
|
532 | 532 | qreal min = INT_MAX; |
|
533 | 533 | |
|
534 | 534 | for (int i = 0; i < m_barSets.count(); i++) { |
|
535 | 535 | int categoryCount = m_barSets.at(i)->count(); |
|
536 | 536 | for (int j = 0; j < categoryCount; j++) { |
|
537 | 537 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
538 | 538 | if (temp < min) |
|
539 | 539 | min = temp; |
|
540 | 540 | } |
|
541 | 541 | } |
|
542 | 542 | return min; |
|
543 | 543 | } |
|
544 | 544 | |
|
545 | 545 | qreal QBarSeriesPrivate::maxX() |
|
546 | 546 | { |
|
547 | 547 | if (m_barSets.count() <= 0) { |
|
548 | 548 | return 0; |
|
549 | 549 | } |
|
550 | 550 | qreal max = INT_MIN; |
|
551 | 551 | |
|
552 | 552 | for (int i = 0; i < m_barSets.count(); i++) { |
|
553 | 553 | int categoryCount = m_barSets.at(i)->count(); |
|
554 | 554 | for (int j = 0; j < categoryCount; j++) { |
|
555 | 555 | qreal temp = m_barSets.at(i)->at(j).x(); |
|
556 | 556 | if (temp > max) |
|
557 | 557 | max = temp; |
|
558 | 558 | } |
|
559 | 559 | } |
|
560 | 560 | |
|
561 | 561 | return max; |
|
562 | 562 | } |
|
563 | 563 | |
|
564 | 564 | |
|
565 | 565 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
566 | 566 | { |
|
567 | 567 | qreal minX(domain.minX()); |
|
568 | 568 | qreal minY(domain.minY()); |
|
569 | 569 | qreal maxX(domain.maxX()); |
|
570 | 570 | qreal maxY(domain.maxY()); |
|
571 | 571 | int tickXCount(domain.tickXCount()); |
|
572 | 572 | int tickYCount(domain.tickYCount()); |
|
573 | 573 | |
|
574 | 574 | qreal seriesMinX = this->minX(); |
|
575 | 575 | qreal seriesMaxX = this->maxX(); |
|
576 | 576 | qreal y = max(); |
|
577 | 577 | minX = qMin(minX, seriesMinX - 0.5); |
|
578 | 578 | minY = qMin(minY, y); |
|
579 | 579 | maxX = qMax(maxX, seriesMaxX + 0.5); |
|
580 | 580 | maxY = qMax(maxY, y); |
|
581 | 581 | tickXCount = categoryCount()+1; |
|
582 | 582 | |
|
583 | 583 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
584 | 584 | } |
|
585 | 585 | |
|
586 | 586 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
587 | 587 | { |
|
588 | 588 | Q_Q(QBarSeries); |
|
589 | 589 | |
|
590 | 590 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
591 | 591 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
592 | 592 | presenter->animator()->addAnimation(bar); |
|
593 | 593 | } |
|
594 | 594 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
595 | 595 | return bar; |
|
596 | 596 | |
|
597 | 597 | } |
|
598 | 598 | |
|
599 | 599 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
600 | 600 | { |
|
601 | 601 | Q_Q(QBarSeries); |
|
602 | 602 | QList<LegendMarker*> markers; |
|
603 | 603 | foreach(QBarSet* set, q->barSets()) { |
|
604 | 604 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
605 | 605 | markers << marker; |
|
606 | 606 | } |
|
607 | 607 | |
|
608 | 608 | return markers; |
|
609 | 609 | } |
|
610 | 610 | |
|
611 | 611 | QAbstractAxis* QBarSeriesPrivate::createAxisX(QObject* parent) |
|
612 | 612 | { |
|
613 | 613 | return new QValuesAxis(parent); |
|
614 | 614 | } |
|
615 | 615 | |
|
616 | 616 | QAbstractAxis* QBarSeriesPrivate::createAxisY(QObject* parent) |
|
617 | 617 | { |
|
618 | 618 | return new QValuesAxis(parent); |
|
619 | 619 | } |
|
620 | 620 | |
|
621 | 621 | bool QBarSeriesPrivate::append(QBarSet *set) |
|
622 | 622 | { |
|
623 | 623 | Q_Q(QBarSeries); |
|
624 | 624 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
625 | 625 | // Fail if set is already in list or set is null. |
|
626 | 626 | return false; |
|
627 | 627 | } |
|
628 | 628 | m_barSets.append(set); |
|
629 | 629 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
630 | 630 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
631 | 631 | emit restructuredBars(); // this notifies barchartitem |
|
632 | 632 | if (m_dataset) { |
|
633 | 633 | m_dataset->updateSeries(q); // this notifies legend |
|
634 | 634 | } |
|
635 | 635 | return true; |
|
636 | 636 | } |
|
637 | 637 | |
|
638 | 638 | bool QBarSeriesPrivate::remove(QBarSet *set) |
|
639 | 639 | { |
|
640 | 640 | Q_Q(QBarSeries); |
|
641 | 641 | if (!m_barSets.contains(set)) { |
|
642 | 642 | // Fail if set is not in list |
|
643 | 643 | return false; |
|
644 | 644 | } |
|
645 | 645 | m_barSets.removeOne(set); |
|
646 | 646 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
647 | 647 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
648 | 648 | emit restructuredBars(); // this notifies barchartitem |
|
649 | 649 | if (m_dataset) { |
|
650 | 650 | m_dataset->updateSeries(q); // this notifies legend |
|
651 | 651 | } |
|
652 | 652 | return true; |
|
653 | 653 | } |
|
654 | 654 | |
|
655 | 655 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
656 | 656 | { |
|
657 | 657 | Q_Q(QBarSeries); |
|
658 | 658 | foreach (QBarSet* set, sets) { |
|
659 | 659 | if ((set == 0) || (m_barSets.contains(set))) { |
|
660 | 660 | // Fail if any of the sets is null or is already appended. |
|
661 | 661 | return false; |
|
662 | 662 | } |
|
663 | 663 | if (sets.count(set) != 1) { |
|
664 | 664 | // Also fail if same set is more than once in given list. |
|
665 | 665 | return false; |
|
666 | 666 | } |
|
667 | 667 | } |
|
668 | 668 | |
|
669 | 669 | foreach (QBarSet* set, sets) { |
|
670 | 670 | m_barSets.append(set); |
|
671 | 671 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
672 | 672 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
673 | 673 | } |
|
674 | 674 | emit restructuredBars(); // this notifies barchartitem |
|
675 | 675 | if (m_dataset) { |
|
676 | 676 | m_dataset->updateSeries(q); // this notifies legend |
|
677 | 677 | } |
|
678 | 678 | return true; |
|
679 | 679 | } |
|
680 | 680 | |
|
681 | 681 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
682 | 682 | { |
|
683 | 683 | Q_Q(QBarSeries); |
|
684 | 684 | if (sets.count() == 0) { |
|
685 | 685 | return false; |
|
686 | 686 | } |
|
687 | 687 | foreach (QBarSet* set, sets) { |
|
688 | 688 | if ((set == 0) || (!m_barSets.contains(set))) { |
|
689 | 689 | // Fail if any of the sets is null or is not in series |
|
690 | 690 | return false; |
|
691 | 691 | } |
|
692 | 692 | if (sets.count(set) != 1) { |
|
693 | 693 | // Also fail if same set is more than once in given list. |
|
694 | 694 | return false; |
|
695 | 695 | } |
|
696 | 696 | } |
|
697 | 697 | |
|
698 | 698 | foreach (QBarSet* set, sets) { |
|
699 | 699 | m_barSets.removeOne(set); |
|
700 | 700 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
701 | 701 | QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
702 | 702 | } |
|
703 | 703 | |
|
704 | 704 | emit restructuredBars(); // this notifies barchartitem |
|
705 | 705 | if (m_dataset) { |
|
706 | 706 | m_dataset->updateSeries(q); // this notifies legend |
|
707 | 707 | } |
|
708 | 708 | return true; |
|
709 | 709 | } |
|
710 | 710 | |
|
711 | 711 | bool QBarSeriesPrivate::insert(int index, QBarSet *set) |
|
712 | 712 | { |
|
713 | 713 | Q_Q(QBarSeries); |
|
714 | 714 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
715 | 715 | // Fail if set is already in list or set is null. |
|
716 | 716 | return false; |
|
717 | 717 | } |
|
718 | 718 | m_barSets.insert(index, set); |
|
719 | 719 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars())); |
|
720 | 720 | QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars())); |
|
721 | 721 | emit restructuredBars(); // this notifies barchartitem |
|
722 | 722 | if (m_dataset) { |
|
723 | 723 | m_dataset->updateSeries(q); // this notifies legend |
|
724 | 724 | } |
|
725 | 725 | return true; |
|
726 | 726 | } |
|
727 | 727 | |
|
728 | 728 | #include "moc_qbarseries.cpp" |
|
729 | 729 | #include "moc_qbarseries_p.cpp" |
|
730 | 730 | |
|
731 | 731 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,82 +1,82 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef BARSERIES_H |
|
22 | 22 | #define BARSERIES_H |
|
23 | 23 | |
|
24 | 24 | #include <qabstractseries.h> |
|
25 | 25 | #include <QStringList> |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | class QBarSet; |
|
30 | 30 | class QBarSeriesPrivate; |
|
31 | 31 | |
|
32 | 32 | // Container for series |
|
33 | 33 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries |
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | 36 | Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth) |
|
37 | 37 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
38 | 38 | Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
39 | 39 | |
|
40 | 40 | public: |
|
41 | 41 | explicit QBarSeries(QObject *parent = 0); |
|
42 | 42 | virtual ~QBarSeries(); |
|
43 | 43 | |
|
44 | 44 | QAbstractSeries::SeriesType type() const; |
|
45 | 45 | |
|
46 | 46 | void setBarWidth(qreal width); |
|
47 | 47 | qreal barWidth() const; |
|
48 | 48 | |
|
49 | 49 | bool append(QBarSet *set); |
|
50 | 50 | bool remove(QBarSet *set); |
|
51 | 51 | bool append(QList<QBarSet* > sets); |
|
52 | 52 | bool insert(int index, QBarSet *set); |
|
53 | 53 | int count() const; |
|
54 | 54 | QList<QBarSet*> barSets() const; |
|
55 | 55 | void clear(); |
|
56 | 56 | |
|
57 | 57 | void setLabelsVisible(bool visible = true); |
|
58 | 58 | bool isLabelsVisible() const; |
|
59 | 59 | |
|
60 | 60 | protected: |
|
61 | 61 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); |
|
62 | 62 | |
|
63 | 63 | Q_SIGNALS: |
|
64 |
void clicked(QBarSet *barset |
|
|
65 |
void hovered( |
|
|
64 | void clicked(int index, QBarSet *barset); | |
|
65 | void hovered(bool status, QBarSet *barset); | |
|
66 | 66 | void countChanged(); |
|
67 | 67 | void labelsVisibleChanged(); |
|
68 | 68 | |
|
69 | 69 | void barsetsAdded(QList<QBarSet*> sets); |
|
70 | 70 | void barsetsRemoved(QList<QBarSet*> sets); |
|
71 | 71 | |
|
72 | 72 | protected: |
|
73 | 73 | Q_DECLARE_PRIVATE(QBarSeries) |
|
74 | 74 | friend class BarChartItem; |
|
75 | 75 | friend class PercentBarChartItem; |
|
76 | 76 | friend class StackedBarChartItem; |
|
77 | 77 | friend class GroupedBarChartItem; |
|
78 | 78 | }; |
|
79 | 79 | |
|
80 | 80 | QTCOMMERCIALCHART_END_NAMESPACE |
|
81 | 81 | |
|
82 | 82 | #endif // BARSERIES_H |
@@ -1,97 +1,97 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QBARSERIES_P_H |
|
31 | 31 | #define QBARSERIES_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qbarseries.h" |
|
34 | 34 | #include "qabstractseries_p.h" |
|
35 | 35 | #include <QStringList> |
|
36 | 36 | #include <QAbstractSeries> |
|
37 | 37 | |
|
38 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | 39 | |
|
40 | 40 | class QBarModelMapper; |
|
41 | 41 | |
|
42 | 42 | class QBarSeriesPrivate : public QAbstractSeriesPrivate |
|
43 | 43 | { |
|
44 | 44 | Q_OBJECT |
|
45 | 45 | public: |
|
46 | 46 | QBarSeriesPrivate(QBarSeries *parent); |
|
47 | 47 | int categoryCount() const; |
|
48 | 48 | |
|
49 | 49 | void setBarWidth(qreal width); |
|
50 | 50 | qreal barWidth() const; |
|
51 | 51 | |
|
52 | 52 | void setVisible(bool visible); |
|
53 | 53 | void setLabelsVisible(bool visible); |
|
54 | 54 | |
|
55 | 55 | void scaleDomain(Domain& domain); |
|
56 | 56 | Chart* createGraphics(ChartPresenter* presenter); |
|
57 | 57 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
58 | 58 | |
|
59 | 59 | QAbstractAxis* createAxisX(QObject* parent = 0); |
|
60 | 60 | QAbstractAxis* createAxisY(QObject* parent = 0); |
|
61 | 61 | |
|
62 | 62 | bool append(QBarSet *set); |
|
63 | 63 | bool remove(QBarSet *set); |
|
64 | 64 | bool append(QList<QBarSet* > sets); |
|
65 | 65 | bool remove(QList<QBarSet* > sets); |
|
66 | 66 | bool insert(int index, QBarSet *set); |
|
67 | 67 | |
|
68 | 68 | QBarSet* barsetAt(int index); |
|
69 | 69 | qreal min(); |
|
70 | 70 | qreal max(); |
|
71 | 71 | qreal valueAt(int set, int category); |
|
72 | 72 | qreal percentageAt(int set, int category); |
|
73 | 73 | qreal categorySum(int category); |
|
74 | 74 | qreal absoluteCategorySum(int category); |
|
75 | 75 | qreal maxCategorySum(); |
|
76 | 76 | qreal minX(); |
|
77 | 77 | qreal maxX(); |
|
78 | 78 | |
|
79 | 79 | Q_SIGNALS: |
|
80 |
void clicked(QBarSet *barset |
|
|
80 | void clicked(int index, QBarSet *barset); | |
|
81 | 81 | void updatedBars(); |
|
82 | 82 | void restructuredBars(); |
|
83 | 83 | void labelsVisibleChanged(bool visible); |
|
84 | 84 | |
|
85 | 85 | protected: |
|
86 | 86 | QList<QBarSet *> m_barSets; |
|
87 | 87 | qreal m_barWidth; |
|
88 | 88 | bool m_labelsVisible; |
|
89 | 89 | bool m_visible; |
|
90 | 90 | |
|
91 | 91 | private: |
|
92 | 92 | Q_DECLARE_PUBLIC(QBarSeries) |
|
93 | 93 | }; |
|
94 | 94 | |
|
95 | 95 | QTCOMMERCIALCHART_END_NAMESPACE |
|
96 | 96 | |
|
97 | 97 | #endif // QBARSERIESPRIVATE_P_H |
@@ -1,571 +1,571 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtTest/QtTest> |
|
22 | 22 | #include <qbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | #include <qchartview.h> |
|
25 | 25 | #include <qchart.h> |
|
26 | 26 | #include "tst_definitions.h" |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | Q_DECLARE_METATYPE(QBarSet*) |
|
31 | 31 | |
|
32 | 32 | class tst_QBarSeries : public QObject |
|
33 | 33 | { |
|
34 | 34 | Q_OBJECT |
|
35 | 35 | |
|
36 | 36 | public slots: |
|
37 | 37 | void initTestCase(); |
|
38 | 38 | void cleanupTestCase(); |
|
39 | 39 | void init(); |
|
40 | 40 | void cleanup(); |
|
41 | 41 | |
|
42 | 42 | private slots: |
|
43 | 43 | void qbarseries_data(); |
|
44 | 44 | void qbarseries(); |
|
45 | 45 | void type_data(); |
|
46 | 46 | void type(); |
|
47 | 47 | void append_data(); |
|
48 | 48 | void append(); |
|
49 | 49 | void remove_data(); |
|
50 | 50 | void remove(); |
|
51 | 51 | void appendList_data(); |
|
52 | 52 | void appendList(); |
|
53 | 53 | void count_data(); |
|
54 | 54 | void count(); |
|
55 | 55 | void barSets_data(); |
|
56 | 56 | void barSets(); |
|
57 | 57 | void setLabelsVisible_data(); |
|
58 | 58 | void setLabelsVisible(); |
|
59 | 59 | void mouseclicked_data(); |
|
60 | 60 | void mouseclicked(); |
|
61 | 61 | void mousehovered_data(); |
|
62 | 62 | void mousehovered(); |
|
63 | 63 | void clearWithAnimations(); |
|
64 | 64 | |
|
65 | 65 | private: |
|
66 | 66 | QBarSeries* m_barseries; |
|
67 | 67 | QBarSeries* m_barseries_with_sets; |
|
68 | 68 | |
|
69 | 69 | QList<QBarSet*> m_testSets; |
|
70 | 70 | |
|
71 | 71 | }; |
|
72 | 72 | |
|
73 | 73 | void tst_QBarSeries::initTestCase() |
|
74 | 74 | { |
|
75 | 75 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | void tst_QBarSeries::cleanupTestCase() |
|
79 | 79 | { |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | void tst_QBarSeries::init() |
|
83 | 83 | { |
|
84 | 84 | m_barseries = new QBarSeries(); |
|
85 | 85 | m_barseries_with_sets = new QBarSeries(); |
|
86 | 86 | |
|
87 | 87 | for (int i=0; i<5; i++) { |
|
88 | 88 | m_testSets.append(new QBarSet("testset")); |
|
89 | 89 | m_barseries_with_sets->append(m_testSets.at(i)); |
|
90 | 90 | } |
|
91 | 91 | } |
|
92 | 92 | |
|
93 | 93 | void tst_QBarSeries::cleanup() |
|
94 | 94 | { |
|
95 | 95 | foreach(QBarSet* s, m_testSets) { |
|
96 | 96 | m_barseries_with_sets->remove(s); |
|
97 | 97 | delete s; |
|
98 | 98 | } |
|
99 | 99 | m_testSets.clear(); |
|
100 | 100 | |
|
101 | 101 | delete m_barseries; |
|
102 | 102 | m_barseries = 0; |
|
103 | 103 | delete m_barseries_with_sets; |
|
104 | 104 | m_barseries_with_sets = 0; |
|
105 | 105 | } |
|
106 | 106 | |
|
107 | 107 | void tst_QBarSeries::qbarseries_data() |
|
108 | 108 | { |
|
109 | 109 | } |
|
110 | 110 | |
|
111 | 111 | void tst_QBarSeries::qbarseries() |
|
112 | 112 | { |
|
113 | 113 | QBarSeries *barseries = new QBarSeries(); |
|
114 | 114 | QVERIFY(barseries != 0); |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | void tst_QBarSeries::type_data() |
|
118 | 118 | { |
|
119 | 119 | |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | 122 | void tst_QBarSeries::type() |
|
123 | 123 | { |
|
124 | 124 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); |
|
125 | 125 | } |
|
126 | 126 | |
|
127 | 127 | void tst_QBarSeries::append_data() |
|
128 | 128 | { |
|
129 | 129 | } |
|
130 | 130 | |
|
131 | 131 | void tst_QBarSeries::append() |
|
132 | 132 | { |
|
133 | 133 | QVERIFY(m_barseries->count() == 0); |
|
134 | 134 | |
|
135 | 135 | bool ret = false; |
|
136 | 136 | |
|
137 | 137 | // Try adding barset |
|
138 | 138 | QBarSet *barset = new QBarSet("testset"); |
|
139 | 139 | ret = m_barseries->append(barset); |
|
140 | 140 | |
|
141 | 141 | QVERIFY(ret == true); |
|
142 | 142 | QVERIFY(m_barseries->count() == 1); |
|
143 | 143 | |
|
144 | 144 | // Try adding another set |
|
145 | 145 | QBarSet *barset2 = new QBarSet("testset2"); |
|
146 | 146 | ret = m_barseries->append(barset2); |
|
147 | 147 | |
|
148 | 148 | QVERIFY(ret == true); |
|
149 | 149 | QVERIFY(m_barseries->count() == 2); |
|
150 | 150 | |
|
151 | 151 | // Try adding same set again |
|
152 | 152 | ret = m_barseries->append(barset2); |
|
153 | 153 | QVERIFY(ret == false); |
|
154 | 154 | QVERIFY(m_barseries->count() == 2); |
|
155 | 155 | |
|
156 | 156 | // Try adding null set |
|
157 | 157 | ret = m_barseries->append(0); |
|
158 | 158 | QVERIFY(ret == false); |
|
159 | 159 | QVERIFY(m_barseries->count() == 2); |
|
160 | 160 | |
|
161 | 161 | } |
|
162 | 162 | |
|
163 | 163 | void tst_QBarSeries::remove_data() |
|
164 | 164 | { |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | void tst_QBarSeries::remove() |
|
168 | 168 | { |
|
169 | 169 | int count = m_testSets.count(); |
|
170 | 170 | QVERIFY(m_barseries_with_sets->count() == count); |
|
171 | 171 | |
|
172 | 172 | // Try to remove null pointer (should not remove, should not crash) |
|
173 | 173 | bool ret = false; |
|
174 | 174 | ret = m_barseries_with_sets->remove(0); |
|
175 | 175 | QVERIFY(ret == false); |
|
176 | 176 | QVERIFY(m_barseries_with_sets->count() == count); |
|
177 | 177 | |
|
178 | 178 | // Try to remove invalid pointer (should not remove, should not crash) |
|
179 | 179 | ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); |
|
180 | 180 | QVERIFY(ret == false); |
|
181 | 181 | QVERIFY(m_barseries_with_sets->count() == count); |
|
182 | 182 | |
|
183 | 183 | // remove some sets |
|
184 | 184 | ret = m_barseries_with_sets->remove(m_testSets.at(2)); |
|
185 | 185 | QVERIFY(ret == true); |
|
186 | 186 | ret = m_barseries_with_sets->remove(m_testSets.at(3)); |
|
187 | 187 | QVERIFY(ret == true); |
|
188 | 188 | ret = m_barseries_with_sets->remove(m_testSets.at(4)); |
|
189 | 189 | QVERIFY(ret == true); |
|
190 | 190 | |
|
191 | 191 | QVERIFY(m_barseries_with_sets->count() == 2); |
|
192 | 192 | |
|
193 | 193 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); |
|
194 | 194 | |
|
195 | 195 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); |
|
196 | 196 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); |
|
197 | 197 | |
|
198 | 198 | // Try removing all sets again (should be ok, even if some sets have already been removed) |
|
199 | 199 | ret = false; |
|
200 | 200 | for (int i=0; i<count; i++) { |
|
201 | 201 | ret |= m_barseries_with_sets->remove(m_testSets.at(i)); |
|
202 | 202 | } |
|
203 | 203 | |
|
204 | 204 | QVERIFY(ret == true); |
|
205 | 205 | QVERIFY(m_barseries_with_sets->count() == 0); |
|
206 | 206 | } |
|
207 | 207 | |
|
208 | 208 | void tst_QBarSeries::appendList_data() |
|
209 | 209 | { |
|
210 | 210 | |
|
211 | 211 | } |
|
212 | 212 | |
|
213 | 213 | void tst_QBarSeries::appendList() |
|
214 | 214 | { |
|
215 | 215 | int count = 5; |
|
216 | 216 | QVERIFY(m_barseries->count() == 0); |
|
217 | 217 | |
|
218 | 218 | QList<QBarSet*> sets; |
|
219 | 219 | for (int i=0; i<count; i++) { |
|
220 | 220 | sets.append(new QBarSet("testset")); |
|
221 | 221 | } |
|
222 | 222 | |
|
223 | 223 | // Append new sets (should succeed, count should match the count of sets) |
|
224 | 224 | bool ret = false; |
|
225 | 225 | ret = m_barseries->append(sets); |
|
226 | 226 | QVERIFY(ret == true); |
|
227 | 227 | QVERIFY(m_barseries->count() == count); |
|
228 | 228 | |
|
229 | 229 | // Append same sets again (should fail, count should remain same) |
|
230 | 230 | ret = m_barseries->append(sets); |
|
231 | 231 | QVERIFY(ret == false); |
|
232 | 232 | QVERIFY(m_barseries->count() == count); |
|
233 | 233 | |
|
234 | 234 | // Try append empty list (should succeed, but count should remain same) |
|
235 | 235 | QList<QBarSet*> invalidList; |
|
236 | 236 | ret = m_barseries->append(invalidList); |
|
237 | 237 | QVERIFY(ret == true); |
|
238 | 238 | QVERIFY(m_barseries->count() == count); |
|
239 | 239 | |
|
240 | 240 | // Try append list with one new and one existing set (should fail, count remains same) |
|
241 | 241 | invalidList.append(new QBarSet("ok set")); |
|
242 | 242 | invalidList.append(sets.at(0)); |
|
243 | 243 | ret = m_barseries->append(invalidList); |
|
244 | 244 | QVERIFY(ret == false); |
|
245 | 245 | QVERIFY(m_barseries->count() == count); |
|
246 | 246 | |
|
247 | 247 | // Try append list with null pointers (should fail, count remains same) |
|
248 | 248 | QList<QBarSet*> invalidList2; |
|
249 | 249 | invalidList2.append(0); |
|
250 | 250 | invalidList2.append(0); |
|
251 | 251 | invalidList2.append(0); |
|
252 | 252 | ret = m_barseries->append(invalidList2); |
|
253 | 253 | QVERIFY(ret == false); |
|
254 | 254 | QVERIFY(m_barseries->count() == count); |
|
255 | 255 | } |
|
256 | 256 | |
|
257 | 257 | void tst_QBarSeries::count_data() |
|
258 | 258 | { |
|
259 | 259 | |
|
260 | 260 | } |
|
261 | 261 | |
|
262 | 262 | void tst_QBarSeries::count() |
|
263 | 263 | { |
|
264 | 264 | QVERIFY(m_barseries->count() == 0); |
|
265 | 265 | QVERIFY(m_barseries_with_sets->count() == m_testSets.count()); |
|
266 | 266 | } |
|
267 | 267 | |
|
268 | 268 | void tst_QBarSeries::barSets_data() |
|
269 | 269 | { |
|
270 | 270 | |
|
271 | 271 | } |
|
272 | 272 | |
|
273 | 273 | void tst_QBarSeries::barSets() |
|
274 | 274 | { |
|
275 | 275 | QVERIFY(m_barseries->barSets().count() == 0); |
|
276 | 276 | |
|
277 | 277 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); |
|
278 | 278 | QVERIFY(sets.count() == m_testSets.count()); |
|
279 | 279 | |
|
280 | 280 | for (int i=0; i<m_testSets.count(); i++) { |
|
281 | 281 | QVERIFY(sets.at(i) == m_testSets.at(i)); |
|
282 | 282 | } |
|
283 | 283 | } |
|
284 | 284 | |
|
285 | 285 | void tst_QBarSeries::setLabelsVisible_data() |
|
286 | 286 | { |
|
287 | 287 | |
|
288 | 288 | } |
|
289 | 289 | |
|
290 | 290 | void tst_QBarSeries::setLabelsVisible() |
|
291 | 291 | { |
|
292 | 292 | // labels should be invisible by default |
|
293 | 293 | QVERIFY(m_barseries->isLabelsVisible() == false); |
|
294 | 294 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); |
|
295 | 295 | |
|
296 | 296 | // turn labels to visible |
|
297 | 297 | m_barseries_with_sets->setLabelsVisible(true); |
|
298 | 298 | // TODO: test the signal |
|
299 | 299 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); |
|
300 | 300 | |
|
301 | 301 | // turn labels to invisible |
|
302 | 302 | m_barseries_with_sets->setLabelsVisible(false); |
|
303 | 303 | // TODO: test the signal |
|
304 | 304 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); |
|
305 | 305 | |
|
306 | 306 | // without parameter, should turn labels to visible |
|
307 | 307 | m_barseries_with_sets->setLabelsVisible(); |
|
308 | 308 | // TODO: test the signal |
|
309 | 309 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); |
|
310 | 310 | } |
|
311 | 311 | |
|
312 | 312 | void tst_QBarSeries::mouseclicked_data() |
|
313 | 313 | { |
|
314 | 314 | |
|
315 | 315 | } |
|
316 | 316 | |
|
317 | 317 | void tst_QBarSeries::mouseclicked() |
|
318 | 318 | { |
|
319 | 319 | QBarSeries* series = new QBarSeries(); |
|
320 | 320 | |
|
321 | 321 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
322 | 322 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
323 | 323 | series->append(set1); |
|
324 | 324 | |
|
325 | 325 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
326 | 326 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
327 | 327 | series->append(set2); |
|
328 | 328 | |
|
329 |
QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet* |
|
|
329 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); | |
|
330 | 330 | QSignalSpy setSpy1(set1, SIGNAL(clicked(int))); |
|
331 | 331 | QSignalSpy setSpy2(set2, SIGNAL(clicked(int))); |
|
332 | 332 | |
|
333 | 333 | QChartView view(new QChart()); |
|
334 | 334 | view.resize(400,300); |
|
335 | 335 | view.chart()->addSeries(series); |
|
336 | 336 | view.show(); |
|
337 | 337 | QTest::qWaitForWindowShown(&view); |
|
338 | 338 | |
|
339 | 339 | //==================================================================================== |
|
340 | 340 | // barset 1, bar 0 |
|
341 | 341 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(102,142)); |
|
342 | 342 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
343 | 343 | |
|
344 | 344 | QCOMPARE(seriesSpy.count(), 1); |
|
345 | 345 | QCOMPARE(setSpy1.count(), 1); |
|
346 | 346 | QCOMPARE(setSpy2.count(), 0); |
|
347 | 347 | |
|
348 | 348 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
349 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
350 |
QVERIFY(seriesSpyArg.at( |
|
|
351 |
QVERIFY(seriesSpyArg.at( |
|
|
349 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
350 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
351 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
352 | 352 | |
|
353 | 353 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
354 | 354 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
355 | 355 | QVERIFY(setSpyArg.at(0).toInt() == 0); |
|
356 | 356 | |
|
357 | 357 | //==================================================================================== |
|
358 | 358 | // barset 1, bar 1 |
|
359 | 359 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(186,142)); |
|
360 | 360 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
361 | 361 | |
|
362 | 362 | QCOMPARE(seriesSpy.count(), 1); |
|
363 | 363 | QCOMPARE(setSpy1.count(), 1); |
|
364 | 364 | QCOMPARE(setSpy2.count(), 0); |
|
365 | 365 | |
|
366 | 366 | seriesSpyArg = seriesSpy.takeFirst(); |
|
367 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
368 |
QVERIFY(seriesSpyArg.at( |
|
|
369 |
QVERIFY(seriesSpyArg.at( |
|
|
367 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
368 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
369 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
370 | 370 | |
|
371 | 371 | setSpyArg = setSpy1.takeFirst(); |
|
372 | 372 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
373 | 373 | QVERIFY(setSpyArg.at(0).toInt() == 1); |
|
374 | 374 | |
|
375 | 375 | //==================================================================================== |
|
376 | 376 | // barset 1, bar 2 |
|
377 | 377 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(271,142)); |
|
378 | 378 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
379 | 379 | |
|
380 | 380 | QCOMPARE(seriesSpy.count(), 1); |
|
381 | 381 | QCOMPARE(setSpy1.count(), 1); |
|
382 | 382 | QCOMPARE(setSpy2.count(), 0); |
|
383 | 383 | |
|
384 | 384 | seriesSpyArg = seriesSpy.takeFirst(); |
|
385 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
386 |
QVERIFY(seriesSpyArg.at( |
|
|
387 |
QVERIFY(seriesSpyArg.at( |
|
|
385 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
386 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
387 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
388 | 388 | |
|
389 | 389 | setSpyArg = setSpy1.takeFirst(); |
|
390 | 390 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
391 | 391 | QVERIFY(setSpyArg.at(0).toInt() == 2); |
|
392 | 392 | |
|
393 | 393 | //==================================================================================== |
|
394 | 394 | // barset 2, bar 0 |
|
395 | 395 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(127,142)); |
|
396 | 396 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
397 | 397 | |
|
398 | 398 | QCOMPARE(seriesSpy.count(), 1); |
|
399 | 399 | QCOMPARE(setSpy1.count(), 0); |
|
400 | 400 | QCOMPARE(setSpy2.count(), 1); |
|
401 | 401 | |
|
402 | 402 | seriesSpyArg = seriesSpy.takeFirst(); |
|
403 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
404 |
QVERIFY(seriesSpyArg.at( |
|
|
405 |
QVERIFY(seriesSpyArg.at( |
|
|
403 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
404 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
405 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
406 | 406 | |
|
407 | 407 | setSpyArg = setSpy2.takeFirst(); |
|
408 | 408 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
409 | 409 | QVERIFY(setSpyArg.at(0).toInt() == 0); |
|
410 | 410 | |
|
411 | 411 | //==================================================================================== |
|
412 | 412 | // barset 2, bar 1 |
|
413 | 413 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(212,142)); |
|
414 | 414 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
415 | 415 | |
|
416 | 416 | QCOMPARE(seriesSpy.count(), 1); |
|
417 | 417 | QCOMPARE(setSpy1.count(), 0); |
|
418 | 418 | QCOMPARE(setSpy2.count(), 1); |
|
419 | 419 | |
|
420 | 420 | seriesSpyArg = seriesSpy.takeFirst(); |
|
421 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
422 |
QVERIFY(seriesSpyArg.at( |
|
|
423 |
QVERIFY(seriesSpyArg.at( |
|
|
421 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
422 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
423 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
424 | 424 | |
|
425 | 425 | setSpyArg = setSpy2.takeFirst(); |
|
426 | 426 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
427 | 427 | QVERIFY(setSpyArg.at(0).toInt() == 1); |
|
428 | 428 | |
|
429 | 429 | //==================================================================================== |
|
430 | 430 | // barset 2, bar 2 |
|
431 | 431 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(296,142)); |
|
432 | 432 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
433 | 433 | |
|
434 | 434 | QCOMPARE(seriesSpy.count(), 1); |
|
435 | 435 | QCOMPARE(setSpy1.count(), 0); |
|
436 | 436 | QCOMPARE(setSpy2.count(), 1); |
|
437 | 437 | |
|
438 | 438 | seriesSpyArg = seriesSpy.takeFirst(); |
|
439 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
440 |
QVERIFY(seriesSpyArg.at( |
|
|
441 |
QVERIFY(seriesSpyArg.at( |
|
|
439 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
440 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
441 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
442 | 442 | |
|
443 | 443 | setSpyArg = setSpy2.takeFirst(); |
|
444 | 444 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
445 | 445 | QVERIFY(setSpyArg.at(0).toInt() == 2); |
|
446 | 446 | } |
|
447 | 447 | |
|
448 | 448 | void tst_QBarSeries::mousehovered_data() |
|
449 | 449 | { |
|
450 | 450 | |
|
451 | 451 | } |
|
452 | 452 | |
|
453 | 453 | void tst_QBarSeries::mousehovered() |
|
454 | 454 | { |
|
455 | 455 | QBarSeries* series = new QBarSeries(); |
|
456 | 456 | |
|
457 | 457 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
458 | 458 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
459 | 459 | series->append(set1); |
|
460 | 460 | |
|
461 | 461 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
462 | 462 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
463 | 463 | series->append(set2); |
|
464 | 464 | |
|
465 |
QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet* |
|
|
465 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); | |
|
466 | 466 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); |
|
467 | 467 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); |
|
468 | 468 | |
|
469 | 469 | QChartView view(new QChart()); |
|
470 | 470 | view.resize(400,300); |
|
471 | 471 | view.chart()->addSeries(series); |
|
472 | 472 | view.show(); |
|
473 | 473 | QTest::qWaitForWindowShown(&view); |
|
474 | 474 | |
|
475 | 475 | //this is hack since view does not get events otherwise |
|
476 | 476 | view.setMouseTracking(true); |
|
477 | 477 | |
|
478 | 478 | //======================================================================= |
|
479 | 479 | // move mouse to left border |
|
480 | 480 | QTest::mouseMove(view.viewport(), QPoint(0, 142)); |
|
481 | 481 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
482 | 482 | TRY_COMPARE(seriesSpy.count(), 0); |
|
483 | 483 | TRY_COMPARE(setSpy1.count(), 0); |
|
484 | 484 | TRY_COMPARE(setSpy2.count(), 0); |
|
485 | 485 | |
|
486 | 486 | //======================================================================= |
|
487 | 487 | // move mouse on top of set1 |
|
488 | 488 | QTest::mouseMove(view.viewport(), QPoint(102,142)); |
|
489 | 489 | TRY_COMPARE(seriesSpy.count(), 1); |
|
490 | 490 | TRY_COMPARE(setSpy1.count(), 1); |
|
491 | 491 | TRY_COMPARE(setSpy2.count(), 0); |
|
492 | 492 | |
|
493 | 493 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
494 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
495 |
QVERIFY(seriesSpyArg.at( |
|
|
496 |
QVERIFY(seriesSpyArg.at( |
|
|
494 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
495 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
496 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
497 | 497 | |
|
498 | 498 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
499 | 499 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
500 | 500 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
501 | 501 | |
|
502 | 502 | //======================================================================= |
|
503 | 503 | // move mouse from top of set1 to top of set2 |
|
504 | 504 | QTest::mouseMove(view.viewport(), QPoint(127,142)); |
|
505 | 505 | TRY_COMPARE(seriesSpy.count(), 2); |
|
506 | 506 | TRY_COMPARE(setSpy1.count(), 1); |
|
507 | 507 | TRY_COMPARE(setSpy2.count(), 1); |
|
508 | 508 | |
|
509 | 509 | // should leave set1 |
|
510 | 510 | seriesSpyArg = seriesSpy.takeFirst(); |
|
511 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
512 |
QVERIFY(seriesSpyArg.at( |
|
|
513 |
QVERIFY(seriesSpyArg.at( |
|
|
511 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
512 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
513 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
514 | 514 | |
|
515 | 515 | setSpyArg = setSpy1.takeFirst(); |
|
516 | 516 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
517 | 517 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
518 | 518 | |
|
519 | 519 | // should enter set2 |
|
520 | 520 | seriesSpyArg = seriesSpy.takeFirst(); |
|
521 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
522 |
QVERIFY(seriesSpyArg.at( |
|
|
523 |
QVERIFY(seriesSpyArg.at( |
|
|
521 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
522 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
523 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
524 | 524 | |
|
525 | 525 | setSpyArg = setSpy2.takeFirst(); |
|
526 | 526 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
527 | 527 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
528 | 528 | |
|
529 | 529 | //======================================================================= |
|
530 | 530 | // move mouse from top of set2 to background |
|
531 | 531 | QTest::mouseMove(view.viewport(), QPoint(127,0)); |
|
532 | 532 | TRY_COMPARE(seriesSpy.count(), 1); |
|
533 | 533 | TRY_COMPARE(setSpy1.count(), 0); |
|
534 | 534 | TRY_COMPARE(setSpy2.count(), 1); |
|
535 | 535 | |
|
536 | 536 | // should leave set2 |
|
537 | 537 | seriesSpyArg = seriesSpy.takeFirst(); |
|
538 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
539 |
QVERIFY(seriesSpyArg.at( |
|
|
540 |
QVERIFY(seriesSpyArg.at( |
|
|
538 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
539 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
540 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
541 | 541 | |
|
542 | 542 | setSpyArg = setSpy2.takeFirst(); |
|
543 | 543 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
544 | 544 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
545 | 545 | } |
|
546 | 546 | |
|
547 | 547 | void tst_QBarSeries::clearWithAnimations() |
|
548 | 548 | { |
|
549 | 549 | QBarSeries* series = new QBarSeries(); |
|
550 | 550 | |
|
551 | 551 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
552 | 552 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); |
|
553 | 553 | series->append(set1); |
|
554 | 554 | |
|
555 | 555 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
556 | 556 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); |
|
557 | 557 | series->append(set2); |
|
558 | 558 | |
|
559 | 559 | QChartView view(new QChart()); |
|
560 | 560 | view.resize(400,300); |
|
561 | 561 | view.chart()->setAnimationOptions(QChart::SeriesAnimations); |
|
562 | 562 | view.chart()->addSeries(series); |
|
563 | 563 | view.show(); |
|
564 | 564 | |
|
565 | 565 | series->clear(); |
|
566 | 566 | } |
|
567 | 567 | |
|
568 | 568 | QTEST_MAIN(tst_QBarSeries) |
|
569 | 569 | |
|
570 | 570 | #include "tst_qbarseries.moc" |
|
571 | 571 |
@@ -1,277 +1,277 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtTest/QtTest> |
|
22 | 22 | #include <qgroupedbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | #include <qchartview.h> |
|
25 | 25 | #include <qchart.h> |
|
26 | 26 | #include <QBarModelMapper> |
|
27 | 27 | #include <QStandardItemModel> |
|
28 | 28 | #include "tst_definitions.h" |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | Q_DECLARE_METATYPE(QBarSet*) |
|
33 | 33 | |
|
34 | 34 | class tst_QGroupedBarSeries : public QObject |
|
35 | 35 | { |
|
36 | 36 | Q_OBJECT |
|
37 | 37 | |
|
38 | 38 | public slots: |
|
39 | 39 | void initTestCase(); |
|
40 | 40 | void cleanupTestCase(); |
|
41 | 41 | void init(); |
|
42 | 42 | void cleanup(); |
|
43 | 43 | |
|
44 | 44 | private slots: |
|
45 | 45 | void qgroupedbarseries_data(); |
|
46 | 46 | void qgroupedbarseries(); |
|
47 | 47 | void type_data(); |
|
48 | 48 | void type(); |
|
49 | 49 | void mouseclicked_data(); |
|
50 | 50 | void mouseclicked(); |
|
51 | 51 | void mousehovered_data(); |
|
52 | 52 | void mousehovered(); |
|
53 | 53 | |
|
54 | 54 | private: |
|
55 | 55 | QGroupedBarSeries* m_barseries; |
|
56 | 56 | }; |
|
57 | 57 | |
|
58 | 58 | void tst_QGroupedBarSeries::initTestCase() |
|
59 | 59 | { |
|
60 | 60 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
61 | 61 | } |
|
62 | 62 | |
|
63 | 63 | void tst_QGroupedBarSeries::cleanupTestCase() |
|
64 | 64 | { |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | void tst_QGroupedBarSeries::init() |
|
68 | 68 | { |
|
69 | 69 | m_barseries = new QGroupedBarSeries(); |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | void tst_QGroupedBarSeries::cleanup() |
|
73 | 73 | { |
|
74 | 74 | delete m_barseries; |
|
75 | 75 | m_barseries = 0; |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | void tst_QGroupedBarSeries::qgroupedbarseries_data() |
|
79 | 79 | { |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | void tst_QGroupedBarSeries::qgroupedbarseries() |
|
83 | 83 | { |
|
84 | 84 | QGroupedBarSeries *barseries = new QGroupedBarSeries(); |
|
85 | 85 | QVERIFY(barseries != 0); |
|
86 | 86 | } |
|
87 | 87 | |
|
88 | 88 | void tst_QGroupedBarSeries::type_data() |
|
89 | 89 | { |
|
90 | 90 | |
|
91 | 91 | } |
|
92 | 92 | |
|
93 | 93 | void tst_QGroupedBarSeries::type() |
|
94 | 94 | { |
|
95 | 95 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeGroupedBar); |
|
96 | 96 | } |
|
97 | 97 | |
|
98 | 98 | void tst_QGroupedBarSeries::mouseclicked_data() |
|
99 | 99 | { |
|
100 | 100 | |
|
101 | 101 | } |
|
102 | 102 | |
|
103 | 103 | void tst_QGroupedBarSeries::mouseclicked() |
|
104 | 104 | { |
|
105 | 105 | QGroupedBarSeries* series = new QGroupedBarSeries(); |
|
106 | 106 | |
|
107 | 107 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
108 | 108 | *set1 << 10 << 10 << 10; |
|
109 | 109 | series->append(set1); |
|
110 | 110 | |
|
111 | 111 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
112 | 112 | *set2 << 10 << 10 << 10; |
|
113 | 113 | series->append(set2); |
|
114 | 114 | |
|
115 |
QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet* |
|
|
115 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); | |
|
116 | 116 | |
|
117 | 117 | QChartView view(new QChart()); |
|
118 | 118 | view.resize(400,300); |
|
119 | 119 | view.chart()->addSeries(series); |
|
120 | 120 | view.show(); |
|
121 | 121 | QTest::qWaitForWindowShown(&view); |
|
122 | 122 | |
|
123 | 123 | //==================================================================================== |
|
124 | 124 | // barset 1, category test1 |
|
125 | 125 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143)); |
|
126 | 126 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
127 | 127 | |
|
128 | 128 | QCOMPARE(seriesSpy.count(), 1); |
|
129 | 129 | |
|
130 | 130 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
131 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
132 |
QVERIFY(seriesSpyArg.at( |
|
|
133 |
QVERIFY(seriesSpyArg.at( |
|
|
131 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
132 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
133 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
134 | 134 | |
|
135 | 135 | //==================================================================================== |
|
136 | 136 | // barset 1, category test2 |
|
137 | 137 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143)); |
|
138 | 138 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
139 | 139 | |
|
140 | 140 | QCOMPARE(seriesSpy.count(), 1); |
|
141 | 141 | |
|
142 | 142 | seriesSpyArg = seriesSpy.takeFirst(); |
|
143 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
144 |
QVERIFY(seriesSpyArg.at( |
|
|
145 |
QVERIFY(seriesSpyArg.at( |
|
|
143 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
144 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
145 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
146 | 146 | |
|
147 | 147 | //==================================================================================== |
|
148 | 148 | // barset 1, category test3 |
|
149 | 149 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143)); |
|
150 | 150 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
151 | 151 | |
|
152 | 152 | QCOMPARE(seriesSpy.count(), 1); |
|
153 | 153 | |
|
154 | 154 | seriesSpyArg = seriesSpy.takeFirst(); |
|
155 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
156 |
QVERIFY(seriesSpyArg.at( |
|
|
157 |
QVERIFY(seriesSpyArg.at( |
|
|
155 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
156 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
157 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
158 | 158 | |
|
159 | 159 | //==================================================================================== |
|
160 | 160 | // barset 2, category test1 |
|
161 | 161 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143)); |
|
162 | 162 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
163 | 163 | |
|
164 | 164 | QCOMPARE(seriesSpy.count(), 1); |
|
165 | 165 | |
|
166 | 166 | seriesSpyArg = seriesSpy.takeFirst(); |
|
167 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
168 |
QVERIFY(seriesSpyArg.at( |
|
|
169 |
QVERIFY(seriesSpyArg.at( |
|
|
167 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
168 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
169 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
170 | 170 | |
|
171 | 171 | //==================================================================================== |
|
172 | 172 | // barset 2, category test2 |
|
173 | 173 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143)); |
|
174 | 174 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
175 | 175 | |
|
176 | 176 | QCOMPARE(seriesSpy.count(), 1); |
|
177 | 177 | |
|
178 | 178 | seriesSpyArg = seriesSpy.takeFirst(); |
|
179 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
180 |
QVERIFY(seriesSpyArg.at( |
|
|
181 |
QVERIFY(seriesSpyArg.at( |
|
|
179 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
180 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
181 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
182 | 182 | |
|
183 | 183 | //==================================================================================== |
|
184 | 184 | // barset 2, category test3 |
|
185 | 185 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143)); |
|
186 | 186 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
187 | 187 | |
|
188 | 188 | QCOMPARE(seriesSpy.count(), 1); |
|
189 | 189 | |
|
190 | 190 | seriesSpyArg = seriesSpy.takeFirst(); |
|
191 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
192 |
QVERIFY(seriesSpyArg.at( |
|
|
193 |
QVERIFY(seriesSpyArg.at( |
|
|
191 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
192 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
193 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | void tst_QGroupedBarSeries::mousehovered_data() |
|
197 | 197 | { |
|
198 | 198 | |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | void tst_QGroupedBarSeries::mousehovered() |
|
202 | 202 | { |
|
203 | 203 | QGroupedBarSeries* series = new QGroupedBarSeries(); |
|
204 | 204 | |
|
205 | 205 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
206 | 206 | *set1 << 10 << 10 << 10; |
|
207 | 207 | series->append(set1); |
|
208 | 208 | |
|
209 | 209 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
210 | 210 | *set2 << 10 << 10 << 10; |
|
211 | 211 | series->append(set2); |
|
212 | 212 | |
|
213 |
QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet* |
|
|
213 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); | |
|
214 | 214 | |
|
215 | 215 | QChartView view(new QChart()); |
|
216 | 216 | view.resize(400,300); |
|
217 | 217 | view.chart()->addSeries(series); |
|
218 | 218 | view.show(); |
|
219 | 219 | QTest::qWaitForWindowShown(&view); |
|
220 | 220 | |
|
221 | 221 | //this is hack since view does not get events otherwise |
|
222 | 222 | view.setMouseTracking(true); |
|
223 | 223 | |
|
224 | 224 | //======================================================================= |
|
225 | 225 | // move mouse to left border |
|
226 | 226 | qDebug() << "move mouse to left border"; |
|
227 | 227 | QTest::mouseMove(view.viewport(), QPoint(0, 143)); |
|
228 | 228 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
229 | 229 | TRY_COMPARE(seriesSpy.count(), 0); |
|
230 | 230 | |
|
231 | 231 | //======================================================================= |
|
232 | 232 | // move mouse on top of set1 |
|
233 | 233 | qDebug() << "move mouse on top of set1"; |
|
234 | 234 | QTest::mouseMove(view.viewport(), QPoint(95,143)); |
|
235 | 235 | TRY_COMPARE(seriesSpy.count(), 1); |
|
236 | 236 | |
|
237 | 237 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
238 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
239 |
QVERIFY(seriesSpyArg.at( |
|
|
240 |
QVERIFY(seriesSpyArg.at( |
|
|
238 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
239 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
240 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
241 | 241 | |
|
242 | 242 | //======================================================================= |
|
243 | 243 | // move mouse from top of set1 to top of set2 |
|
244 | 244 | qDebug() << "move mouse from top of set1 to top of set2"; |
|
245 | 245 | QTest::mouseMove(view.viewport(), QPoint(118,143)); |
|
246 | 246 | TRY_COMPARE(seriesSpy.count(), 2); |
|
247 | 247 | |
|
248 | 248 | // should leave set1 |
|
249 | 249 | seriesSpyArg = seriesSpy.takeFirst(); |
|
250 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
251 |
QVERIFY(seriesSpyArg.at( |
|
|
252 |
QVERIFY(seriesSpyArg.at( |
|
|
250 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
251 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
252 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
253 | 253 | |
|
254 | 254 | // should enter set2 |
|
255 | 255 | seriesSpyArg = seriesSpy.takeFirst(); |
|
256 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
257 |
QVERIFY(seriesSpyArg.at( |
|
|
258 |
QVERIFY(seriesSpyArg.at( |
|
|
256 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
257 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
258 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
259 | 259 | |
|
260 | 260 | //======================================================================= |
|
261 | 261 | // move mouse from top of set2 to background |
|
262 | 262 | qDebug() << "move mouse from top of set2 to background"; |
|
263 | 263 | |
|
264 | 264 | QTest::mouseMove(view.viewport(), QPoint(118,0)); |
|
265 | 265 | TRY_COMPARE(seriesSpy.count(), 1); |
|
266 | 266 | |
|
267 | 267 | // should leave set2 |
|
268 | 268 | seriesSpyArg = seriesSpy.takeFirst(); |
|
269 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
270 |
QVERIFY(seriesSpyArg.at( |
|
|
271 |
QVERIFY(seriesSpyArg.at( |
|
|
269 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
270 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
271 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
272 | 272 | } |
|
273 | 273 | |
|
274 | 274 | QTEST_MAIN(tst_QGroupedBarSeries) |
|
275 | 275 | |
|
276 | 276 | #include "tst_qgroupedbarseries.moc" |
|
277 | 277 |
@@ -1,270 +1,270 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtTest/QtTest> |
|
22 | 22 | #include <qpercentbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | #include <qchartview.h> |
|
25 | 25 | #include <qchart.h> |
|
26 | 26 | #include "tst_definitions.h" |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | Q_DECLARE_METATYPE(QBarSet*) |
|
31 | 31 | |
|
32 | 32 | class tst_QPercentBarSeries : public QObject |
|
33 | 33 | { |
|
34 | 34 | Q_OBJECT |
|
35 | 35 | |
|
36 | 36 | public slots: |
|
37 | 37 | void initTestCase(); |
|
38 | 38 | void cleanupTestCase(); |
|
39 | 39 | void init(); |
|
40 | 40 | void cleanup(); |
|
41 | 41 | |
|
42 | 42 | private slots: |
|
43 | 43 | void qpercentbarseries_data(); |
|
44 | 44 | void qpercentbarseries(); |
|
45 | 45 | void type_data(); |
|
46 | 46 | void type(); |
|
47 | 47 | void mouseclicked_data(); |
|
48 | 48 | void mouseclicked(); |
|
49 | 49 | void mousehovered_data(); |
|
50 | 50 | void mousehovered(); |
|
51 | 51 | |
|
52 | 52 | private: |
|
53 | 53 | QPercentBarSeries* m_barseries; |
|
54 | 54 | }; |
|
55 | 55 | |
|
56 | 56 | void tst_QPercentBarSeries::initTestCase() |
|
57 | 57 | { |
|
58 | 58 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | void tst_QPercentBarSeries::cleanupTestCase() |
|
62 | 62 | { |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | void tst_QPercentBarSeries::init() |
|
66 | 66 | { |
|
67 | 67 | m_barseries = new QPercentBarSeries(); |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | void tst_QPercentBarSeries::cleanup() |
|
71 | 71 | { |
|
72 | 72 | delete m_barseries; |
|
73 | 73 | m_barseries = 0; |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | void tst_QPercentBarSeries::qpercentbarseries_data() |
|
77 | 77 | { |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | void tst_QPercentBarSeries::qpercentbarseries() |
|
81 | 81 | { |
|
82 | 82 | QPercentBarSeries *barseries = new QPercentBarSeries(); |
|
83 | 83 | QVERIFY(barseries != 0); |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | void tst_QPercentBarSeries::type_data() |
|
87 | 87 | { |
|
88 | 88 | |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | void tst_QPercentBarSeries::type() |
|
92 | 92 | { |
|
93 | 93 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar); |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | void tst_QPercentBarSeries::mouseclicked_data() |
|
97 | 97 | { |
|
98 | 98 | |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | void tst_QPercentBarSeries::mouseclicked() |
|
102 | 102 | { |
|
103 | 103 | QPercentBarSeries* series = new QPercentBarSeries(); |
|
104 | 104 | |
|
105 | 105 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
106 | 106 | *set1 << 10 << 10 << 10; |
|
107 | 107 | series->append(set1); |
|
108 | 108 | |
|
109 | 109 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
110 | 110 | *set2 << 10 << 10 << 10; |
|
111 | 111 | series->append(set2); |
|
112 | 112 | |
|
113 |
QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet* |
|
|
113 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); | |
|
114 | 114 | |
|
115 | 115 | QChartView view(new QChart()); |
|
116 | 116 | view.resize(400,300); |
|
117 | 117 | view.chart()->addSeries(series); |
|
118 | 118 | view.show(); |
|
119 | 119 | QTest::qWaitForWindowShown(&view); |
|
120 | 120 | |
|
121 | 121 | //==================================================================================== |
|
122 | 122 | // barset 1, category test1 |
|
123 | 123 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); |
|
124 | 124 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
125 | 125 | |
|
126 | 126 | QCOMPARE(seriesSpy.count(), 1); |
|
127 | 127 | |
|
128 | 128 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
129 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
130 |
QVERIFY(seriesSpyArg.at( |
|
|
131 |
QVERIFY(seriesSpyArg.at( |
|
|
129 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
130 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
131 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
132 | 132 | |
|
133 | 133 | //==================================================================================== |
|
134 | 134 | // barset 1, category test2 |
|
135 | 135 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); |
|
136 | 136 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
137 | 137 | |
|
138 | 138 | QCOMPARE(seriesSpy.count(), 1); |
|
139 | 139 | |
|
140 | 140 | seriesSpyArg = seriesSpy.takeFirst(); |
|
141 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
142 |
QVERIFY(seriesSpyArg.at( |
|
|
143 |
QVERIFY(seriesSpyArg.at( |
|
|
141 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
142 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
143 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
144 | 144 | |
|
145 | 145 | //==================================================================================== |
|
146 | 146 | // barset 1, category test3 |
|
147 | 147 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); |
|
148 | 148 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
149 | 149 | |
|
150 | 150 | QCOMPARE(seriesSpy.count(), 1); |
|
151 | 151 | |
|
152 | 152 | seriesSpyArg = seriesSpy.takeFirst(); |
|
153 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
154 |
QVERIFY(seriesSpyArg.at( |
|
|
155 |
QVERIFY(seriesSpyArg.at( |
|
|
153 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
154 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
155 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
156 | 156 | |
|
157 | 157 | //==================================================================================== |
|
158 | 158 | // barset 2, category test1 |
|
159 | 159 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); |
|
160 | 160 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
161 | 161 | |
|
162 | 162 | QCOMPARE(seriesSpy.count(), 1); |
|
163 | 163 | |
|
164 | 164 | seriesSpyArg = seriesSpy.takeFirst(); |
|
165 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
166 |
QVERIFY(seriesSpyArg.at( |
|
|
167 |
QVERIFY(seriesSpyArg.at( |
|
|
165 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
166 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
167 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
168 | 168 | |
|
169 | 169 | //==================================================================================== |
|
170 | 170 | // barset 2, category test2 |
|
171 | 171 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); |
|
172 | 172 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
173 | 173 | |
|
174 | 174 | QCOMPARE(seriesSpy.count(), 1); |
|
175 | 175 | |
|
176 | 176 | seriesSpyArg = seriesSpy.takeFirst(); |
|
177 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
178 |
QVERIFY(seriesSpyArg.at( |
|
|
179 |
QVERIFY(seriesSpyArg.at( |
|
|
177 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
178 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
179 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
180 | 180 | |
|
181 | 181 | //==================================================================================== |
|
182 | 182 | // barset 2, category test3 |
|
183 | 183 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); |
|
184 | 184 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
185 | 185 | |
|
186 | 186 | QCOMPARE(seriesSpy.count(), 1); |
|
187 | 187 | |
|
188 | 188 | seriesSpyArg = seriesSpy.takeFirst(); |
|
189 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
190 |
QVERIFY(seriesSpyArg.at( |
|
|
191 |
QVERIFY(seriesSpyArg.at( |
|
|
189 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
190 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
191 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
192 | 192 | } |
|
193 | 193 | |
|
194 | 194 | void tst_QPercentBarSeries::mousehovered_data() |
|
195 | 195 | { |
|
196 | 196 | |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | 199 | void tst_QPercentBarSeries::mousehovered() |
|
200 | 200 | { |
|
201 | 201 | QPercentBarSeries* series = new QPercentBarSeries(); |
|
202 | 202 | |
|
203 | 203 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
204 | 204 | *set1 << 10 << 10 << 10; |
|
205 | 205 | series->append(set1); |
|
206 | 206 | |
|
207 | 207 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
208 | 208 | *set2 << 10 << 10 << 10; |
|
209 | 209 | series->append(set2); |
|
210 | 210 | |
|
211 |
QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet* |
|
|
211 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); | |
|
212 | 212 | |
|
213 | 213 | QChartView view(new QChart()); |
|
214 | 214 | view.resize(400,300); |
|
215 | 215 | view.chart()->addSeries(series); |
|
216 | 216 | view.show(); |
|
217 | 217 | QTest::qWaitForWindowShown(&view); |
|
218 | 218 | |
|
219 | 219 | //this is hack since view does not get events otherwise |
|
220 | 220 | view.setMouseTracking(true); |
|
221 | 221 | |
|
222 | 222 | //======================================================================= |
|
223 | 223 | // move mouse to left border |
|
224 | 224 | QTest::mouseMove(view.viewport(), QPoint(0, 190)); |
|
225 | 225 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
226 | 226 | TRY_COMPARE(seriesSpy.count(), 0); |
|
227 | 227 | |
|
228 | 228 | //======================================================================= |
|
229 | 229 | // move mouse on top of set1 |
|
230 | 230 | QTest::mouseMove(view.viewport(), QPoint(106,190)); |
|
231 | 231 | TRY_COMPARE(seriesSpy.count(), 1); |
|
232 | 232 | |
|
233 | 233 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
234 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
235 |
QVERIFY(seriesSpyArg.at( |
|
|
236 |
QVERIFY(seriesSpyArg.at( |
|
|
234 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
235 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
236 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
237 | 237 | |
|
238 | 238 | //======================================================================= |
|
239 | 239 | // move mouse from top of set1 to top of set2 |
|
240 | 240 | QTest::mouseMove(view.viewport(), QPoint(106,95)); |
|
241 | 241 | TRY_COMPARE(seriesSpy.count(), 2); |
|
242 | 242 | |
|
243 | 243 | // should leave set1 |
|
244 | 244 | seriesSpyArg = seriesSpy.takeFirst(); |
|
245 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
246 |
QVERIFY(seriesSpyArg.at( |
|
|
247 |
QVERIFY(seriesSpyArg.at( |
|
|
245 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
246 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
247 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
248 | 248 | |
|
249 | 249 | // should enter set2 |
|
250 | 250 | seriesSpyArg = seriesSpy.takeFirst(); |
|
251 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
252 |
QVERIFY(seriesSpyArg.at( |
|
|
253 |
QVERIFY(seriesSpyArg.at( |
|
|
251 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
252 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
253 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
254 | 254 | |
|
255 | 255 | //======================================================================= |
|
256 | 256 | // move mouse from top of set2 to background |
|
257 | 257 | QTest::mouseMove(view.viewport(), QPoint(106,0)); |
|
258 | 258 | TRY_COMPARE(seriesSpy.count(), 1); |
|
259 | 259 | |
|
260 | 260 | // should leave set2 |
|
261 | 261 | seriesSpyArg = seriesSpy.takeFirst(); |
|
262 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
263 |
QVERIFY(seriesSpyArg.at( |
|
|
264 |
QVERIFY(seriesSpyArg.at( |
|
|
262 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
263 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
264 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | QTEST_MAIN(tst_QPercentBarSeries) |
|
268 | 268 | |
|
269 | 269 | #include "tst_qpercentbarseries.moc" |
|
270 | 270 |
@@ -1,270 +1,270 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtTest/QtTest> |
|
22 | 22 | #include <qstackedbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | #include <qchartview.h> |
|
25 | 25 | #include <qchart.h> |
|
26 | 26 | #include "tst_definitions.h" |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | Q_DECLARE_METATYPE(QBarSet*) |
|
31 | 31 | |
|
32 | 32 | class tst_QStackedBarSeries : public QObject |
|
33 | 33 | { |
|
34 | 34 | Q_OBJECT |
|
35 | 35 | |
|
36 | 36 | public slots: |
|
37 | 37 | void initTestCase(); |
|
38 | 38 | void cleanupTestCase(); |
|
39 | 39 | void init(); |
|
40 | 40 | void cleanup(); |
|
41 | 41 | |
|
42 | 42 | private slots: |
|
43 | 43 | void qstackedbarseries_data(); |
|
44 | 44 | void qstackedbarseries(); |
|
45 | 45 | void type_data(); |
|
46 | 46 | void type(); |
|
47 | 47 | void mouseclicked_data(); |
|
48 | 48 | void mouseclicked(); |
|
49 | 49 | void mousehovered_data(); |
|
50 | 50 | void mousehovered(); |
|
51 | 51 | |
|
52 | 52 | private: |
|
53 | 53 | QStackedBarSeries* m_barseries; |
|
54 | 54 | }; |
|
55 | 55 | |
|
56 | 56 | void tst_QStackedBarSeries::initTestCase() |
|
57 | 57 | { |
|
58 | 58 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | void tst_QStackedBarSeries::cleanupTestCase() |
|
62 | 62 | { |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | void tst_QStackedBarSeries::init() |
|
66 | 66 | { |
|
67 | 67 | m_barseries = new QStackedBarSeries(); |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | void tst_QStackedBarSeries::cleanup() |
|
71 | 71 | { |
|
72 | 72 | delete m_barseries; |
|
73 | 73 | m_barseries = 0; |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | void tst_QStackedBarSeries::qstackedbarseries_data() |
|
77 | 77 | { |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | void tst_QStackedBarSeries::qstackedbarseries() |
|
81 | 81 | { |
|
82 | 82 | QStackedBarSeries *barseries = new QStackedBarSeries(); |
|
83 | 83 | QVERIFY(barseries != 0); |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | void tst_QStackedBarSeries::type_data() |
|
87 | 87 | { |
|
88 | 88 | |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | void tst_QStackedBarSeries::type() |
|
92 | 92 | { |
|
93 | 93 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar); |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | void tst_QStackedBarSeries::mouseclicked_data() |
|
97 | 97 | { |
|
98 | 98 | |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | void tst_QStackedBarSeries::mouseclicked() |
|
102 | 102 | { |
|
103 | 103 | QStackedBarSeries* series = new QStackedBarSeries(); |
|
104 | 104 | |
|
105 | 105 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
106 | 106 | *set1 << 10 << 10 << 10; |
|
107 | 107 | series->append(set1); |
|
108 | 108 | |
|
109 | 109 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
110 | 110 | *set2 << 10 << 10 << 10; |
|
111 | 111 | series->append(set2); |
|
112 | 112 | |
|
113 |
QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet* |
|
|
113 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); | |
|
114 | 114 | |
|
115 | 115 | QChartView view(new QChart()); |
|
116 | 116 | view.resize(400,300); |
|
117 | 117 | view.chart()->addSeries(series); |
|
118 | 118 | view.show(); |
|
119 | 119 | QTest::qWaitForWindowShown(&view); |
|
120 | 120 | |
|
121 | 121 | //==================================================================================== |
|
122 | 122 | // barset 1, category test1 |
|
123 | 123 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); |
|
124 | 124 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
125 | 125 | |
|
126 | 126 | QCOMPARE(seriesSpy.count(), 1); |
|
127 | 127 | |
|
128 | 128 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
129 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
130 |
QVERIFY(seriesSpyArg.at( |
|
|
131 |
QVERIFY(seriesSpyArg.at( |
|
|
129 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
130 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
131 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
132 | 132 | |
|
133 | 133 | //==================================================================================== |
|
134 | 134 | // barset 1, category test2 |
|
135 | 135 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); |
|
136 | 136 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
137 | 137 | |
|
138 | 138 | QCOMPARE(seriesSpy.count(), 1); |
|
139 | 139 | |
|
140 | 140 | seriesSpyArg = seriesSpy.takeFirst(); |
|
141 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
142 |
QVERIFY(seriesSpyArg.at( |
|
|
143 |
QVERIFY(seriesSpyArg.at( |
|
|
141 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
142 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
143 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
144 | 144 | |
|
145 | 145 | //==================================================================================== |
|
146 | 146 | // barset 1, category test3 |
|
147 | 147 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); |
|
148 | 148 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
149 | 149 | |
|
150 | 150 | QCOMPARE(seriesSpy.count(), 1); |
|
151 | 151 | |
|
152 | 152 | seriesSpyArg = seriesSpy.takeFirst(); |
|
153 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
154 |
QVERIFY(seriesSpyArg.at( |
|
|
155 |
QVERIFY(seriesSpyArg.at( |
|
|
153 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
154 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
155 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
156 | 156 | |
|
157 | 157 | //==================================================================================== |
|
158 | 158 | // barset 2, category test1 |
|
159 | 159 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); |
|
160 | 160 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
161 | 161 | |
|
162 | 162 | QCOMPARE(seriesSpy.count(), 1); |
|
163 | 163 | |
|
164 | 164 | seriesSpyArg = seriesSpy.takeFirst(); |
|
165 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
166 |
QVERIFY(seriesSpyArg.at( |
|
|
167 |
QVERIFY(seriesSpyArg.at( |
|
|
165 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
166 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
167 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
|
168 | 168 | |
|
169 | 169 | //==================================================================================== |
|
170 | 170 | // barset 2, category test2 |
|
171 | 171 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); |
|
172 | 172 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
173 | 173 | |
|
174 | 174 | QCOMPARE(seriesSpy.count(), 1); |
|
175 | 175 | |
|
176 | 176 | seriesSpyArg = seriesSpy.takeFirst(); |
|
177 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
178 |
QVERIFY(seriesSpyArg.at( |
|
|
179 |
QVERIFY(seriesSpyArg.at( |
|
|
177 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
178 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
179 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
|
180 | 180 | |
|
181 | 181 | //==================================================================================== |
|
182 | 182 | // barset 2, category test3 |
|
183 | 183 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); |
|
184 | 184 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
185 | 185 | |
|
186 | 186 | QCOMPARE(seriesSpy.count(), 1); |
|
187 | 187 | |
|
188 | 188 | seriesSpyArg = seriesSpy.takeFirst(); |
|
189 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
190 |
QVERIFY(seriesSpyArg.at( |
|
|
191 |
QVERIFY(seriesSpyArg.at( |
|
|
189 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
190 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
|
191 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
|
192 | 192 | } |
|
193 | 193 | |
|
194 | 194 | void tst_QStackedBarSeries::mousehovered_data() |
|
195 | 195 | { |
|
196 | 196 | |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | 199 | void tst_QStackedBarSeries::mousehovered() |
|
200 | 200 | { |
|
201 | 201 | QStackedBarSeries* series = new QStackedBarSeries(); |
|
202 | 202 | |
|
203 | 203 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
204 | 204 | *set1 << 10 << 10 << 10; |
|
205 | 205 | series->append(set1); |
|
206 | 206 | |
|
207 | 207 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
208 | 208 | *set2 << 10 << 10 << 10; |
|
209 | 209 | series->append(set2); |
|
210 | 210 | |
|
211 |
QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet* |
|
|
211 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); | |
|
212 | 212 | |
|
213 | 213 | QChartView view(new QChart()); |
|
214 | 214 | view.resize(400,300); |
|
215 | 215 | view.chart()->addSeries(series); |
|
216 | 216 | view.show(); |
|
217 | 217 | QTest::qWaitForWindowShown(&view); |
|
218 | 218 | |
|
219 | 219 | //this is hack since view does not get events otherwise |
|
220 | 220 | view.setMouseTracking(true); |
|
221 | 221 | |
|
222 | 222 | //======================================================================= |
|
223 | 223 | // move mouse to left border |
|
224 | 224 | QTest::mouseMove(view.viewport(), QPoint(0, 190)); |
|
225 | 225 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
226 | 226 | TRY_COMPARE(seriesSpy.count(), 0); |
|
227 | 227 | |
|
228 | 228 | //======================================================================= |
|
229 | 229 | // move mouse on top of set1 |
|
230 | 230 | QTest::mouseMove(view.viewport(), QPoint(106,190)); |
|
231 | 231 | TRY_COMPARE(seriesSpy.count(), 1); |
|
232 | 232 | |
|
233 | 233 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
234 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
235 |
QVERIFY(seriesSpyArg.at( |
|
|
236 |
QVERIFY(seriesSpyArg.at( |
|
|
234 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
235 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
236 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
237 | 237 | |
|
238 | 238 | //======================================================================= |
|
239 | 239 | // move mouse from top of set1 to top of set2 |
|
240 | 240 | QTest::mouseMove(view.viewport(), QPoint(106,95)); |
|
241 | 241 | TRY_COMPARE(seriesSpy.count(), 2); |
|
242 | 242 | |
|
243 | 243 | // should leave set1 |
|
244 | 244 | seriesSpyArg = seriesSpy.takeFirst(); |
|
245 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
246 |
QVERIFY(seriesSpyArg.at( |
|
|
247 |
QVERIFY(seriesSpyArg.at( |
|
|
245 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
|
246 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
247 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
248 | 248 | |
|
249 | 249 | // should enter set2 |
|
250 | 250 | seriesSpyArg = seriesSpy.takeFirst(); |
|
251 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
252 |
QVERIFY(seriesSpyArg.at( |
|
|
253 |
QVERIFY(seriesSpyArg.at( |
|
|
251 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
252 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
253 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
|
254 | 254 | |
|
255 | 255 | //======================================================================= |
|
256 | 256 | // move mouse from top of set2 to background |
|
257 | 257 | QTest::mouseMove(view.viewport(), QPoint(106,0)); |
|
258 | 258 | TRY_COMPARE(seriesSpy.count(), 1); |
|
259 | 259 | |
|
260 | 260 | // should leave set2 |
|
261 | 261 | seriesSpyArg = seriesSpy.takeFirst(); |
|
262 |
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at( |
|
|
263 |
QVERIFY(seriesSpyArg.at( |
|
|
264 |
QVERIFY(seriesSpyArg.at( |
|
|
262 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
|
263 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
|
264 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | QTEST_MAIN(tst_QStackedBarSeries) |
|
268 | 268 | |
|
269 | 269 | #include "tst_qstackedbarseries.moc" |
|
270 | 270 |
General Comments 0
You need to be logged in to leave comments.
Login now