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