Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesignerItemLine.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 62 | { | |||
---|---|---|---|---|---|
63 | init(scene, d); | 63 | init(scene, d); | ||
64 | setLineScene(QLineF(startPos, endPos)); | 64 | setLineScene(QLineF(startPos, endPos)); | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | KReportDesignerItemLine::KReportDesignerItemLine(const QDomNode & entity, KReportDesigner * d, QGraphicsScene * scene) | 67 | KReportDesignerItemLine::KReportDesignerItemLine(const QDomNode & entity, KReportDesigner * d, QGraphicsScene * scene) | ||
68 | : KReportItemLine(entity), KReportDesignerItemBase(d, this) | 68 | : KReportItemLine(entity), KReportDesignerItemBase(d, this) | ||
69 | { | 69 | { | ||
70 | init(scene, d); | 70 | init(scene, d); | ||
71 | QPointF s = scenePosition(m_start->value().toPointF()); | 71 | QPointF s = scenePosition(startPosition()); | ||
72 | QPointF e = scenePosition(m_end->value().toPointF()); | 72 | QPointF e = scenePosition(endPosition()); | ||
73 | 73 | | |||
74 | setLine ( s.x(), s.y(), e.x(), e.y() ); | 74 | setLine ( s.x(), s.y(), e.x(), e.y() ); | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | KReportDesignerItemLine* KReportDesignerItemLine::clone() | 77 | KReportDesignerItemLine* KReportDesignerItemLine::clone() | ||
78 | { | 78 | { | ||
79 | QDomDocument d; | 79 | QDomDocument d; | ||
80 | QDomElement e = d.createElement(QLatin1String("clone")); | 80 | QDomElement e = d.createElement(QLatin1String("clone")); | ||
Show All 28 Lines | |||||
109 | 109 | | |||
110 | void KReportDesignerItemLine::buildXML(QDomDocument *doc, QDomElement *parent) | 110 | void KReportDesignerItemLine::buildXML(QDomDocument *doc, QDomElement *parent) | ||
111 | { | 111 | { | ||
112 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 112 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
113 | 113 | | |||
114 | // properties | 114 | // properties | ||
115 | addPropertyAsAttribute(&entity, nameProperty()); | 115 | addPropertyAsAttribute(&entity, nameProperty()); | ||
116 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 116 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | ||
117 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x1"), m_start->value().toPointF().x()); | 117 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x1"), startPosition().x()); | ||
118 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y1"), m_start->value().toPointF().y()); | 118 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y1"), startPosition().y()); | ||
119 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x2"), m_end->value().toPointF().x()); | 119 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x2"), endPosition().x()); | ||
120 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y2"), m_end->value().toPointF().y()); | 120 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y2"), endPosition().y()); | ||
121 | 121 | | |||
122 | buildXMLLineStyle(doc, &entity, lineStyle()); | 122 | buildXMLLineStyle(doc, &entity, lineStyle()); | ||
123 | 123 | | |||
124 | parent->appendChild(entity); | 124 | parent->appendChild(entity); | ||
125 | } | 125 | } | ||
126 | 126 | | |||
127 | void KReportDesignerItemLine::propertyChanged(KPropertySet &s, KProperty &p) | 127 | void KReportDesignerItemLine::propertyChanged(KPropertySet &s, KProperty &p) | ||
128 | { | 128 | { | ||
129 | Q_UNUSED(s); | 129 | Q_UNUSED(s); | ||
130 | 130 | | |||
131 | if (p.name() == "startposition" || p.name() == "endposition") { | 131 | if (p.name() == "startposition" || p.name() == "endposition") { | ||
132 | QPointF s = scenePosition(m_start->value().toPointF()); | 132 | QPointF s = scenePosition(startPosition()); | ||
133 | QPointF e = scenePosition(m_end->value().toPointF()); | 133 | QPointF e = scenePosition(endPosition()); | ||
134 | 134 | | |||
135 | setLine ( s.x(), s.y(), e.x(), e.y() ); | 135 | setLine ( s.x(), s.y(), e.x(), e.y() ); | ||
136 | } | 136 | } | ||
137 | else if (p.name() == "name") { | 137 | else if (p.name() == "name") { | ||
138 | //For some reason p.oldValue returns an empty string | 138 | //For some reason p.oldValue returns an empty string | ||
139 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | 139 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
140 | p.setValue(oldName()); | 140 | p.setValue(oldName()); | ||
141 | } else { | 141 | } else { | ||
Show All 40 Lines | 169 | { | |||
182 | 182 | | |||
183 | if (x < 0) x = 0; | 183 | if (x < 0) x = 0; | ||
184 | if (y < 0) y = 0; | 184 | if (y < 0) y = 0; | ||
185 | if (x > scene()->width()) x = scene()->width(); | 185 | if (x > scene()->width()) x = scene()->width(); | ||
186 | if (y > scene()->height()) y = scene()->height(); | 186 | if (y > scene()->height()) y = scene()->height(); | ||
187 | 187 | | |||
188 | switch (m_grabAction) { | 188 | switch (m_grabAction) { | ||
189 | case 1: | 189 | case 1: | ||
190 | m_start->setValue(positionFromScene(QPointF(x,y))); | 190 | setStartPosition(positionFromScene(QPointF(x,y))); | ||
191 | break; | 191 | break; | ||
192 | case 2: | 192 | case 2: | ||
193 | m_end->setValue(positionFromScene(QPointF(x,y))); | 193 | setEndPosition(positionFromScene(QPointF(x,y))); | ||
194 | break; | 194 | break; | ||
195 | default: | 195 | default: | ||
196 | QPointF d = mapToItem(this, section->gridPoint(event->scenePos())) - mapToItem(this, section->gridPoint(event->lastScenePos())); | 196 | QPointF d = mapToItem(this, section->gridPoint(event->scenePos())) - mapToItem(this, section->gridPoint(event->lastScenePos())); | ||
197 | 197 | | |||
198 | if (((line().p1() + d).x() >= 0) && | 198 | if (((line().p1() + d).x() >= 0) && | ||
199 | ((line().p2() + d).x() >= 0) && | 199 | ((line().p2() + d).x() >= 0) && | ||
200 | ((line().p1() + d).y() >= 0) && | 200 | ((line().p1() + d).y() >= 0) && | ||
201 | ((line().p2() + d).y() >= 0) && | 201 | ((line().p2() + d).y() >= 0) && | ||
Show All 32 Lines | 233 | case 2: //Point 2 | |||
234 | setCursor(Qt::SizeAllCursor); | 234 | setCursor(Qt::SizeAllCursor); | ||
235 | break; | 235 | break; | ||
236 | default: | 236 | default: | ||
237 | unsetCursor(); | 237 | unsetCursor(); | ||
238 | } | 238 | } | ||
239 | } | 239 | } | ||
240 | } | 240 | } | ||
241 | 241 | | |||
242 | void KReportDesignerItemLine::setLineScene(QLineF l) | 242 | void KReportDesignerItemLine::setLineScene(const QLineF &line) | ||
243 | { | 243 | { | ||
244 | m_start->setValue(positionFromScene(l.p1())); | 244 | setStartPosition(positionFromScene(line.p1())); | ||
245 | m_end->setValue(positionFromScene(l.p2())); | 245 | setEndPosition(positionFromScene(line.p2())); | ||
246 | 246 | setLine(line); | |||
247 | setLine(l); | | |||
248 | } | 247 | } | ||
249 | 248 | | |||
250 | void KReportDesignerItemLine::move(const QPointF& m) | 249 | void KReportDesignerItemLine::move(const QPointF& m) | ||
251 | { | 250 | { | ||
252 | QPointF original = scenePosition(position()); | 251 | QPointF original = scenePosition(position()); | ||
253 | original += m; | 252 | original += m; | ||
254 | 253 | | |||
255 | setPosition(positionFromScene(original)); | 254 | setPosition(positionFromScene(original)); | ||
256 | } | 255 | } |