##// END OF EJS Templates
legendmarker doc update
sauimone -
r2217:b8a798289b0a
parent child
Show More
@@ -1,210 +1,212
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qlegendmarker.h"
21 #include "qlegendmarker.h"
22 #include "qlegendmarker_p.h"
22 #include "qlegendmarker_p.h"
23 #include "legendmarkeritem_p.h"
23 #include "legendmarkeritem_p.h"
24 #include "qlegend.h"
24 #include "qlegend.h"
25 #include "qlegend_p.h"
25 #include "qlegend_p.h"
26 #include "legendlayout_p.h"
26 #include "legendlayout_p.h"
27 #include <QFontMetrics>
27 #include <QFontMetrics>
28 #include <QGraphicsSceneEvent>
28 #include <QGraphicsSceneEvent>
29 #include <QAbstractSeries>
29 #include <QAbstractSeries>
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 /*!
33 /*!
34 \class QLegendMarker
34 \class QLegendMarker
35 \brief LegendMarker object
35 \brief LegendMarker object
36 \mainclass
36 \mainclass
37
37
38 QLegendMarker is abstract object that can be used to access markers inside QLegend. The QLegendMarker is always connected
38 QLegendMarker is abstract object that can be used to access markers inside QLegend. Legend marker consists of two
39 to some series
39 items: The colored box, which reflects the color of series and label, which is the name of series (or label of slice/barset
40 in case of pie or bar series)
41 The QLegendMarker is always related to one series.
40
42
41 \image examples_legendmarkers.png
43 \image examples_percentbarchart_legend.png
42
44
43 \sa QLegend
45 \sa QLegend
44 */
46 */
45 /*!
47 /*!
46 \enum QLegendMarker::LegendMarkerType
48 \enum QLegendMarker::LegendMarkerType
47
49
48 The type of the legendmarker object.
50 The type of the legendmarker object.
49
51
50 \value LegendMarkerTypeArea
52 \value LegendMarkerTypeArea
51 \value LegendMarkerTypeBar
53 \value LegendMarkerTypeBar
52 \value LegendMarkerTypePie
54 \value LegendMarkerTypePie
53 \value LegendMarkerTypeXY
55 \value LegendMarkerTypeXY
54 */
56 */
55
57
56 /*!
58 /*!
57 \fn virtual LegendMarkerType QLegendMarker::type() = 0;
59 \fn virtual LegendMarkerType QLegendMarker::type() = 0;
58 Returns the type of legendmarker. Type depends of the related series. LegendMarkerTypeXY is used for all QXYSeries derived
60 Returns the type of legendmarker. Type depends of the related series. LegendMarkerTypeXY is used for all QXYSeries derived
59 classes.
61 classes.
60 */
62 */
61
63
62 /*!
64 /*!
63 \fn virtual QAbstractSeries* QLegendMarker::series() = 0;
65 \fn virtual QAbstractSeries* QLegendMarker::series() = 0;
64 Returns pointer to series, which is related to this marker. Marker is always related to some series.
66 Returns pointer to series, which is related to this marker. Marker is always related to some series.
65 */
67 */
66
68
67 /*!
69 /*!
68 \fn void QLegendMarker::clicked();
70 \fn void QLegendMarker::clicked();
69 This signal is emitted, when marker is clicked with mouse.
71 This signal is emitted, when marker is clicked with mouse.
70 */
72 */
71
73
72 /*!
74 /*!
73 \fn void QLegendMarker::hovered(bool status);
75 \fn void QLegendMarker::hovered(bool status);
74 This signal is emitted, when mouse is hovered over marker. \a status is true, when mouse enters the marker
76 This signal is emitted, when mouse is hovered over marker. \a status is true, when mouse enters the marker
75 and false when it leaves the marker.
77 and false when it leaves the marker.
76 */
78 */
77
79
78 /*!
80 /*!
79 Constructor of marker
81 Constructor of marker
80 */
82 */
81 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
83 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
82 QObject(parent),
84 QObject(parent),
83 d_ptr(&d)
85 d_ptr(&d)
84 {
86 {
85 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
87 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
86 }
88 }
87
89
88 /*!
90 /*!
89 Destructor of marker
91 Destructor of marker
90 */
92 */
91 QLegendMarker::~QLegendMarker()
93 QLegendMarker::~QLegendMarker()
92 {
94 {
93 }
95 }
94
96
95 /*!
97 /*!
96 Returns the label of the marker.
98 Returns the label of the marker.
97 */
99 */
98 QString QLegendMarker::label() const
100 QString QLegendMarker::label() const
99 {
101 {
100 return d_ptr->m_item->label();
102 return d_ptr->m_item->label();
101 }
103 }
102
104
103 /*!
105 /*!
104 Sets the \a label of marker. Note that changing name of series will also change label of its marker.
106 Sets the \a label of marker. Note that changing name of series will also change label of its marker.
105 */
107 */
106 void QLegendMarker::setLabel(const QString &label)
108 void QLegendMarker::setLabel(const QString &label)
107 {
109 {
108 d_ptr->m_item->setLabel(label);
110 d_ptr->m_item->setLabel(label);
109 }
111 }
110 /*!
112 /*!
111 Returns the brush which is used to draw label.
113 Returns the brush which is used to draw label.
112 */
114 */
113 QBrush QLegendMarker::labelBrush() const
115 QBrush QLegendMarker::labelBrush() const
114 {
116 {
115 return d_ptr->m_item->labelBrush();
117 return d_ptr->m_item->labelBrush();
116 }
118 }
117
119
118 /*!
120 /*!
119 Sets the \a brush of label
121 Sets the \a brush of label
120 */
122 */
121 void QLegendMarker::setLabelBrush(const QBrush &brush)
123 void QLegendMarker::setLabelBrush(const QBrush &brush)
122 {
124 {
123 d_ptr->m_item->setLabelBrush(brush);
125 d_ptr->m_item->setLabelBrush(brush);
124 }
126 }
125
127
126 /*!
128 /*!
127 Retuns the font of label
129 Retuns the font of label
128 */
130 */
129 QFont QLegendMarker::font() const
131 QFont QLegendMarker::font() const
130 {
132 {
131 return d_ptr->m_item->font();
133 return d_ptr->m_item->font();
132 }
134 }
133
135
134 /*!
136 /*!
135 Sets the \a font of label
137 Sets the \a font of label
136 */
138 */
137 void QLegendMarker::setFont(const QFont &font)
139 void QLegendMarker::setFont(const QFont &font)
138 {
140 {
139 d_ptr->m_item->setFont(font);
141 d_ptr->m_item->setFont(font);
140 }
142 }
141
143
142 /*!
144 /*!
143 Returns the pen of marker item
145 Returns the pen of marker item
144 */
146 */
145 QPen QLegendMarker::pen() const
147 QPen QLegendMarker::pen() const
146 {
148 {
147 return d_ptr->m_item->pen();
149 return d_ptr->m_item->pen();
148 }
150 }
149
151
150 /*!
152 /*!
151 Sets the \a pen of marker item
153 Sets the \a pen of marker item
152 */
154 */
153 void QLegendMarker::setPen(const QPen &pen)
155 void QLegendMarker::setPen(const QPen &pen)
154 {
156 {
155 d_ptr->m_item->setPen(pen);
157 d_ptr->m_item->setPen(pen);
156 }
158 }
157
159
158 /*!
160 /*!
159 Returns the brush of marker item
161 Returns the brush of marker item
160 */
162 */
161 QBrush QLegendMarker::brush() const
163 QBrush QLegendMarker::brush() const
162 {
164 {
163 return d_ptr->m_item->brush();
165 return d_ptr->m_item->brush();
164 }
166 }
165
167
166 /*!
168 /*!
167 Sets the \a brush of marker item. Note that changing color of the series also changes this.
169 Sets the \a brush of marker item. Note that changing color of the series also changes this.
168 */
170 */
169 void QLegendMarker::setBrush(const QBrush &brush)
171 void QLegendMarker::setBrush(const QBrush &brush)
170 {
172 {
171 d_ptr->m_item->setBrush(brush);
173 d_ptr->m_item->setBrush(brush);
172 }
174 }
173
175
174 /*!
176 /*!
175 Returns visibility of the marker
177 Returns visibility of the marker
176 */
178 */
177 bool QLegendMarker::isVisible() const
179 bool QLegendMarker::isVisible() const
178 {
180 {
179 return d_ptr->m_item->isVisible();
181 return d_ptr->m_item->isVisible();
180 }
182 }
181
183
182 /*!
184 /*!
183 Sets markers visibility to \a visible
185 Sets markers visibility to \a visible
184 */
186 */
185 void QLegendMarker::setVisible(bool visible)
187 void QLegendMarker::setVisible(bool visible)
186 {
188 {
187 d_ptr->m_item->setVisible(visible);
189 d_ptr->m_item->setVisible(visible);
188 }
190 }
189
191
190 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
192 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
191 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
193 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
192 m_legend(legend),
194 m_legend(legend),
193 q_ptr(q)
195 q_ptr(q)
194 {
196 {
195 m_item = new LegendMarkerItem(this);
197 m_item = new LegendMarkerItem(this);
196 }
198 }
197
199
198 QLegendMarkerPrivate::~QLegendMarkerPrivate()
200 QLegendMarkerPrivate::~QLegendMarkerPrivate()
199 {
201 {
200 }
202 }
201
203
202 void QLegendMarkerPrivate::invalidateLegend()
204 void QLegendMarkerPrivate::invalidateLegend()
203 {
205 {
204 m_legend->d_ptr->m_layout->invalidate();
206 m_legend->d_ptr->m_layout->invalidate();
205 }
207 }
206
208
207 #include "moc_qlegendmarker.cpp"
209 #include "moc_qlegendmarker.cpp"
208 #include "moc_qlegendmarker_p.cpp"
210 #include "moc_qlegendmarker_p.cpp"
209
211
210 QTCOMMERCIALCHART_END_NAMESPACE
212 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now