summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp')
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp45
1 files changed, 8 insertions, 37 deletions
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
index 80c4447..24eb6cf 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
@@ -14,6 +14,8 @@
#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>
using namespace std;
@@ -127,24 +129,10 @@ namespace Swift {
setSession(whiteboardSession);
}
- void QtWhiteboardWindow::addItem(const std::string& item) {
- string temp;
- char mode;
- int x1, x2, y1, y2;
- std::istringstream stream(item);
- stream.get(mode);
- if (mode == 'L') {
- getline(stream, temp, ',');
- x1 = atoi(temp.c_str());
- getline(stream, temp, ',');
- y1 = atoi(temp.c_str());
- getline(stream, temp, ',');
- x2 = atoi(temp.c_str());
- getline(stream, temp, ',');
- y2 = atoi(temp.c_str());
- QGraphicsLineItem *lineItem = new QGraphicsLineItem(x1, y1, x2, y2);
- graphicsView->scene()->addItem(lineItem);
- }
+ void QtWhiteboardWindow::handleWhiteboardElementReceive(const WhiteboardElement::ref element) {
+ WhiteboardElementDrawingVisitor visitor(graphicsView);
+ element->accept(visitor);
+/*
else if (mode == 'F') {
FreehandLineItem *freehandLineItem = new FreehandLineItem();
getline(stream, temp, ',');
@@ -159,7 +147,7 @@ namespace Swift {
freehandLineItem->lineTo(QPointF(x1, y1));
}
graphicsView->scene()->addItem(freehandLineItem);
- }
+ }*/
}
void QtWhiteboardWindow::changeLineWidth(int i)
@@ -233,7 +221,7 @@ namespace Swift {
void QtWhiteboardWindow::setSession(WhiteboardSession::ref session) {
whiteboardSession_ = session;
- whiteboardSession_->onDataReceived.connect(boost::bind(&QtWhiteboardWindow::addItem, this, _1));
+ whiteboardSession_->onElementReceived.connect(boost::bind(&QtWhiteboardWindow::handleWhiteboardElementReceive, this, _1));
whiteboardSession_->onRequestAccepted.connect(boost::bind(&QWidget::show, this));
whiteboardSession_->onSessionTerminateReceived.connect(boost::bind(&QtWhiteboardWindow::handleSessionTerminate, this));
}
@@ -247,10 +235,6 @@ namespace Swift {
QGraphicsLineItem* lineItem = qgraphicsitem_cast<QGraphicsLineItem*>(item);
if (lineItem != 0) {
QLine line = lineItem->line().toLine();
-/* std::stringstream stream;
- stream << "L";
- stream << line.x1() << "," << line.y1() << "," << line.x2() << "," << line.y2();
- stream >> serialized;*/
WhiteboardLineElement::ref element = boost::make_shared<WhiteboardLineElement>(line.x1(), line.y1(), line.x2(), line.y2());
whiteboardSession_->sendElement(element);
@@ -258,8 +242,6 @@ namespace Swift {
FreehandLineItem* freehandLineItem = qgraphicsitem_cast<FreehandLineItem*>(item);
if (freehandLineItem != 0) {
QVector<QPointF> points = freehandLineItem->points();
-
-
QVector<QPointF>::iterator it;
std::stringstream stream;
stream << "F";
@@ -269,17 +251,6 @@ namespace Swift {
}
stream >> serialized;
}
- if (!serialized.empty()) {
- cout << "serialized: " << serialized << endl;
-/* boost::shared_ptr<Message> mes(new Message());
- mes->setTo(jid_);
- boost::shared_ptr<WhiteboardPayload> wbPayload(new WhiteboardPayload);
- wbPayload->setData(serialized);
-// mes->setType(Swift::Message::Chat);
- mes->addPayload(wbPayload);
-// stanzaChannel_->sendMessage(mes);*/
- whiteboardSession_->sendData(serialized);
- }
}
void QtWhiteboardWindow::handleSessionTerminate() {