From dc04410eb678b8db257dc04b04662f974f6b3b83 Mon Sep 17 00:00:00 2001 From: Mateusz Piekos Date: Tue, 26 Jun 2012 14:53:26 +0200 Subject: Fixed duplicating of polygons diff --git a/Swift/QtUI/Whiteboard/GView.cpp b/Swift/QtUI/Whiteboard/GView.cpp index a450808..588f369 100644 --- a/Swift/QtUI/Whiteboard/GView.cpp +++ b/Swift/QtUI/Whiteboard/GView.cpp @@ -50,6 +50,11 @@ namespace Swift { return items_.value(id); } + void GView::addItem(QGraphicsItem* item, QString id) { + scene()->addItem(item); + items_.insert(id, item); + } + void GView::mouseMoveEvent(QMouseEvent* event) { if (!mousePressed) { diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h index 1a4dc42..8b416a1 100644 --- a/Swift/QtUI/Whiteboard/GView.h +++ b/Swift/QtUI/Whiteboard/GView.h @@ -32,6 +32,7 @@ namespace Swift { void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); QGraphicsItem* getItem(const QString id) const; + void addItem(QGraphicsItem* item, QString id); public slots: void moveUpSelectedItem(); diff --git a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h index 214ea10..f3d2526 100644 --- a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h +++ b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h @@ -74,7 +74,7 @@ namespace Swift { brush.setColor(QColor(brushColor.getRed(), brushColor.getGreen(), brushColor.getBlue(), brushColor.getAlpha())); item->setPen(pen); item->setBrush(brush); - graphicsView_->scene()->addItem(item); + graphicsView_->addItem(item, P2QSTRING(element.getID())); } QPolygonF polygon; std::vector >::const_iterator it = element.getPoints().begin(); diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index aca3103..0477988 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -164,7 +164,7 @@ namespace Swift { brushColor.setAlpha(opacityToAlpha(attributes.getAttributeValue("fill-opacity").get_value_or("1"))); whiteboardElement->setPenColor(penColor); whiteboardElement->setBrushColor(brushColor); - + whiteboardElement->setID(attributes.getAttributeValue("id").get_value_or("")); getPayloadInternal()->setElement(whiteboardElement); } else if (element == "text") { int x = 0; -- cgit v0.10.2-6-g49f6