[Kst] extragear/graphics/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Tue Aug 16 02:45:38 CEST 2005
SVN commit 449578 by rchern:
Saving/loading support for lines and arrows
M +34 -34 kstviewarrow.cpp
M +7 -6 kstviewline.cpp
M +1 -1 kstviewline.h
--- trunk/extragear/graphics/kst/kst/kstviewarrow.cpp #449577:449578
@@ -34,40 +34,43 @@
KstViewArrow::KstViewArrow(const QDomElement& e)
: KstViewLine(e) {
+
+ int orientationInt;
-// QPoint in_from, in_to;
-//
-//
-// QDomNode n = e.firstChild();
-// while (!n.isNull()) {
-// QDomElement el = n.toElement();
-// if (!el.isNull()) {
-// if (el.tagName() == "fromx") {
-// in_from.setX(el.text().toInt());
-// } else if (el.tagName() == "fromy") {
-// in_from.setY(el.text().toInt());
-// } else if (el.tagName() == "tox") {
-// in_to.setX(el.text().toInt());
-// } else if (el.tagName() == "toy") {
-// in_to.setY(el.text().toInt());
-// } else if (metaObject()->findProperty(el.tagName().latin1(), true) > -1) {
-// setProperty(el.tagName().latin1(), QVariant(el.text()));
-// }
-// }
-// n = n.nextSibling();
-// }
-//
-// printf("setting from (%d, %d)\n", in_from.x(), in_from.y());
-// printf("setting to (%d, %d)\n", in_to.x(), in_to.y());
-//
-// setFrom(in_from);
-// setTo(in_to);
-//
-// printf("set from (%d, %d)\n", from().x(), from().y());
-// printf("set to (%d, %d)\n", to().x(), to().y());
+ QDomNode n = e.firstChild();
+ while (!n.isNull()) {
+ QDomElement el = n.toElement();
+ if (!el.isNull()) {
+ if (el.tagName() == "orientation") {
+ orientationInt = el.text().toInt();
+ } else if (metaObject()->findProperty(el.tagName().latin1(), true) > -1) {
+ setProperty(el.tagName().latin1(), QVariant(el.text()));
+ }
+ }
+ n = n.nextSibling();
+ }
+ switch (orientationInt) {
+ case 0:
+ _orientation = UpLeft;
+ break;
+ case 1:
+ _orientation = UpRight;
+ break;
+ case 2:
+ _orientation = DownLeft;
+ break;
+ case 3:
+ _orientation = DownRight;
+ break;
+ default:
+ _orientation = UpLeft;
+ }
+
// always has this value
_type = "Arrow";
+ setTransparent(true);
+ _layoutActions |= Delete | Raise | Lower | RaiseToTop | LowerToBottom | Rename | MoveTo | Copy | CopyTo;
}
@@ -138,11 +141,8 @@
void KstViewArrow::save(QTextStream& ts, const QString& indent) {
ts << indent << "<" << type() << ">" << endl;
+ ts << indent + " " << "<orientation>" << _orientation << "</orientation>" << endl;
KstViewObject::save(ts, indent + " ");
- ts << indent + " " << "<fromx>" << from().x() << "</fromx>" << endl;
- ts << indent + " " << "<fromy>" << from().y() << "</fromy>" << endl;
- ts << indent + " " << "<tox>" << to().x() << "</tox>" << endl;
- ts << indent + " " << "<toy>" << to().y() << "</toy>" << endl;;
ts << indent << "</" << type() << ">" << endl;
}
--- trunk/extragear/graphics/kst/kst/kstviewline.cpp #449577:449578
@@ -20,6 +20,7 @@
#include <klocale.h>
+#include <qmetaobject.h>
#include <qpainter.h>
#include <qvariant.h>
@@ -43,9 +44,12 @@
KstViewLine::KstViewLine(const QDomElement& e)
: KstViewObject(e) {
+
_width = 1;
_capStyle = Qt::FlatCap;
- _penStyle = Qt::SolidLine;
+ _penStyle = Qt::SolidLine;
+
+ // always these values
setTransparent(true);
_type = "Line";
_layoutActions |= Delete | Raise | Lower | RaiseToTop | LowerToBottom | Rename | MoveTo | Copy | CopyTo;
@@ -87,12 +91,9 @@
void KstViewLine::save(QTextStream& ts, const QString& indent) {
ts << indent << "<" << type() << ">" << endl;
+ // and save the orientation
+ ts << indent + " " << "<orientation>" << _orientation << "</orientation>" << endl;
KstViewObject::save(ts, indent + " ");
- // and save the from and to points
- ts << indent + " " << "<fromx>" << from().x() << "</fromx>" << endl;
- ts << indent + " " << "<fromy>" << from().y() << "</fromy>" << endl;
- ts << indent + " " << "<tox>" << to().x() << "</tox>" << endl;
- ts << indent + " " << "<toy>" << to().y() << "</toy>" << endl;
ts << indent << "</" << type() << ">" << endl;
}
--- trunk/extragear/graphics/kst/kst/kstviewline.h #449577:449578
@@ -75,7 +75,7 @@
virtual void save(QTextStream& ts, const QString& indent = QString::null);
protected:
- enum Direction { UpLeft, UpRight, DownLeft, DownRight };
+ enum Direction { UpLeft = 0, UpRight = 1, DownLeft = 2, DownRight = 3 };
Direction _orientation;
void updateOrientation();
int _width;
More information about the Kst
mailing list