[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Wed Nov 7 22:01:58 CET 2007
SVN commit 734024 by fenton:
Update Save/Restore for PlotRenderItems to save/restore relations.
Update GraphicFactories to have access to the ObjectStore.
M +2 -2 libkstapp/boxitem.cpp
M +1 -1 libkstapp/boxitem.h
M +2 -2 libkstapp/cartesianrenderitem.cpp
M +1 -1 libkstapp/cartesianrenderitem.h
M +1 -1 libkstapp/document.cpp
M +2 -2 libkstapp/ellipseitem.cpp
M +1 -1 libkstapp/ellipseitem.h
M +2 -2 libkstapp/graphicsfactory.cpp
M +3 -2 libkstapp/graphicsfactory.h
M +2 -2 libkstapp/labelitem.cpp
M +1 -1 libkstapp/labelitem.h
M +2 -2 libkstapp/layoutboxitem.cpp
M +1 -1 libkstapp/layoutboxitem.h
M +2 -2 libkstapp/lineitem.cpp
M +1 -1 libkstapp/lineitem.h
M +2 -2 libkstapp/pictureitem.cpp
M +1 -1 libkstapp/pictureitem.h
M +2 -1 libkstapp/plotaxisitem.cpp
M +2 -1 libkstapp/plotaxisitem.h
M +4 -4 libkstapp/plotitem.cpp
M +1 -1 libkstapp/plotitem.h
M +11 -6 libkstapp/plotrenderitem.cpp
M +1 -1 libkstapp/plotrenderitem.h
M +2 -2 libkstapp/svgitem.cpp
M +1 -1 libkstapp/svgitem.h
M +1 -2 libkstapp/viewitem.cpp
M +1 -0 libkstmath/curve.cpp
M +1 -0 libkstmath/image.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.cpp #734023:734024
@@ -62,7 +62,7 @@
}
-ViewItem* BoxItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* BoxItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
BoxItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -77,7 +77,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.h #734023:734024
@@ -41,7 +41,7 @@
public:
BoxItemFactory();
~BoxItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/cartesianrenderitem.cpp #734023:734024
@@ -99,10 +99,10 @@
}
-bool CartesianRenderItem::configureFromXml(QXmlStreamReader &xml) {
+bool CartesianRenderItem::configureFromXml(QXmlStreamReader &xml, ObjectStore *store) {
bool validTag = false;
if (xml.isStartElement() && xml.name().toString() == "cartesianrender") {
- validTag = PlotRenderItem::configureFromXml(xml);
+ validTag = PlotRenderItem::configureFromXml(xml, store);
if (validTag && xml.isEndElement() && xml.name().toString() == "cartesianrender") {
validTag = true;
}
--- branches/work/kst/portto4/kst/src/libkstapp/cartesianrenderitem.h #734023:734024
@@ -26,7 +26,7 @@
virtual void saveInPlot(QXmlStreamWriter &xml);
virtual void paintRelations(QPainter *painter);
- bool configureFromXml(QXmlStreamReader &xml);
+ bool configureFromXml(QXmlStreamReader &xml, ObjectStore *store);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/document.cpp #734023:734024
@@ -207,7 +207,7 @@
break;
case View:
{
- ViewItem *i = GraphicsFactory::parse(xml, currentView);
+ ViewItem *i = GraphicsFactory::parse(xml, objectStore(), currentView);
if (i) {
currentView->scene()->addItem(i);
}
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.cpp #734023:734024
@@ -71,7 +71,7 @@
}
-ViewItem* EllipseItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* EllipseItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
EllipseItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -86,7 +86,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.h #734023:734024
@@ -42,7 +42,7 @@
public:
EllipseItemFactory();
~EllipseItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/graphicsfactory.cpp #734023:734024
@@ -51,7 +51,7 @@
}
-ViewItem *GraphicsFactory::parse(QXmlStreamReader& stream, View *view, ViewItem *parent) {
+ViewItem *GraphicsFactory::parse(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent) {
if (!factories) {
return 0;
}
@@ -61,7 +61,7 @@
return 0;
}
- return f->generateGraphics(stream, view, parent);
+ return f->generateGraphics(stream, store, view, parent);
}
--- branches/work/kst/portto4/kst/src/libkstapp/graphicsfactory.h #734023:734024
@@ -21,6 +21,7 @@
namespace Kst {
class ViewItem;
+class ObjectStore;
class GraphicsFactory {
public:
@@ -30,8 +31,8 @@
// This takes ownership
static void registerFactory(const QString& node, GraphicsFactory *factory);
static void registerFactory(const QStringList& nodes, GraphicsFactory *factory);
- KST_EXPORT static ViewItem *parse(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
- virtual ViewItem *generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0) = 0;
+ KST_EXPORT static ViewItem *parse(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
+ virtual ViewItem *generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0) = 0;
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #734023:734024
@@ -96,7 +96,7 @@
}
-ViewItem* LabelItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* LabelItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
LabelItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -116,7 +116,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #734023:734024
@@ -48,7 +48,7 @@
public:
LabelItemFactory();
~LabelItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/layoutboxitem.cpp #734023:734024
@@ -169,7 +169,7 @@
}
-ViewItem* LayoutBoxItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* LayoutBoxItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
LayoutBoxItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -187,7 +187,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/layoutboxitem.h #734023:734024
@@ -42,7 +42,7 @@
public:
LayoutBoxItemFactory();
~LayoutBoxItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #734023:734024
@@ -205,7 +205,7 @@
}
-ViewItem* LineItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* LineItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
LineItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -220,7 +220,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.h #734023:734024
@@ -63,7 +63,7 @@
public:
LineItemFactory();
~LineItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.cpp #734023:734024
@@ -88,7 +88,7 @@
}
-ViewItem* PictureItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* PictureItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
PictureItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -115,7 +115,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.h #734023:734024
@@ -48,7 +48,7 @@
public:
PictureItemFactory();
~PictureItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxisitem.cpp #734023:734024
@@ -148,7 +148,8 @@
}
-bool PlotAxisItem::configureFromXml(QXmlStreamReader &xml) {
+bool PlotAxisItem::configureFromXml(QXmlStreamReader &xml, ObjectStore *store) {
+ Q_UNUSED(store);
bool validTag = false;
if (xml.isStartElement() && xml.name().toString() == "plotaxis") {
QXmlStreamAttributes attrs = xml.attributes();
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxisitem.h #734023:734024
@@ -17,6 +17,7 @@
namespace Kst {
class PlotItem;
+class ObjectStore;
class PlotAxisItem : public ViewItem
{
@@ -48,7 +49,7 @@
virtual void save(QXmlStreamWriter &xml);
void saveInPlot(QXmlStreamWriter &xml);
- bool configureFromXml(QXmlStreamReader &xml);
+ bool configureFromXml(QXmlStreamReader &xml, ObjectStore *store);
virtual void paint(QPainter *painter);
virtual void paintMajorGridLines(QPainter *painter,
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #734023:734024
@@ -538,7 +538,7 @@
}
-ViewItem* PlotItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* PlotItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
PlotItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -574,17 +574,17 @@
// TODO add any specialized PlotItem Properties here.
} else if (xml.name().toString() == "plotaxis") {
Q_ASSERT(rc);
- validTag = rc->plotAxisItem()->configureFromXml(xml);
+ validTag = rc->plotAxisItem()->configureFromXml(xml, store);
} else if (xml.name().toString() == "cartesianrender") {
Q_ASSERT(rc);
PlotRenderItem * renderItem = rc->renderItem(PlotRenderItem::Cartesian);
if (renderItem) {
- validTag = renderItem->configureFromXml(xml);
+ validTag = renderItem->configureFromXml(xml, store);
}
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #734023:734024
@@ -144,7 +144,7 @@
public:
PlotItemFactory();
~PlotItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #734023:734024
@@ -16,6 +16,7 @@
#include "viewitemzorder.h"
#include "plotitemmanager.h"
#include "application.h"
+#include "objectstore.h"
#include "plotrenderitemdialog.h"
@@ -205,8 +206,7 @@
void PlotRenderItem::saveInPlot(QXmlStreamWriter &xml) {
- //TODO Update with proper Object Tag.
- //xml.writeAttribute("name", name());
+ xml.writeAttribute("name", name());
xml.writeAttribute("type", QVariant(_type).toString());
xml.writeAttribute("xzoommode", QVariant(_xAxisZoomMode).toString());
xml.writeAttribute("yzoommode", QVariant(_yAxisZoomMode).toString());
@@ -222,14 +222,13 @@
xml.writeEndElement();
foreach (RelationPtr relation, relationList()) {
xml.writeStartElement("relation");
- //TODO replace with with a valid object tag to correctly identify the relations.
- xml.writeAttribute("name", relation->name());
+ xml.writeAttribute("tag", relation->tag().tagString());
xml.writeEndElement();
}
}
-bool PlotRenderItem::configureFromXml(QXmlStreamReader &xml) {
+bool PlotRenderItem::configureFromXml(QXmlStreamReader &xml, ObjectStore *store) {
bool validTag = true;
QString primaryTag = xml.name().toString();
QXmlStreamAttributes attrs = xml.attributes();
@@ -287,7 +286,13 @@
setProjectionRect(QRectF(QPointF(x, y), QSizeF(w, h)));
} else if (xml.isStartElement() && xml.name().toString() == "relation") {
expectedEnd = xml.name().toString();
- // TODO Process the relation.
+ attrs = xml.attributes();
+ ObjectTag tag = ObjectTag::fromString(attrs.value("tag").toString());
+ qDebug(tag.tagString());
+ RelationPtr relation = kst_cast<Relation>(store->retrieveObject(tag));
+ if (relation) {
+ addRelation(relation);
+ }
} else if (xml.isEndElement()) {
if (xml.name().toString() != expectedEnd) {
validTag = false;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #734023:734024
@@ -87,7 +87,7 @@
virtual void paint(QPainter *painter);
virtual void paintRelations(QPainter *painter) = 0;
- virtual bool configureFromXml(QXmlStreamReader &xml);
+ virtual bool configureFromXml(QXmlStreamReader &xml, ObjectStore *store);
QString leftLabel() const;
QString bottomLabel() const;
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.cpp #734023:734024
@@ -92,7 +92,7 @@
}
-ViewItem* SvgItemFactory::generateGraphics(QXmlStreamReader& xml, View *view, ViewItem *parent) {
+ViewItem* SvgItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
SvgItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
@@ -117,7 +117,7 @@
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
- ViewItem *i = GraphicsFactory::parse(xml, view, rc);
+ ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.h #734023:734024
@@ -51,7 +51,7 @@
public:
SvgItemFactory();
~SvgItemFactory();
- ViewItem* generateGraphics(QXmlStreamReader& stream, View *view, ViewItem *parent = 0);
+ ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #734023:734024
@@ -66,8 +66,7 @@
}
void ViewItem::save(QXmlStreamWriter &xml) {
-// TODO Add proper writing of ObjectTag
-// xml.writeAttribute("name", name());
+ xml.writeAttribute("name", name());
xml.writeStartElement("position");
xml.writeAttribute("x", QVariant(pos().x()).toString());
xml.writeAttribute("y", QVariant(pos().y()).toString());
--- branches/work/kst/portto4/kst/src/libkstmath/curve.cpp #734023:734024
@@ -504,6 +504,7 @@
s.writeAttribute("hasbars", QVariant(HasBars).toString());
s.writeAttribute("barstyle", QString::number(BarStyle));
s.writeAttribute("ignoreautoscale", QVariant(_ignoreAutoScale).toString());
+ s.writeEndElement();
}
--- branches/work/kst/portto4/kst/src/libkstmath/image.cpp #734023:734024
@@ -191,6 +191,7 @@
s.writeAttribute("contourcolor", _contourColor.name());
s.writeAttribute("autothreshold", QVariant(_autoThreshold).toString());
+ s.writeEndElement();
}
More information about the Kst
mailing list