diff options
Diffstat (limited to 'Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp')
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp index 0a1afe3..a53b0dd 100644 --- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp @@ -14,6 +14,7 @@ #include <Swiften/Whiteboard/WhiteboardSession.h> #include <Swiften/Elements/WhiteboardPayload.h> #include <Swiften/Whiteboard/Elements/WhiteboardLineElement.h> +#include <Swiften/Whiteboard/Elements/WhiteboardRectElement.h> #include <Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h> #include <QMessageBox> @@ -131,22 +132,6 @@ namespace Swift { void QtWhiteboardWindow::handleWhiteboardElementReceive(const WhiteboardElement::ref element) { WhiteboardElementDrawingVisitor visitor(graphicsView); element->accept(visitor); -/* - else if (mode == 'F') { - FreehandLineItem *freehandLineItem = new FreehandLineItem(); - getline(stream, temp, ','); - x1 = atoi(temp.c_str()); - getline(stream, temp, ','); - y1 = atoi(temp.c_str()); - freehandLineItem->setStartPoint(QPointF(x1, y1)); - while (getline(stream, temp, ',')) { - x1 = atoi(temp.c_str()); - getline(stream, temp, ','); - y1 = atoi(temp.c_str()); - freehandLineItem->lineTo(QPointF(x1, y1)); - } - graphicsView->scene()->addItem(freehandLineItem); - }*/ } void QtWhiteboardWindow::changeLineWidth(int i) @@ -259,7 +244,56 @@ namespace Swift { element->setID(freehandLineItem->data(0).toString().toStdString()); whiteboardSession_->sendElement(element); + } + + QGraphicsRectItem* rectItem = qgraphicsitem_cast<QGraphicsRectItem*>(item); + if (rectItem != 0) { + QRectF rect = rectItem->rect(); + WhiteboardRectElement::ref element = boost::make_shared<WhiteboardRectElement>(rect.x(), rect.y(), rect.width(), rect.height()); + QColor penColor = rectItem->pen().color(); + QColor brushColor = rectItem->brush().color(); + + element->setBrushColor(Color(brushColor.red(), brushColor.green(), brushColor.blue(), brushColor.alpha())); + element->setPenColor(Color(penColor.red(), penColor.green(), penColor.blue(), penColor.alpha())); + element->setPenWidth(rectItem->pen().width()); + + element->setID(rectItem->data(1).toString().toStdString()); + whiteboardSession_->sendElement(element); + } + + QGraphicsTextItem* textItem = qgraphicsitem_cast<QGraphicsTextItem*>(item); + if (textItem != 0) { + QPointF point = textItem->pos(); + WhiteboardTextElement::ref element = boost::make_shared<WhiteboardTextElement>(point.x(), point.y()); + element->setText(textItem->toPlainText().toStdString()); + + QColor color = textItem->defaultTextColor(); + element->setColor(Color(color.red(), color.green(), color.blue(), color.alpha())); + + element->setID(rectItem->data(0).toString().toStdString()); + whiteboardSession_->sendElement(element); + } + QGraphicsPolygonItem* polygonItem = qgraphicsitem_cast<QGraphicsPolygonItem*>(item); + if (polygonItem) { + WhiteboardPolygonElement::ref element = boost::make_shared<WhiteboardPolygonElement>(); + QPolygonF polygon = polygonItem->polygon(); + std::vector<std::pair<int, int> > points; + QVector<QPointF>::const_iterator it = polygon.begin(); + for (; it != polygon.end(); ++it) { + points.push_back(std::pair<int, int>(it->x(), it->y())); + } + + element->setPoints(points); + + QColor penColor = polygonItem->pen().color(); + QColor brushColor = polygonItem->brush().color(); + element->setPenColor(Color(penColor.red(), penColor.green(), penColor.blue(), penColor.alpha())); + element->setBrushColor(Color(brushColor.red(), brushColor.green(), brushColor.blue(), brushColor.alpha())); + element->setPenWidth(polygonItem->pen().width()); + + element->setID(polygonItem->data(0).toString().toStdString()); + whiteboardSession_->sendElement(element); } } |