##// END OF EJS Templates
legend markers doc update
sauimone -
r2226:107ef39d2750
parent child
Show More
@@ -1,218 +1,243
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. Legend marker consists of two
38 QLegendMarker is abstract object that can be used to access markers inside QLegend. Legend marker consists of two
39 items: The colored box, which reflects the color of series and label, which is the name of series (or label of slice/barset
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)
40 in case of pie or bar series)
41 The QLegendMarker is always related to one series.
41 The QLegendMarker is always related to one series.
42
42
43 \image examples_percentbarchart_legend.png
43 \image examples_percentbarchart_legend.png
44
44
45 \sa QLegend
45 \sa QLegend
46 */
46 */
47 /*!
47 /*!
48 \enum QLegendMarker::LegendMarkerType
48 \enum QLegendMarker::LegendMarkerType
49
49
50 The type of the legendmarker object.
50 The type of the legendmarker object.
51
51
52 \value LegendMarkerTypeArea
52 \value LegendMarkerTypeArea
53 \value LegendMarkerTypeBar
53 \value LegendMarkerTypeBar
54 \value LegendMarkerTypePie
54 \value LegendMarkerTypePie
55 \value LegendMarkerTypeXY
55 \value LegendMarkerTypeXY
56 */
56 */
57
57
58 /*!
58 /*!
59 \fn virtual LegendMarkerType QLegendMarker::type() = 0;
59 \fn virtual LegendMarkerType QLegendMarker::type() = 0;
60 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
61 classes.
61 classes.
62 */
62 */
63
63
64 /*!
64 /*!
65 \fn virtual QAbstractSeries* QLegendMarker::series() = 0;
65 \fn virtual QAbstractSeries* QLegendMarker::series() = 0;
66 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.
67 */
67 */
68
68
69 /*!
69 /*!
70 \fn void QLegendMarker::clicked();
70 \fn void QLegendMarker::clicked();
71 This signal is emitted, when marker is clicked with mouse.
71 This signal is emitted, when marker is clicked with mouse.
72 */
72 */
73
73
74 /*!
74 /*!
75 \fn void QLegendMarker::hovered(bool status);
75 \fn void QLegendMarker::hovered(bool status);
76 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
77 and false when it leaves the marker.
77 and false when it leaves the marker.
78 */
78 */
79
79
80 /*!
80 /*!
81 \property QLegendMarker::label
81 \property QLegendMarker::label
82 Label of the marker. This is the text that is shown in legend.
82 Label of the marker. This is the text that is shown in legend.
83 \sa QScatterSeries::pen()
84 */
83 */
85
84
86 /*!
85 /*!
86 \property QLegendMarker::labelBrush
87 Brush of the label
88 */
89
90 /*!
91 \property QLegendMarker::font
92 Font of the label
93 */
94
95 /*!
96 \property QLegendMarker::pen
97 Pen of the marker. This is the outline of the colored square.
98 */
99
100 /*!
101 \property QLegendMarker::brush
102 Brush of the marker. This is the inside of the colored square.
103 */
104
105 /*!
106 \property QLegendMarker::visible
107 Visibility of the legend marker. Affects label and the colored square.
108 */
109
110
111 /*!
87 Constructor of marker
112 Constructor of marker
88 */
113 */
89 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
114 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
90 QObject(parent),
115 QObject(parent),
91 d_ptr(&d)
116 d_ptr(&d)
92 {
117 {
93 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
118 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
94 }
119 }
95
120
96 /*!
121 /*!
97 Destructor of marker
122 Destructor of marker
98 */
123 */
99 QLegendMarker::~QLegendMarker()
124 QLegendMarker::~QLegendMarker()
100 {
125 {
101 }
126 }
102
127
103 /*!
128 /*!
104 Returns the label of the marker.
129 Returns the label of the marker.
105 */
130 */
106 QString QLegendMarker::label() const
131 QString QLegendMarker::label() const
107 {
132 {
108 return d_ptr->m_item->label();
133 return d_ptr->m_item->label();
109 }
134 }
110
135
111 /*!
136 /*!
112 Sets the \a label of marker. Note that changing name of series will also change label of its marker.
137 Sets the \a label of marker. Note that changing name of series will also change label of its marker.
113 */
138 */
114 void QLegendMarker::setLabel(const QString &label)
139 void QLegendMarker::setLabel(const QString &label)
115 {
140 {
116 d_ptr->m_item->setLabel(label);
141 d_ptr->m_item->setLabel(label);
117 }
142 }
118 /*!
143 /*!
119 Returns the brush which is used to draw label.
144 Returns the brush which is used to draw label.
120 */
145 */
121 QBrush QLegendMarker::labelBrush() const
146 QBrush QLegendMarker::labelBrush() const
122 {
147 {
123 return d_ptr->m_item->labelBrush();
148 return d_ptr->m_item->labelBrush();
124 }
149 }
125
150
126 /*!
151 /*!
127 Sets the \a brush of label
152 Sets the \a brush of label
128 */
153 */
129 void QLegendMarker::setLabelBrush(const QBrush &brush)
154 void QLegendMarker::setLabelBrush(const QBrush &brush)
130 {
155 {
131 d_ptr->m_item->setLabelBrush(brush);
156 d_ptr->m_item->setLabelBrush(brush);
132 }
157 }
133
158
134 /*!
159 /*!
135 Retuns the font of label
160 Retuns the font of label
136 */
161 */
137 QFont QLegendMarker::font() const
162 QFont QLegendMarker::font() const
138 {
163 {
139 return d_ptr->m_item->font();
164 return d_ptr->m_item->font();
140 }
165 }
141
166
142 /*!
167 /*!
143 Sets the \a font of label
168 Sets the \a font of label
144 */
169 */
145 void QLegendMarker::setFont(const QFont &font)
170 void QLegendMarker::setFont(const QFont &font)
146 {
171 {
147 d_ptr->m_item->setFont(font);
172 d_ptr->m_item->setFont(font);
148 }
173 }
149
174
150 /*!
175 /*!
151 Returns the pen of marker item
176 Returns the pen of marker item
152 */
177 */
153 QPen QLegendMarker::pen() const
178 QPen QLegendMarker::pen() const
154 {
179 {
155 return d_ptr->m_item->pen();
180 return d_ptr->m_item->pen();
156 }
181 }
157
182
158 /*!
183 /*!
159 Sets the \a pen of marker item
184 Sets the \a pen of marker item
160 */
185 */
161 void QLegendMarker::setPen(const QPen &pen)
186 void QLegendMarker::setPen(const QPen &pen)
162 {
187 {
163 d_ptr->m_item->setPen(pen);
188 d_ptr->m_item->setPen(pen);
164 }
189 }
165
190
166 /*!
191 /*!
167 Returns the brush of marker item
192 Returns the brush of marker item
168 */
193 */
169 QBrush QLegendMarker::brush() const
194 QBrush QLegendMarker::brush() const
170 {
195 {
171 return d_ptr->m_item->brush();
196 return d_ptr->m_item->brush();
172 }
197 }
173
198
174 /*!
199 /*!
175 Sets the \a brush of marker item. Note that changing color of the series also changes this.
200 Sets the \a brush of marker item. Note that changing color of the series also changes this.
176 */
201 */
177 void QLegendMarker::setBrush(const QBrush &brush)
202 void QLegendMarker::setBrush(const QBrush &brush)
178 {
203 {
179 d_ptr->m_item->setBrush(brush);
204 d_ptr->m_item->setBrush(brush);
180 }
205 }
181
206
182 /*!
207 /*!
183 Returns visibility of the marker
208 Returns visibility of the marker
184 */
209 */
185 bool QLegendMarker::isVisible() const
210 bool QLegendMarker::isVisible() const
186 {
211 {
187 return d_ptr->m_item->isVisible();
212 return d_ptr->m_item->isVisible();
188 }
213 }
189
214
190 /*!
215 /*!
191 Sets markers visibility to \a visible
216 Sets markers visibility to \a visible
192 */
217 */
193 void QLegendMarker::setVisible(bool visible)
218 void QLegendMarker::setVisible(bool visible)
194 {
219 {
195 d_ptr->m_item->setVisible(visible);
220 d_ptr->m_item->setVisible(visible);
196 }
221 }
197
222
198 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
223 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
199 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
224 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
200 m_legend(legend),
225 m_legend(legend),
201 q_ptr(q)
226 q_ptr(q)
202 {
227 {
203 m_item = new LegendMarkerItem(this);
228 m_item = new LegendMarkerItem(this);
204 }
229 }
205
230
206 QLegendMarkerPrivate::~QLegendMarkerPrivate()
231 QLegendMarkerPrivate::~QLegendMarkerPrivate()
207 {
232 {
208 }
233 }
209
234
210 void QLegendMarkerPrivate::invalidateLegend()
235 void QLegendMarkerPrivate::invalidateLegend()
211 {
236 {
212 m_legend->d_ptr->m_layout->invalidate();
237 m_legend->d_ptr->m_layout->invalidate();
213 }
238 }
214
239
215 #include "moc_qlegendmarker.cpp"
240 #include "moc_qlegendmarker.cpp"
216 #include "moc_qlegendmarker_p.cpp"
241 #include "moc_qlegendmarker_p.cpp"
217
242
218 QTCOMMERCIALCHART_END_NAMESPACE
243 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now