##// END OF EJS Templates
Added plotAreaChanged signal to chart....
Miikka Heikkinen -
r2716:bf30bed1cefb
parent child
Show More
@@ -67,6 +67,7 void ChartPresenter::setGeometry(const QRectF rect)
67 67 chart->domain()->setSize(rect.size());
68 68 chart->setPos(rect.topLeft());
69 69 }
70 emit plotAreaChanged(m_rect);
70 71 }
71 72 }
72 73
@@ -169,6 +169,9 public Q_SLOTS:
169 169 void handleAxisAdded(QAbstractAxis *axis);
170 170 void handleAxisRemoved(QAbstractAxis *axis);
171 171
172 signals:
173 void plotAreaChanged(const QRectF &plotArea);
174
172 175 private:
173 176 QChart *m_chart;
174 177 QList<ChartItem *> m_chartItems;
@@ -169,6 +169,12 QT_CHARTS_BEGIN_NAMESPACE
169 169 */
170 170
171 171 /*!
172 \property QChart::plotArea
173 Holds the rectangle within which the drawing of the chart is done.
174 It does not include the area defined by margins.
175 */
176
177 /*!
172 178 \internal
173 179 Constructs a chart object of \a type which is a child of a \a parent.
174 180 Parameter \a wFlags is passed to the QGraphicsWidget constructor.
@@ -526,10 +532,6 QChart::ChartType QChart::chartType() const
526 532 return d_ptr->m_type;
527 533 }
528 534
529 /*!
530 Returns the the rectangle within which the drawing of the chart is done.
531 It does not include the area defined by margins.
532 */
533 535 QRectF QChart::plotArea() const
534 536 {
535 537 return d_ptr->m_presenter->geometry();
@@ -762,6 +764,7 QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type):
762 764 QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*)));
763 765 QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*)));
764 766 QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*)));
767 QObject::connect(m_presenter, &ChartPresenter::plotAreaChanged, q, &QChart::plotAreaChanged);
765 768 }
766 769
767 770 QChartPrivate::~QChartPrivate()
@@ -51,6 +51,7 class QT_CHARTS_EXPORT QChart : public QGraphicsWidget
51 51 Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible)
52 52 Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers)
53 53 Q_PROPERTY(QLocale locale READ locale WRITE setLocale)
54 Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged)
54 55 Q_ENUMS(ChartTheme)
55 56 Q_ENUMS(AnimationOption)
56 57 Q_ENUMS(ChartType)
@@ -163,6 +164,9 public:
163 164
164 165 ChartType chartType() const;
165 166
167 signals:
168 void plotAreaChanged(const QRectF &plotArea);
169
166 170 protected:
167 171 explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags);
168 172 QScopedPointer<QChartPrivate> d_ptr;
@@ -265,13 +265,6 QT_CHARTS_BEGIN_NAMESPACE
265 265 */
266 266
267 267 /*!
268 \qmlsignal ChartView::onPlotAreaChanged(rect plotArea)
269 The plot area of the chart has changed. This may happen for example, if you modify minimumMargins
270 or if you resize the chart, or if you modify font size related properties of the legend or chart
271 title.
272 */
273
274 /*!
275 268 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
276 269 The \a series has been added to the chart.
277 270 */
@@ -327,6 +320,7 void DeclarativeChart::initChart(QChart::ChartType type)
327 320 connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int)));
328 321 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*)));
329 322 connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*)));
323 connect(m_chart, &QChart::plotAreaChanged, this, &DeclarativeChart::plotAreaChanged);
330 324 }
331 325
332 326 void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series)
@@ -338,7 +332,6 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int r
338 332 {
339 333 m_chart->setMargins(QMargins(left, top, right, bottom));
340 334 emit minimumMarginsChanged();
341 emit plotAreaChanged(m_chart->plotArea());
342 335 }
343 336
344 337 DeclarativeChart::~DeclarativeChart()
@@ -454,11 +447,6 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &
454 447 }
455 448 }
456 449 QQuickItem::geometryChanged(newGeometry, oldGeometry);
457
458 // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or
459 // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is
460 // to implement it here for the QML API purposes.
461 emit plotAreaChanged(m_chart->plotArea());
462 450 }
463 451
464 452 void DeclarativeChart::sceneChanged(QList<QRectF> region)
General Comments 0
You need to be logged in to leave comments. Login now