Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/web/KReportDesignerItemWeb.cpp
Show All 25 Lines | |||||
26 | #include <KPropertySet> | 26 | #include <KPropertySet> | ||
27 | 27 | | |||
28 | #include <QGraphicsScene> | 28 | #include <QGraphicsScene> | ||
29 | #include <QGraphicsSceneMouseEvent> | 29 | #include <QGraphicsSceneMouseEvent> | ||
30 | #include <QDomDocument> | 30 | #include <QDomDocument> | ||
31 | #include <QPainter> | 31 | #include <QPainter> | ||
32 | #include "kreportplugin_debug.h" | 32 | #include "kreportplugin_debug.h" | ||
33 | 33 | | |||
34 | void KReportDesignerItemWeb::init(QGraphicsScene *scene, KReportDesigner *d) //done,compared,add function if necessary | 34 | void KReportDesignerItemWeb::init(QGraphicsScene *scene, KReportDesigner *d) | ||
35 | { | 35 | { | ||
36 | if (scene) | 36 | if (scene) | ||
37 | scene->addItem(this); | 37 | scene->addItem(this); | ||
38 | 38 | | |||
39 | connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | 39 | connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | ||
40 | KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); | 40 | | ||
41 | setZValue(Z); | 41 | setZValue(z()); | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | KReportDesignerItemWeb::KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene, | 44 | KReportDesignerItemWeb::KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene, | ||
45 | const QPointF &pos) //done,compared | 45 | const QPointF &pos) : KReportDesignerItemRectBase(rw, this) | ||
46 | : KReportDesignerItemRectBase(rw) | | |||
47 | { | 46 | { | ||
48 | Q_UNUSED(pos); | 47 | Q_UNUSED(pos); | ||
49 | init(scene, rw); | 48 | init(scene, rw); | ||
50 | setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); | 49 | setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); | ||
51 | m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); | 50 | nameProperty()->setValue(designer()->suggestEntityName(typeName())); | ||
52 | } | 51 | } | ||
53 | 52 | | |||
54 | KReportDesignerItemWeb::KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw, | 53 | KReportDesignerItemWeb::KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw, | ||
55 | QGraphicsScene *scene) //done,compared | 54 | QGraphicsScene *scene) | ||
56 | : KReportItemWeb(element), KReportDesignerItemRectBase(rw) | 55 | : KReportItemWeb(element), KReportDesignerItemRectBase(rw, this) | ||
57 | { | 56 | { | ||
58 | init(scene, rw); | 57 | init(scene, rw); | ||
59 | setSceneRect(m_pos.toScene(), m_size.toScene()); | 58 | setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); | ||
60 | } | 59 | } | ||
61 | 60 | | |||
62 | KReportDesignerItemWeb *KReportDesignerItemWeb::clone() //done,compared | 61 | KReportDesignerItemWeb *KReportDesignerItemWeb::clone() | ||
63 | { | 62 | { | ||
64 | QDomDocument d; | 63 | QDomDocument d; | ||
65 | QDomElement e = d.createElement(QLatin1String("clone")); | 64 | QDomElement e = d.createElement(QLatin1String("clone")); | ||
66 | QDomNode n; | 65 | QDomNode n; | ||
67 | buildXML(&d, &e); | 66 | buildXML(&d, &e); | ||
68 | n = e.firstChild(); | 67 | n = e.firstChild(); | ||
69 | return new KReportDesignerItemWeb(n, designer(), 0); | 68 | return new KReportDesignerItemWeb(n, designer(), 0); | ||
70 | } | 69 | } | ||
Show All 19 Lines | |||||
90 | void KReportDesignerItemWeb::buildXML(QDomDocument *doc, QDomElement *parent) | 89 | void KReportDesignerItemWeb::buildXML(QDomDocument *doc, QDomElement *parent) | ||
91 | { | 90 | { | ||
92 | Q_UNUSED(doc); | 91 | Q_UNUSED(doc); | ||
93 | Q_UNUSED(parent); | 92 | Q_UNUSED(parent); | ||
94 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 93 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
95 | 94 | | |||
96 | // properties | 95 | // properties | ||
97 | addPropertyAsAttribute(&entity, m_controlSource); | 96 | addPropertyAsAttribute(&entity, m_controlSource); | ||
98 | addPropertyAsAttribute(&entity, m_name); | 97 | addPropertyAsAttribute(&entity, nameProperty()); | ||
99 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 98 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | ||
100 | buildXMLRect(doc, &entity, &m_pos, &m_size); | 99 | buildXMLRect(doc, &entity, this); | ||
101 | parent->appendChild(entity); | 100 | parent->appendChild(entity); | ||
102 | } | 101 | } | ||
103 | 102 | | |||
104 | void KReportDesignerItemWeb::slotPropertyChanged(KPropertySet &s, KProperty &p) | 103 | void KReportDesignerItemWeb::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
105 | { | 104 | { | ||
106 | if (p.name() == "name") { | 105 | if (p.name() == "name") { | ||
107 | if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { | 106 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
108 | p.setValue(m_oldName); | 107 | p.setValue(oldName()); | ||
109 | } | 108 | } | ||
110 | else { | 109 | else { | ||
111 | m_oldName = p.value().toString(); | 110 | setOldName(p.value().toString()); | ||
112 | } | 111 | } | ||
113 | } | 112 | } | ||
114 | 113 | | |||
115 | KReportDesignerItemRectBase::propertyChanged(s, p); | 114 | KReportDesignerItemRectBase::propertyChanged(s, p); | ||
116 | if (m_reportDesigner) { | 115 | if (designer()) { | ||
117 | m_reportDesigner->setModified(true); | 116 | designer()->setModified(true); | ||
118 | } | 117 | } | ||
119 | } | 118 | } | ||
120 | 119 | | |||
121 | void KReportDesignerItemWeb::mousePressEvent(QGraphicsSceneMouseEvent *event) | 120 | void KReportDesignerItemWeb::mousePressEvent(QGraphicsSceneMouseEvent *event) | ||
122 | { | 121 | { | ||
123 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 122 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
124 | KReportDesignerItemRectBase::mousePressEvent(event); | 123 | KReportDesignerItemRectBase::mousePressEvent(event); | ||
125 | } | 124 | } |