##// END OF EJS Templates
refactoring internal barchart items
sauimone -
r1674:2849be5cffb7
parent child
Show More
@@ -0,0 +1,179
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "abstractbarchartitem_p.h"
22 #include "bar_p.h"
23 #include "qbarset.h"
24 #include "qbarset_p.h"
25 #include "qabstractbarseries.h"
26 #include "qabstractbarseries_p.h"
27 #include "qchart.h"
28 #include "chartpresenter_p.h"
29 #include "chartanimator_p.h"
30 #include "abstractbaranimation_p.h"
31 #include "chartdataset_p.h"
32 #include <QPainter>
33
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
36 AbstractBarChartItem::AbstractBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) :
37 ChartItem(presenter),
38 m_animation(0),
39 m_series(series)
40 {
41 setFlag(ItemClipsChildrenToShape);
42 connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged()));
43 connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(handleLabelsVisibleChanged(bool)));
44 connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged()));
45 connect(series, SIGNAL(visibleChanged()), this, SLOT(handleVisibleChanged()));
46 setZValue(ChartPresenter::BarSeriesZValue);
47 handleDataStructureChanged();
48 }
49
50 AbstractBarChartItem::~AbstractBarChartItem()
51 {
52 }
53
54 void AbstractBarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
55 {
56 Q_UNUSED(painter);
57 Q_UNUSED(option);
58 Q_UNUSED(widget);
59 }
60
61 QRectF AbstractBarChartItem::boundingRect() const
62 {
63 return m_rect;
64 }
65
66 void AbstractBarChartItem::applyLayout(const QVector<QRectF> &layout)
67 {
68 if (m_animation) {
69 m_animation->setup(m_layout,layout);
70 presenter()->startAnimation(m_animation);
71
72 } else {
73 setLayout(layout);
74 update();
75 }
76 }
77
78 void AbstractBarChartItem::setAnimation(AbstractBarAnimation *animation)
79 {
80 m_animation = animation;
81 }
82
83 void AbstractBarChartItem::setLayout(const QVector<QRectF> &layout)
84 {
85 if (layout.count() != m_bars.count())
86 return;
87
88 m_layout = layout;
89
90 for (int i=0; i < m_bars.count(); i++) {
91 m_bars.at(i)->setRect(layout.at(i));
92 }
93 }
94 //handlers
95
96 void AbstractBarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
97 {
98 m_domainMinX = minX;
99 m_domainMaxX = maxX;
100 m_domainMinY = minY;
101 m_domainMaxY = maxY;
102 handleLayoutChanged();
103 }
104
105 void AbstractBarChartItem::handleGeometryChanged(const QRectF &rect)
106 {
107 prepareGeometryChange();
108 m_rect = rect;
109 handleLayoutChanged();
110 }
111
112 void AbstractBarChartItem::handleLayoutChanged()
113 {
114 if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) {
115 // rect size zero.
116 return;
117 }
118 QVector<QRectF> layout = calculateLayout();
119 applyLayout(layout);
120 }
121
122 void AbstractBarChartItem::handleLabelsVisibleChanged(bool visible)
123 {
124 foreach (QGraphicsSimpleTextItem* label, m_labels) {
125 label->setVisible(visible);
126 }
127 update();
128 }
129
130 void AbstractBarChartItem::handleDataStructureChanged()
131 {
132 foreach(QGraphicsItem *item, childItems()) {
133 delete item;
134 }
135
136 m_bars.clear();
137 m_labels.clear();
138 m_layout.clear();
139
140 bool labelsVisible = m_series->isLabelsVisible();
141
142 // Create new graphic items for bars
143 for (int c = 0; c < m_series->d_func()->categoryCount(); c++) {
144 for (int s = 0; s < m_series->count(); s++) {
145 QBarSet *set = m_series->d_func()->barsetAt(s);
146
147 // Bars
148 Bar *bar = new Bar(set,c,this);
149 m_bars.append(bar);
150 connect(bar, SIGNAL(clicked(int, QBarSet*)), m_series, SIGNAL(clicked(int, QBarSet*)));
151 connect(bar, SIGNAL(hovered(bool, QBarSet*)), m_series, SIGNAL(hovered(bool, QBarSet*)));
152 connect(bar, SIGNAL(clicked(int, QBarSet*)), set, SIGNAL(clicked(int)));
153 connect(bar, SIGNAL(hovered(bool, QBarSet*)), set, SIGNAL(hovered(bool)));
154 m_layout.append(QRectF(0, 0, 0, 0));
155
156 // Labels
157 QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this);
158 label->setVisible(labelsVisible);
159 m_labels.append(label);
160 }
161 }
162
163 // TODO: Is this the right place to call it?
164 presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series));
165 handleLayoutChanged();
166 }
167
168 void AbstractBarChartItem::handleVisibleChanged()
169 {
170 bool visible = m_series->isVisible();
171 handleLabelsVisibleChanged(visible);
172 foreach(QGraphicsItem *item, childItems()) {
173 item->setVisible(visible);
174 }
175 }
176
177 #include "moc_abstractbarchartitem_p.cpp"
178
179 QTCOMMERCIALCHART_END_NAMESPACE
@@ -19,7 +19,7
19 19 ****************************************************************************/
20 20
21 21 #include "abstractbaranimation_p.h"
22 #include "barchartitem_p.h"
22 #include "abstractbarchartitem_p.h"
23 23 #include <QTimer>
24 24 #include <QDebug>
25 25
@@ -27,7 +27,7 Q_DECLARE_METATYPE(QVector<QRectF>)
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 AbstractBarAnimation::AbstractBarAnimation(BarChartItem *item)
30 AbstractBarAnimation::AbstractBarAnimation(AbstractBarChartItem *item)
31 31 :ChartAnimation(item),
32 32 m_item(item)
33 33 {
@@ -34,14 +34,14
34 34
35 35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36 36
37 class BarChartItem;
37 class AbstractBarChartItem;
38 38
39 39 class AbstractBarAnimation : public ChartAnimation
40 40 {
41 41 Q_OBJECT
42 42
43 43 public:
44 AbstractBarAnimation(BarChartItem *item);
44 AbstractBarAnimation(AbstractBarChartItem *item);
45 45 ~AbstractBarAnimation();
46 46
47 47 public: // from QVariantAnimation
@@ -51,7 +51,7 public: // from QVariantAnimation
51 51 void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
52 52
53 53 protected:
54 BarChartItem *m_item;
54 AbstractBarChartItem *m_item;
55 55 };
56 56
57 57 QTCOMMERCIALCHART_END_NAMESPACE
@@ -19,14 +19,14
19 19 ****************************************************************************/
20 20
21 21 #include "baranimation_p.h"
22 #include "barchartitem_p.h"
22 #include "abstractbarchartitem_p.h"
23 23 #include <QTimer>
24 24
25 25 Q_DECLARE_METATYPE(QVector<QRectF>)
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 BarAnimation::BarAnimation(BarChartItem *item)
29 BarAnimation::BarAnimation(AbstractBarChartItem *item)
30 30 :AbstractBarAnimation(item)
31 31 {
32 32 setDuration(ChartAnimationDuration);
@@ -32,18 +32,18
32 32
33 33 #include "abstractbaranimation_p.h"
34 34 #include "chartanimation_p.h"
35 #include "barchartitem_p.h"
35 #include "abstractbarchartitem_p.h"
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 class BarChartItem;
39 class AbstractBarChartItem;
40 40
41 41 class BarAnimation : public AbstractBarAnimation
42 42 {
43 43 Q_OBJECT
44 44
45 45 public:
46 BarAnimation(BarChartItem *item);
46 BarAnimation(AbstractBarChartItem *item);
47 47 ~BarAnimation();
48 48
49 49 public: // from QVariantAnimation
@@ -25,7 +25,7
25 25 #include "xychart_p.h"
26 26 #include "pieanimation_p.h"
27 27 #include "baranimation_p.h"
28 #include "barchartitem_p.h"
28 #include "abstractbarchartitem_p.h"
29 29 #include "stackedbaranimation_p.h"
30 30 #include "stackedbarchartitem_p.h"
31 31 #include "percentbaranimation_p.h"
@@ -33,7 +33,7
33 33 #include "qchartglobal.h"
34 34 #include "chartanimation_p.h"
35 35 #include "piechartitem_p.h"
36 #include "barchartitem_p.h"
36 #include "abstractbarchartitem_p.h"
37 37 #include <QPointF>
38 38
39 39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -12,7 +12,7
12 12
13 13 #include "chartanimation_p.h"
14 14 #include "abstractbaranimation_p.h"
15 #include "barchartitem_p.h"
15 #include "abstractbarchartitem_p.h"
16 16
17 17 QTCOMMERCIALCHART_BEGIN_NAMESPACE
18 18
@@ -11,7 +11,7
11 11 #define STACKEDBARANIMATION_P_H
12 12
13 13 #include "chartanimation_p.h"
14 #include "barchartitem_p.h"
14 #include "abstractbarchartitem_p.h"
15 15 #include "abstractbaranimation_p.h"
16 16
17 17 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -28,25 +28,67
28 28 // We mean it.
29 29
30 30
31 #ifndef GROUPEDBARCHARTITEM_H
32 #define GROUPEDBARCHARTITEM_H
31 #ifndef ABSTRACTBARCHARTITEM_H
32 #define ABSTRACTBARCHARTITEM_H
33 33
34 #include "barchartitem_p.h"
35 #include "qstackedbarseries.h"
36 #include <QGraphicsItem>
34 #include "chartitem_p.h"
35 #include "qabstractbarseries.h"
36 #include <QPen>
37 #include <QBrush>
37 38
38 39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 40
40 class GroupedBarChartItem : public BarChartItem
41 class Bar;
42 class QAxisCategories;
43 class QChart;
44 class AbstractBarAnimation;
45
46 class AbstractBarChartItem : public ChartItem
41 47 {
42 48 Q_OBJECT
43 49 public:
44 GroupedBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter);
50 AbstractBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter);
51 virtual ~AbstractBarChartItem();
52
53 public:
54 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
55 QRectF boundingRect() const;
56
57 virtual QVector<QRectF> calculateLayout() = 0;
58 virtual void applyLayout(const QVector<QRectF> &layout);
59 virtual void setAnimation(AbstractBarAnimation* animation);
60 void setLayout(const QVector<QRectF> &layout);
61 void updateLayout(const QVector<QRectF> &layout);
62
63
64 QRectF geometry() const { return m_rect;}
65
66 public Q_SLOTS:
67 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
68 void handleGeometryChanged(const QRectF &size);
69 void handleLayoutChanged();
70 void handleLabelsVisibleChanged(bool visible);
71 void handleDataStructureChanged(); // structure of of series has changed, recreate graphic items
72 void handleVisibleChanged();
73
74 protected:
75
76 qreal m_domainMinX;
77 qreal m_domainMaxX;
78 qreal m_domainMinY;
79 qreal m_domainMaxY;
80
81 QRectF m_rect;
82 QVector<QRectF> m_layout;
83
84 AbstractBarAnimation *m_animation;
45 85
46 private:
47 virtual QVector<QRectF> calculateLayout();
86 // Not owned.
87 QAbstractBarSeries *m_series;
88 QList<Bar *> m_bars;
89 QList<QGraphicsSimpleTextItem *> m_labels;
48 90 };
49 91
50 92 QTCOMMERCIALCHART_END_NAMESPACE
51 93
52 #endif // GROUPEDBARCHARTITEM_H
94 #endif // ABSTRACTBARCHARTITEM_H
@@ -3,9 +3,9 DEPENDPATH += $$PWD
3 3
4 4 SOURCES += \
5 5 $$PWD/bar.cpp \
6 $$PWD/barchartitem.cpp \
6 $$PWD/abstractbarchartitem.cpp \
7 7 $$PWD/percentbarchartitem.cpp \
8 $$PWD/groupedbarchartitem.cpp \
8 $$PWD/barchartitem.cpp \
9 9 $$PWD/qabstractbarseries.cpp \
10 10 $$PWD/qbarset.cpp \
11 11 $$PWD/qpercentbarseries.cpp \
@@ -20,10 +20,10 SOURCES += \
20 20
21 21 PRIVATE_HEADERS += \
22 22 $$PWD/bar_p.h \
23 $$PWD/barchartitem_p.h \
23 $$PWD/abstractbarchartitem_p.h \
24 24 $$PWD/percentbarchartitem_p.h \
25 25 $$PWD/stackedbarchartitem_p.h \
26 $$PWD/groupedbarchartitem_p.h \
26 $$PWD/barchartitem_p.h \
27 27 $$PWD/qbarset_p.h \
28 28 $$PWD/qabstractbarseries_p.h \
29 29 $$PWD/qstackedbarseries_p.h\
@@ -20,47 +20,16
20 20
21 21 #include "barchartitem_p.h"
22 22 #include "bar_p.h"
23 #include "qbarset.h"
24 23 #include "qbarset_p.h"
25 #include "qabstractbarseries.h"
26 24 #include "qabstractbarseries_p.h"
27 #include "qchart.h"
28 #include "chartpresenter_p.h"
29 #include "chartanimator_p.h"
30 #include "abstractbaranimation_p.h"
31 #include "chartdataset_p.h"
32 #include <QPainter>
25 #include "qbarset.h"
26 #include "qbarset_p.h"
33 27
34 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 29
36 30 BarChartItem::BarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) :
37 ChartItem(presenter),
38 m_animation(0),
39 m_series(series)
40 {
41 setFlag(ItemClipsChildrenToShape);
42 connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged()));
43 connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(handleLabelsVisibleChanged(bool)));
44 connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleDataStructureChanged()));
45 connect(series, SIGNAL(visibleChanged()), this, SLOT(handleVisibleChanged()));
46 setZValue(ChartPresenter::BarSeriesZValue);
47 handleDataStructureChanged();
48 }
49
50 BarChartItem::~BarChartItem()
51 {
52 }
53
54 void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
55 {
56 Q_UNUSED(painter);
57 Q_UNUSED(option);
58 Q_UNUSED(widget);
59 }
60
61 QRectF BarChartItem::boundingRect() const
31 AbstractBarChartItem(series, presenter)
62 32 {
63 return m_rect;
64 33 }
65 34
66 35 QVector<QRectF> BarChartItem::calculateLayout()
@@ -79,19 +48,21 QVector<QRectF> BarChartItem::calculateLayout()
79 48 qreal rangeX = m_domainMaxX - m_domainMinX;
80 49 qreal scaleY = (height / rangeY);
81 50 qreal scaleX = (width / rangeX);
82 qreal barWidth = scaleX * m_series->d_func()->barWidth();
51 qreal barWidth = (scaleX / setCount) * m_series->d_func()->barWidth();
83 52
84 53 int itemIndex(0);
85 54 for (int category = 0; category < categoryCount; category++) {
86 55 qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y();
87 56 for (int set = 0; set < setCount; set++) {
88 57 QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data();
89 qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2;
90 qreal barHeight = barSet->at(category).y() * scaleY;
91 58
59 qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left();
60 xPos -= setCount*barWidth/2;
61 xPos += set*barWidth;
62 qreal barHeight = barSet->at(category).y() * scaleY;
92 63 Bar* bar = m_bars.at(itemIndex);
93 QRectF rect(xPos, yPos - barHeight, barWidth, barHeight);
94 64
65 QRectF rect(xPos, yPos - barHeight, barWidth, barHeight);
95 66 layout.append(rect);
96 67 bar->setPen(barSet->m_pen);
97 68 bar->setBrush(barSet->m_brush);
@@ -117,123 +88,9 QVector<QRectF> BarChartItem::calculateLayout()
117 88 itemIndex++;
118 89 }
119 90 }
120
121 91 return layout;
122 92 }
123 93
124 void BarChartItem::applyLayout(const QVector<QRectF> &layout)
125 {
126 if (m_animation) {
127 m_animation->setup(m_layout,layout);
128 presenter()->startAnimation(m_animation);
129
130 } else {
131 setLayout(layout);
132 update();
133 }
134 }
135
136 void BarChartItem::setAnimation(AbstractBarAnimation *animation)
137 {
138 m_animation = animation;
139 }
140
141 void BarChartItem::setLayout(const QVector<QRectF> &layout)
142 {
143 if (layout.count() != m_bars.count())
144 return;
145
146 m_layout = layout;
147
148 for (int i=0; i < m_bars.count(); i++) {
149 m_bars.at(i)->setRect(layout.at(i));
150 }
151 }
152 //handlers
153
154 void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
155 {
156 m_domainMinX = minX;
157 m_domainMaxX = maxX;
158 m_domainMinY = minY;
159 m_domainMaxY = maxY;
160 handleLayoutChanged();
161 }
162
163 void BarChartItem::handleGeometryChanged(const QRectF &rect)
164 {
165 prepareGeometryChange();
166 m_rect = rect;
167 handleLayoutChanged();
168 }
169
170 void BarChartItem::handleLayoutChanged()
171 {
172 if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) {
173 // rect size zero.
174 return;
175 }
176 QVector<QRectF> layout = calculateLayout();
177 applyLayout(layout);
178 }
179
180
181
182 void BarChartItem::handleLabelsVisibleChanged(bool visible)
183 {
184 foreach (QGraphicsSimpleTextItem* label, m_labels) {
185 label->setVisible(visible);
186 }
187 update();
188 }
189
190 void BarChartItem::handleDataStructureChanged()
191 {
192 foreach(QGraphicsItem *item, childItems()) {
193 delete item;
194 }
195
196 m_bars.clear();
197 m_labels.clear();
198 m_layout.clear();
199
200 bool labelsVisible = m_series->isLabelsVisible();
201
202 // Create new graphic items for bars
203 for (int c = 0; c < m_series->d_func()->categoryCount(); c++) {
204 for (int s = 0; s < m_series->count(); s++) {
205 QBarSet *set = m_series->d_func()->barsetAt(s);
206
207 // Bars
208 Bar *bar = new Bar(set,c,this);
209 m_bars.append(bar);
210 connect(bar, SIGNAL(clicked(int, QBarSet*)), m_series, SIGNAL(clicked(int, QBarSet*)));
211 connect(bar, SIGNAL(hovered(bool, QBarSet*)), m_series, SIGNAL(hovered(bool, QBarSet*)));
212 connect(bar, SIGNAL(clicked(int, QBarSet*)), set, SIGNAL(clicked(int)));
213 connect(bar, SIGNAL(hovered(bool, QBarSet*)), set, SIGNAL(hovered(bool)));
214 m_layout.append(QRectF(0, 0, 0, 0));
215
216 // Labels
217 QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this);
218 label->setVisible(labelsVisible);
219 m_labels.append(label);
220 }
221 }
222
223 // TODO: Is this the right place to call it?
224 presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series));
225 handleLayoutChanged();
226 }
227
228 void BarChartItem::handleVisibleChanged()
229 {
230 bool visible = m_series->isVisible();
231 handleLabelsVisibleChanged(visible);
232 foreach(QGraphicsItem *item, childItems()) {
233 item->setVisible(visible);
234 }
235 }
236
237 94 #include "moc_barchartitem_p.cpp"
238 95
239 96 QTCOMMERCIALCHART_END_NAMESPACE
@@ -31,62 +31,20
31 31 #ifndef BARCHARTITEM_H
32 32 #define BARCHARTITEM_H
33 33
34 #include "chartitem_p.h"
35 #include "qabstractbarseries.h"
36 #include <QPen>
37 #include <QBrush>
34 #include "abstractbarchartitem_p.h"
35 #include "qstackedbarseries.h"
36 #include <QGraphicsItem>
38 37
39 38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 39
41 class Bar;
42 class QAxisCategories;
43 class QChart;
44 class AbstractBarAnimation;
45
46 class BarChartItem : public ChartItem
40 class BarChartItem : public AbstractBarChartItem
47 41 {
48 42 Q_OBJECT
49 43 public:
50 44 BarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter);
51 virtual ~BarChartItem();
52
53 public:
54 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
55 QRectF boundingRect() const;
56 45
46 private:
57 47 virtual QVector<QRectF> calculateLayout();
58 virtual void applyLayout(const QVector<QRectF> &layout);
59 virtual void setAnimation(AbstractBarAnimation* animation);
60 void setLayout(const QVector<QRectF> &layout);
61 void updateLayout(const QVector<QRectF> &layout);
62
63
64 QRectF geometry() const { return m_rect;}
65
66 public Q_SLOTS:
67 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
68 void handleGeometryChanged(const QRectF &size);
69 void handleLayoutChanged();
70 void handleLabelsVisibleChanged(bool visible);
71 void handleDataStructureChanged(); // structure of of series has changed, recreate graphic items
72 void handleVisibleChanged();
73
74 protected:
75
76 qreal m_domainMinX;
77 qreal m_domainMaxX;
78 qreal m_domainMinY;
79 qreal m_domainMaxY;
80
81 QRectF m_rect;
82 QVector<QRectF> m_layout;
83
84 AbstractBarAnimation *m_animation;
85
86 // Not owned.
87 QAbstractBarSeries *m_series;
88 QList<Bar *> m_bars;
89 QList<QGraphicsSimpleTextItem *> m_labels;
90 48 };
91 49
92 50 QTCOMMERCIALCHART_END_NAMESPACE
@@ -3,7 +3,7
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 HorizontalBarChartitem::HorizontalBarChartitem(QAbstractBarSeries *series, ChartPresenter *presenter) :
6 BarChartItem(series, presenter)
6 AbstractBarChartItem(series, presenter)
7 7 {
8 8 }
9 9
@@ -1,14 +1,14
1 1 #ifndef HORIZONTALBARCHARTITEM_H
2 2 #define HORIZONTALBARCHARTITEM_H
3 3
4 #include "barchartitem_p.h"
4 #include "abstractbarchartitem_p.h"
5 5 #include "qstackedbarseries.h"
6 6 #include <QGraphicsItem>
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10
11 class HorizontalBarChartitem : public BarChartItem
11 class HorizontalBarChartitem : public AbstractBarChartItem
12 12 {
13 13 Q_OBJECT
14 14 public:
@@ -28,7 +28,7
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 PercentBarChartItem::PercentBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) :
31 BarChartItem(series, presenter)
31 AbstractBarChartItem(series, presenter)
32 32 {
33 33 }
34 34
@@ -31,14 +31,14
31 31 #ifndef PERCENTBARCHARTITEM_H
32 32 #define PERCENTBARCHARTITEM_H
33 33
34 #include "barchartitem_p.h"
34 #include "abstractbarchartitem_p.h"
35 35 #include <QGraphicsItem>
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 39 class QAbstractBarSeries;
40 40
41 class PercentBarChartItem : public BarChartItem
41 class PercentBarChartItem : public AbstractBarChartItem
42 42 {
43 43 Q_OBJECT
44 44 public:
@@ -43,8 +43,6 protected:
43 43 public:
44 44 virtual ~QAbstractBarSeries();
45 45
46 // virtual QAbstractSeries::SeriesType type() const = 0;
47
48 46 void setBarWidth(qreal width);
49 47 qreal barWidth() const;
50 48
@@ -73,10 +71,10 Q_SIGNALS:
73 71
74 72 protected:
75 73 Q_DECLARE_PRIVATE(QAbstractBarSeries)
76 friend class BarChartItem;
74 friend class AbstractBarChartItem;
77 75 friend class PercentBarChartItem;
78 76 friend class StackedBarChartItem;
79 friend class GroupedBarChartItem;
77 friend class BarChartItem;
80 78 };
81 79
82 80 QTCOMMERCIALCHART_END_NAMESPACE
@@ -20,7 +20,7
20 20
21 21 #include "qbarseries.h"
22 22 #include "qbarseries_p.h"
23 #include "groupedbarchartitem_p.h"
23 #include "barchartitem_p.h"
24 24 #include "chartdataset_p.h"
25 25 #include "charttheme_p.h"
26 26 #include "chartanimator_p.h"
@@ -65,7 +65,7 QBarSeries::QBarSeries(QObject *parent)
65 65 }
66 66
67 67 /*!
68 Returns QChartSeries::SeriesTypeGroupedBar.
68 Returns QChartSeries::SeriesTypeBar.
69 69 */
70 70 QAbstractSeries::SeriesType QBarSeries::type() const
71 71 {
@@ -104,7 +104,7 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
104 104 {
105 105 Q_Q(QBarSeries);
106 106
107 GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter);
107 BarChartItem* bar = new BarChartItem(q,presenter);
108 108 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
109 109 bar->setAnimator(presenter->animator());
110 110 bar->setAnimation(new BarAnimation(bar));
@@ -103,11 +103,11 private:
103 103 Q_DISABLE_COPY(QBarSet)
104 104 friend class QAbstractBarSeries;
105 105 friend class BarLegendMarker;
106 friend class BarChartItem;
106 friend class AbstractBarChartItem;
107 107 friend class QAbstractBarSeriesPrivate;
108 108 friend class StackedBarChartItem;
109 109 friend class PercentBarChartItem;
110 friend class GroupedBarChartItem;
110 friend class BarChartItem;
111 111 };
112 112
113 113 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,7 +28,7
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29
30 30 StackedBarChartItem::StackedBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) :
31 BarChartItem(series, presenter)
31 AbstractBarChartItem(series, presenter)
32 32 {
33 33 }
34 34
@@ -31,13 +31,13
31 31 #ifndef STACKEDBARCHARTITEM_H
32 32 #define STACKEDBARCHARTITEM_H
33 33
34 #include "barchartitem_p.h"
34 #include "abstractbarchartitem_p.h"
35 35 #include "qstackedbarseries.h"
36 36 #include <QGraphicsItem>
37 37
38 38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 39
40 class StackedBarChartItem : public BarChartItem
40 class StackedBarChartItem : public AbstractBarChartItem
41 41 {
42 42 Q_OBJECT
43 43 public:
@@ -41,7 +41,7
41 41
42 42 //items
43 43 #include "chartaxis_p.h"
44 #include "barchartitem_p.h"
44 #include "abstractbarchartitem_p.h"
45 45 #include "stackedbarchartitem_p.h"
46 46 #include "percentbarchartitem_p.h"
47 47 #include "linechartitem_p.h"
@@ -40,7 +40,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 40 class ChartItem;
41 41 class LineChartItem;
42 42 class QLineSeries;
43 class BarChartItem;
43 class AbstractBarChartItem;
44 44 class QAbstractBarSeries;
45 45 class StackedBarChartItem;
46 46 class QStackedBarSeries;
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now