##// END OF EJS Templates
legendmarker doc update
sauimone -
r2217:b8a798289b0a
parent child
Show More
@@ -1,210 +1,212
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 QLegendMarker is abstract object that can be used to access markers inside QLegend. The QLegendMarker is always connected
39 to some series
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
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 45 \sa QLegend
44 46 */
45 47 /*!
46 48 \enum QLegendMarker::LegendMarkerType
47 49
48 50 The type of the legendmarker object.
49 51
50 52 \value LegendMarkerTypeArea
51 53 \value LegendMarkerTypeBar
52 54 \value LegendMarkerTypePie
53 55 \value LegendMarkerTypeXY
54 56 */
55 57
56 58 /*!
57 59 \fn virtual LegendMarkerType QLegendMarker::type() = 0;
58 60 Returns the type of legendmarker. Type depends of the related series. LegendMarkerTypeXY is used for all QXYSeries derived
59 61 classes.
60 62 */
61 63
62 64 /*!
63 65 \fn virtual QAbstractSeries* QLegendMarker::series() = 0;
64 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 70 \fn void QLegendMarker::clicked();
69 71 This signal is emitted, when marker is clicked with mouse.
70 72 */
71 73
72 74 /*!
73 75 \fn void QLegendMarker::hovered(bool status);
74 76 This signal is emitted, when mouse is hovered over marker. \a status is true, when mouse enters the marker
75 77 and false when it leaves the marker.
76 78 */
77 79
78 80 /*!
79 81 Constructor of marker
80 82 */
81 83 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
82 84 QObject(parent),
83 85 d_ptr(&d)
84 86 {
85 87 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
86 88 }
87 89
88 90 /*!
89 91 Destructor of marker
90 92 */
91 93 QLegendMarker::~QLegendMarker()
92 94 {
93 95 }
94 96
95 97 /*!
96 98 Returns the label of the marker.
97 99 */
98 100 QString QLegendMarker::label() const
99 101 {
100 102 return d_ptr->m_item->label();
101 103 }
102 104
103 105 /*!
104 106 Sets the \a label of marker. Note that changing name of series will also change label of its marker.
105 107 */
106 108 void QLegendMarker::setLabel(const QString &label)
107 109 {
108 110 d_ptr->m_item->setLabel(label);
109 111 }
110 112 /*!
111 113 Returns the brush which is used to draw label.
112 114 */
113 115 QBrush QLegendMarker::labelBrush() const
114 116 {
115 117 return d_ptr->m_item->labelBrush();
116 118 }
117 119
118 120 /*!
119 121 Sets the \a brush of label
120 122 */
121 123 void QLegendMarker::setLabelBrush(const QBrush &brush)
122 124 {
123 125 d_ptr->m_item->setLabelBrush(brush);
124 126 }
125 127
126 128 /*!
127 129 Retuns the font of label
128 130 */
129 131 QFont QLegendMarker::font() const
130 132 {
131 133 return d_ptr->m_item->font();
132 134 }
133 135
134 136 /*!
135 137 Sets the \a font of label
136 138 */
137 139 void QLegendMarker::setFont(const QFont &font)
138 140 {
139 141 d_ptr->m_item->setFont(font);
140 142 }
141 143
142 144 /*!
143 145 Returns the pen of marker item
144 146 */
145 147 QPen QLegendMarker::pen() const
146 148 {
147 149 return d_ptr->m_item->pen();
148 150 }
149 151
150 152 /*!
151 153 Sets the \a pen of marker item
152 154 */
153 155 void QLegendMarker::setPen(const QPen &pen)
154 156 {
155 157 d_ptr->m_item->setPen(pen);
156 158 }
157 159
158 160 /*!
159 161 Returns the brush of marker item
160 162 */
161 163 QBrush QLegendMarker::brush() const
162 164 {
163 165 return d_ptr->m_item->brush();
164 166 }
165 167
166 168 /*!
167 169 Sets the \a brush of marker item. Note that changing color of the series also changes this.
168 170 */
169 171 void QLegendMarker::setBrush(const QBrush &brush)
170 172 {
171 173 d_ptr->m_item->setBrush(brush);
172 174 }
173 175
174 176 /*!
175 177 Returns visibility of the marker
176 178 */
177 179 bool QLegendMarker::isVisible() const
178 180 {
179 181 return d_ptr->m_item->isVisible();
180 182 }
181 183
182 184 /*!
183 185 Sets markers visibility to \a visible
184 186 */
185 187 void QLegendMarker::setVisible(bool visible)
186 188 {
187 189 d_ptr->m_item->setVisible(visible);
188 190 }
189 191
190 192 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
191 193 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
192 194 m_legend(legend),
193 195 q_ptr(q)
194 196 {
195 197 m_item = new LegendMarkerItem(this);
196 198 }
197 199
198 200 QLegendMarkerPrivate::~QLegendMarkerPrivate()
199 201 {
200 202 }
201 203
202 204 void QLegendMarkerPrivate::invalidateLegend()
203 205 {
204 206 m_legend->d_ptr->m_layout->invalidate();
205 207 }
206 208
207 209 #include "moc_qlegendmarker.cpp"
208 210 #include "moc_qlegendmarker_p.cpp"
209 211
210 212 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now