17#include "KReportDesignerItemChart.h"
19#include <KReportDesignerItemBase.h>
20#include "KReportDesigner.h"
23#include <KPropertySet>
25#include <QGraphicsScene>
26#include <QGraphicsSceneMouseEvent>
27#include <QDomDocument>
30void KReportDesignerItemChart::init(
QGraphicsScene* scene, KoReportDesigner *d)
37 connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
38 this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
40 KoReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d);
43 connect(m_reportDesigner, SIGNAL(reportDataChanged()),
this, SLOT(slotReportDataChanged()));
46KReportDesignerItemChart::KReportDesignerItemChart(KoReportDesigner * rd,
QGraphicsScene* scene,
const QPointF &pos)
47 : KoReportDesignerItemRectBase(rd)
51 setSceneRect(properRect(*rd, m_dpiX, m_dpiY));
52 m_name->setValue(m_reportDesigner->suggestEntityName(
typeName()));
55KReportDesignerItemChart::KReportDesignerItemChart(
QDomNode *element, KoReportDesigner * rd,
QGraphicsScene* scene) :
56 KReportItemChart(element), KoReportDesignerItemRectBase(rd)
60 setSceneRect(m_pos.toScene(), m_size.toScene());
64KReportDesignerItemChart::~KReportDesignerItemChart()
74 QFont f = painter->
font();
75 QPen p = painter->
pen();
81 m_chartWidget->setFixedSize(m_size.toScene().toSize());
83 QPixmap::grabWidget(m_chartWidget).toImage(),
84 0, 0,
rect().width(),
rect().height());
91 painter->
setPen(QPen(QColor(224, 224, 224)));
102KReportDesignerItemChart* KReportDesignerItemChart::clone()
105 QDomElement e = d.createElement(
"clone");
109 return new KReportDesignerItemChart(n, designer(), 0);
117 addPropertyAsAttribute(&entity, nameProperty());
118 addPropertyAsAttribute(&entity, dataSourceProperty());
119 addPropertyAsAttribute(&entity, m_chartType);
120 addPropertyAsAttribute(&entity, m_chartSubType);
121 addPropertyAsAttribute(&entity, m_threeD);
122 addPropertyAsAttribute(&entity, m_colorScheme);
123 addPropertyAsAttribute(&entity, m_aa);
124 addPropertyAsAttribute(&entity, m_xTitle);
125 addPropertyAsAttribute(&entity, m_yTitle);
126 addPropertyAsAttribute(&entity, m_backgroundColor);
127 addPropertyAsAttribute(&entity, m_displayLegend);
128 addPropertyAsAttribute(&entity, m_legendPosition);
129 addPropertyAsAttribute(&entity, m_legendOrientation);
130 addPropertyAsAttribute(&entity, m_linkChild);
131 addPropertyAsAttribute(&entity, m_linkMaster);
135 buildXMLRect(doc, &entity, &m_pos, &m_size);
137 parent->appendChild(entity);
142 if (p.
name() ==
"name") {
144 if (!m_reportDesigner->isEntityNameUnique(p.
value().
toString(),
this)) {
149 }
else if (p.
name() ==
"three-dimensions") {
151 }
else if (p.
name() ==
"antialiased") {
153 }
else if (p.
name() ==
"color-scheme") {
155 }
else if (p.
name() ==
"data-source") {
157 }
else if (p.
name() ==
"title-x-axis" || p.
name() ==
"title-y-axis") {
158 setAxis(m_xTitle->value().toString(), m_yTitle->value().toString());
159 }
else if (p.
name() ==
"background-color") {
160 setBackgroundColor(p.
value().
value<QColor>());
161 }
else if (p.
name() ==
"display-legend") {
165 }
else if (p.
name() ==
"legend-position") {
169 }
else if (p.
name() ==
"legend-orientation") {
173 }
else if (p.
name() ==
"chart-type") {
178 }
else if (p.
name() ==
"chart-sub-type") {
180 m_chartWidget->setSubType((KDChart::Widget::SubType) m_chartSubType->value().toInt());
184 KoReportDesignerItemRectBase::propertyChanged(s, p);
185 if (m_reportDesigner) m_reportDesigner->setModified(
true);
190 if (m_reportDesigner->reportData()) {
191 QStringList ql = m_reportDesigner->reportData()->dataSources();
192 QStringList qn = m_reportDesigner->reportData()->dataSourceNames();
193 dataSourceProperty()->setListData(ql, qn);
195 KoReportDesignerItemRectBase::mousePressEvent(
event);
198void KReportDesignerItemChart::slotReportDataChanged()
200 setConnection(m_reportDesigner->reportData());
bool setValue(const QVariant &value, ValueOptions options=ValueOptions())
virtual QString typeName() const =0
Return the item type as a string.
QString itemDataSource() const
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
KOSM_EXPORT const char * typeName(Type type)
QDomElement createElement(const QString &tagName)
void setAttribute(const QString &name, const QString &value)
QDomNode firstChild() const const
QGraphicsScene * scene() const const
void setPos(const QPointF &pos)
qreal zValue() const const
QRectF rect() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual bool event(QEvent *e)
QObject * parent() const const
void drawImage(const QPoint &point, const QImage &image)
void drawRect(const QRect &rectangle)
void drawText(const QPoint &position, const QString &text)
void fillRect(const QRect &rectangle, QGradient::Preset preset)
const QFont & font() const const
const QPen & pen() const const
void setBackground(const QBrush &brush)
void setBackgroundMode(Qt::BGMode mode)
void setFont(const QFont &font)
void setPen(Qt::PenStyle style)
QTextStream & left(QTextStream &stream)
bool toBool() const const
QString toString() const const