Changeset View
Changeset View
Standalone View
Standalone View
src/items/field/KReportDesignerItemField.cpp
Show All 30 Lines | |||||
31 | // class ReportEntityField | 31 | // class ReportEntityField | ||
32 | // | 32 | // | ||
33 | 33 | | |||
34 | void KReportDesignerItemField::init(QGraphicsScene * scene, KReportDesigner * d) | 34 | void KReportDesignerItemField::init(QGraphicsScene * scene, KReportDesigner * d) | ||
35 | { | 35 | { | ||
36 | if (scene) | 36 | if (scene) | ||
37 | scene->addItem(this); | 37 | scene->addItem(this); | ||
38 | 38 | | |||
39 | KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); | 39 | setZValue(z()); | ||
40 | | ||||
41 | connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | | |||
42 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | | |||
43 | | ||||
44 | setZValue(Z); | | |||
45 | 40 | | |||
46 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field")); | 41 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field")); | ||
47 | } | 42 | } | ||
48 | 43 | | |||
49 | // methods (constructors) | 44 | // methods (constructors) | ||
50 | KReportDesignerItemField::KReportDesignerItemField(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos) | 45 | KReportDesignerItemField::KReportDesignerItemField(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos) | ||
51 | : KReportDesignerItemRectBase(rw) | 46 | : KReportDesignerItemRectBase(rw, this) | ||
52 | { | 47 | { | ||
53 | Q_UNUSED(pos); | 48 | Q_UNUSED(pos); | ||
54 | init(scene, rw); | 49 | init(scene, rw); | ||
55 | setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height())); | 50 | setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height())); | ||
56 | m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); | 51 | nameProperty()->setValue(designer()->suggestEntityName(typeName())); | ||
57 | } | 52 | } | ||
58 | 53 | | |||
59 | KReportDesignerItemField::KReportDesignerItemField(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) | 54 | KReportDesignerItemField::KReportDesignerItemField(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) | ||
60 | : KReportItemField(element), KReportDesignerItemRectBase(d) | 55 | : KReportItemField(element), KReportDesignerItemRectBase(d, this) | ||
61 | { | 56 | { | ||
62 | init(s, d); | 57 | init(s, d); | ||
63 | setSceneRect(m_pos.toScene(), m_size.toScene()); | 58 | setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); | ||
64 | } | 59 | } | ||
65 | 60 | | |||
66 | KReportDesignerItemField* KReportDesignerItemField::clone() | 61 | KReportDesignerItemField* KReportDesignerItemField::clone() | ||
67 | { | 62 | { | ||
68 | QDomDocument d; | 63 | QDomDocument d; | ||
69 | QDomElement e = d.createElement(QLatin1String("clone")); | 64 | QDomElement e = d.createElement(QLatin1String("clone")); | ||
70 | QDomNode n; | 65 | QDomNode n; | ||
71 | buildXML(&d, &e); | 66 | buildXML(&d, &e); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 83 | { | |||
122 | painter->setPen(p); | 117 | painter->setPen(p); | ||
123 | } | 118 | } | ||
124 | 119 | | |||
125 | void KReportDesignerItemField::buildXML(QDomDocument *doc, QDomElement *parent) | 120 | void KReportDesignerItemField::buildXML(QDomDocument *doc, QDomElement *parent) | ||
126 | { | 121 | { | ||
127 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 122 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
128 | 123 | | |||
129 | // properties | 124 | // properties | ||
130 | addPropertyAsAttribute(&entity, m_name); | 125 | addPropertyAsAttribute(&entity, nameProperty()); | ||
131 | addPropertyAsAttribute(&entity, m_controlSource); | 126 | addPropertyAsAttribute(&entity, m_controlSource); | ||
132 | addPropertyAsAttribute(&entity, m_verticalAlignment); | 127 | addPropertyAsAttribute(&entity, m_verticalAlignment); | ||
133 | addPropertyAsAttribute(&entity, m_horizontalAlignment); | 128 | addPropertyAsAttribute(&entity, m_horizontalAlignment); | ||
134 | addPropertyAsAttribute(&entity, m_wordWrap); | 129 | addPropertyAsAttribute(&entity, m_wordWrap); | ||
135 | addPropertyAsAttribute(&entity, m_canGrow); | 130 | addPropertyAsAttribute(&entity, m_canGrow); | ||
136 | addPropertyAsAttribute(&entity, m_itemValue); | 131 | addPropertyAsAttribute(&entity, m_itemValue); | ||
137 | 132 | | |||
138 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 133 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | ||
139 | 134 | | |||
140 | // bounding rect | 135 | // bounding rect | ||
141 | buildXMLRect(doc, &entity, &m_pos, &m_size); | 136 | buildXMLRect(doc, &entity, this); | ||
142 | 137 | | |||
143 | //text style info | 138 | //text style info | ||
144 | buildXMLTextStyle(doc, &entity, textStyle()); | 139 | buildXMLTextStyle(doc, &entity, textStyle()); | ||
145 | 140 | | |||
146 | //Line Style | 141 | //Line Style | ||
147 | buildXMLLineStyle(doc, &entity, lineStyle()); | 142 | buildXMLLineStyle(doc, &entity, lineStyle()); | ||
148 | 143 | | |||
149 | 144 | | |||
Show All 13 Lines | |||||
163 | } | 158 | } | ||
164 | 159 | | |||
165 | void KReportDesignerItemField::slotPropertyChanged(KPropertySet &s, KProperty &p) | 160 | void KReportDesignerItemField::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
166 | { | 161 | { | ||
167 | Q_UNUSED(s); | 162 | Q_UNUSED(s); | ||
168 | 163 | | |||
169 | if (p.name() == "name") { | 164 | if (p.name() == "name") { | ||
170 | //For some reason p.oldValue returns an empty string | 165 | //For some reason p.oldValue returns an empty string | ||
171 | if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { | 166 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
172 | p.setValue(m_oldName); | 167 | p.setValue(oldName()); | ||
173 | } else { | 168 | } else { | ||
174 | m_oldName = p.value().toString(); | 169 | setOldName(p.value().toString()); | ||
175 | } | 170 | } | ||
176 | } | 171 | } | ||
177 | 172 | | |||
178 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field")); | 173 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field")); | ||
179 | 174 | | |||
180 | KReportDesignerItemRectBase::propertyChanged(s, p); | 175 | KReportDesignerItemRectBase::propertyChanged(s, p); | ||
181 | if (m_reportDesigner)m_reportDesigner->setModified(true); | 176 | if (designer())designer()->setModified(true); | ||
182 | } | 177 | } | ||
183 | 178 | | |||
184 | void KReportDesignerItemField::mousePressEvent(QGraphicsSceneMouseEvent * event) | 179 | void KReportDesignerItemField::mousePressEvent(QGraphicsSceneMouseEvent * event) | ||
185 | { | 180 | { | ||
186 | //kreportpluginDebug() << m_reportDesigner->fieldKeys() << m_reportDesigner->fieldNames(); | 181 | //kreportpluginDebug() << m_reportDesigner->fieldKeys() << m_reportDesigner->fieldNames(); | ||
187 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 182 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
188 | KReportDesignerItemRectBase::mousePressEvent(event); | 183 | KReportDesignerItemRectBase::mousePressEvent(event); | ||
189 | } | 184 | } | ||
190 | 185 | | |||
191 | 186 | |