+ gitem = txt;
+ } 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();
+ QPixmap pix(url);
+ QGraphicsPixmapItem *rec = m_scene->addPixmap(pix);
+ rec->setData(Qt::UserRole, url);
+ gitem = rec;
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsSvgItem") {
+ QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
+ QGraphicsSvgItem *rec = new QGraphicsSvgItem(url);
+ m_scene->addItem(rec);
+ rec->setData(Qt::UserRole, url);
+ gitem = rec;
+ }
+ }
+ //pos and transform
+ if (gitem) {
+ QPointF p(items.item(i).namedItem("position").attributes().namedItem("x").nodeValue().toDouble(),
+ items.item(i).namedItem("position").attributes().namedItem("y").nodeValue().toDouble());
+ gitem->setPos(p);
+ QDomElement trans = items.item(i).namedItem("position").firstChild().toElement();
+ gitem->setTransform(stringToTransform(trans.firstChild().nodeValue()));
+ QString rotate = trans.attribute("rotation");
+ if (!rotate.isEmpty()) gitem->setData(ROTATEFACTOR, stringToList(rotate));
+ QString zoom = trans.attribute("zoom");
+ if (!zoom.isEmpty()) gitem->setData(ZOOMFACTOR, zoom.toInt());
+ int zValue = items.item(i).attributes().namedItem("z-index").nodeValue().toInt();
+ if (zValue > maxZValue) maxZValue = zValue;
+ gitem->setZValue(zValue);
+ gitem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+
+#if QT_VERSION >= 0x040600
+ // effects
+ QDomNode eff = items.item(i).namedItem("effect");
+ if (!eff.isNull()) {
+ QDomElement e = eff.toElement();
+ if (e.attribute("type") == "blur") {
+ QGraphicsBlurEffect *blur = new QGraphicsBlurEffect();
+ blur->setBlurRadius(e.attribute("blurradius").toInt());
+ gitem->setGraphicsEffect(blur);
+ } else if (e.attribute("type") == "shadow") {
+ QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
+ shadow->setBlurRadius(e.attribute("blurradius").toInt());
+ shadow->setOffset(e.attribute("xoffset").toInt(), e.attribute("yoffset").toInt());
+ gitem->setGraphicsEffect(shadow);
+ }
+ }
+#endif
+ }