Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/maps/KReportDesignerItemMaps.cpp
Show All 28 Lines | |||||
29 | #include <QPainter> | 29 | #include <QPainter> | ||
30 | #include "kreportplugin_debug.h" | 30 | #include "kreportplugin_debug.h" | ||
31 | 31 | | |||
32 | void KReportDesignerItemMaps::init(QGraphicsScene *scene, KReportDesigner *d) | 32 | void KReportDesignerItemMaps::init(QGraphicsScene *scene, KReportDesigner *d) | ||
33 | { | 33 | { | ||
34 | if (scene) | 34 | if (scene) | ||
35 | scene->addItem(this); | 35 | scene->addItem(this); | ||
36 | 36 | | |||
37 | KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); | 37 | connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | ||
38 | | ||||
39 | connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | | |||
40 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | 38 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | ||
41 | 39 | | |||
42 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 40 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
43 | setZValue(Z); | 41 | setZValue(z()); | ||
44 | } | 42 | } | ||
45 | 43 | | |||
46 | KReportDesignerItemMaps::KReportDesignerItemMaps(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) | 44 | KReportDesignerItemMaps::KReportDesignerItemMaps(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) | ||
47 | : KReportDesignerItemRectBase(rw) | 45 | : KReportDesignerItemRectBase(rw, this) | ||
48 | { | 46 | { | ||
49 | Q_UNUSED(pos); | 47 | Q_UNUSED(pos); | ||
50 | init(scene, rw); | 48 | init(scene, rw); | ||
51 | 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)); | ||
52 | m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); | 50 | nameProperty()->setValue(designer()->suggestEntityName(typeName())); | ||
53 | } | 51 | } | ||
54 | 52 | | |||
55 | KReportDesignerItemMaps::KReportDesignerItemMaps(const QDomNode &element, KReportDesigner * rw, QGraphicsScene* scene) | 53 | KReportDesignerItemMaps::KReportDesignerItemMaps(const QDomNode &element, KReportDesigner * rw, QGraphicsScene* scene) | ||
56 | : KReportItemMaps(element), KReportDesignerItemRectBase(rw) | 54 | : KReportItemMaps(element), KReportDesignerItemRectBase(rw, this) | ||
57 | { | 55 | { | ||
58 | init(scene, rw); | 56 | init(scene, rw); | ||
59 | setSceneRect(m_pos.toScene(), m_size.toScene()); | 57 | setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); | ||
60 | } | 58 | } | ||
61 | 59 | | |||
62 | KReportDesignerItemMaps* KReportDesignerItemMaps::clone() | 60 | KReportDesignerItemMaps* KReportDesignerItemMaps::clone() | ||
63 | { | 61 | { | ||
64 | QDomDocument d; | 62 | QDomDocument d; | ||
65 | QDomElement e = d.createElement(QLatin1String("clone")); | 63 | QDomElement e = d.createElement(QLatin1String("clone")); | ||
66 | QDomNode n; | 64 | QDomNode n; | ||
67 | buildXML(&d, &e); | 65 | buildXML(&d, &e); | ||
Show All 26 Lines | 76 | { | |||
94 | painter->setPen(p); | 92 | painter->setPen(p); | ||
95 | } | 93 | } | ||
96 | 94 | | |||
97 | void KReportDesignerItemMaps::buildXML(QDomDocument *doc, QDomElement *parent) | 95 | void KReportDesignerItemMaps::buildXML(QDomDocument *doc, QDomElement *parent) | ||
98 | { | 96 | { | ||
99 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 97 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
100 | 98 | | |||
101 | // properties | 99 | // properties | ||
102 | addPropertyAsAttribute(&entity, m_name); | 100 | addPropertyAsAttribute(&entity, nameProperty()); | ||
103 | addPropertyAsAttribute(&entity, m_controlSource); | 101 | addPropertyAsAttribute(&entity, m_controlSource); | ||
104 | addPropertyAsAttribute(&entity, m_latitudeProperty); | 102 | addPropertyAsAttribute(&entity, m_latitudeProperty); | ||
105 | addPropertyAsAttribute(&entity, m_longitudeProperty); | 103 | addPropertyAsAttribute(&entity, m_longitudeProperty); | ||
106 | addPropertyAsAttribute(&entity, m_zoomProperty); | 104 | addPropertyAsAttribute(&entity, m_zoomProperty); | ||
107 | addPropertyAsAttribute(&entity, m_themeProperty); | 105 | addPropertyAsAttribute(&entity, m_themeProperty); | ||
108 | //addPropertyAsAttribute(&entity, m_resizeMode); | 106 | //addPropertyAsAttribute(&entity, m_resizeMode); | ||
109 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 107 | entity.setAttribute(QLatin1String("report:z-index"), z()); | ||
110 | buildXMLRect(doc, &entity, &m_pos, &m_size); | 108 | buildXMLRect(doc, &entity, this); | ||
111 | 109 | | |||
112 | parent->appendChild(entity); | 110 | parent->appendChild(entity); | ||
113 | } | 111 | } | ||
114 | 112 | | |||
115 | void KReportDesignerItemMaps::slotPropertyChanged(KPropertySet &s, KProperty &p) | 113 | void KReportDesignerItemMaps::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
116 | { | 114 | { | ||
117 | //kreportpluginDebug() << p.name() << ":" << p.value(); | 115 | //kreportpluginDebug() << p.name() << ":" << p.value(); | ||
118 | if (p.name().toLower() == "name") { | 116 | if (p.name().toLower() == "name") { | ||
119 | //For some reason p.oldValue returns an empty string | 117 | //For some reason p.oldValue returns an empty string | ||
120 | if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { | 118 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
121 | p.setValue(m_oldName); | 119 | p.setValue(oldName()); | ||
122 | } else { | 120 | } else { | ||
123 | m_oldName = p.value().toString(); | 121 | setOldName(p.value().toString()); | ||
124 | } | 122 | } | ||
125 | } | 123 | } | ||
126 | 124 | | |||
127 | KReportDesignerItemRectBase::propertyChanged(s, p); | 125 | KReportDesignerItemRectBase::propertyChanged(s, p); | ||
128 | if (m_reportDesigner) m_reportDesigner->setModified(true); | 126 | if (designer()) designer()->setModified(true); | ||
129 | } | 127 | } | ||
130 | 128 | | |||
131 | void KReportDesignerItemMaps::mousePressEvent(QGraphicsSceneMouseEvent * event) | 129 | void KReportDesignerItemMaps::mousePressEvent(QGraphicsSceneMouseEvent * event) | ||
132 | { | 130 | { | ||
133 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 131 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
134 | KReportDesignerItemRectBase::mousePressEvent(event); | 132 | KReportDesignerItemRectBase::mousePressEvent(event); | ||
135 | } | 133 | } |