- 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), 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);
- gitem->setTransform(stringToTransform(items.item(i).namedItem("position").firstChild().firstChild().nodeValue()));
- 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 (items.item(i).nodeName() == "background") {
- QColor color = QColor(stringToColor(items.item(i).attributes().namedItem("color").nodeValue()));
- //color.setAlpha(items.item(i).attributes().namedItem("alpha").nodeValue().toInt());
- QList<QGraphicsItem *> items = m_scene->items();
- for (int i = 0; i < items.size(); i++) {
- if (items.at(i)->zValue() == -1100) {
- ((QGraphicsRectItem *)items.at(i))->setBrush(QBrush(color));
- break;
- }
- }
- } /*else if (items.item(i).nodeName() == "startviewport" && startv) {
- QPointF p(items.item(i).attributes().namedItem("x").nodeValue().toDouble(), items.item(i).attributes().namedItem("y").nodeValue().toDouble());
- double width = items.item(i).attributes().namedItem("size").nodeValue().toDouble();
- QRectF rect(-width, -width / aspect_ratio, width*2.0, width / aspect_ratio*2.0);
- kDebug() << width << rect;
- startv->setPolygon(rect);
- startv->setPos(p);
- } else if (items.item(i).nodeName() == "endviewport" && endv) {
- QPointF p(items.item(i).attributes().namedItem("x").nodeValue().toDouble(), items.item(i).attributes().namedItem("y").nodeValue().toDouble());
- double width = items.item(i).attributes().namedItem("size").nodeValue().toDouble();
- QRectF rect(-width, -width / aspect_ratio, width*2.0, width / aspect_ratio*2.0);
- kDebug() << width << rect;
- endv->setPolygon(rect);
- endv->setPos(p);
- }*/
- }
- }
- return maxZValue;
+ 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 ), 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 );
+ gitem->setTransform( stringToTransform( items.item( i ).namedItem( "position" ).firstChild().firstChild().nodeValue() ) );
+ 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 ( items.item( i ).nodeName() == "background" )
+ {
+ QColor color = QColor( stringToColor( items.item( i ).attributes().namedItem( "color" ).nodeValue() ) );
+ //color.setAlpha(items.item(i).attributes().namedItem("alpha").nodeValue().toInt());
+ QList<QGraphicsItem *> items = m_scene->items();
+ for ( int i = 0; i < items.size(); i++ )
+ {
+ if ( items.at( i )->zValue() == -1100 )
+ {
+ (( QGraphicsRectItem * )items.at( i ) )->setBrush( QBrush( color ) );
+ break;
+ }
+ }
+ }
+ else if ( items.item( i ).nodeName() == "startviewport" && startv )
+ {
+ QString rect = items.item( i ).attributes().namedItem( "rect" ).nodeValue();
+ startv->setPolygon( stringToRect( rect ) );
+ }
+ else if ( items.item( i ).nodeName() == "endviewport" && endv )
+ {
+ QString rect = items.item( i ).attributes().namedItem( "rect" ).nodeValue();
+ endv->setPolygon( stringToRect( rect ) );
+ }
+ }
+ }
+ return maxZValue;