summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-26 12:53:26 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-26 12:53:26 (GMT)
commitdc04410eb678b8db257dc04b04662f974f6b3b83 (patch)
treeb14e8249f7f9bea1d463dad1b68c1538b5576b6f
parent60076b8e5dc557716e82d7588ff9a99247e485bf (diff)
downloadswift-contrib-dc04410eb678b8db257dc04b04662f974f6b3b83.zip
swift-contrib-dc04410eb678b8db257dc04b04662f974f6b3b83.tar.bz2
Fixed duplicating of polygons
-rw-r--r--Swift/QtUI/Whiteboard/GView.cpp5
-rw-r--r--Swift/QtUI/Whiteboard/GView.h1
-rw-r--r--Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h2
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.cpp2
4 files changed, 8 insertions, 2 deletions
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<std::pair<int, int> >::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;