@@ -55,7 +55,6 public: | |||||
55 | public Q_SLOTS: |
|
55 | public Q_SLOTS: | |
56 | void handleRightClick(QBarSet *barset, QString category) |
|
56 | void handleRightClick(QBarSet *barset, QString category) | |
57 | { |
|
57 | { | |
58 | // qDebug() << "DrilldownChart::handleRightClick" << barset->name() << category; |
|
|||
59 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); |
|
58 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); | |
60 | changeSeries(series->drilldownSeries(category)); |
|
59 | changeSeries(series->drilldownSeries(category)); | |
61 | } |
|
60 | } | |
@@ -140,9 +139,6 int main(int argc, char *argv[]) | |||||
140 |
|
139 | |||
141 | drilldownChart->axisX()->setGridLineVisible(false); |
|
140 | drilldownChart->axisX()->setGridLineVisible(false); | |
142 |
|
141 | |||
143 | QLegend* l = drilldownChart->legend(); |
|
|||
144 | l->handleGeometryChanged(QRectF(50,270,300,20)); |
|
|||
145 |
|
||||
146 | window.setCentralWidget(drilldownChart); |
|
142 | window.setCentralWidget(drilldownChart); | |
147 | window.resize(400, 300); |
|
143 | window.resize(400, 300); | |
148 | window.show(); |
|
144 | window.show(); |
@@ -338,6 +338,17 void QChart::updateLayout() | |||||
338 | if (m_backgroundItem) { |
|
338 | if (m_backgroundItem) { | |
339 | m_backgroundItem->setRect(rect); |
|
339 | m_backgroundItem->setRect(rect); | |
340 | } |
|
340 | } | |
|
341 | ||||
|
342 | // recalculate legend position | |||
|
343 | // TODO: better layout | |||
|
344 | if (m_legend) { | |||
|
345 | QRectF boundingRect(m_rect.adjusted(margin(), | |||
|
346 | rect.height() + margin() + margin()/2 - m_legend->minimumSize().height()/2, | |||
|
347 | -margin(), | |||
|
348 | -margin()/2 + m_legend->minimumSize().height()/2)); | |||
|
349 | m_legend->handleGeometryChanged(boundingRect); | |||
|
350 | qDebug() << "legend rect:" << m_legend->boundingRect(); | |||
|
351 | } | |||
341 | } |
|
352 | } | |
342 | #include "moc_qchart.cpp" |
|
353 | #include "moc_qchart.cpp" | |
343 |
|
354 |
@@ -24,6 +24,7 QLegend::QLegend(QGraphicsItem *parent) | |||||
24 | : QGraphicsObject(parent) |
|
24 | : QGraphicsObject(parent) | |
25 | ,mBoundingRect(0,0,1,1) |
|
25 | ,mBoundingRect(0,0,1,1) | |
26 | ,mBackgroundBrush(Qt::darkGray) // TODO: from theme? |
|
26 | ,mBackgroundBrush(Qt::darkGray) // TODO: from theme? | |
|
27 | ,mMinimumSize(50,20) // TODO: magic numbers | |||
27 | { |
|
28 | { | |
28 | } |
|
29 | } | |
29 |
|
30 | |||
@@ -54,6 +55,16 QBrush QLegend::backgroundBrush() const | |||||
54 | return mBackgroundBrush; |
|
55 | return mBackgroundBrush; | |
55 | } |
|
56 | } | |
56 |
|
57 | |||
|
58 | QSizeF QLegend::minimumSize() const | |||
|
59 | { | |||
|
60 | return mMinimumSize; | |||
|
61 | } | |||
|
62 | ||||
|
63 | void QLegend::setMinimumSize(const QSizeF size) | |||
|
64 | { | |||
|
65 | mMinimumSize = size; | |||
|
66 | } | |||
|
67 | ||||
57 | void QLegend::handleSeriesAdded(QSeries* series,Domain* domain) |
|
68 | void QLegend::handleSeriesAdded(QSeries* series,Domain* domain) | |
58 | { |
|
69 | { | |
59 | mSeriesList.append(series); |
|
70 | mSeriesList.append(series); |
@@ -28,6 +28,9 public: | |||||
28 | void setBackgroundBrush(const QBrush& brush); |
|
28 | void setBackgroundBrush(const QBrush& brush); | |
29 | QBrush backgroundBrush() const; |
|
29 | QBrush backgroundBrush() const; | |
30 |
|
30 | |||
|
31 | QSizeF minimumSize() const; | |||
|
32 | void setMinimumSize(const QSizeF size); | |||
|
33 | ||||
31 | signals: |
|
34 | signals: | |
32 | // for interactions. |
|
35 | // for interactions. | |
33 | void clicked(QSeries* series, Qt::MouseButton button); |
|
36 | void clicked(QSeries* series, Qt::MouseButton button); | |
@@ -54,6 +57,7 private: | |||||
54 | QList<LegendMarker*> mMarkers; |
|
57 | QList<LegendMarker*> mMarkers; | |
55 |
|
58 | |||
56 | QBrush mBackgroundBrush; |
|
59 | QBrush mBackgroundBrush; | |
|
60 | QSizeF mMinimumSize; | |||
57 | }; |
|
61 | }; | |
58 |
|
62 | |||
59 | QTCOMMERCIALCHART_END_NAMESPACE |
|
63 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -41,6 +41,7 public: | |||||
41 | // TODO |
|
41 | // TODO | |
42 | virtual bool setModel(QAbstractItemModel* /*model*/) { return false; } |
|
42 | virtual bool setModel(QAbstractItemModel* /*model*/) { return false; } | |
43 |
|
43 | |||
|
44 | // TODO: consider this | |||
44 | virtual QList<QSeries::LegendEntry> legendEntries() { QList<QSeries::LegendEntry> l; return l; } |
|
45 | virtual QList<QSeries::LegendEntry> legendEntries() { QList<QSeries::LegendEntry> l; return l; } | |
45 |
|
46 | |||
46 | void setTitle(QString title) { m_title = title; } |
|
47 | void setTitle(QString title) { m_title = title; } |
General Comments 0
You need to be logged in to leave comments.
Login now