summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-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);
}