mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Save and load image paints
This commit is contained in:
+2
-13
@@ -90,25 +90,14 @@ void ProjectReader::parsePaint(const QDomElement& paint)
|
||||
QString paintAttrName = paint.attribute("name", "");
|
||||
QString paintAttrType = paint.attribute("type", "");
|
||||
|
||||
if (paintAttrType == "media")
|
||||
if (paintAttrType == "media" || paintAttrType == "image")
|
||||
{
|
||||
QString uri = paint.firstChildElement("uri").text();
|
||||
QString x = paint.firstChildElement("x").text();
|
||||
QString y = paint.firstChildElement("y").text();
|
||||
|
||||
uid id = _window->createMediaPaint(paintAttrId.toInt(), uri, x.toFloat(), y.toFloat(),
|
||||
std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), false);
|
||||
if (id == NULL_UID)
|
||||
_xml.raiseError(QObject::tr("Cannot create media with uri %1.").arg(uri));
|
||||
}
|
||||
else if (paintAttrType == "image")
|
||||
{
|
||||
QString uri = paint.firstChildElement("uri").text();
|
||||
QString x = paint.firstChildElement("x").text();
|
||||
QString y = paint.firstChildElement("y").text();
|
||||
|
||||
uid id = _window->createMediaPaint(paintAttrId.toInt(), uri, x.toFloat(), y.toFloat(),
|
||||
std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), true);
|
||||
std::tr1::shared_ptr<Paint>(static_cast<Paint*>(0)), paintAttrType == "image");
|
||||
if (id == NULL_UID)
|
||||
_xml.raiseError(QObject::tr("Cannot create media with uri %1.").arg(uri));
|
||||
}
|
||||
|
||||
+22
-1
@@ -59,7 +59,7 @@ void ProjectWriter::writeItem(Paint *item)
|
||||
|
||||
if (item->getType() == "media")
|
||||
{
|
||||
// FIXME: check paint type before casting to Image
|
||||
// FIXME: check paint type before casting to Media
|
||||
Media *media = (Media *) item;
|
||||
|
||||
_xml.writeTextElement("uri", media->getUri());
|
||||
@@ -78,6 +78,27 @@ void ProjectWriter::writeItem(Paint *item)
|
||||
_xml.writeEndElement();
|
||||
//_xml.writeEmptyElement("hello");
|
||||
}
|
||||
else if (item->getType() == "image")
|
||||
{
|
||||
// FIXME: check paint type before casting to Image
|
||||
Image *media = (Image *) item;
|
||||
|
||||
_xml.writeTextElement("uri", media->getUri());
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << media->getX();
|
||||
_xml.writeTextElement("x", os.str().c_str());
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << media->getY();
|
||||
_xml.writeTextElement("y", os.str().c_str());
|
||||
}
|
||||
|
||||
_xml.writeEndElement();
|
||||
//_xml.writeEmptyElement("hello");
|
||||
}
|
||||
else if (item->getType() == "color")
|
||||
{
|
||||
// FIXME: check paint type before casting to Image
|
||||
|
||||
Reference in New Issue
Block a user