@@ -127,6 +127,7 qreal QBarSet::total() | |||||
127 | void QBarSet::setPen(const QPen pen) |
|
127 | void QBarSet::setPen(const QPen pen) | |
128 | { |
|
128 | { | |
129 | mPen = pen; |
|
129 | mPen = pen; | |
|
130 | emit changed(); | |||
130 | } |
|
131 | } | |
131 |
|
132 | |||
132 | /*! |
|
133 | /*! | |
@@ -143,6 +144,7 QPen QBarSet::pen() const | |||||
143 | void QBarSet::setBrush(const QBrush brush) |
|
144 | void QBarSet::setBrush(const QBrush brush) | |
144 | { |
|
145 | { | |
145 | mBrush = brush; |
|
146 | mBrush = brush; | |
|
147 | emit changed(); | |||
146 | } |
|
148 | } | |
147 |
|
149 | |||
148 | /*! |
|
150 | /*! |
@@ -43,6 +43,7 Q_SIGNALS: | |||||
43 |
|
43 | |||
44 | // TODO: Expose this to user or not? |
|
44 | // TODO: Expose this to user or not? | |
45 | // TODO: TO PIMPL ---> |
|
45 | // TODO: TO PIMPL ---> | |
|
46 | void changed(); | |||
46 | void hoverEnter(QPoint pos); |
|
47 | void hoverEnter(QPoint pos); | |
47 | void hoverLeave(); |
|
48 | void hoverLeave(); | |
48 | void showToolTip(QPoint pos, QString tip); // Private signal |
|
49 | void showToolTip(QPoint pos, QString tip); // Private signal |
@@ -1,5 +1,7 | |||||
1 | #include "qchartglobal.h" |
|
1 | #include "qchartglobal.h" | |
2 | #include "legendmarker_p.h" |
|
2 | #include "legendmarker_p.h" | |
|
3 | #include <qpieslice.h> | |||
|
4 | #include <qbarset.h> | |||
3 | #include <QPainter> |
|
5 | #include <QPainter> | |
4 | #include <QGraphicsSceneEvent> |
|
6 | #include <QGraphicsSceneEvent> | |
5 |
|
7 | |||
@@ -116,6 +118,27 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||||
116 | } |
|
118 | } | |
117 | } |
|
119 | } | |
118 |
|
120 | |||
|
121 | void LegendMarker::changed() | |||
|
122 | { | |||
|
123 | switch (mType) | |||
|
124 | { | |||
|
125 | case LegendMarkerTypeSeries: { | |||
|
126 | // TODO: | |||
|
127 | break; | |||
|
128 | } | |||
|
129 | case LegendMarkerTypeBarset: { | |||
|
130 | setBrush(mBarset->brush()); | |||
|
131 | setName(mBarset->name()); | |||
|
132 | break; | |||
|
133 | } | |||
|
134 | case LegendMarkerTypePieslice: { | |||
|
135 | setBrush(mPieslice->sliceBrush()); | |||
|
136 | setName(mPieslice->label()); | |||
|
137 | break; | |||
|
138 | } | |||
|
139 | } | |||
|
140 | } | |||
|
141 | ||||
119 | #include "moc_legendmarker_p.cpp" |
|
142 | #include "moc_legendmarker_p.cpp" | |
120 |
|
143 | |||
121 | QTCOMMERCIALCHART_END_NAMESPACE |
|
144 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -49,6 +49,9 Q_SIGNALS: | |||||
49 | void clicked(QBarSet* barset, Qt::MouseButton button); |
|
49 | void clicked(QBarSet* barset, Qt::MouseButton button); | |
50 | void clicked(QPieSlice* pieslice, Qt::MouseButton button); |
|
50 | void clicked(QPieSlice* pieslice, Qt::MouseButton button); | |
51 |
|
51 | |||
|
52 | public Q_SLOTS: | |||
|
53 | void changed(); | |||
|
54 | ||||
52 | private: |
|
55 | private: | |
53 | QRectF mBoundingRect; |
|
56 | QRectF mBoundingRect; | |
54 | QRectF mMarkerBoundingRect; |
|
57 | QRectF mMarkerBoundingRect; |
@@ -88,16 +88,6 void QLegend::handleGeometryChanged(const QRectF& size) | |||||
88 | layoutChanged(); |
|
88 | layoutChanged(); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | void QLegend::handleThemeChanged() |
|
|||
92 | { |
|
|||
93 | foreach(QSeries *s, mSeriesList) { |
|
|||
94 | deleteMarkers(s); |
|
|||
95 | } |
|
|||
96 | foreach(QSeries *s, mSeriesList) { |
|
|||
97 | createMarkers(s); |
|
|||
98 | } |
|
|||
99 | } |
|
|||
100 |
|
||||
101 | void QLegend::createMarkers(QSeries *series) |
|
91 | void QLegend::createMarkers(QSeries *series) | |
102 | { |
|
92 | { | |
103 | switch (series->type()) |
|
93 | switch (series->type()) | |
@@ -174,6 +164,7 void QLegend::appendMarkers(QBarSeries *series) | |||||
174 | marker->setName(s->name()); |
|
164 | marker->setName(s->name()); | |
175 | marker->setBrush(s->brush()); |
|
165 | marker->setBrush(s->brush()); | |
176 | connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton))); |
|
166 | connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton))); | |
|
167 | connect(s,SIGNAL(changed()),marker,SLOT(changed())); | |||
177 | mMarkers.append(marker); |
|
168 | mMarkers.append(marker); | |
178 | childItems().append(marker); |
|
169 | childItems().append(marker); | |
179 | } |
|
170 | } | |
@@ -186,6 +177,7 void QLegend::appendMarkers(QPieSeries *series) | |||||
186 | marker->setName(s->label()); |
|
177 | marker->setName(s->label()); | |
187 | marker->setBrush(s->sliceBrush()); |
|
178 | marker->setBrush(s->sliceBrush()); | |
188 | connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton))); |
|
179 | connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton))); | |
|
180 | connect(s,SIGNAL(changed()),marker,SLOT(changed())); | |||
189 | mMarkers.append(marker); |
|
181 | mMarkers.append(marker); | |
190 | childItems().append(marker); |
|
182 | childItems().append(marker); | |
191 | } |
|
183 | } |
@@ -42,11 +42,6 public slots: | |||||
42 | void handleSeriesRemoved(QSeries* series); |
|
42 | void handleSeriesRemoved(QSeries* series); | |
43 | void handleGeometryChanged(const QRectF& size); |
|
43 | void handleGeometryChanged(const QRectF& size); | |
44 |
|
44 | |||
45 | // PIMPL ---> |
|
|||
46 | // Internal slot. Legend needs to know when theme has changed (or color of some series, if user changes it) |
|
|||
47 | void handleThemeChanged(); |
|
|||
48 | // <--- PIMPL |
|
|||
49 |
|
||||
50 | private: |
|
45 | private: | |
51 | // PIMPL ---> |
|
46 | // PIMPL ---> | |
52 | void createMarkers(QSeries* series); |
|
47 | void createMarkers(QSeries* series); |
General Comments 0
You need to be logged in to leave comments.
Login now