summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Whiteboard/GView.cpp')
-rw-r--r--Swift/QtUI/Whiteboard/GView.cpp21
1 files changed, 18 insertions, 3 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());
+ }
+ }
+ }
}