##// END OF EJS Templates
tidying up legend marker code. Added QBarLegendMarker
sauimone -
r2174:c23be8282bab
parent child
Show More
@@ -0,0 +1,90
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 "qbarlegendmarker.h"
22 #include "qbarlegendmarker_p.h"
23 #include <QAbstractBarSeries>
24 #include <QBarSet>
25 #include <QDebug>
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
29 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries* series, QBarSet* barset, QLegend *legend, QObject *parent) :
30 QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent)
31 {
32 }
33
34 QBarLegendMarker::~QBarLegendMarker()
35 {
36 // qDebug() << "deleting bar marker" << this;
37 }
38
39 /*!
40 \internal
41 */
42 QBarLegendMarker::QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent) :
43 QLegendMarker(d, parent)
44 {
45 }
46
47 QAbstractBarSeries *QBarLegendMarker::series()
48 {
49 Q_D(QBarLegendMarker);
50 return d->m_series;
51 }
52
53 QBarSet* QBarLegendMarker::peerObject()
54 {
55 Q_D(QBarLegendMarker);
56 return d->m_barset;
57 }
58
59 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60
61 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) :
62 QLegendMarkerPrivate(q,legend),
63 m_series(series),
64 m_barset(barset)
65 {
66 QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
67 QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
68 QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
69 updated();
70 }
71
72 QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate()
73 {
74 QObject::disconnect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
75 QObject::disconnect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
76 QObject::disconnect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
77 }
78
79 void QBarLegendMarkerPrivate::updated()
80 {
81 m_item->setPen(m_barset->pen());
82 m_item->setBrush(m_barset->brush());
83 m_item->setLabel(m_barset->label());
84 }
85
86 #include "moc_qbarlegendmarker.cpp"
87 #include "moc_qbarlegendmarker_p.cpp"
88
89 QTCOMMERCIALCHART_END_NAMESPACE
90
@@ -0,0 +1,59
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 #ifndef QBARLEGENDMARKER_H
21 #define QBARLEGENDMARKER_H
22
23 #include <QChartGlobal>
24 #include <QLegendMarker>
25 #include <QAbstractBarSeries>
26 #include <QBarSet>
27 //#include "qbarlegendmarker_p.h"
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31 class QLegend;
32 class QBarLegendMarkerPrivate;
33
34 class QTCOMMERCIALCHART_EXPORT QBarLegendMarker : public QLegendMarker
35 {
36 Q_OBJECT
37 public:
38 explicit QBarLegendMarker(QAbstractBarSeries* series, QBarSet* barset, QLegend *legend, QObject *parent = 0);
39 virtual ~QBarLegendMarker();
40
41 virtual QAbstractBarSeries* series();
42 virtual QBarSet* peerObject(); // TODO: rename to slice and remove these virtuals from base class?
43
44 protected:
45 QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = 0);
46
47 //Q_SIGNALS:
48
49 //public Q_SLOTS:
50
51 private:
52 Q_DECLARE_PRIVATE(QBarLegendMarker)
53 Q_DISABLE_COPY(QBarLegendMarker)
54
55 };
56
57 QTCOMMERCIALCHART_END_NAMESPACE
58
59 #endif // QBARLEGENDMARKER_H
@@ -0,0 +1,67
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 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29
30 #ifndef QBARLEGENDMARKER_P_H
31 #define QBARLEGENDMARKER_P_H
32
33 #include "qchartglobal.h"
34 #include "qlegendmarker_p.h"
35 #include "legendmarkeritem_p.h"
36 #include <QAbstractBarSeries>
37 #include <QBarSet>
38
39 #include <QDebug>
40
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
43 class QBarLegendMarker;
44
45 class QBarLegendMarkerPrivate : public QLegendMarkerPrivate
46 {
47 Q_OBJECT
48 public:
49 explicit QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend);
50 virtual ~QBarLegendMarkerPrivate();
51
52 public Q_SLOTS:
53 virtual void updated();
54
55 private:
56 QBarLegendMarker *q_ptr;
57
58 QAbstractBarSeries* m_series;
59 QBarSet* m_barset;
60
61 friend class QLegendPrivate; // TODO: Is this needed?
62 Q_DECLARE_PUBLIC(QBarLegendMarker)
63 };
64
65 QTCOMMERCIALCHART_END_NAMESPACE
66
67 #endif // QBARLEGENDMARKER_P_H
@@ -29,6 +29,8
29 #include "qvalueaxis.h"
29 #include "qvalueaxis.h"
30 #include "qbarcategoryaxis.h"
30 #include "qbarcategoryaxis.h"
31
31
32 #include "qbarlegendmarker.h"
33
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33
35
34 /*!
36 /*!
@@ -661,16 +663,13 QList<LegendMarker *> QAbstractBarSeriesPrivate::createLegendMarker(QLegend *leg
661
663
662 QList<QLegendMarker*> QAbstractBarSeriesPrivate::createLegendMarkers(QLegend* legend)
664 QList<QLegendMarker*> QAbstractBarSeriesPrivate::createLegendMarkers(QLegend* legend)
663 {
665 {
664 Q_UNUSED(legend);
666 Q_Q(QAbstractBarSeries);
665 // Q_Q(QAbstractBarSeries);
666 QList<QLegendMarker*> markers;
667 QList<QLegendMarker*> markers;
667 // TODO: when QBarLegendMarker is implemented
668
668 /*
669 foreach(QBarSet* set, q->barSets()) {
669 foreach(QBarSet* set, q->barSets()) {
670 BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
670 QBarLegendMarker* marker = new QBarLegendMarker(q,set,legend);
671 markers << marker;
671 markers << marker;
672 }
672 }
673 */
674 return markers;
673 return markers;
675 }
674 }
676
675
@@ -7,7 +7,8 SOURCES += \
7 $$PWD/legendlayout.cpp \
7 $$PWD/legendlayout.cpp \
8 $$PWD/qlegendmarker.cpp \
8 $$PWD/qlegendmarker.cpp \
9 $$PWD/qpielegendmarker.cpp \
9 $$PWD/qpielegendmarker.cpp \
10 $$PWD/legendmarkeritem.cpp
10 $$PWD/legendmarkeritem.cpp \
11 $$PWD/qbarlegendmarker.cpp
11
12
12 PRIVATE_HEADERS += \
13 PRIVATE_HEADERS += \
13 $$PWD/legendmarker_p.h \
14 $$PWD/legendmarker_p.h \
@@ -16,10 +17,12 PRIVATE_HEADERS += \
16 $$PWD/legendlayout_p.h \
17 $$PWD/legendlayout_p.h \
17 $$PWD/qlegendmarker_p.h \
18 $$PWD/qlegendmarker_p.h \
18 $$PWD/legendmarkeritem_p.h \
19 $$PWD/legendmarkeritem_p.h \
19 $$PWD/qpielegendmarker_p.h
20 $$PWD/qpielegendmarker_p.h \
21 $$PWD/qbarlegendmarker_p.h
20
22
21
23
22 PUBLIC_HEADERS += \
24 PUBLIC_HEADERS += \
23 $$PWD/qlegend.h \
25 $$PWD/qlegend.h \
24 $$PWD/qlegendmarker.h \
26 $$PWD/qlegendmarker.h \
25 $$PWD/qpielegendmarker.h
27 $$PWD/qpielegendmarker.h \
28 $$PWD/qbarlegendmarker.h
@@ -76,13 +76,13 QFont LegendMarkerItem::font() const
76
76
77 void LegendMarkerItem::setLabel(const QString label)
77 void LegendMarkerItem::setLabel(const QString label)
78 {
78 {
79 m_text = label;
79 m_label = label;
80 updateGeometry();
80 updateGeometry();
81 }
81 }
82
82
83 QString LegendMarkerItem::label() const
83 QString LegendMarkerItem::label() const
84 {
84 {
85 return m_text;
85 return m_label;
86 }
86 }
87
87
88 void LegendMarkerItem::setLabelBrush(const QBrush &brush)
88 void LegendMarkerItem::setLabelBrush(const QBrush &brush)
@@ -103,15 +103,15 void LegendMarkerItem::setGeometry(const QRectF& rect)
103 qreal x = m_margin + m_markerRect.width() + m_space + m_margin;
103 qreal x = m_margin + m_markerRect.width() + m_space + m_margin;
104 qreal y = qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin);
104 qreal y = qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin);
105
105
106 if (fn.boundingRect(m_text).width() + x > width)
106 if (fn.boundingRect(m_label).width() + x > width)
107 {
107 {
108 QString string = m_text + "...";
108 QString string = m_label + "...";
109 while(fn.boundingRect(string).width() + x > width && string.length() > 3)
109 while(fn.boundingRect(string).width() + x > width && string.length() > 3)
110 string.remove(string.length() - 4, 1);
110 string.remove(string.length() - 4, 1);
111 m_textItem->setText(string);
111 m_textItem->setText(string);
112 }
112 }
113 else
113 else
114 m_textItem->setText(m_text);
114 m_textItem->setText(m_label);
115
115
116 const QRectF& textRect = m_textItem->boundingRect();
116 const QRectF& textRect = m_textItem->boundingRect();
117
117
@@ -148,7 +148,7 QSizeF LegendMarkerItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint)
148 sh = QSizeF(fn.boundingRect("...").width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin));
148 sh = QSizeF(fn.boundingRect("...").width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin));
149 break;
149 break;
150 case Qt::PreferredSize:
150 case Qt::PreferredSize:
151 sh = QSizeF(fn.boundingRect(m_text).width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin));
151 sh = QSizeF(fn.boundingRect(m_label).width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin));
152 break;
152 break;
153 default:
153 default:
154 break;
154 break;
@@ -84,15 +84,15 protected:
84 QGraphicsRectItem *m_rectItem;
84 QGraphicsRectItem *m_rectItem;
85 qreal m_margin;
85 qreal m_margin;
86 qreal m_space;
86 qreal m_space;
87 QString m_text;
88
89 QString m_label;
87 QString m_label;
88
90 QBrush m_labelBrush;
89 QBrush m_labelBrush;
91 QFont m_font;
90 QFont m_font;
92 QPen m_pen;
91 QPen m_pen;
93 QBrush m_brush;
92 QBrush m_brush;
94 bool m_visible;
93 bool m_visible;
95
94
95 friend class QLegendMarker;
96 friend class QLegendMarkerPrivate;
96 friend class QLegendMarkerPrivate;
97 friend class LegendLayout;
97 friend class LegendLayout;
98 };
98 };
@@ -27,13 +27,7
27 #include <QGraphicsSceneEvent>
27 #include <QGraphicsSceneEvent>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 /*
30
31 QLegendMarker::QLegendMarker(QAbstractSeries* series, QObject *parent) :
32 QObject(parent),
33 d_ptr(new QLegendMarkerPrivate(series, this))
34 {
35 }
36 */
37 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
31 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
38 QObject(parent),
32 QObject(parent),
39 d_ptr(&d)
33 d_ptr(&d)
@@ -46,62 +40,62 QLegendMarker::~QLegendMarker()
46
40
47 QString QLegendMarker::label() const
41 QString QLegendMarker::label() const
48 {
42 {
49 return d_ptr->label();
43 return d_ptr->m_item->label();
50 }
44 }
51
45
52 void QLegendMarker::setLabel(const QString &label)
46 void QLegendMarker::setLabel(const QString &label)
53 {
47 {
54 d_ptr->setLabel(label);
48 d_ptr->m_item->setLabel(label);
55 }
49 }
56
50
57 QBrush QLegendMarker::labelBrush() const
51 QBrush QLegendMarker::labelBrush() const
58 {
52 {
59 return d_ptr->labelBrush();
53 return d_ptr->m_item->brush();
60 }
54 }
61
55
62 void QLegendMarker::setLabelBrush(const QBrush &brush)
56 void QLegendMarker::setLabelBrush(const QBrush &brush)
63 {
57 {
64 d_ptr->setLabelBrush(brush);
58 d_ptr->m_item->setLabelBrush(brush);
65 }
59 }
66
60
67 QFont QLegendMarker::font() const
61 QFont QLegendMarker::font() const
68 {
62 {
69 return d_ptr->font();
63 return d_ptr->m_item->font();
70 }
64 }
71
65
72 void QLegendMarker::setFont(const QFont &font)
66 void QLegendMarker::setFont(const QFont &font)
73 {
67 {
74 d_ptr->setFont(font);
68 d_ptr->m_item->setFont(font);
75 }
69 }
76
70
77 QPen QLegendMarker::pen() const
71 QPen QLegendMarker::pen() const
78 {
72 {
79 return d_ptr->pen();
73 return d_ptr->m_item->pen();
80 }
74 }
81
75
82 void QLegendMarker::setPen(const QPen &pen)
76 void QLegendMarker::setPen(const QPen &pen)
83 {
77 {
84 d_ptr->setPen(pen);
78 d_ptr->m_item->setPen(pen);
85 }
79 }
86
80
87 QBrush QLegendMarker::brush() const
81 QBrush QLegendMarker::brush() const
88 {
82 {
89 return d_ptr->brush();
83 return d_ptr->m_item->brush();
90 }
84 }
91
85
92 void QLegendMarker::setBrush(const QBrush &brush)
86 void QLegendMarker::setBrush(const QBrush &brush)
93 {
87 {
94 d_ptr->setBrush(brush);
88 d_ptr->m_item->setBrush(brush);
95 }
89 }
96
90
97 bool QLegendMarker::isVisible() const
91 bool QLegendMarker::isVisible() const
98 {
92 {
99 return d_ptr->isVisible();
93 return d_ptr->m_item->isVisible();
100 }
94 }
101
95
102 void QLegendMarker::setVisible(bool visible)
96 void QLegendMarker::setVisible(bool visible)
103 {
97 {
104 d_ptr->setVisible(visible);
98 d_ptr->m_item->setVisible(visible);
105 }
99 }
106
100
107 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
101 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -109,7 +103,6 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
109 q_ptr(q),
103 q_ptr(q),
110 m_legend(legend)
104 m_legend(legend)
111 {
105 {
112 // qDebug() << "QLegendMarkerPrivate created";
113 m_item = new LegendMarkerItem(this);
106 m_item = new LegendMarkerItem(this);
114 }
107 }
115
108
@@ -127,67 +120,6 void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event)
127 emit q->clicked();
120 emit q->clicked();
128 }
121 }
129
122
130 void QLegendMarkerPrivate::setPen(const QPen &pen)
131 {
132 m_item->setPen(pen);
133 }
134
135 QPen QLegendMarkerPrivate::pen() const
136 {
137 return m_item->pen();
138 }
139
140 void QLegendMarkerPrivate::setBrush(const QBrush &brush)
141 {
142 m_item->setBrush(brush);
143 }
144
145 QBrush QLegendMarkerPrivate::brush() const
146 {
147 return m_item->brush();
148 }
149
150 void QLegendMarkerPrivate::setFont(const QFont &font)
151 {
152 m_item->setFont(font);
153 }
154
155 QFont QLegendMarkerPrivate::font() const
156 {
157 return m_item->font();
158 }
159
160 void QLegendMarkerPrivate::setLabel(const QString label)
161 {
162 m_item->setLabel(label);
163 }
164
165 QString QLegendMarkerPrivate::label() const
166 {
167 return m_item->label();
168 }
169
170 void QLegendMarkerPrivate::setLabelBrush(const QBrush &brush)
171 {
172 m_item->setLabelBrush(brush);
173 }
174
175 QBrush QLegendMarkerPrivate::labelBrush() const
176 {
177 return m_item->labelBrush();
178 }
179
180 bool QLegendMarkerPrivate::isVisible() const
181 {
182 return m_item->isVisible();
183 }
184
185 void QLegendMarkerPrivate::setVisible(bool visible)
186 {
187 m_item->setVisible(visible);
188 }
189
190
191 #include "moc_qlegendmarker.cpp"
123 #include "moc_qlegendmarker.cpp"
192 #include "moc_qlegendmarker_p.cpp"
124 #include "moc_qlegendmarker_p.cpp"
193
125
@@ -65,8 +65,8 public:
65 bool isVisible() const;
65 bool isVisible() const;
66 void setVisible(bool visible);
66 void setVisible(bool visible);
67
67
68 // virtual QAbstractSeries::SeriesType type() = 0; // TODO?
68 // virtual QAbstractSeries::SeriesType type() = 0; // TODO? Or use LegendMarker type enum?
69 virtual QAbstractSeries* series() = 0;
69 virtual QAbstractSeries* series() = 0; // TODO: remove these and use specialised functions on derived classes?
70 virtual QObject* peerObject() = 0;
70 virtual QObject* peerObject() = 0;
71
71
72 protected:
72 protected:
@@ -57,30 +57,10 class QLegendMarkerPrivate : public QObject
57 {
57 {
58 Q_OBJECT
58 Q_OBJECT
59 public:
59 public:
60 // explicit QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q);
61 explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend);
60 explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend);
62 virtual ~QLegendMarkerPrivate();
61 virtual ~QLegendMarkerPrivate();
63
62
64 // TODO: remove temporary setters/getters and use the m_item directly from public class via d_ptr
63 // Helper for now. (or deckare LegendLayout as friend)
65 void setPen(const QPen &pen);
66 QPen pen() const;
67
68 void setBrush(const QBrush &brush);
69 QBrush brush() const;
70
71 void setFont(const QFont &font);
72 QFont font() const;
73
74 void setLabel(const QString label);
75 QString label() const;
76
77 void setLabelBrush(const QBrush &brush);
78 QBrush labelBrush() const;
79
80 bool isVisible() const;
81 void setVisible(bool visible);
82
83 // Helper for now.
84 LegendMarkerItem* item() const { return m_item; }
64 LegendMarkerItem* item() const { return m_item; }
85
65
86 // Item gets the event, logic for event is here
66 // Item gets the event, logic for event is here
@@ -96,16 +76,6 protected:
96 private:
76 private:
97 QLegendMarker *q_ptr;
77 QLegendMarker *q_ptr;
98
78
99 // New legend marker properties
100 // Moved to item.
101 /*
102 QString m_label;
103 QBrush m_labelBrush;
104 QFont m_font;
105 QPen m_pen;
106 QBrush m_brush;
107 bool m_visible;
108 */
109 friend class QLegendPrivate; // TODO: Is this needed?
79 friend class QLegendPrivate; // TODO: Is this needed?
110 Q_DECLARE_PUBLIC(QLegendMarker)
80 Q_DECLARE_PUBLIC(QLegendMarker)
111 };
81 };
@@ -21,6 +21,7
21 #include "qpielegendmarker.h"
21 #include "qpielegendmarker.h"
22 #include "qpielegendmarker_p.h"
22 #include "qpielegendmarker_p.h"
23 #include <QPieSeries>
23 #include <QPieSeries>
24 #include <QPieSlice>
24 #include <QDebug>
25 #include <QDebug>
25
26
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -32,7 +33,7 QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend
32
33
33 QPieLegendMarker::~QPieLegendMarker()
34 QPieLegendMarker::~QPieLegendMarker()
34 {
35 {
35 qDebug() << "deleting pie marker" << this;
36 // qDebug() << "deleting pie marker" << this;
36 }
37 }
37
38
38 /*!
39 /*!
@@ -43,7 +44,7 QPieLegendMarker::QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent)
43 {
44 {
44 }
45 }
45
46
46 QAbstractSeries* QPieLegendMarker::series()
47 QPieSeries* QPieLegendMarker::series()
47 {
48 {
48 Q_D(QPieLegendMarker);
49 Q_D(QPieLegendMarker);
49 return d->m_series;
50 return d->m_series;
@@ -64,6 +65,7 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries
64 {
65 {
65 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
66 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
66 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
67 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
68 QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
67 updated();
69 updated();
68 }
70 }
69
71
@@ -71,14 +73,14 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
71 {
73 {
72 QObject::disconnect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
74 QObject::disconnect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
73 QObject::disconnect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
75 QObject::disconnect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
76 QObject::disconnect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
74 }
77 }
75
78
76 void QPieLegendMarkerPrivate::updated()
79 void QPieLegendMarkerPrivate::updated()
77 {
80 {
78 m_item->setBrush(m_slice->brush());
79 m_item->setLabel(m_slice->label());
80 m_item->setPen(m_slice->pen());
81 m_item->setPen(m_slice->pen());
81 m_item->setBrush(m_slice->brush());
82 m_item->setBrush(m_slice->brush());
83 m_item->setLabel(m_slice->label());
82 }
84 }
83
85
84 #include "moc_qpielegendmarker.cpp"
86 #include "moc_qpielegendmarker.cpp"
@@ -23,12 +23,15
23
23
24 #include <QChartGlobal>
24 #include <QChartGlobal>
25 #include <QLegendMarker>
25 #include <QLegendMarker>
26 #include <QPieSeries>
26 #include <QPieSlice>
27 #include <QPieSlice>
27 #include "qpielegendmarker_p.h"
28 //#include "qpielegendmarker_p.h"
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
31 // TODO: No export, make this private. QLegendMarker should be enough for user of the api (why expose the details?)
32 class QPieLegendMarkerPrivate;
33
34 // TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?)
32 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker
35 class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker
33 {
36 {
34 Q_OBJECT
37 Q_OBJECT
@@ -37,8 +40,8 public:
37 explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend *legend, QObject *parent = 0);
40 explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend *legend, QObject *parent = 0);
38 virtual ~QPieLegendMarker();
41 virtual ~QPieLegendMarker();
39
42
40 virtual QAbstractSeries* series();
43 virtual QPieSeries* series();
41 virtual QPieSlice* peerObject();
44 virtual QPieSlice* peerObject(); // TODO: rename to slice and remove these virtuals from base class?
42
45
43 protected:
46 protected:
44 QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = 0);
47 QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = 0);
@@ -46,7 +46,6 class QPieLegendMarkerPrivate : public QLegendMarkerPrivate
46 {
46 {
47 Q_OBJECT
47 Q_OBJECT
48 public:
48 public:
49 // explicit QPieLegendMarkerPrivate(QAbstractSeries *series, QPieLegendMarker *q);
50 explicit QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend);
49 explicit QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend);
51 virtual ~QPieLegendMarkerPrivate();
50 virtual ~QPieLegendMarkerPrivate();
52
51
General Comments 0
You need to be logged in to leave comments. Login now