[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Sun Apr 18 07:13:09 CEST 2004
CVS commit by staikos:
save and restore bordered view object properties too, and allow other view
objects to save/restore their properties
M +12 -0 kstborderedviewobject.cpp 1.8
M +7 -1 kstborderedviewobject.h 1.7
M +24 -16 kstviewobject.cpp 1.26
M +2 -0 kstviewobject.h 1.24
--- kdeextragear-2/kst/kst/kstviewobject.h #1.23:1.24
@@ -149,4 +149,6 @@ class KstViewObject : public KstObject {
protected:
virtual KstViewObjectFactoryMethod factory() const;
+ virtual void writeBinary(QDataStream& str);
+ virtual void readBinary(QDataStream& str);
KstViewObjectList _children;
--- kdeextragear-2/kst/kst/kstviewobject.cpp #1.25:1.26
@@ -526,34 +526,44 @@ KstViewObjectFactoryMethod KstViewObject
QDataStream& operator<<(QDataStream& str, KstViewObjectPtr obj) {
+ obj->writeBinary(str);
+ return str;
+}
+
+
+void KstViewObject::writeBinary(QDataStream& str) {
// FIXME: this must be done at startup if we want to be able
// to drag between processes
- assert(obj->factory());
- KstViewObjectFactory::self()->registerType(obj, obj->factory());
+ assert(factory());
+ KstViewObjectFactory::self()->registerType(this, factory());
- str << KstViewObjectFactory::self()->typeOf(obj);
- str << obj->tagName();
- str << obj->_geom << obj->_backgroundColor << obj->_foregroundColor;
+ str << KstViewObjectFactory::self()->typeOf(this);
+ str << tagName();
+ str << _geom << _backgroundColor << _foregroundColor;
// _parent should not be sent since it is meaningless in a drag context
- str << obj->_standardActions << obj->_aspect;
+ str << _standardActions << _aspect;
- str << obj->_children.count();
- for (KstViewObjectList::Iterator i = obj->_children.begin(); i != obj->_children.end(); ++i) {
+ str << _children.count();
+ for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
str << *i;
}
+}
+
+QDataStream& operator>>(QDataStream& str, KstViewObjectPtr obj) {
+ obj->readBinary(str);
return str;
}
-QDataStream& operator>>(QDataStream& str, KstViewObjectPtr obj) {
+void KstViewObject::readBinary(QDataStream& str) {
QString tagName;
str >> tagName;
- obj->setTagName(tagName);
+ setTagName(tagName);
kdDebug() << "Decoding " << tagName << " from drag." << endl;
// FIXME: rename objects if they cause a namespace conflict
- str >> obj->_geom >> obj->_backgroundColor >> obj->_foregroundColor;
- str >> obj->_standardActions >> obj->_aspect;
+ str >> _geom >> _backgroundColor >> _foregroundColor;
+ str >> _standardActions >> _aspect;
- obj->_children.clear();
+ _children.clear();
uint cc = 0;
str >> cc;
@@ -564,5 +574,5 @@ QDataStream& operator>>(QDataStream& str
if (o.data()) {
str >> o;
- obj->_children.append(o);
+ _children.append(o);
} else {
abort();
@@ -570,6 +580,4 @@ QDataStream& operator>>(QDataStream& str
}
}
-
- return str;
}
--- kdeextragear-2/kst/kst/kstborderedviewobject.cpp #1.7:1.8
@@ -112,4 +112,16 @@ QRect KstBorderedViewObject::contentsRec
+void KstBorderedViewObject::writeBinary(QDataStream& str) {
+ KstViewObject::writeBinary(str);
+ str << _borderColor << _borderWidth << _padding << _margin;
+}
+
+
+void KstBorderedViewObject::readBinary(QDataStream& str) {
+ KstViewObject::readBinary(str);
+ str >> _borderColor >> _borderWidth >> _padding >> _margin;
+}
+
+
#include "kstborderedviewobject.moc"
// vim: ts=2 sw=2 et
--- kdeextragear-2/kst/kst/kstborderedviewobject.h #1.6:1.7
@@ -56,4 +56,7 @@ object.y = position().y() + margin() + p
***************************************************************************/
+class KstBorderedViewObject;
+typedef KstSharedPtr<KstBorderedViewObject> KstBorderedViewObjectPtr;
+
class KstBorderedViewObject : public KstViewObject {
Q_OBJECT
@@ -85,4 +88,8 @@ class KstBorderedViewObject : public Kst
virtual void paint(QPainter& p);
+ protected:
+ virtual void readBinary(QDataStream& str);
+ virtual void writeBinary(QDataStream& str);
+
private:
QColor _borderColor;
@@ -91,5 +98,4 @@ class KstBorderedViewObject : public Kst
};
-typedef KstSharedPtr<KstBorderedViewObject> KstBorderedViewObjectPtr;
typedef KstObjectList<KstBorderedViewObjectPtr> KstBorderedViewObjectList;
More information about the Kst
mailing list