@@ -1,146 +1,146 | |||||
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 <QBrush> |
|
35 | #include <QBrush> | |
36 | #include <QPen> |
|
36 | #include <QPen> | |
37 | #include <QGraphicsSimpleTextItem> |
|
37 | #include <QGraphicsSimpleTextItem> | |
38 | #include <QGraphicsLayoutItem> |
|
38 | #include <QGraphicsLayoutItem> | |
39 |
|
39 | |||
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class QAbstractSeries; |
|
42 | class QAbstractSeries; | |
43 | class QAreaSeries; |
|
43 | class QAreaSeries; | |
44 | class QXYSeries; |
|
44 | class QXYSeries; | |
45 | class QBarSet; |
|
45 | class QBarSet; | |
46 | class QAbstractBarSeries; |
|
46 | class QAbstractBarSeries; | |
47 | class QPieSlice; |
|
47 | class QPieSlice; | |
48 | class QLegend; |
|
48 | class QLegend; | |
49 | class QPieSeries; |
|
49 | class QPieSeries; | |
50 |
|
50 | |||
51 | class LegendMarkerItem : public QGraphicsObject, public QGraphicsLayoutItem |
|
51 | class LegendMarkerItem : public QGraphicsObject, public QGraphicsLayoutItem | |
52 | { |
|
52 | { | |
53 | Q_OBJECT |
|
53 | Q_OBJECT | |
54 | Q_INTERFACES(QGraphicsLayoutItem) |
|
54 | Q_INTERFACES(QGraphicsLayoutItem) | |
55 | public: |
|
55 | public: | |
56 | explicit LegendMarkerItem(QAbstractSeries *m_series, QGraphicsObject *parent); |
|
56 | explicit LegendMarkerItem(QAbstractSeries *m_series, QGraphicsObject *parent = 0); | |
57 |
|
57 | |||
58 | void setPen(const QPen &pen); |
|
58 | void setPen(const QPen &pen); | |
59 | QPen pen() const; |
|
59 | QPen pen() const; | |
60 |
|
60 | |||
61 | void setBrush(const QBrush &brush); |
|
61 | void setBrush(const QBrush &brush); | |
62 | QBrush brush() const; |
|
62 | QBrush brush() const; | |
63 |
|
63 | |||
64 | void setFont(const QFont &font); |
|
64 | void setFont(const QFont &font); | |
65 | QFont font() const; |
|
65 | QFont font() const; | |
66 |
|
66 | |||
67 | void setLabel(const QString label); |
|
67 | void setLabel(const QString label); | |
68 | QString label() const; |
|
68 | QString label() const; | |
69 |
|
69 | |||
70 | void setLabelBrush(const QBrush &brush); |
|
70 | void setLabelBrush(const QBrush &brush); | |
71 | QBrush labelBrush() const; |
|
71 | QBrush labelBrush() const; | |
72 |
|
72 | |||
73 | QAbstractSeries *series() const { return m_series;} |
|
73 | QAbstractSeries *series() const { return m_series;} | |
74 |
|
74 | |||
75 | void setGeometry(const QRectF& rect); |
|
75 | void setGeometry(const QRectF& rect); | |
76 |
|
76 | |||
77 | QRectF boundingRect() const; |
|
77 | QRectF boundingRect() const; | |
78 |
|
78 | |||
79 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
79 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
80 |
|
80 | |||
81 | QSizeF sizeHint (Qt::SizeHint which, const QSizeF& constraint) const; |
|
81 | QSizeF sizeHint (Qt::SizeHint which, const QSizeF& constraint) const; | |
82 |
|
82 | |||
83 | protected: |
|
83 | protected: | |
84 | // From QGraphicsObject |
|
84 | // From QGraphicsObject | |
85 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
85 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
86 |
|
86 | |||
87 | //public Q_SLOTS: |
|
87 | //public Q_SLOTS: | |
88 | //virtual void updated() = 0; |
|
88 | //virtual void updated() = 0; | |
89 |
|
89 | |||
90 | protected: |
|
90 | protected: | |
91 | QAbstractSeries *m_series; |
|
91 | QAbstractSeries *m_series; | |
92 | QRectF m_markerRect; |
|
92 | QRectF m_markerRect; | |
93 | QRectF m_boundingRect; |
|
93 | QRectF m_boundingRect; | |
94 | // QLegend* m_legend; |
|
94 | // QLegend* m_legend; | |
95 | QGraphicsSimpleTextItem *m_textItem; |
|
95 | QGraphicsSimpleTextItem *m_textItem; | |
96 | QGraphicsRectItem *m_rectItem; |
|
96 | QGraphicsRectItem *m_rectItem; | |
97 | qreal m_margin; |
|
97 | qreal m_margin; | |
98 | qreal m_space; |
|
98 | qreal m_space; | |
99 | QString m_text; |
|
99 | QString m_text; | |
100 |
|
100 | |||
101 | }; |
|
101 | }; | |
102 |
|
102 | |||
103 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
103 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
104 | class XYLegendMarkerItem : public LegendMarkerItem |
|
104 | class XYLegendMarkerItem : public LegendMarkerItem | |
105 | { |
|
105 | { | |
106 | public: |
|
106 | public: | |
107 | XYLegendMarkerItem(QXYSeries *series, QLegend *legend); |
|
107 | XYLegendMarkerItem(QXYSeries *series, QLegend *legend); | |
108 | protected: |
|
108 | protected: | |
109 | void updated(); |
|
109 | void updated(); | |
110 | private: |
|
110 | private: | |
111 | QXYSeries *m_series; |
|
111 | QXYSeries *m_series; | |
112 | }; |
|
112 | }; | |
113 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
113 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
114 | class AreaLegendMarkerItem : public LegendMarkerItem |
|
114 | class AreaLegendMarkerItem : public LegendMarkerItem | |
115 | { |
|
115 | { | |
116 | public: |
|
116 | public: | |
117 | AreaLegendMarkerItem(QAreaSeries *series, QLegend *legend); |
|
117 | AreaLegendMarkerItem(QAreaSeries *series, QLegend *legend); | |
118 | protected: |
|
118 | protected: | |
119 | void updated(); |
|
119 | void updated(); | |
120 | private: |
|
120 | private: | |
121 | QAreaSeries *m_series; |
|
121 | QAreaSeries *m_series; | |
122 | }; |
|
122 | }; | |
123 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
123 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
124 | class BarLegendMarkerItem : public LegendMarkerItem |
|
124 | class BarLegendMarkerItem : public LegendMarkerItem | |
125 | { |
|
125 | { | |
126 | public: |
|
126 | public: | |
127 | BarLegendMarkerItem(QAbstractBarSeries *barseries, QBarSet *barset,QLegend *legend); |
|
127 | BarLegendMarkerItem(QAbstractBarSeries *barseries, QBarSet *barset,QLegend *legend); | |
128 | protected: |
|
128 | protected: | |
129 | void updated(); |
|
129 | void updated(); | |
130 | private: |
|
130 | private: | |
131 | QBarSet *m_barset; |
|
131 | QBarSet *m_barset; | |
132 | }; |
|
132 | }; | |
133 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
134 | class PieLegendMarkerItem : public LegendMarkerItem |
|
134 | class PieLegendMarkerItem : public LegendMarkerItem | |
135 | { |
|
135 | { | |
136 | public: |
|
136 | public: | |
137 | PieLegendMarkerItem(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend); |
|
137 | PieLegendMarkerItem(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend); | |
138 | protected: |
|
138 | protected: | |
139 | void updated(); |
|
139 | void updated(); | |
140 | private: |
|
140 | private: | |
141 | QPieSlice *m_pieslice; |
|
141 | QPieSlice *m_pieslice; | |
142 | }; |
|
142 | }; | |
143 |
|
143 | |||
144 | QTCOMMERCIALCHART_END_NAMESPACE |
|
144 | QTCOMMERCIALCHART_END_NAMESPACE | |
145 |
|
145 | |||
146 | #endif // LEGENDMARKERITEM_P_H |
|
146 | #endif // LEGENDMARKERITEM_P_H |
@@ -1,187 +1,116 | |||||
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 <QDebug> |
|
24 | #include <QDebug> | |
25 | #include <QFontMetrics> |
|
25 | #include <QFontMetrics> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | QLegendMarker::QLegendMarker(QAbstractSeries* series, QObject *parent) : |
|
29 | QLegendMarker::QLegendMarker(QAbstractSeries* series, QObject *parent) : | |
30 | QObject(parent), |
|
30 | QObject(parent), | |
31 | d_ptr(new QLegendMarkerPrivate(series, this)) |
|
31 | d_ptr(new QLegendMarkerPrivate(series, this)) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | QLegendMarker::~QLegendMarker() |
|
35 | QLegendMarker::~QLegendMarker() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QString QLegendMarker::label() const |
|
39 | QString QLegendMarker::label() const | |
40 | { |
|
40 | { | |
41 | return d_ptr->m_label; |
|
41 | return d_ptr->m_label; | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void QLegendMarker::setLabel(const QString &label) |
|
44 | void QLegendMarker::setLabel(const QString &label) | |
45 | { |
|
45 | { | |
46 | d_ptr->m_label = label; |
|
46 | d_ptr->m_label = label; | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | QBrush QLegendMarker::labelBrush() const |
|
49 | QBrush QLegendMarker::labelBrush() const | |
50 | { |
|
50 | { | |
51 | return d_ptr->m_labelBrush; |
|
51 | return d_ptr->m_labelBrush; | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | void QLegendMarker::setLabelBrush(const QBrush &brush) |
|
54 | void QLegendMarker::setLabelBrush(const QBrush &brush) | |
55 | { |
|
55 | { | |
56 | d_ptr->m_labelBrush = brush; |
|
56 | d_ptr->m_labelBrush = brush; | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | QFont QLegendMarker::font() const |
|
59 | QFont QLegendMarker::font() const | |
60 | { |
|
60 | { | |
61 | return d_ptr->m_font; |
|
61 | return d_ptr->m_font; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void QLegendMarker::setFont(const QFont &font) |
|
64 | void QLegendMarker::setFont(const QFont &font) | |
65 | { |
|
65 | { | |
66 | d_ptr->m_font = font; |
|
66 | d_ptr->m_font = font; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | QPen QLegendMarker::pen() const |
|
69 | QPen QLegendMarker::pen() const | |
70 | { |
|
70 | { | |
71 | return d_ptr->m_pen; |
|
71 | return d_ptr->m_pen; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void QLegendMarker::setPen(const QPen &pen) |
|
74 | void QLegendMarker::setPen(const QPen &pen) | |
75 | { |
|
75 | { | |
76 | d_ptr->m_pen = pen; |
|
76 | d_ptr->m_pen = pen; | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | QBrush QLegendMarker::brush() const |
|
79 | QBrush QLegendMarker::brush() const | |
80 | { |
|
80 | { | |
81 | return d_ptr->m_brush; |
|
81 | return d_ptr->m_brush; | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void QLegendMarker::setBrush(const QBrush &brush) |
|
84 | void QLegendMarker::setBrush(const QBrush &brush) | |
85 | { |
|
85 | { | |
86 | d_ptr->m_brush = brush; |
|
86 | d_ptr->m_brush = brush; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | bool QLegendMarker::isVisible() const |
|
89 | bool QLegendMarker::isVisible() const | |
90 | { |
|
90 | { | |
91 | return d_ptr->m_visible; |
|
91 | return d_ptr->m_visible; | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | void QLegendMarker::setVisible(bool visible) |
|
94 | void QLegendMarker::setVisible(bool visible) | |
95 | { |
|
95 | { | |
96 | d_ptr->m_visible = visible; |
|
96 | d_ptr->m_visible = visible; | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | QAbstractSeries* QLegendMarker::series() |
|
99 | QAbstractSeries* QLegendMarker::series() | |
100 | { |
|
100 | { | |
101 | return d_ptr->m_series; |
|
101 | return d_ptr->m_series; | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
104 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
105 |
|
105 | |||
106 | QLegendMarkerPrivate::QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q) : |
|
106 | QLegendMarkerPrivate::QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q) : | |
107 | q_ptr(q), |
|
107 | q_ptr(q), | |
108 | m_series(series) |
|
108 | m_series(series) | |
109 | { |
|
109 | { | |
110 |
m_item = new LegendMarkerItem(m_series |
|
110 | m_item = new LegendMarkerItem(m_series); | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | void QLegendMarkerPrivate::setGeometry(const QRectF& rect) |
|
|||
114 | { |
|
|||
115 | QFontMetrics fn (m_font); |
|
|||
116 |
|
||||
117 |
|
||||
118 | int width = rect.width(); |
|
|||
119 | qreal x = m_margin + m_markerRect.width() + m_space + m_margin; |
|
|||
120 | qreal y = qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin); |
|
|||
121 |
|
||||
122 | if (fn.boundingRect(m_label).width() + x > width) |
|
|||
123 | { |
|
|||
124 | QString string = m_label + "..."; |
|
|||
125 | while(fn.boundingRect(string).width() + x > width && string.length() > 3) |
|
|||
126 | string.remove(string.length() - 4, 1); |
|
|||
127 | m_textItem->setText(string); |
|
|||
128 | } |
|
|||
129 | else |
|
|||
130 | m_textItem->setText(m_label); |
|
|||
131 |
|
||||
132 | const QRectF& textRect = m_textItem->boundingRect(); |
|
|||
133 |
|
||||
134 |
|
||||
135 | m_textItem->setPos(x-m_margin,y/2 - textRect.height()/2); |
|
|||
136 | m_rectItem->setRect(m_markerRect); |
|
|||
137 | m_rectItem->setPos(m_margin,y/2 - m_markerRect.height()/2); |
|
|||
138 |
|
||||
139 | prepareGeometryChange(); |
|
|||
140 | m_boundingRect = QRectF(0,0,x+textRect.width()+m_margin,y); |
|
|||
141 | } |
|
|||
142 |
|
||||
143 | QRectF QLegendMarkerPrivate::boundingRect() const |
|
|||
144 | { |
|
|||
145 | return m_boundingRect; |
|
|||
146 | } |
|
|||
147 |
|
||||
148 | void QLegendMarkerPrivate::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
|||
149 | { |
|
|||
150 | Q_UNUSED(option) |
|
|||
151 | Q_UNUSED(widget) |
|
|||
152 | Q_UNUSED(painter) |
|
|||
153 | } |
|
|||
154 |
|
||||
155 | QSizeF QLegendMarkerPrivate::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const |
|
|||
156 | { |
|
|||
157 | Q_UNUSED(constraint) |
|
|||
158 |
|
||||
159 | QFontMetrics fn(m_textItem->font()); |
|
|||
160 | QSizeF sh; |
|
|||
161 |
|
||||
162 | switch (which) { |
|
|||
163 | case Qt::MinimumSize: |
|
|||
164 | sh = QSizeF(fn.boundingRect("...").width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin)); |
|
|||
165 | break; |
|
|||
166 | case Qt::PreferredSize: |
|
|||
167 | sh = QSizeF(fn.boundingRect(m_label).width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin)); |
|
|||
168 | break; |
|
|||
169 | default: |
|
|||
170 | break; |
|
|||
171 | } |
|
|||
172 |
|
||||
173 | return sh; |
|
|||
174 | } |
|
|||
175 |
|
||||
176 | void QLegendMarkerPrivate::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
|||
177 | { |
|
|||
178 | qDebug() << "QLegendMarkerPrivate::mousePressEvent" << event; |
|
|||
179 | QGraphicsObject::mousePressEvent(event); |
|
|||
180 | //TODO: selected signal removed for now |
|
|||
181 | } |
|
|||
182 |
|
||||
183 |
|
||||
184 | #include "moc_qlegendmarker.cpp" |
|
113 | #include "moc_qlegendmarker.cpp" | |
185 | #include "moc_qlegendmarker_p.cpp" |
|
114 | #include "moc_qlegendmarker_p.cpp" | |
186 |
|
115 | |||
187 | QTCOMMERCIALCHART_END_NAMESPACE |
|
116 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,124 +1,112 | |||||
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 QLEGENDMARKERPRIVATE_H |
|
30 | #ifndef QLEGENDMARKERPRIVATE_H | |
31 | #define QLEGENDMARKERPRIVATE_H |
|
31 | #define QLEGENDMARKERPRIVATE_H | |
32 |
|
32 | |||
33 | #include "qchartglobal.h" |
|
33 | #include "qchartglobal.h" | |
34 | #include <QGraphicsObject> |
|
34 | #include <QGraphicsObject> | |
35 | #include <QBrush> |
|
35 | #include <QBrush> | |
36 | #include <QPen> |
|
36 | #include <QPen> | |
37 | #include <QGraphicsSimpleTextItem> |
|
37 | #include <QGraphicsSimpleTextItem> | |
38 | #include <QGraphicsLayoutItem> |
|
38 | #include <QGraphicsLayoutItem> | |
39 |
|
39 | |||
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | // TODO: check these |
|
42 | // TODO: check these | |
43 | class QAbstractSeries; |
|
43 | class QAbstractSeries; | |
44 | class QAreaSeries; |
|
44 | class QAreaSeries; | |
45 | class QXYSeries; |
|
45 | class QXYSeries; | |
46 | class QBarSet; |
|
46 | class QBarSet; | |
47 | class QAbstractBarSeries; |
|
47 | class QAbstractBarSeries; | |
48 | class QPieSlice; |
|
48 | class QPieSlice; | |
49 | class QLegend; |
|
49 | class QLegend; | |
50 | class QPieSeries; |
|
50 | class QPieSeries; | |
51 |
|
51 | |||
52 | class QLegendMarker; |
|
52 | class QLegendMarker; | |
53 | class LegendMarkerItem; |
|
53 | class LegendMarkerItem; | |
54 |
|
54 | |||
55 |
class QLegendMarkerPrivate : public Q |
|
55 | class QLegendMarkerPrivate : public QObject | |
56 | { |
|
56 | { | |
57 | Q_OBJECT |
|
57 | Q_OBJECT | |
58 | Q_INTERFACES(QGraphicsLayoutItem) |
|
|||
59 | public: |
|
58 | public: | |
60 | explicit QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q); |
|
59 | explicit QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q); | |
61 | /* |
|
60 | /* | |
62 | void setPen(const QPen &pen); |
|
61 | void setPen(const QPen &pen); | |
63 | QPen pen() const; |
|
62 | QPen pen() const; | |
64 |
|
63 | |||
65 | void setBrush(const QBrush &brush); |
|
64 | void setBrush(const QBrush &brush); | |
66 | QBrush brush() const; |
|
65 | QBrush brush() const; | |
67 |
|
66 | |||
68 | void setFont(const QFont &font); |
|
67 | void setFont(const QFont &font); | |
69 | QFont font() const; |
|
68 | QFont font() const; | |
70 |
|
69 | |||
71 | void setLabel(const QString label); |
|
70 | void setLabel(const QString label); | |
72 | QString label() const; |
|
71 | QString label() const; | |
73 |
|
72 | |||
74 | void setLabelBrush(const QBrush &brush); |
|
73 | void setLabelBrush(const QBrush &brush); | |
75 | QBrush labelBrush() const; |
|
74 | QBrush labelBrush() const; | |
76 | */ |
|
75 | */ | |
77 | void setGeometry(const QRectF& rect); |
|
|||
78 |
|
||||
79 | QRectF boundingRect() const; |
|
|||
80 |
|
||||
81 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
|||
82 |
|
||||
83 | QSizeF sizeHint (Qt::SizeHint which, const QSizeF& constraint) const; |
|
|||
84 |
|
||||
85 | protected: |
|
|||
86 | // From QGraphicsObject |
|
|||
87 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
|||
88 |
|
76 | |||
89 | public Q_SLOTS: |
|
77 | public Q_SLOTS: | |
90 | virtual void updated() {}; |
|
78 | virtual void updated() {}; | |
91 |
|
79 | |||
92 | private: |
|
80 | private: | |
93 | QLegendMarker *q_ptr; |
|
81 | QLegendMarker *q_ptr; | |
94 |
|
82 | |||
95 | LegendMarkerItem *m_item; |
|
83 | LegendMarkerItem *m_item; | |
96 |
|
84 | |||
97 | /* |
|
85 | /* | |
98 | QLegend* m_legend; |
|
86 | QLegend* m_legend; | |
99 | */ |
|
87 | */ | |
100 |
|
88 | |||
101 | // New legend marker properties |
|
89 | // New legend marker properties | |
102 | QAbstractSeries* m_series; |
|
90 | QAbstractSeries* m_series; | |
103 | QString m_label; |
|
91 | QString m_label; | |
104 | QBrush m_labelBrush; |
|
92 | QBrush m_labelBrush; | |
105 | QFont m_font; |
|
93 | QFont m_font; | |
106 | QPen m_pen; |
|
94 | QPen m_pen; | |
107 | QBrush m_brush; |
|
95 | QBrush m_brush; | |
108 | bool m_visible; |
|
96 | bool m_visible; | |
109 |
|
97 | |||
110 | // Implementation details of new marker |
|
98 | // Implementation details of new marker | |
111 | QRectF m_markerRect; |
|
99 | QRectF m_markerRect; | |
112 | QRectF m_boundingRect; |
|
100 | QRectF m_boundingRect; | |
113 | QGraphicsSimpleTextItem *m_textItem; |
|
101 | QGraphicsSimpleTextItem *m_textItem; | |
114 | QGraphicsRectItem *m_rectItem; |
|
102 | QGraphicsRectItem *m_rectItem; | |
115 | qreal m_margin; |
|
103 | qreal m_margin; | |
116 | qreal m_space; |
|
104 | qreal m_space; | |
117 |
|
105 | |||
118 | friend class QLegendPrivate; // TODO: Is this needed? |
|
106 | friend class QLegendPrivate; // TODO: Is this needed? | |
119 | Q_DECLARE_PUBLIC(QLegendMarker) |
|
107 | Q_DECLARE_PUBLIC(QLegendMarker) | |
120 | }; |
|
108 | }; | |
121 |
|
109 | |||
122 | QTCOMMERCIALCHART_END_NAMESPACE |
|
110 | QTCOMMERCIALCHART_END_NAMESPACE | |
123 |
|
111 | |||
124 | #endif // QLEGENDMARKERPRIVATE_H |
|
112 | #endif // QLEGENDMARKERPRIVATE_H |
General Comments 0
You need to be logged in to leave comments.
Login now