##// END OF EJS Templates
fixed warnings in legendmarker
sauimone -
r2202:e0ce227ad162
parent child
Show More
@@ -1,99 +1,98
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 // W A R N I N G
22 22 // -------------
23 23 //
24 24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 25 // implementation detail. This header file may change from version to
26 26 // version without notice, or even be removed.
27 27 //
28 28 // We mean it.
29 29
30 30 #ifndef LEGENDMARKERITEM_P_H
31 31 #define LEGENDMARKERITEM_P_H
32 32
33 33 #include "qchartglobal.h"
34 34 #include <QGraphicsObject>
35 35 #include <QFont>
36 36 #include <QBrush>
37 37 #include <QPen>
38 38 #include <QGraphicsSimpleTextItem>
39 39 #include <QGraphicsLayoutItem>
40 40
41 41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42 42
43 43 class QLegendMarkerPrivate;
44 44
45 45 class LegendMarkerItem : public QGraphicsObject, public QGraphicsLayoutItem
46 46 {
47 47 Q_OBJECT
48 48 Q_INTERFACES(QGraphicsLayoutItem)
49 49 public:
50 50 explicit LegendMarkerItem(QLegendMarkerPrivate *marker, QGraphicsObject *parent = 0);
51 51
52 52 void setPen(const QPen &pen);
53 53 QPen pen() const;
54 54
55 55 void setBrush(const QBrush &brush);
56 56 QBrush brush() const;
57 57
58 58 void setFont(const QFont &font);
59 59 QFont font() const;
60 60
61 61 void setLabel(const QString label);
62 62 QString label() const;
63 63
64 64 void setLabelBrush(const QBrush &brush);
65 65 QBrush labelBrush() const;
66 66
67 67 void setGeometry(const QRectF &rect);
68 68 QRectF boundingRect() const;
69 69
70 70 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
71 71 QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint) const;
72 72
73 73 protected:
74 74 QLegendMarkerPrivate *m_marker; // Knows
75 75 QRectF m_markerRect;
76 76 QRectF m_boundingRect;
77 77 QGraphicsSimpleTextItem *m_textItem;
78 78 QGraphicsRectItem *m_rectItem;
79 79 qreal m_margin;
80 80 qreal m_space;
81 81 QString m_label;
82 82
83 83 QBrush m_labelBrush;
84 84 QFont m_font;
85 85 QPen m_pen;
86 86 QBrush m_brush;
87 87 bool m_visible;
88 88
89 89 QPointF m_pressPos;
90 90
91 91 friend class QLegendMarker;
92 92 friend class QLegendMarkerPrivate;
93 friend class LegendMarkerItem;
94 93 friend class LegendLayout;
95 94 };
96 95
97 96 QTCOMMERCIALCHART_END_NAMESPACE
98 97
99 98 #endif // LEGENDMARKERITEM_P_H
@@ -1,127 +1,127
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 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
34 34 QObject(parent),
35 35 d_ptr(&d)
36 36 {
37 37 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
38 38 }
39 39
40 40 QLegendMarker::~QLegendMarker()
41 41 {
42 42 }
43 43
44 44 QString QLegendMarker::label() const
45 45 {
46 46 return d_ptr->m_item->label();
47 47 }
48 48
49 49 void QLegendMarker::setLabel(const QString &label)
50 50 {
51 51 d_ptr->m_item->setLabel(label);
52 52 }
53 53
54 54 QBrush QLegendMarker::labelBrush() const
55 55 {
56 56 return d_ptr->m_item->labelBrush();
57 57 }
58 58
59 59 void QLegendMarker::setLabelBrush(const QBrush &brush)
60 60 {
61 61 d_ptr->m_item->setLabelBrush(brush);
62 62 }
63 63
64 64 QFont QLegendMarker::font() const
65 65 {
66 66 return d_ptr->m_item->font();
67 67 }
68 68
69 69 void QLegendMarker::setFont(const QFont &font)
70 70 {
71 71 d_ptr->m_item->setFont(font);
72 72 }
73 73
74 74 QPen QLegendMarker::pen() const
75 75 {
76 76 return d_ptr->m_item->pen();
77 77 }
78 78
79 79 void QLegendMarker::setPen(const QPen &pen)
80 80 {
81 81 d_ptr->m_item->setPen(pen);
82 82 }
83 83
84 84 QBrush QLegendMarker::brush() const
85 85 {
86 86 return d_ptr->m_item->brush();
87 87 }
88 88
89 89 void QLegendMarker::setBrush(const QBrush &brush)
90 90 {
91 91 d_ptr->m_item->setBrush(brush);
92 92 }
93 93
94 94 bool QLegendMarker::isVisible() const
95 95 {
96 96 return d_ptr->m_item->isVisible();
97 97 }
98 98
99 99 void QLegendMarker::setVisible(bool visible)
100 100 {
101 101 d_ptr->m_item->setVisible(visible);
102 102 }
103 103
104 104 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
105 105 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
106 q_ptr(q),
107 m_legend(legend)
106 m_legend(legend),
107 q_ptr(q)
108 108 {
109 109 m_item = new LegendMarkerItem(this);
110 110 // m_item->setVisible(q->series()->isVisible());
111 111 }
112 112
113 113 QLegendMarkerPrivate::~QLegendMarkerPrivate()
114 114 {
115 115 }
116 116
117 117 void QLegendMarkerPrivate::invalidateLegend()
118 118 {
119 119 m_legend->d_ptr->m_layout->invalidate();
120 120 }
121 121
122 122
123 123
124 124 #include "moc_qlegendmarker.cpp"
125 125 #include "moc_qlegendmarker_p.cpp"
126 126
127 127 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now