summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-18 10:55:55 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-18 10:55:55 (GMT)
commite0c79b3b885f126a2a2a34cb0d5df90796821130 (patch)
treed53e7a822a02ebc7ae136d01db18475be4283854 /Swift/QtUI
parentf3cc4c80787657ea770468915ec716dea2676d22 (diff)
downloadswift-contrib-e0c79b3b885f126a2a2a34cb0d5df90796821130.zip
swift-contrib-e0c79b3b885f126a2a2a34cb0d5df90796821130.tar.bz2
Completed serialization and parsing of line element
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/Whiteboard/GView.cpp4
-rw-r--r--Swift/QtUI/Whiteboard/GView.h4
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp6
-rw-r--r--Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h5
4 files changed, 16 insertions, 3 deletions
diff --git a/Swift/QtUI/Whiteboard/GView.cpp b/Swift/QtUI/Whiteboard/GView.cpp
index 634ff75..478dee0 100644
--- a/Swift/QtUI/Whiteboard/GView.cpp
+++ b/Swift/QtUI/Whiteboard/GView.cpp
@@ -57,6 +57,7 @@ namespace Swift {
QLineF line = item->line();
line.setP1(this->mapToScene(event->pos()));
item->setLine(line);
+
}
}
else if (mode == Rect) {
@@ -142,7 +143,10 @@ namespace Swift {
if (mode == Line) {
QPointF point = this->mapToScene(event->pos());
QGraphicsItem* item = scene()->addLine(point.x(), point.y(), point.x(), point.y(), pen);
+ QString id = QString::fromStdString(idGenerator.generateID());
item->setZValue(zValue++);
+ item->setData(0, id);
+ items_.insert(id, item);
lastItem = item;
}
diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h
index 6a141ee..74da7a4 100644
--- a/Swift/QtUI/Whiteboard/GView.h
+++ b/Swift/QtUI/Whiteboard/GView.h
@@ -11,12 +11,11 @@
#include <QMouseEvent>
#include <QPen>
#include <iostream>
+#include <Swiften/Base/SimpleIDGenerator.h>
#include "TextDialog.h"
#include "FreehandLineItem.h"
-using namespace std;
-
namespace Swift {
class GView : public QGraphicsView {
Q_OBJECT;
@@ -47,6 +46,7 @@ namespace Swift {
QGraphicsRectItem* selectionRect;
TextDialog* textDialog;
QHash<QString, QGraphicsItem*> items_;
+ SimpleIDGenerator idGenerator;
signals:
void lastItemChanged(QGraphicsItem* item);
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
index 24eb6cf..612e467 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
@@ -14,7 +14,6 @@
#include <Swiften/Whiteboard/WhiteboardSession.h>
#include <Swiften/Elements/WhiteboardPayload.h>
#include <Swiften/Whiteboard/Elements/WhiteboardLineElement.h>
-#include <Swiften/Base/SimpleIDGenerator.h>
#include <Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h>
#include <QMessageBox>
@@ -235,7 +234,12 @@ namespace Swift {
QGraphicsLineItem* lineItem = qgraphicsitem_cast<QGraphicsLineItem*>(item);
if (lineItem != 0) {
QLine line = lineItem->line().toLine();
+ QColor color = lineItem->pen().color();
WhiteboardLineElement::ref element = boost::make_shared<WhiteboardLineElement>(line.x1(), line.y1(), line.x2(), line.y2());
+ element->setColor(Color(color.red(), color.green(), color.blue(), color.alpha()));
+ element->setPenWidth(lineItem->pen().width());
+
+ element->setID(lineItem->data(0).toString().toStdString());
whiteboardSession_->sendElement(element);
}
diff --git a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
index 962fd79..a1715bc 100644
--- a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
+++ b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
@@ -17,6 +17,11 @@ namespace Swift {
void visit(const WhiteboardLineElement* element) {
QGraphicsLineItem *item = new QGraphicsLineItem(element->x1(), element->y1(), element->x2(), element->y2());
+ QPen pen;
+ Color color = element->getColor();
+ pen.setColor(QColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
+ pen.setWidth(element->getPenWidth());
+ item->setPen(pen);
graphicsView_->scene()->addItem(item);
}