summaryrefslogtreecommitdiffstats
path: root/sigmodr/widgets
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-04-28 01:46:28 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-04-28 01:46:28 -0400
commitb69c4e1979e9820599b04c44978794a72b1bdc43 (patch)
treedbd3239ae993cb821e1ae08240ea554cba1fe5ca /sigmodr/widgets
parent97c8f1182a3bc40e9c28c9987a4361748bf140e7 (diff)
downloadsigen-b69c4e1979e9820599b04c44978794a72b1bdc43.tar.gz
sigen-b69c4e1979e9820599b04c44978794a72b1bdc43.tar.xz
sigen-b69c4e1979e9820599b04c44978794a72b1bdc43.zip
Enable placement algorithm and fix old code
Diffstat (limited to 'sigmodr/widgets')
-rw-r--r--sigmodr/widgets/mapeditor/WorldMapItem.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/sigmodr/widgets/mapeditor/WorldMapItem.cpp b/sigmodr/widgets/mapeditor/WorldMapItem.cpp
index c956d4cc..8a3f3f3d 100644
--- a/sigmodr/widgets/mapeditor/WorldMapItem.cpp
+++ b/sigmodr/widgets/mapeditor/WorldMapItem.cpp
@@ -126,19 +126,25 @@ void WorldMapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
void WorldMapItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
-// QList<QGraphicsItem*> items = scene()->items();
-// QtConcurrent::blockingFilter(items, isSetWorldMapItem);
-// items.removeAll(this);
-// if (items.size())
-// {
-// WorldMapPlacement placement(QSize(m_map->width(), m_map->height()));
-// foreach (QGraphicsItem* item, items)
-// placement.addRect(item->boundingRect().adjusted(1, 1, -1, -1).toRect());
-// setPos(placement.find((event->scenePos() - event->buttonDownPos(Qt::LeftButton)).toPoint()));
-// event->accept();
-// }
-// else
- QGraphicsItem::mouseMoveEvent(event);
+ QList<QGraphicsItem*> items = scene()->items();
+ QList<QGraphicsItem*> cItems = scene()->items(QRectF(event->scenePos() - event->buttonDownPos(Qt::LeftButton), QSizeF(m_map->width(), m_map->height())));
+ QtConcurrent::blockingFilter(items, isSetWorldMapItem);
+ QtConcurrent::blockingFilter(cItems, isSetWorldMapItem);
+ items.removeAll(this);
+ cItems.removeAll(this);
+ if (cItems.size())
+ {
+ WorldMapPlacement placement(QSize(m_map->width(), m_map->height()));
+ foreach (QGraphicsItem* item, items)
+ {
+ WorldMapItem* mapItem = qgraphicsitem_cast<WorldMapItem*>(item);
+ placement.addRect(QRectF(item->scenePos(), QSizeF(mapItem->m_map->width(), mapItem->m_map->height())));
+ }
+ setPos(placement.find(((QPointF(m_map->width(), m_map->height()) / 2.) + event->scenePos() - event->buttonDownPos(Qt::LeftButton)).toPoint()));
+ }
+ else
+ setPos(event->scenePos() - event->buttonDownPos(Qt::LeftButton));
+ event->accept();
moveTo(scenePos().toPoint());
update();
}
@@ -160,7 +166,7 @@ void WorldMapItem::keyPressEvent(QKeyEvent* event)
m_locked = !m_locked;
setFlag(ItemIsMovable, !m_locked);
update();
-// WorldMapPlacement::invalidateCache();
+ WorldMapPlacement::invalidateCache();
return;
}
}