@@ -5,7 +5,6 | |||
|
5 | 5 | #include <qstackedbarseries.h> |
|
6 | 6 | #include <qbarset.h> |
|
7 | 7 | #include <qchartaxis.h> |
|
8 | #include <qlegend.h> | |
|
9 | 8 | #include <QStringList> |
|
10 | 9 | #include <QDebug> |
|
11 | 10 |
@@ -269,9 +269,9 QChartAxis* QChart::axisY() const | |||
|
269 | 269 | } |
|
270 | 270 | |
|
271 | 271 | /*! |
|
272 | Returns the legend object of the chart | |
|
272 | Returns the legend object of the chart. Ownership stays in chart. | |
|
273 | 273 | */ |
|
274 | QLegend* QChart::legend() | |
|
274 | QLegend* QChart::legend() const | |
|
275 | 275 | { |
|
276 | 276 | return m_legend; |
|
277 | 277 | } |
@@ -341,9 +341,10 void QChart::updateLayout() | |||
|
341 | 341 | |
|
342 | 342 | // recalculate legend position |
|
343 | 343 | if (m_legend) { |
|
344 | if (m_legend->parentObject() == this) { | |
|
344 | 345 | m_legend->setMaximumSize(rect.size()); |
|
345 | 346 | m_legend->setPos(rect.topLeft()); |
|
346 | m_legend->setPreferredLayout(QLegend::PreferredLayoutHorizontal); | |
|
347 | } | |
|
347 | 348 | } |
|
348 | 349 | } |
|
349 | 350 |
@@ -90,9 +90,7 public: | |||
|
90 | 90 | QChartAxis* axisX() const; |
|
91 | 91 | QChartAxis* axisY() const; |
|
92 | 92 | |
|
93 | // TODO: take (and give) legend instead of this. | |
|
94 | QLegend* legend(); | |
|
95 | ||
|
93 | QLegend* legend() const; | |
|
96 | 94 | |
|
97 | 95 | int padding() const; |
|
98 | 96 |
@@ -30,7 +30,7 QLegend::QLegend(QGraphicsItem *parent) | |||
|
30 | 30 | ,m_brush(Qt::darkGray) // TODO: from theme? |
|
31 | 31 | ,mPreferredLayout(QLegend::PreferredLayoutVertical) |
|
32 | 32 | { |
|
33 |
|
|
|
33 | setVisible(false); | |
|
34 | 34 | setZValue(ChartPresenter::LegendZValue); |
|
35 | 35 | } |
|
36 | 36 | |
@@ -90,6 +90,7 QSizeF QLegend::maximumSize() const | |||
|
90 | 90 | void QLegend::setMaximumSize(const QSizeF size) |
|
91 | 91 | { |
|
92 | 92 | mMaximumSize = size; |
|
93 | layoutChanged(); | |
|
93 | 94 | } |
|
94 | 95 | |
|
95 | 96 | void QLegend::setSize(const QSizeF size) |
@@ -106,13 +107,13 void QLegend::setSize(const QSizeF size) | |||
|
106 | 107 | void QLegend::setPos(const QPointF &pos) |
|
107 | 108 | { |
|
108 | 109 | mPos = pos; |
|
110 | layoutChanged(); | |
|
109 | 111 | } |
|
110 | 112 | |
|
111 | 113 | void QLegend::handleSeriesAdded(QSeries* series, Domain* domain) |
|
112 | 114 | { |
|
113 | 115 | Q_UNUSED(domain) |
|
114 | 116 | |
|
115 | // mSeriesList.append(series); | |
|
116 | 117 | createMarkers(series); |
|
117 | 118 | connectSeries(series); |
|
118 | 119 | layoutChanged(); |
@@ -132,7 +133,6 void QLegend::handleSeriesRemoved(QSeries* series) | |||
|
132 | 133 | deleteMarkers(series); |
|
133 | 134 | } |
|
134 | 135 | |
|
135 | // mSeriesList.removeOne(series); | |
|
136 | 136 | layoutChanged(); |
|
137 | 137 | } |
|
138 | 138 | |
@@ -374,7 +374,6 void QLegend::deleteMarkers(QSeries *series) | |||
|
374 | 374 | void QLegend::layoutChanged() |
|
375 | 375 | { |
|
376 | 376 | // Calculate layout for markers and text |
|
377 | qDebug() << "Marker count:" << mMarkers.count(); | |
|
378 | 377 | if (mMarkers.count() <= 0) { |
|
379 | 378 | // Nothing to do |
|
380 | 379 | return; |
General Comments 0
You need to be logged in to leave comments.
Login now