Changeset View
Changeset View
Standalone View
Standalone View
src/items/image/KReportDesignerItemImage.cpp
Show All 31 Lines | |||||
32 | // contructors/deconstructors | 32 | // contructors/deconstructors | ||
33 | 33 | | |||
34 | void KReportDesignerItemImage::init(QGraphicsScene *scene, KReportDesigner *d) | 34 | void KReportDesignerItemImage::init(QGraphicsScene *scene, KReportDesigner *d) | ||
35 | { | 35 | { | ||
36 | //kreportpluginDebug(); | 36 | //kreportpluginDebug(); | ||
37 | if (scene) | 37 | if (scene) | ||
38 | scene->addItem(this); | 38 | scene->addItem(this); | ||
39 | 39 | | |||
40 | KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); | 40 | connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | ||
41 | | ||||
42 | connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | | |||
43 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | 41 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | ||
44 | 42 | | |||
45 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 43 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
46 | setZValue(Z); | 44 | setZValue(z()); | ||
47 | } | 45 | } | ||
48 | 46 | | |||
49 | KReportDesignerItemImage::KReportDesignerItemImage(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) | 47 | KReportDesignerItemImage::KReportDesignerItemImage(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) | ||
50 | : KReportDesignerItemRectBase(rw) | 48 | : KReportDesignerItemRectBase(rw, this) | ||
51 | { | 49 | { | ||
52 | Q_UNUSED(pos); | 50 | Q_UNUSED(pos); | ||
53 | //kreportpluginDebug(); | 51 | //kreportpluginDebug(); | ||
54 | init(scene, rw); | 52 | init(scene, rw); | ||
55 | setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); | 53 | setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); | ||
56 | m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); | 54 | nameProperty()->setValue(designer()->suggestEntityName(typeName())); | ||
57 | } | 55 | } | ||
58 | 56 | | |||
59 | KReportDesignerItemImage::KReportDesignerItemImage(const QDomNode & element, KReportDesigner * rw, QGraphicsScene* scene) | 57 | KReportDesignerItemImage::KReportDesignerItemImage(const QDomNode & element, KReportDesigner * rw, QGraphicsScene* scene) | ||
60 | : KReportItemImage(element), KReportDesignerItemRectBase(rw) | 58 | : KReportItemImage(element), KReportDesignerItemRectBase(rw, this) | ||
61 | { | 59 | { | ||
62 | init(scene, rw); | 60 | init(scene, rw); | ||
63 | setSceneRect(m_pos.toScene(), m_size.toScene()); | 61 | setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); | ||
64 | } | 62 | } | ||
65 | 63 | | |||
66 | KReportDesignerItemImage* KReportDesignerItemImage::clone() | 64 | KReportDesignerItemImage* KReportDesignerItemImage::clone() | ||
67 | { | 65 | { | ||
68 | QDomDocument d; | 66 | QDomDocument d; | ||
69 | QDomElement e = d.createElement(QLatin1String("clone")); | 67 | QDomElement e = d.createElement(QLatin1String("clone")); | ||
70 | QDomNode n; | 68 | QDomNode n; | ||
71 | buildXML(&d, &e); | 69 | buildXML(&d, &e); | ||
Show All 36 Lines | 80 | { | |||
108 | painter->setPen(p); | 106 | painter->setPen(p); | ||
109 | } | 107 | } | ||
110 | 108 | | |||
111 | void KReportDesignerItemImage::buildXML(QDomDocument *doc, QDomElement *parent) | 109 | void KReportDesignerItemImage::buildXML(QDomDocument *doc, QDomElement *parent) | ||
112 | { | 110 | { | ||
113 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 111 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
114 | 112 | | |||
115 | // properties | 113 | // properties | ||
116 | addPropertyAsAttribute(&entity, m_name); | 114 | addPropertyAsAttribute(&entity, nameProperty()); | ||
117 | addPropertyAsAttribute(&entity, m_resizeMode); | 115 | addPropertyAsAttribute(&entity, m_resizeMode); | ||
118 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 116 | entity.setAttribute(QLatin1String("report:z-index"), z()); | ||
119 | buildXMLRect(doc, &entity, &m_pos, &m_size); | 117 | buildXMLRect(doc, &entity, this); | ||
120 | 118 | | |||
121 | 119 | | |||
122 | if (isInline()) { | 120 | if (isInline()) { | ||
123 | QDomElement map = doc->createElement(QLatin1String("report:inline-image-data")); | 121 | QDomElement map = doc->createElement(QLatin1String("report:inline-image-data")); | ||
124 | map.appendChild(doc->createTextNode(QLatin1String(inlineImageData()))); | 122 | map.appendChild(doc->createTextNode(QLatin1String(inlineImageData()))); | ||
125 | entity.appendChild(map); | 123 | entity.appendChild(map); | ||
126 | } else { | 124 | } else { | ||
127 | addPropertyAsAttribute(&entity, m_controlSource); | 125 | addPropertyAsAttribute(&entity, m_controlSource); | ||
128 | } | 126 | } | ||
129 | 127 | | |||
130 | parent->appendChild(entity); | 128 | parent->appendChild(entity); | ||
131 | } | 129 | } | ||
132 | 130 | | |||
133 | void KReportDesignerItemImage::slotPropertyChanged(KPropertySet &s, KProperty &p) | 131 | void KReportDesignerItemImage::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
134 | { | 132 | { | ||
135 | if (p.name() == "name") { | 133 | if (p.name() == "name") { | ||
136 | //For some reason p.oldValue returns an empty string | 134 | //For some reason p.oldValue returns an empty string | ||
137 | if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { | 135 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
138 | p.setValue(m_oldName); | 136 | p.setValue(oldName()); | ||
139 | } else { | 137 | } else { | ||
140 | m_oldName = p.value().toString(); | 138 | setOldName(p.value().toString()); | ||
141 | } | 139 | } | ||
142 | } | 140 | } | ||
143 | 141 | | |||
144 | KReportDesignerItemRectBase::propertyChanged(s, p); | 142 | KReportDesignerItemRectBase::propertyChanged(s, p); | ||
145 | if (m_reportDesigner) m_reportDesigner->setModified(true); | 143 | if (designer()) designer()->setModified(true); | ||
146 | } | 144 | } | ||
147 | 145 | | |||
148 | void KReportDesignerItemImage::mousePressEvent(QGraphicsSceneMouseEvent * event) | 146 | void KReportDesignerItemImage::mousePressEvent(QGraphicsSceneMouseEvent * event) | ||
149 | { | 147 | { | ||
150 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 148 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
151 | KReportDesignerItemRectBase::mousePressEvent(event); | 149 | KReportDesignerItemRectBase::mousePressEvent(event); | ||
152 | } | 150 | } |