summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-07-31 09:56:01 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-07-31 09:56:01 (GMT)
commit10c32b6e6ae334b5ad5280da6e526609e0e9370a (patch)
treed9b245724a4856148aa50854673c0b316803f0b1 /Swift
parent4321da432e3332e868abf07678f15d305fec2a4b (diff)
downloadswift-contrib-10c32b6e6ae334b5ad5280da6e526609e0e9370a.zip
swift-contrib-10c32b6e6ae334b5ad5280da6e526609e0e9370a.tar.bz2
Added removing of selection rect of items modified by other party
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Whiteboard/GView.cpp21
-rw-r--r--Swift/QtUI/Whiteboard/GView.h3
-rw-r--r--Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h6
3 files changed, 26 insertions, 4 deletions
diff --git a/Swift/QtUI/Whiteboard/GView.cpp b/Swift/QtUI/Whiteboard/GView.cpp
index 0fb42a0..d9c94a9 100644
--- a/Swift/QtUI/Whiteboard/GView.cpp
+++ b/Swift/QtUI/Whiteboard/GView.cpp
@@ -60,7 +60,7 @@ namespace Swift {
void GView::setMode(Mode mode) {
this->mode = mode;
lastItem = 0;
- unselect();
+ deselect();
}
void GView::addItem(QGraphicsItem* item, QString id, int pos) {
@@ -106,6 +106,7 @@ namespace Swift {
}
void GView::deleteItem(QString id) {
+ deselect(id);
QGraphicsItem* item = itemsMap_.value(id);
items_.removeOne(item);
itemsMap_.remove(id);
@@ -222,7 +223,7 @@ namespace Swift {
void GView::mousePressEvent(QMouseEvent *event)
{
mousePressed = true;
- unselect();
+ deselect();
if (mode == Line) {
QPointF point = this->mapToScene(event->pos());
QGraphicsItem* item = scene()->addLine(point.x(), point.y(), point.x(), point.y(), pen);
@@ -496,7 +497,7 @@ namespace Swift {
lineWidthChanged(pen.width());
}
- void GView::unselect() {
+ void GView::deselect() {
if (selectionRect != 0) {
pen = defaultPen;
brush = defaultBrush;
@@ -506,4 +507,18 @@ namespace Swift {
lineWidthChanged(pen.width());
}
}
+
+ void GView::deselect(QString id) {
+ if (selectionRect != 0) {
+ QGraphicsItem* item = getItem(id);
+ if (item && selectionRect->data(1).value<QGraphicsItem*>() == item) {
+ pen = defaultPen;
+ brush = defaultBrush;
+ scene()->removeItem(selectionRect);
+ delete selectionRect;
+ selectionRect = 0;
+ lineWidthChanged(pen.width());
+ }
+ }
+ }
}
diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h
index f0d4fef..8f3fdeb 100644
--- a/Swift/QtUI/Whiteboard/GView.h
+++ b/Swift/QtUI/Whiteboard/GView.h
@@ -39,6 +39,7 @@ namespace Swift {
void deleteItem(QString id);
QString getNewID();
void move(QGraphicsItem* item, int npos);
+ void deselect(QString id);
public slots:
void moveUpSelectedItem();
@@ -49,7 +50,7 @@ namespace Swift {
private:
void changePenAndBrush(QGraphicsItem* item, QPen pen, QBrush brush);
void setActualPenAndBrushFromItem(QGraphicsItem* item);
- void unselect();
+ void deselect();
int zValue;
bool mousePressed;
diff --git a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
index 3ca29bf..1041e84 100644
--- a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
+++ b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
@@ -30,6 +30,7 @@ namespace Swift {
QLineF line(element.x1(), element.y1(), element.x2(), element.y2());
item->setLine(line);
item->setPos(0,0);
+ graphicsView_->deselect(P2QSTRING(element.getID()));
}
if (item) {
QPen pen;
@@ -49,6 +50,7 @@ namespace Swift {
} else {
item = qgraphicsitem_cast<FreehandLineItem*>(graphicsView_->getItem(P2QSTRING(element.getID())));
item->setPos(0,0);
+ graphicsView_->deselect(P2QSTRING(element.getID()));
}
if (item) {
@@ -82,6 +84,7 @@ namespace Swift {
QRectF rect(element.getX(), element.getY(), element.getWidth(), element.getHeight());
item->setRect(rect);
item->setPos(0,0);
+ graphicsView_->deselect(P2QSTRING(element.getID()));
}
if (item) {
@@ -107,6 +110,7 @@ namespace Swift {
item->setData(100, id);
graphicsView_->addItem(item, id, pos_);
}
+ graphicsView_->deselect(P2QSTRING(element.getID()));
QPen pen;
QBrush brush(Qt::SolidPattern);
Color penColor = element.getPenColor();
@@ -134,6 +138,7 @@ namespace Swift {
graphicsView_->addItem(item, id, pos_);
} else {
item = qgraphicsitem_cast<QGraphicsTextItem*>(graphicsView_->getItem(id));
+ graphicsView_->deselect(P2QSTRING(element.getID()));
}
if (item) {
item->setPlainText(P2QSTRING(element.getText()));
@@ -160,6 +165,7 @@ namespace Swift {
item = qgraphicsitem_cast<QGraphicsEllipseItem*>(graphicsView_->getItem(id));
item->setRect(rect);
item->setPos(0,0);
+ graphicsView_->deselect(P2QSTRING(element.getID()));
}
QPen pen;
QBrush brush(Qt::SolidPattern);