@@ -0,0 +1,90 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "qbarlegendmarker.h" | |
|
22 | #include "qbarlegendmarker_p.h" | |
|
23 | #include <QAbstractBarSeries> | |
|
24 | #include <QBarSet> | |
|
25 | #include <QDebug> | |
|
26 | ||
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
28 | ||
|
29 | QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries* series, QBarSet* barset, QLegend *legend, QObject *parent) : | |
|
30 | QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent) | |
|
31 | { | |
|
32 | } | |
|
33 | ||
|
34 | QBarLegendMarker::~QBarLegendMarker() | |
|
35 | { | |
|
36 | // qDebug() << "deleting bar marker" << this; | |
|
37 | } | |
|
38 | ||
|
39 | /*! | |
|
40 | \internal | |
|
41 | */ | |
|
42 | QBarLegendMarker::QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent) : | |
|
43 | QLegendMarker(d, parent) | |
|
44 | { | |
|
45 | } | |
|
46 | ||
|
47 | QAbstractBarSeries *QBarLegendMarker::series() | |
|
48 | { | |
|
49 | Q_D(QBarLegendMarker); | |
|
50 | return d->m_series; | |
|
51 | } | |
|
52 | ||
|
53 | QBarSet* QBarLegendMarker::peerObject() | |
|
54 | { | |
|
55 | Q_D(QBarLegendMarker); | |
|
56 | return d->m_barset; | |
|
57 | } | |
|
58 | ||
|
59 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
60 | ||
|
61 | QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) : | |
|
62 | QLegendMarkerPrivate(q,legend), | |
|
63 | m_series(series), | |
|
64 | m_barset(barset) | |
|
65 | { | |
|
66 | QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated())); | |
|
67 | QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated())); | |
|
68 | QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated())); | |
|
69 | updated(); | |
|
70 | } | |
|
71 | ||
|
72 | QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate() | |
|
73 | { | |
|
74 | QObject::disconnect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated())); | |
|
75 | QObject::disconnect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated())); | |
|
76 | QObject::disconnect(m_barset, SIGNAL(penChanged()), this, SLOT(updated())); | |
|
77 | } | |
|
78 | ||
|
79 | void QBarLegendMarkerPrivate::updated() | |
|
80 | { | |
|
81 | m_item->setPen(m_barset->pen()); | |
|
82 | m_item->setBrush(m_barset->brush()); | |
|
83 | m_item->setLabel(m_barset->label()); | |
|
84 | } | |
|
85 | ||
|
86 | #include "moc_qbarlegendmarker.cpp" | |
|
87 | #include "moc_qbarlegendmarker_p.cpp" | |
|
88 | ||
|
89 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
90 |
@@ -0,0 +1,59 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | #ifndef QBARLEGENDMARKER_H | |
|
21 | #define QBARLEGENDMARKER_H | |
|
22 | ||
|
23 | #include <QChartGlobal> | |
|
24 | #include <QLegendMarker> | |
|
25 | #include <QAbstractBarSeries> | |
|
26 | #include <QBarSet> | |
|
27 | //#include "qbarlegendmarker_p.h" | |
|
28 | ||
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
30 | ||
|
31 | class QLegend; | |
|
32 | class QBarLegendMarkerPrivate; | |
|
33 | ||
|
34 | class QTCOMMERCIALCHART_EXPORT QBarLegendMarker : public QLegendMarker | |
|
35 | { | |
|
36 | Q_OBJECT | |
|
37 | public: | |
|
38 | explicit QBarLegendMarker(QAbstractBarSeries* series, QBarSet* barset, QLegend *legend, QObject *parent = 0); | |
|
39 | virtual ~QBarLegendMarker(); | |
|
40 | ||
|
41 | virtual QAbstractBarSeries* series(); | |
|
42 | virtual QBarSet* peerObject(); // TODO: rename to slice and remove these virtuals from base class? | |
|
43 | ||
|
44 | protected: | |
|
45 | QBarLegendMarker(QBarLegendMarkerPrivate &d, QObject *parent = 0); | |
|
46 | ||
|
47 | //Q_SIGNALS: | |
|
48 | ||
|
49 | //public Q_SLOTS: | |
|
50 | ||
|
51 | private: | |
|
52 | Q_DECLARE_PRIVATE(QBarLegendMarker) | |
|
53 | Q_DISABLE_COPY(QBarLegendMarker) | |
|
54 | ||
|
55 | }; | |
|
56 | ||
|
57 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
58 | ||
|
59 | #endif // QBARLEGENDMARKER_H |
@@ -0,0 +1,67 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | #ifndef QBARLEGENDMARKER_P_H | |
|
31 | #define QBARLEGENDMARKER_P_H | |
|
32 | ||
|
33 | #include "qchartglobal.h" | |
|
34 | #include "qlegendmarker_p.h" | |
|
35 | #include "legendmarkeritem_p.h" | |
|
36 | #include <QAbstractBarSeries> | |
|
37 | #include <QBarSet> | |
|
38 | ||
|
39 | #include <QDebug> | |
|
40 | ||
|
41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
42 | ||
|
43 | class QBarLegendMarker; | |
|
44 | ||
|
45 | class QBarLegendMarkerPrivate : public QLegendMarkerPrivate | |
|
46 | { | |
|
47 | Q_OBJECT | |
|
48 | public: | |
|
49 | explicit QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend); | |
|
50 | virtual ~QBarLegendMarkerPrivate(); | |
|
51 | ||
|
52 | public Q_SLOTS: | |
|
53 | virtual void updated(); | |
|
54 | ||
|
55 | private: | |
|
56 | QBarLegendMarker *q_ptr; | |
|
57 | ||
|
58 | QAbstractBarSeries* m_series; | |
|
59 | QBarSet* m_barset; | |
|
60 | ||
|
61 | friend class QLegendPrivate; // TODO: Is this needed? | |
|
62 | Q_DECLARE_PUBLIC(QBarLegendMarker) | |
|
63 | }; | |
|
64 | ||
|
65 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
66 | ||
|
67 | #endif // QBARLEGENDMARKER_P_H |
@@ -29,6 +29,8 | |||
|
29 | 29 | #include "qvalueaxis.h" |
|
30 | 30 | #include "qbarcategoryaxis.h" |
|
31 | 31 | |
|
32 | #include "qbarlegendmarker.h" | |
|
33 | ||
|
32 | 34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | 35 | |
|
34 | 36 | /*! |
@@ -661,16 +663,13 QList<LegendMarker *> QAbstractBarSeriesPrivate::createLegendMarker(QLegend *leg | |||
|
661 | 663 | |
|
662 | 664 | QList<QLegendMarker*> QAbstractBarSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
663 | 665 | { |
|
664 | Q_UNUSED(legend); | |
|
665 | // Q_Q(QAbstractBarSeries); | |
|
666 | Q_Q(QAbstractBarSeries); | |
|
666 | 667 | QList<QLegendMarker*> markers; |
|
667 | // TODO: when QBarLegendMarker is implemented | |
|
668 | /* | |
|
668 | ||
|
669 | 669 | foreach(QBarSet* set, q->barSets()) { |
|
670 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); | |
|
670 | QBarLegendMarker* marker = new QBarLegendMarker(q,set,legend); | |
|
671 | 671 | markers << marker; |
|
672 | 672 | } |
|
673 | */ | |
|
674 | 673 | return markers; |
|
675 | 674 | } |
|
676 | 675 |
@@ -7,7 +7,8 SOURCES += \ | |||
|
7 | 7 | $$PWD/legendlayout.cpp \ |
|
8 | 8 | $$PWD/qlegendmarker.cpp \ |
|
9 | 9 | $$PWD/qpielegendmarker.cpp \ |
|
10 | $$PWD/legendmarkeritem.cpp | |
|
10 | $$PWD/legendmarkeritem.cpp \ | |
|
11 | $$PWD/qbarlegendmarker.cpp | |
|
11 | 12 | |
|
12 | 13 | PRIVATE_HEADERS += \ |
|
13 | 14 | $$PWD/legendmarker_p.h \ |
@@ -16,10 +17,12 PRIVATE_HEADERS += \ | |||
|
16 | 17 | $$PWD/legendlayout_p.h \ |
|
17 | 18 | $$PWD/qlegendmarker_p.h \ |
|
18 | 19 | $$PWD/legendmarkeritem_p.h \ |
|
19 | $$PWD/qpielegendmarker_p.h | |
|
20 | $$PWD/qpielegendmarker_p.h \ | |
|
21 | $$PWD/qbarlegendmarker_p.h | |
|
20 | 22 | |
|
21 | 23 | |
|
22 | 24 | PUBLIC_HEADERS += \ |
|
23 | 25 | $$PWD/qlegend.h \ |
|
24 | 26 | $$PWD/qlegendmarker.h \ |
|
25 | $$PWD/qpielegendmarker.h | |
|
27 | $$PWD/qpielegendmarker.h \ | |
|
28 | $$PWD/qbarlegendmarker.h |
@@ -76,13 +76,13 QFont LegendMarkerItem::font() const | |||
|
76 | 76 | |
|
77 | 77 | void LegendMarkerItem::setLabel(const QString label) |
|
78 | 78 | { |
|
79 |
m_ |
|
|
79 | m_label = label; | |
|
80 | 80 | updateGeometry(); |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | QString LegendMarkerItem::label() const |
|
84 | 84 | { |
|
85 |
return m_ |
|
|
85 | return m_label; | |
|
86 | 86 | } |
|
87 | 87 | |
|
88 | 88 | void LegendMarkerItem::setLabelBrush(const QBrush &brush) |
@@ -103,15 +103,15 void LegendMarkerItem::setGeometry(const QRectF& rect) | |||
|
103 | 103 | qreal x = m_margin + m_markerRect.width() + m_space + m_margin; |
|
104 | 104 | qreal y = qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin); |
|
105 | 105 | |
|
106 |
if (fn.boundingRect(m_ |
|
|
106 | if (fn.boundingRect(m_label).width() + x > width) | |
|
107 | 107 | { |
|
108 |
QString string = m_ |
|
|
108 | QString string = m_label + "..."; | |
|
109 | 109 | while(fn.boundingRect(string).width() + x > width && string.length() > 3) |
|
110 | 110 | string.remove(string.length() - 4, 1); |
|
111 | 111 | m_textItem->setText(string); |
|
112 | 112 | } |
|
113 | 113 | else |
|
114 |
m_textItem->setText(m_ |
|
|
114 | m_textItem->setText(m_label); | |
|
115 | 115 | |
|
116 | 116 | const QRectF& textRect = m_textItem->boundingRect(); |
|
117 | 117 | |
@@ -148,7 +148,7 QSizeF LegendMarkerItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint) | |||
|
148 | 148 | 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)); |
|
149 | 149 | break; |
|
150 | 150 | case Qt::PreferredSize: |
|
151 |
sh = QSizeF(fn.boundingRect(m_ |
|
|
151 | 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)); | |
|
152 | 152 | break; |
|
153 | 153 | default: |
|
154 | 154 | break; |
@@ -84,15 +84,15 protected: | |||
|
84 | 84 | QGraphicsRectItem *m_rectItem; |
|
85 | 85 | qreal m_margin; |
|
86 | 86 | qreal m_space; |
|
87 | QString m_text; | |
|
88 | ||
|
89 | 87 | QString m_label; |
|
88 | ||
|
90 | 89 | QBrush m_labelBrush; |
|
91 | 90 | QFont m_font; |
|
92 | 91 | QPen m_pen; |
|
93 | 92 | QBrush m_brush; |
|
94 | 93 | bool m_visible; |
|
95 | 94 | |
|
95 | friend class QLegendMarker; | |
|
96 | 96 | friend class QLegendMarkerPrivate; |
|
97 | 97 | friend class LegendLayout; |
|
98 | 98 | }; |
@@ -27,13 +27,7 | |||
|
27 | 27 | #include <QGraphicsSceneEvent> |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | /* | |
|
31 | QLegendMarker::QLegendMarker(QAbstractSeries* series, QObject *parent) : | |
|
32 | QObject(parent), | |
|
33 | d_ptr(new QLegendMarkerPrivate(series, this)) | |
|
34 | { | |
|
35 | } | |
|
36 | */ | |
|
30 | ||
|
37 | 31 | QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) : |
|
38 | 32 | QObject(parent), |
|
39 | 33 | d_ptr(&d) |
@@ -46,62 +40,62 QLegendMarker::~QLegendMarker() | |||
|
46 | 40 | |
|
47 | 41 | QString QLegendMarker::label() const |
|
48 | 42 | { |
|
49 | return d_ptr->label(); | |
|
43 | return d_ptr->m_item->label(); | |
|
50 | 44 | } |
|
51 | 45 | |
|
52 | 46 | void QLegendMarker::setLabel(const QString &label) |
|
53 | 47 | { |
|
54 | d_ptr->setLabel(label); | |
|
48 | d_ptr->m_item->setLabel(label); | |
|
55 | 49 | } |
|
56 | 50 | |
|
57 | 51 | QBrush QLegendMarker::labelBrush() const |
|
58 | 52 | { |
|
59 |
return d_ptr-> |
|
|
53 | return d_ptr->m_item->brush(); | |
|
60 | 54 | } |
|
61 | 55 | |
|
62 | 56 | void QLegendMarker::setLabelBrush(const QBrush &brush) |
|
63 | 57 | { |
|
64 | d_ptr->setLabelBrush(brush); | |
|
58 | d_ptr->m_item->setLabelBrush(brush); | |
|
65 | 59 | } |
|
66 | 60 | |
|
67 | 61 | QFont QLegendMarker::font() const |
|
68 | 62 | { |
|
69 | return d_ptr->font(); | |
|
63 | return d_ptr->m_item->font(); | |
|
70 | 64 | } |
|
71 | 65 | |
|
72 | 66 | void QLegendMarker::setFont(const QFont &font) |
|
73 | 67 | { |
|
74 | d_ptr->setFont(font); | |
|
68 | d_ptr->m_item->setFont(font); | |
|
75 | 69 | } |
|
76 | 70 | |
|
77 | 71 | QPen QLegendMarker::pen() const |
|
78 | 72 | { |
|
79 | return d_ptr->pen(); | |
|
73 | return d_ptr->m_item->pen(); | |
|
80 | 74 | } |
|
81 | 75 | |
|
82 | 76 | void QLegendMarker::setPen(const QPen &pen) |
|
83 | 77 | { |
|
84 | d_ptr->setPen(pen); | |
|
78 | d_ptr->m_item->setPen(pen); | |
|
85 | 79 | } |
|
86 | 80 | |
|
87 | 81 | QBrush QLegendMarker::brush() const |
|
88 | 82 | { |
|
89 | return d_ptr->brush(); | |
|
83 | return d_ptr->m_item->brush(); | |
|
90 | 84 | } |
|
91 | 85 | |
|
92 | 86 | void QLegendMarker::setBrush(const QBrush &brush) |
|
93 | 87 | { |
|
94 | d_ptr->setBrush(brush); | |
|
88 | d_ptr->m_item->setBrush(brush); | |
|
95 | 89 | } |
|
96 | 90 | |
|
97 | 91 | bool QLegendMarker::isVisible() const |
|
98 | 92 | { |
|
99 | return d_ptr->isVisible(); | |
|
93 | return d_ptr->m_item->isVisible(); | |
|
100 | 94 | } |
|
101 | 95 | |
|
102 | 96 | void QLegendMarker::setVisible(bool visible) |
|
103 | 97 | { |
|
104 | d_ptr->setVisible(visible); | |
|
98 | d_ptr->m_item->setVisible(visible); | |
|
105 | 99 | } |
|
106 | 100 | |
|
107 | 101 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
@@ -109,7 +103,6 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) : | |||
|
109 | 103 | q_ptr(q), |
|
110 | 104 | m_legend(legend) |
|
111 | 105 | { |
|
112 | // qDebug() << "QLegendMarkerPrivate created"; | |
|
113 | 106 | m_item = new LegendMarkerItem(this); |
|
114 | 107 | } |
|
115 | 108 | |
@@ -127,67 +120,6 void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event) | |||
|
127 | 120 | emit q->clicked(); |
|
128 | 121 | } |
|
129 | 122 | |
|
130 | void QLegendMarkerPrivate::setPen(const QPen &pen) | |
|
131 | { | |
|
132 | m_item->setPen(pen); | |
|
133 | } | |
|
134 | ||
|
135 | QPen QLegendMarkerPrivate::pen() const | |
|
136 | { | |
|
137 | return m_item->pen(); | |
|
138 | } | |
|
139 | ||
|
140 | void QLegendMarkerPrivate::setBrush(const QBrush &brush) | |
|
141 | { | |
|
142 | m_item->setBrush(brush); | |
|
143 | } | |
|
144 | ||
|
145 | QBrush QLegendMarkerPrivate::brush() const | |
|
146 | { | |
|
147 | return m_item->brush(); | |
|
148 | } | |
|
149 | ||
|
150 | void QLegendMarkerPrivate::setFont(const QFont &font) | |
|
151 | { | |
|
152 | m_item->setFont(font); | |
|
153 | } | |
|
154 | ||
|
155 | QFont QLegendMarkerPrivate::font() const | |
|
156 | { | |
|
157 | return m_item->font(); | |
|
158 | } | |
|
159 | ||
|
160 | void QLegendMarkerPrivate::setLabel(const QString label) | |
|
161 | { | |
|
162 | m_item->setLabel(label); | |
|
163 | } | |
|
164 | ||
|
165 | QString QLegendMarkerPrivate::label() const | |
|
166 | { | |
|
167 | return m_item->label(); | |
|
168 | } | |
|
169 | ||
|
170 | void QLegendMarkerPrivate::setLabelBrush(const QBrush &brush) | |
|
171 | { | |
|
172 | m_item->setLabelBrush(brush); | |
|
173 | } | |
|
174 | ||
|
175 | QBrush QLegendMarkerPrivate::labelBrush() const | |
|
176 | { | |
|
177 | return m_item->labelBrush(); | |
|
178 | } | |
|
179 | ||
|
180 | bool QLegendMarkerPrivate::isVisible() const | |
|
181 | { | |
|
182 | return m_item->isVisible(); | |
|
183 | } | |
|
184 | ||
|
185 | void QLegendMarkerPrivate::setVisible(bool visible) | |
|
186 | { | |
|
187 | m_item->setVisible(visible); | |
|
188 | } | |
|
189 | ||
|
190 | ||
|
191 | 123 | #include "moc_qlegendmarker.cpp" |
|
192 | 124 | #include "moc_qlegendmarker_p.cpp" |
|
193 | 125 |
@@ -65,8 +65,8 public: | |||
|
65 | 65 | bool isVisible() const; |
|
66 | 66 | void setVisible(bool visible); |
|
67 | 67 | |
|
68 | // virtual QAbstractSeries::SeriesType type() = 0; // TODO? | |
|
69 | virtual QAbstractSeries* series() = 0; | |
|
68 | // virtual QAbstractSeries::SeriesType type() = 0; // TODO? Or use LegendMarker type enum? | |
|
69 | virtual QAbstractSeries* series() = 0; // TODO: remove these and use specialised functions on derived classes? | |
|
70 | 70 | virtual QObject* peerObject() = 0; |
|
71 | 71 | |
|
72 | 72 | protected: |
@@ -57,30 +57,10 class QLegendMarkerPrivate : public QObject | |||
|
57 | 57 | { |
|
58 | 58 | Q_OBJECT |
|
59 | 59 | public: |
|
60 | // explicit QLegendMarkerPrivate(QAbstractSeries *series, QLegendMarker *q); | |
|
61 | 60 | explicit QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend); |
|
62 | 61 | virtual ~QLegendMarkerPrivate(); |
|
63 | 62 | |
|
64 | // TODO: remove temporary setters/getters and use the m_item directly from public class via d_ptr | |
|
65 | void setPen(const QPen &pen); | |
|
66 | QPen pen() const; | |
|
67 | ||
|
68 | void setBrush(const QBrush &brush); | |
|
69 | QBrush brush() const; | |
|
70 | ||
|
71 | void setFont(const QFont &font); | |
|
72 | QFont font() const; | |
|
73 | ||
|
74 | void setLabel(const QString label); | |
|
75 | QString label() const; | |
|
76 | ||
|
77 | void setLabelBrush(const QBrush &brush); | |
|
78 | QBrush labelBrush() const; | |
|
79 | ||
|
80 | bool isVisible() const; | |
|
81 | void setVisible(bool visible); | |
|
82 | ||
|
83 | // Helper for now. | |
|
63 | // Helper for now. (or deckare LegendLayout as friend) | |
|
84 | 64 | LegendMarkerItem* item() const { return m_item; } |
|
85 | 65 | |
|
86 | 66 | // Item gets the event, logic for event is here |
@@ -96,16 +76,6 protected: | |||
|
96 | 76 | private: |
|
97 | 77 | QLegendMarker *q_ptr; |
|
98 | 78 | |
|
99 | // New legend marker properties | |
|
100 | // Moved to item. | |
|
101 | /* | |
|
102 | QString m_label; | |
|
103 | QBrush m_labelBrush; | |
|
104 | QFont m_font; | |
|
105 | QPen m_pen; | |
|
106 | QBrush m_brush; | |
|
107 | bool m_visible; | |
|
108 | */ | |
|
109 | 79 | friend class QLegendPrivate; // TODO: Is this needed? |
|
110 | 80 | Q_DECLARE_PUBLIC(QLegendMarker) |
|
111 | 81 | }; |
@@ -21,6 +21,7 | |||
|
21 | 21 | #include "qpielegendmarker.h" |
|
22 | 22 | #include "qpielegendmarker_p.h" |
|
23 | 23 | #include <QPieSeries> |
|
24 | #include <QPieSlice> | |
|
24 | 25 | #include <QDebug> |
|
25 | 26 | |
|
26 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -32,7 +33,7 QPieLegendMarker::QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend | |||
|
32 | 33 | |
|
33 | 34 | QPieLegendMarker::~QPieLegendMarker() |
|
34 | 35 | { |
|
35 | qDebug() << "deleting pie marker" << this; | |
|
36 | // qDebug() << "deleting pie marker" << this; | |
|
36 | 37 | } |
|
37 | 38 | |
|
38 | 39 | /*! |
@@ -43,7 +44,7 QPieLegendMarker::QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent) | |||
|
43 | 44 | { |
|
44 | 45 | } |
|
45 | 46 | |
|
46 |
Q |
|
|
47 | QPieSeries* QPieLegendMarker::series() | |
|
47 | 48 | { |
|
48 | 49 | Q_D(QPieLegendMarker); |
|
49 | 50 | return d->m_series; |
@@ -64,6 +65,7 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries | |||
|
64 | 65 | { |
|
65 | 66 | QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); |
|
66 | 67 | QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated())); |
|
68 | QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated())); | |
|
67 | 69 | updated(); |
|
68 | 70 | } |
|
69 | 71 | |
@@ -71,14 +73,14 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate() | |||
|
71 | 73 | { |
|
72 | 74 | QObject::disconnect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); |
|
73 | 75 | QObject::disconnect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated())); |
|
76 | QObject::disconnect(m_slice, SIGNAL(penChanged()), this, SLOT(updated())); | |
|
74 | 77 | } |
|
75 | 78 | |
|
76 | 79 | void QPieLegendMarkerPrivate::updated() |
|
77 | 80 | { |
|
78 | m_item->setBrush(m_slice->brush()); | |
|
79 | m_item->setLabel(m_slice->label()); | |
|
80 | 81 | m_item->setPen(m_slice->pen()); |
|
81 | 82 | m_item->setBrush(m_slice->brush()); |
|
83 | m_item->setLabel(m_slice->label()); | |
|
82 | 84 | } |
|
83 | 85 | |
|
84 | 86 | #include "moc_qpielegendmarker.cpp" |
@@ -23,12 +23,15 | |||
|
23 | 23 | |
|
24 | 24 | #include <QChartGlobal> |
|
25 | 25 | #include <QLegendMarker> |
|
26 | #include <QPieSeries> | |
|
26 | 27 | #include <QPieSlice> |
|
27 | #include "qpielegendmarker_p.h" | |
|
28 | //#include "qpielegendmarker_p.h" | |
|
28 | 29 | |
|
29 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 31 | |
|
31 | // TODO: No export, make this private. QLegendMarker should be enough for user of the api (why expose the details?) | |
|
32 | class QPieLegendMarkerPrivate; | |
|
33 | ||
|
34 | // TODO: No export? make this private. QLegendMarker should be enough for user of the api (why expose the details?) | |
|
32 | 35 | class QTCOMMERCIALCHART_EXPORT QPieLegendMarker : public QLegendMarker |
|
33 | 36 | { |
|
34 | 37 | Q_OBJECT |
@@ -37,8 +40,8 public: | |||
|
37 | 40 | explicit QPieLegendMarker(QPieSeries* series, QPieSlice* slice, QLegend *legend, QObject *parent = 0); |
|
38 | 41 | virtual ~QPieLegendMarker(); |
|
39 | 42 | |
|
40 |
virtual Q |
|
|
41 | virtual QPieSlice* peerObject(); | |
|
43 | virtual QPieSeries* series(); | |
|
44 | virtual QPieSlice* peerObject(); // TODO: rename to slice and remove these virtuals from base class? | |
|
42 | 45 | |
|
43 | 46 | protected: |
|
44 | 47 | QPieLegendMarker(QPieLegendMarkerPrivate &d, QObject *parent = 0); |
@@ -46,7 +46,6 class QPieLegendMarkerPrivate : public QLegendMarkerPrivate | |||
|
46 | 46 | { |
|
47 | 47 | Q_OBJECT |
|
48 | 48 | public: |
|
49 | // explicit QPieLegendMarkerPrivate(QAbstractSeries *series, QPieLegendMarker *q); | |
|
50 | 49 | explicit QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend); |
|
51 | 50 | virtual ~QPieLegendMarkerPrivate(); |
|
52 | 51 |
General Comments 0
You need to be logged in to leave comments.
Login now