qtcharts/qmlplugin/declarativechart.cpp

41 lines
994 B
C++
Raw Normal View History

2012-01-03 14:22:10 +00:00
#include "declarativechart.h"
2012-03-20 10:19:09 +00:00
#include <QPainter>
2012-01-03 14:22:10 +00:00
QTCOMMERCIALCHART_BEGIN_NAMESPACE
2012-01-03 14:22:10 +00:00
DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
: QDeclarativeItem(parent),
m_chart(new QChart(this))
2012-01-03 14:22:10 +00:00
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
}
DeclarativeChart::ChartTheme DeclarativeChart::theme()
{
2012-02-24 09:33:17 +00:00
return (ChartTheme) m_chart->chartTheme();
2012-01-03 14:22:10 +00:00
}
void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
2012-01-03 14:22:10 +00:00
{
2012-03-19 11:01:01 +00:00
Q_UNUSED(oldGeometry)
2012-02-17 09:03:26 +00:00
if (newGeometry.isValid()) {
if (newGeometry.width() > 0 && newGeometry.height() > 0) {
m_chart->resize(newGeometry.width(), newGeometry.height());
2012-02-17 09:03:26 +00:00
}
}
2012-01-03 14:22:10 +00:00
}
2012-03-19 11:01:01 +00:00
void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
// TODO: optimized?
painter->setRenderHint(QPainter::Antialiasing, true);
}
#include "moc_declarativechart.cpp"
QTCOMMERCIALCHART_END_NAMESPACE