Changeset View
Changeset View
Standalone View
Standalone View
src/items/text/KReportDesignerItemText.cpp
Show All 36 Lines | |||||
37 | { | 37 | { | ||
38 | //setFlags(ItemIsSelectable | ItemIsMovable); | 38 | //setFlags(ItemIsSelectable | ItemIsMovable); | ||
39 | if (scene) | 39 | if (scene) | ||
40 | scene->addItem(this); | 40 | scene->addItem(this); | ||
41 | 41 | | |||
42 | connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | 42 | connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | ||
43 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | 43 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | ||
44 | 44 | | |||
45 | KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); | 45 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
46 | 46 | setZValue(z()); | |||
47 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | | |||
48 | setZValue(Z); | | |||
49 | 47 | | |||
50 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), | 48 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), | ||
51 | QLatin1String("textarea")); | 49 | QLatin1String("textarea")); | ||
52 | } | 50 | } | ||
53 | 51 | | |||
54 | KReportDesignerItemText::KReportDesignerItemText(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos) | 52 | KReportDesignerItemText::KReportDesignerItemText(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos) | ||
55 | : KReportDesignerItemRectBase(rw) | 53 | : KReportDesignerItemRectBase(rw, this) | ||
56 | { | 54 | { | ||
57 | Q_UNUSED(pos); | 55 | Q_UNUSED(pos); | ||
58 | init(scene, rw); | 56 | init(scene, rw); | ||
59 | setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height())); | 57 | setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height())); | ||
60 | m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); | 58 | nameProperty()->setValue(designer()->suggestEntityName(typeName())); | ||
61 | } | 59 | } | ||
62 | 60 | | |||
63 | KReportDesignerItemText::KReportDesignerItemText(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) | 61 | KReportDesignerItemText::KReportDesignerItemText(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) | ||
64 | : KReportItemText(element), KReportDesignerItemRectBase(d) | 62 | : KReportItemText(element), KReportDesignerItemRectBase(d, this) | ||
65 | { | 63 | { | ||
66 | init(s, d); | 64 | init(s, d); | ||
67 | setSceneRect(m_pos.toScene(), m_size.toScene()); | 65 | setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); | ||
68 | } | 66 | } | ||
69 | 67 | | |||
70 | KReportDesignerItemText* KReportDesignerItemText::clone() | 68 | KReportDesignerItemText* KReportDesignerItemText::clone() | ||
71 | { | 69 | { | ||
72 | QDomDocument d; | 70 | QDomDocument d; | ||
73 | QDomElement e = d.createElement(QLatin1String("clone")); | 71 | QDomElement e = d.createElement(QLatin1String("clone")); | ||
74 | QDomNode n; | 72 | QDomNode n; | ||
75 | buildXML(&d, &e); | 73 | buildXML(&d, &e); | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
124 | } | 122 | } | ||
125 | 123 | | |||
126 | void KReportDesignerItemText::buildXML(QDomDocument *doc, QDomElement *parent) | 124 | void KReportDesignerItemText::buildXML(QDomDocument *doc, QDomElement *parent) | ||
127 | { | 125 | { | ||
128 | //kreportpluginDebug(); | 126 | //kreportpluginDebug(); | ||
129 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 127 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
130 | 128 | | |||
131 | // properties | 129 | // properties | ||
132 | addPropertyAsAttribute(&entity, m_name); | 130 | addPropertyAsAttribute(&entity, nameProperty()); | ||
133 | addPropertyAsAttribute(&entity, m_controlSource); | 131 | addPropertyAsAttribute(&entity, m_controlSource); | ||
134 | addPropertyAsAttribute(&entity, m_verticalAlignment); | 132 | addPropertyAsAttribute(&entity, m_verticalAlignment); | ||
135 | addPropertyAsAttribute(&entity, m_horizontalAlignment); | 133 | addPropertyAsAttribute(&entity, m_horizontalAlignment); | ||
136 | entity.setAttribute(QLatin1String("report:bottom-padding"), m_bottomPadding); | 134 | entity.setAttribute(QLatin1String("report:bottom-padding"), m_bottomPadding); | ||
137 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 135 | entity.setAttribute(QLatin1String("report:z-index"), z()); | ||
138 | addPropertyAsAttribute(&entity, m_itemValue); | 136 | addPropertyAsAttribute(&entity, m_itemValue); | ||
139 | 137 | | |||
140 | // bounding rect | 138 | // bounding rect | ||
141 | buildXMLRect(doc, &entity, &m_pos, &m_size); | 139 | buildXMLRect(doc, &entity, this); | ||
142 | 140 | | |||
143 | //text style info | 141 | //text style info | ||
144 | buildXMLTextStyle(doc, &entity, textStyle()); | 142 | buildXMLTextStyle(doc, &entity, textStyle()); | ||
145 | 143 | | |||
146 | //Line Style | 144 | //Line Style | ||
147 | buildXMLLineStyle(doc, &entity, lineStyle()); | 145 | buildXMLLineStyle(doc, &entity, lineStyle()); | ||
148 | 146 | | |||
149 | parent->appendChild(entity); | 147 | parent->appendChild(entity); | ||
150 | } | 148 | } | ||
151 | 149 | | |||
152 | void KReportDesignerItemText::mousePressEvent(QGraphicsSceneMouseEvent * event) | 150 | void KReportDesignerItemText::mousePressEvent(QGraphicsSceneMouseEvent * event) | ||
153 | { | 151 | { | ||
154 | m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); | 152 | m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); | ||
155 | KReportDesignerItemRectBase::mousePressEvent(event); | 153 | KReportDesignerItemRectBase::mousePressEvent(event); | ||
156 | } | 154 | } | ||
157 | 155 | | |||
158 | 156 | | |||
159 | void KReportDesignerItemText::slotPropertyChanged(KPropertySet &s, KProperty &p) | 157 | void KReportDesignerItemText::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
160 | { | 158 | { | ||
161 | Q_UNUSED(s); | 159 | Q_UNUSED(s); | ||
162 | 160 | | |||
163 | if (p.name() == "position") { | 161 | if (p.name() == "name") { | ||
164 | m_pos.setUnitPos(p.value().toPointF(), KReportPosition::DontUpdateProperty); | | |||
165 | } else if (p.name() == "size") { | | |||
166 | m_size.setUnitSize(p.value().toSizeF(), KReportSize::DontUpdateProperty); | | |||
167 | } else if (p.name() == "name") { | | |||
168 | //For some reason p.oldValue returns an empty string | 162 | //For some reason p.oldValue returns an empty string | ||
169 | if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { | 163 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
170 | p.setValue(m_oldName); | 164 | p.setValue(oldName()); | ||
171 | } else { | 165 | } else { | ||
172 | m_oldName = p.value().toString(); | 166 | setOldName(p.value().toString()); | ||
173 | } | 167 | } | ||
174 | } | 168 | } | ||
175 | 169 | | |||
176 | setSceneRect(m_pos.toScene(), m_size.toScene(), DontUpdateProperty); | 170 | KReportDesignerItemRectBase::propertyChanged(s, p); | ||
177 | if (m_reportDesigner) | 171 | if (designer()) designer()->setModified(true); | ||
178 | m_reportDesigner->setModified(true); | | |||
179 | if (scene()) | | |||
180 | scene()->update(); | | |||
181 | 172 | | |||
182 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), | 173 | updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), | ||
183 | QLatin1String("textarea")); | 174 | QLatin1String("textarea")); | ||
184 | } | 175 | } |