[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Wed Jun 6 16:30:18 CEST 2007
SVN commit 672247 by treat:
* Movement commands for all items are done, compression
is enabled and macro commands for selection moves completed.
M +0 -15 labelitem.cpp
M +0 -4 labelitem.h
M +22 -10 view.cpp
M +10 -0 viewitem.cpp
M +6 -0 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #672246:672247
@@ -62,21 +62,6 @@
}
-void LabelItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
- QGraphicsRectItem::mousePressEvent(event);
- _originalPos = pos();
-}
-
-
-void LabelItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
- QGraphicsRectItem::mouseReleaseEvent(event);
-
- QPointF newPos = pos();
- if (_originalPos != newPos)
- new MoveCommand(this, _originalPos, newPos);
-}
-
-
void LabelItem::creationPolygonChanged(View::CreationEvent event) {
if (event == View::MousePress) {
const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #672246:672247
@@ -31,10 +31,6 @@
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
- protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
-
private Q_SLOTS:
void creationPolygonChanged(View::CreationEvent event);
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #672246:672247
@@ -100,29 +100,41 @@
bool View::eventFilter(QObject *obj, QEvent *event) {
- if (obj != scene() || _mouseMode != Create)
+ if (obj != scene())
return QGraphicsView::eventFilter(obj, event);
switch (event->type()) {
case QEvent::GraphicsSceneMousePress:
{
- QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
- _creationPolygonPress << e->buttonDownScenePos(Qt::LeftButton);
- emit creationPolygonChanged(MousePress);
+ if (_mouseMode == Create) {
+ QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
+ _creationPolygonPress << e->buttonDownScenePos(Qt::LeftButton);
+ emit creationPolygonChanged(MousePress);
+ }
return false;
}
case QEvent::GraphicsSceneMouseRelease:
{
- QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
- _creationPolygonRelease << e->scenePos();
- emit creationPolygonChanged(MouseRelease);
+ if (_mouseMode == Create) {
+ QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
+ _creationPolygonRelease << e->scenePos();
+ emit creationPolygonChanged(MouseRelease);
+ } else if (_mouseMode == Move) {
+ setMouseMode(Default);
+ _undoStack->endMacro();
+ }
return false;
}
case QEvent::GraphicsSceneMouseMove:
{
- QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
- _creationPolygonMove << e->scenePos();
- emit creationPolygonChanged(MouseMove);
+ if (_mouseMode == Create) {
+ QGraphicsSceneMouseEvent *e = static_cast<QGraphicsSceneMouseEvent*>(event);
+ _creationPolygonMove << e->scenePos();
+ emit creationPolygonChanged(MouseMove);
+ } else if (_mouseMode == Default && scene()->mouseGrabberItem()) {
+ setMouseMode(Move);
+ _undoStack->beginMacro(tr("Move"));
+ }
return false;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #672246:672247
@@ -29,6 +29,8 @@
_rectItem->setBrush(semiRed);
parent->scene()->addItem(_rectItem);
#endif
+
+ connect(parent, SIGNAL(mouseModeChanged()), this, SLOT(mouseModeChanged()));
}
@@ -41,6 +43,14 @@
}
+void ViewItem::mouseModeChanged() {
+ if (parentView()->mouseMode() == View::Move)
+ _originalPosition = graphicsItem()->pos();
+ else if (_originalPosition != graphicsItem()->pos())
+ new MoveCommand(this, _originalPosition, graphicsItem()->pos());
+}
+
+
#ifdef DEBUG_GEOMETRY
void ViewItem::debugGeometry() {
_rectItem->setRect(graphicsItem()->boundingRect());
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #672246:672247
@@ -37,6 +37,12 @@
Q_SIGNALS:
void creationComplete();
+private Q_SLOTS:
+ void mouseModeChanged();
+
+private:
+ QPointF _originalPosition;
+
#ifdef DEBUG_GEOMETRY
protected:
void debugGeometry();
More information about the Kst
mailing list