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