@@ -5,7 +5,6 | |||||
5 | #include <qstackedbarseries.h> |
|
5 | #include <qstackedbarseries.h> | |
6 | #include <qbarset.h> |
|
6 | #include <qbarset.h> | |
7 | #include <qchartaxis.h> |
|
7 | #include <qchartaxis.h> | |
8 | #include <qlegend.h> |
|
|||
9 | #include <QStringList> |
|
8 | #include <QStringList> | |
10 | #include <QDebug> |
|
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 | return m_legend; |
|
276 | return m_legend; | |
277 | } |
|
277 | } | |
@@ -341,9 +341,10 void QChart::updateLayout() | |||||
341 |
|
341 | |||
342 | // recalculate legend position |
|
342 | // recalculate legend position | |
343 | if (m_legend) { |
|
343 | if (m_legend) { | |
344 | m_legend->setMaximumSize(rect.size()); |
|
344 | if (m_legend->parentObject() == this) { | |
345 |
m_legend->set |
|
345 | m_legend->setMaximumSize(rect.size()); | |
346 | m_legend->setPreferredLayout(QLegend::PreferredLayoutHorizontal); |
|
346 | m_legend->setPos(rect.topLeft()); | |
|
347 | } | |||
347 | } |
|
348 | } | |
348 | } |
|
349 | } | |
349 |
|
350 |
@@ -90,9 +90,7 public: | |||||
90 | QChartAxis* axisX() const; |
|
90 | QChartAxis* axisX() const; | |
91 | QChartAxis* axisY() const; |
|
91 | QChartAxis* axisY() const; | |
92 |
|
92 | |||
93 | // TODO: take (and give) legend instead of this. |
|
93 | QLegend* legend() const; | |
94 | QLegend* legend(); |
|
|||
95 |
|
||||
96 |
|
94 | |||
97 | int padding() const; |
|
95 | int padding() const; | |
98 |
|
96 |
@@ -30,7 +30,7 QLegend::QLegend(QGraphicsItem *parent) | |||||
30 | ,m_brush(Qt::darkGray) // TODO: from theme? |
|
30 | ,m_brush(Qt::darkGray) // TODO: from theme? | |
31 | ,mPreferredLayout(QLegend::PreferredLayoutVertical) |
|
31 | ,mPreferredLayout(QLegend::PreferredLayoutVertical) | |
32 | { |
|
32 | { | |
33 |
|
|
33 | setVisible(false); | |
34 | setZValue(ChartPresenter::LegendZValue); |
|
34 | setZValue(ChartPresenter::LegendZValue); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
@@ -90,6 +90,7 QSizeF QLegend::maximumSize() const | |||||
90 | void QLegend::setMaximumSize(const QSizeF size) |
|
90 | void QLegend::setMaximumSize(const QSizeF size) | |
91 | { |
|
91 | { | |
92 | mMaximumSize = size; |
|
92 | mMaximumSize = size; | |
|
93 | layoutChanged(); | |||
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 | void QLegend::setSize(const QSizeF size) |
|
96 | void QLegend::setSize(const QSizeF size) | |
@@ -106,13 +107,13 void QLegend::setSize(const QSizeF size) | |||||
106 | void QLegend::setPos(const QPointF &pos) |
|
107 | void QLegend::setPos(const QPointF &pos) | |
107 | { |
|
108 | { | |
108 | mPos = pos; |
|
109 | mPos = pos; | |
|
110 | layoutChanged(); | |||
109 | } |
|
111 | } | |
110 |
|
112 | |||
111 | void QLegend::handleSeriesAdded(QSeries* series, Domain* domain) |
|
113 | void QLegend::handleSeriesAdded(QSeries* series, Domain* domain) | |
112 | { |
|
114 | { | |
113 | Q_UNUSED(domain) |
|
115 | Q_UNUSED(domain) | |
114 |
|
116 | |||
115 | // mSeriesList.append(series); |
|
|||
116 | createMarkers(series); |
|
117 | createMarkers(series); | |
117 | connectSeries(series); |
|
118 | connectSeries(series); | |
118 | layoutChanged(); |
|
119 | layoutChanged(); | |
@@ -132,7 +133,6 void QLegend::handleSeriesRemoved(QSeries* series) | |||||
132 | deleteMarkers(series); |
|
133 | deleteMarkers(series); | |
133 | } |
|
134 | } | |
134 |
|
135 | |||
135 | // mSeriesList.removeOne(series); |
|
|||
136 | layoutChanged(); |
|
136 | layoutChanged(); | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
@@ -374,7 +374,6 void QLegend::deleteMarkers(QSeries *series) | |||||
374 | void QLegend::layoutChanged() |
|
374 | void QLegend::layoutChanged() | |
375 | { |
|
375 | { | |
376 | // Calculate layout for markers and text |
|
376 | // Calculate layout for markers and text | |
377 | qDebug() << "Marker count:" << mMarkers.count(); |
|
|||
378 | if (mMarkers.count() <= 0) { |
|
377 | if (mMarkers.count() <= 0) { | |
379 | // Nothing to do |
|
378 | // Nothing to do | |
380 | return; |
|
379 | return; |
@@ -74,7 +74,6 private: | |||||
74 | QSizeF mMinimumSize; |
|
74 | QSizeF mMinimumSize; | |
75 | QSizeF mMaximumSize; |
|
75 | QSizeF mMaximumSize; | |
76 |
|
76 | |||
77 | // QList<QSeries*> mSeriesList; |
|
|||
78 | QList<LegendMarker*> mMarkers; |
|
77 | QList<LegendMarker*> mMarkers; | |
79 |
|
78 | |||
80 | QBrush m_brush; |
|
79 | QBrush m_brush; |
@@ -48,11 +48,6 | |||||
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | \fn QList<QSeries::Legend> QSeries::legend() |
|
|||
52 | \brief Returns the legend of the series. If series is empty, empty list is returned. |
|
|||
53 | */ |
|
|||
54 |
|
||||
55 | /*! |
|
|||
56 | \fn void QSeries::setTitle(QString title) |
|
51 | \fn void QSeries::setTitle(QString title) | |
57 | \brief Sets a \a title for the series. |
|
52 | \brief Sets a \a title for the series. | |
58 |
|
53 |
General Comments 0
You need to be logged in to leave comments.
Login now