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() | 77 | KReportDesignerItemLine::~KReportDesignerItemLine() | ||
78 | { | 78 | { | ||
79 | } | 79 | } | ||
80 | 80 | | |||
Show All 32 Lines | |||||
113 | 113 | | |||
114 | void KReportDesignerItemLine::buildXML(QDomDocument *doc, QDomElement *parent) | 114 | void KReportDesignerItemLine::buildXML(QDomDocument *doc, QDomElement *parent) | ||
115 | { | 115 | { | ||
116 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | 116 | QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); | ||
117 | 117 | | |||
118 | // properties | 118 | // properties | ||
119 | addPropertyAsAttribute(&entity, nameProperty()); | 119 | addPropertyAsAttribute(&entity, nameProperty()); | ||
120 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | 120 | entity.setAttribute(QLatin1String("report:z-index"), zValue()); | ||
121 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x1"), m_start->value().toPointF().x()); | 121 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x1"), startPosition().x()); | ||
122 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y1"), m_start->value().toPointF().y()); | 122 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y1"), startPosition().y()); | ||
123 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x2"), m_end->value().toPointF().x()); | 123 | KReportUtils::setAttribute(&entity, QLatin1String("svg:x2"), endPosition().x()); | ||
124 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y2"), m_end->value().toPointF().y()); | 124 | KReportUtils::setAttribute(&entity, QLatin1String("svg:y2"), endPosition().y()); | ||
125 | 125 | | |||
126 | buildXMLLineStyle(doc, &entity, lineStyle()); | 126 | buildXMLLineStyle(doc, &entity, lineStyle()); | ||
127 | 127 | | |||
128 | parent->appendChild(entity); | 128 | parent->appendChild(entity); | ||
129 | } | 129 | } | ||
130 | 130 | | |||
131 | void KReportDesignerItemLine::propertyChanged(KPropertySet &s, KProperty &p) | 131 | void KReportDesignerItemLine::propertyChanged(KPropertySet &s, KProperty &p) | ||
132 | { | 132 | { | ||
133 | Q_UNUSED(s); | 133 | Q_UNUSED(s); | ||
134 | 134 | | |||
135 | if (p.name() == "startposition" || p.name() == "endposition") { | 135 | if (p.name() == "startposition" || p.name() == "endposition") { | ||
136 | QPointF s = scenePosition(m_start->value().toPointF()); | 136 | QPointF s = scenePosition(startPosition()); | ||
137 | QPointF e = scenePosition(m_end->value().toPointF()); | 137 | QPointF e = scenePosition(endPosition()); | ||
138 | 138 | | |||
139 | setLine ( s.x(), s.y(), e.x(), e.y() ); | 139 | setLine ( s.x(), s.y(), e.x(), e.y() ); | ||
140 | } | 140 | } | ||
141 | else if (p.name() == "name") { | 141 | else if (p.name() == "name") { | ||
142 | //For some reason p.oldValue returns an empty string | 142 | //For some reason p.oldValue returns an empty string | ||
143 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | 143 | if (!designer()->isEntityNameUnique(p.value().toString(), this)) { | ||
144 | p.setValue(oldName()); | 144 | p.setValue(oldName()); | ||
145 | } else { | 145 | } else { | ||
Show All 40 Lines | 173 | { | |||
186 | 186 | | |||
187 | if (x < 0) x = 0; | 187 | if (x < 0) x = 0; | ||
188 | if (y < 0) y = 0; | 188 | if (y < 0) y = 0; | ||
189 | if (x > scene()->width()) x = scene()->width(); | 189 | if (x > scene()->width()) x = scene()->width(); | ||
190 | if (y > scene()->height()) y = scene()->height(); | 190 | if (y > scene()->height()) y = scene()->height(); | ||
191 | 191 | | |||
192 | switch (m_grabAction) { | 192 | switch (m_grabAction) { | ||
193 | case 1: | 193 | case 1: | ||
194 | m_start->setValue(positionFromScene(QPointF(x,y))); | 194 | setStartPosition(positionFromScene(QPointF(x,y))); | ||
195 | break; | 195 | break; | ||
196 | case 2: | 196 | case 2: | ||
197 | m_end->setValue(positionFromScene(QPointF(x,y))); | 197 | setEndPosition(positionFromScene(QPointF(x,y))); | ||
198 | break; | 198 | break; | ||
199 | default: | 199 | default: | ||
200 | QPointF d = mapToItem(this, section->gridPoint(event->scenePos())) - mapToItem(this, section->gridPoint(event->lastScenePos())); | 200 | QPointF d = mapToItem(this, section->gridPoint(event->scenePos())) - mapToItem(this, section->gridPoint(event->lastScenePos())); | ||
201 | 201 | | |||
202 | if (((line().p1() + d).x() >= 0) && | 202 | if (((line().p1() + d).x() >= 0) && | ||
203 | ((line().p2() + d).x() >= 0) && | 203 | ((line().p2() + d).x() >= 0) && | ||
204 | ((line().p1() + d).y() >= 0) && | 204 | ((line().p1() + d).y() >= 0) && | ||
205 | ((line().p2() + d).y() >= 0) && | 205 | ((line().p2() + d).y() >= 0) && | ||
Show All 34 Lines | 231 | if (isSelected()) { | |||
240 | default: | 240 | default: | ||
241 | unsetCursor(); | 241 | unsetCursor(); | ||
242 | } | 242 | } | ||
243 | } | 243 | } | ||
244 | } | 244 | } | ||
245 | 245 | | |||
246 | void KReportDesignerItemLine::setLineScene(const QLineF &line) | 246 | void KReportDesignerItemLine::setLineScene(const QLineF &line) | ||
247 | { | 247 | { | ||
248 | m_start->setValue(positionFromScene(line.p1())); | 248 | setStartPosition(positionFromScene(line.p1())); | ||
249 | m_end->setValue(positionFromScene(line.p2())); | 249 | setEndPosition(positionFromScene(line.p2())); | ||
250 | | ||||
251 | setLine(line); | 250 | setLine(line); | ||
252 | } | 251 | } | ||
253 | 252 | | |||
254 | void KReportDesignerItemLine::move(const QPointF& m) | 253 | void KReportDesignerItemLine::move(const QPointF& m) | ||
255 | { | 254 | { | ||
256 | QPointF original = scenePosition(position()); | 255 | QPointF original = scenePosition(position()); | ||
257 | original += m; | 256 | original += m; | ||
258 | 257 | | |||
259 | setPosition(positionFromScene(original)); | 258 | setPosition(positionFromScene(original)); | ||
260 | } | 259 | } |