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