- } else
- if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsRectItem") {
- QString rect = items.item(i).namedItem("content").attributes().namedItem("rect").nodeValue();
- QString br_str = items.item(i).namedItem("content").attributes().namedItem("brushcolor").nodeValue();
- QString pen_str = items.item(i).namedItem("content").attributes().namedItem("pencolor").nodeValue();
- double penwidth = items.item(i).namedItem("content").attributes().namedItem("penwidth").nodeValue().toDouble();
- QGraphicsRectItem *rec = scene->addRect(stringToRect(rect), QPen(QBrush(stringToColor(pen_str)), penwidth), QBrush(stringToColor(br_str)));
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsRectItem") {
+ QString rect = items.item(i).namedItem("content").attributes().namedItem("rect").nodeValue();
+ QString br_str = items.item(i).namedItem("content").attributes().namedItem("brushcolor").nodeValue();
+ QString pen_str = items.item(i).namedItem("content").attributes().namedItem("pencolor").nodeValue();
+ double penwidth = items.item(i).namedItem("content").attributes().namedItem("penwidth").nodeValue().toDouble();
+ QGraphicsRectItem *rec = m_scene->addRect(stringToRect(rect), QPen(QBrush(stringToColor(pen_str)), penwidth, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin), QBrush(stringToColor(br_str)));
+ gitem = rec;
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsPixmapItem") {
+ QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
+ QString base64 = items.item(i).namedItem("content").attributes().namedItem("base64").nodeValue();
+ QPixmap pix;
+ if (base64.isEmpty()) {
+ pix.load(url);
+ } else {
+ pix.loadFromData(QByteArray::fromBase64(base64.toAscii()));
+ }
+ QGraphicsPixmapItem *rec = m_scene->addPixmap(pix);
+ rec->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+ rec->setData(Qt::UserRole, url);
+ if (!base64.isEmpty()) {
+ rec->setData(Qt::UserRole + 1, base64);
+ }
+ gitem = rec;
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsSvgItem") {
+ QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
+ QString base64 = items.item(i).namedItem("content").attributes().namedItem("base64").nodeValue();
+ QGraphicsSvgItem *rec = NULL;
+ if (base64.isEmpty()) {
+ rec = new QGraphicsSvgItem(url);
+ } else {
+ rec = new QGraphicsSvgItem();
+ QSvgRenderer *renderer = new QSvgRenderer(QByteArray::fromBase64(base64.toAscii()), rec);
+ rec->setSharedRenderer(renderer);
+ //QString elem=rec->elementId();
+ //QRectF bounds = renderer->boundsOnElement(elem);
+ }
+ if (rec) {
+ m_scene->addItem(rec);
+ rec->setData(Qt::UserRole, url);
+ if (!base64.isEmpty()) {
+ rec->setData(Qt::UserRole + 1, base64);
+ }