@@ -127,6 +127,7 qreal QBarSet::total() | |||
|
127 | 127 | void QBarSet::setPen(const QPen pen) |
|
128 | 128 | { |
|
129 | 129 | mPen = pen; |
|
130 | emit changed(); | |
|
130 | 131 | } |
|
131 | 132 | |
|
132 | 133 | /*! |
@@ -143,6 +144,7 QPen QBarSet::pen() const | |||
|
143 | 144 | void QBarSet::setBrush(const QBrush brush) |
|
144 | 145 | { |
|
145 | 146 | mBrush = brush; |
|
147 | emit changed(); | |
|
146 | 148 | } |
|
147 | 149 | |
|
148 | 150 | /*! |
@@ -43,6 +43,7 Q_SIGNALS: | |||
|
43 | 43 | |
|
44 | 44 | // TODO: Expose this to user or not? |
|
45 | 45 | // TODO: TO PIMPL ---> |
|
46 | void changed(); | |
|
46 | 47 | void hoverEnter(QPoint pos); |
|
47 | 48 | void hoverLeave(); |
|
48 | 49 | void showToolTip(QPoint pos, QString tip); // Private signal |
@@ -1,5 +1,7 | |||
|
1 | 1 | #include "qchartglobal.h" |
|
2 | 2 | #include "legendmarker_p.h" |
|
3 | #include <qpieslice.h> | |
|
4 | #include <qbarset.h> | |
|
3 | 5 | #include <QPainter> |
|
4 | 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 | 142 | #include "moc_legendmarker_p.cpp" |
|
120 | 143 | |
|
121 | 144 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -49,6 +49,9 Q_SIGNALS: | |||
|
49 | 49 | void clicked(QBarSet* barset, Qt::MouseButton button); |
|
50 | 50 | void clicked(QPieSlice* pieslice, Qt::MouseButton button); |
|
51 | 51 | |
|
52 | public Q_SLOTS: | |
|
53 | void changed(); | |
|
54 | ||
|
52 | 55 | private: |
|
53 | 56 | QRectF mBoundingRect; |
|
54 | 57 | QRectF mMarkerBoundingRect; |
@@ -88,16 +88,6 void QLegend::handleGeometryChanged(const QRectF& size) | |||
|
88 | 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 | 91 | void QLegend::createMarkers(QSeries *series) |
|
102 | 92 | { |
|
103 | 93 | switch (series->type()) |
@@ -174,6 +164,7 void QLegend::appendMarkers(QBarSeries *series) | |||
|
174 | 164 | marker->setName(s->name()); |
|
175 | 165 | marker->setBrush(s->brush()); |
|
176 | 166 | connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton))); |
|
167 | connect(s,SIGNAL(changed()),marker,SLOT(changed())); | |
|
177 | 168 | mMarkers.append(marker); |
|
178 | 169 | childItems().append(marker); |
|
179 | 170 | } |
@@ -186,6 +177,7 void QLegend::appendMarkers(QPieSeries *series) | |||
|
186 | 177 | marker->setName(s->label()); |
|
187 | 178 | marker->setBrush(s->sliceBrush()); |
|
188 | 179 | connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton))); |
|
180 | connect(s,SIGNAL(changed()),marker,SLOT(changed())); | |
|
189 | 181 | mMarkers.append(marker); |
|
190 | 182 | childItems().append(marker); |
|
191 | 183 | } |
@@ -42,11 +42,6 public slots: | |||
|
42 | 42 | void handleSeriesRemoved(QSeries* series); |
|
43 | 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 | 45 | private: |
|
51 | 46 | // PIMPL ---> |
|
52 | 47 | void createMarkers(QSeries* series); |
General Comments 0
You need to be logged in to leave comments.
Login now