[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello
Pierre Pettera
ppmakusu at gmail.com
Thu Jan 18 21:41:01 UTC 2007
SVN commit 625080 by pettera:
Undo / Redo Commit
Ajout de la commande undo/redo pour le déplacement d'un widget
=> A rajouter les commentaires plus tard :)
M +2 -0 CMakeLists.txt
M +1 -0 cmds.h
A cmds/cmd_moveWidget.cpp [License: GPL (v2+)]
A cmds/cmd_moveWidget.h [License: GPL (v2+)]
M +62 -11 umlwidgetcontroller.cpp
M +31 -18 umlwidgetcontroller.h
--- branches/work/isi-umbrello/umbrello/umbrello/CMakeLists.txt #625079:625080
@@ -230,6 +230,8 @@
cmds/classdiag/cmd_create_class.cpp
cmds/widgets/cmd_create_umlobject.cpp
+ cmds/cmd_moveWidget.cpp
+
)
kde4_automoc(${libclipboard_SRCS})
########### next target ###############
--- branches/work/isi-umbrello/umbrello/umbrello/cmds.h #625079:625080
@@ -24,6 +24,7 @@
#include "cmds/cmd_create_seqdiag.h"
#include "cmds/cmd_create_statediag.h"
#include "cmds/cmd_create_usecasediag.h"
+#include "cmds/cmd_moveWidget.h"
/************************************************************
* Widgets
--- branches/work/isi-umbrello/umbrello/umbrello/umlwidgetcontroller.cpp #625079:625080
@@ -32,6 +32,10 @@
#include "associationwidget.h"
#include "messagewidget.h"
+// own header
+#include "uml.h"
+
+#include "cmds.h"
using namespace Uml;
UMLWidgetController::UMLWidgetController(UMLWidget *widget) {
@@ -57,8 +61,11 @@
return;
}
+
+
if (me->button() == Qt::LeftButton) {
m_leftButtonDown = true;
+ //saveWidgetValues(me);
} else if (me->button() == Qt::RightButton) {
m_rightButtonDown = true;
} else {
@@ -144,6 +151,11 @@
diffY = m_oldY - m_widget->getY();
}
+/* Commands
+ UMLDoc* m_doc = UMLApp::app()->getDocument();
+ m_doc->executeCommand(new cmdMoveWidget(this,diffX,diffY));*/
+
+ // moveWidget(diffX,diffY);
constrainMovementForAllWidgets(diffX, diffY);
//Nothing to move
@@ -163,6 +175,10 @@
while ((widget = it.current()) != 0) {
++it;
+ //UMLDoc* m_doc = UMLApp::app()->getDocument();
+ //cmdMoveWidgetBy* cmd = new cmdMoveWidgetBy(widget,diffX,diffY);
+ //m_doc->executeCommand(cmd);
+ //m_doc->executeCommand(new cmdMoveWidgetBy(widget,diffX,diffY));
widget->getWidgetController()->moveWidgetBy(diffX, diffY);
}
@@ -177,8 +193,26 @@
m_widget->m_pView->resizeCanvasToItems();
updateSelectionBounds(diffX, diffY);
+
}
+void UMLWidgetController::widgetMoved()
+{ //reverseOldNewValues();
+ m_moved = false;
+ //Ensure associations are updated (the timer could prevent the
+ //adjustment in the last move event before the release)
+ UMLWidgetListIt it(m_selectedWidgetsList);
+ UMLWidget* widget;
+ it.toFirst();
+ while ((widget = it.current()) != 0) {
+ ++it;
+ widget->adjustAssocs(widget->getX(), widget->getY());
+ }
+
+ m_widget->m_bStartMove = false;
+}
+
+
void UMLWidgetController::mouseReleaseEvent(QMouseEvent *me) {
if (me->button() != Qt::LeftButton && me->button() != Qt::RightButton) {
if (m_middleButtonDown) {
@@ -197,19 +231,11 @@
}
} else {
if (m_moved) {
- m_moved = false;
- //Ensure associations are updated (the timer could prevent the
- //adjustment in the last move event before the release)
- UMLWidgetListIt it(m_selectedWidgetsList);
- UMLWidget* widget;
- it.toFirst();
- while ((widget = it.current()) != 0) {
- ++it;
- widget->adjustAssocs(widget->getX(), widget->getY());
- }
+/* Commands */
+ UMLDoc* m_doc = UMLApp::app()->getDocument();
+ m_doc->executeCommand(new cmdMoveWidget(this));
- m_widget->m_bStartMove = false;
} else {
m_resized = false;
}
@@ -257,6 +283,12 @@
}
}
+UMLWidget* UMLWidgetController::getWidget()
+{
+return m_widget;
+
+}
+
void UMLWidgetController::mouseDoubleClickEvent(QMouseEvent *me) {
if (me->button() != Qt::LeftButton) {
return;
@@ -343,6 +375,25 @@
m_oldH = m_widget->height();
}
+void UMLWidgetController::insertSaveValues(int _oldX, int _oldY, int X, int Y)
+{
+ m_widget->setX(X);
+ m_widget->setY(Y);
+ m_oldX = _oldX;
+ m_oldY = _oldY;
+}
+
+int UMLWidgetController::getOldX()
+{
+ return m_oldX;
+}
+
+int UMLWidgetController::getOldY()
+{
+ return m_oldY;
+}
+
+
void UMLWidgetController::setSelectionBounds() {
if (m_widget->m_pView->getSelectCount() > 0) {
m_selectedWidgetsList.clear();
--- branches/work/isi-umbrello/umbrello/umbrello/umlwidgetcontroller.h #625079:625080
@@ -22,6 +22,7 @@
class QMouseEvent;
class QMoveEvent;
class QPoint;
+class UMLDoc;
class UMLWidget;
@@ -177,6 +178,33 @@
*/
virtual void mouseDoubleClickEvent(QMouseEvent *me);
+ virtual void widgetMoved();
+int getOldX();
+int getOldY();
+void insertSaveValues(int _oldX, int _oldY, int X, int Y);
+
+ /**
+ * Moves the widget to a new position using the difference between the
+ * current position and the new position.
+ * This method doesn't adjust associations. It only moves the widget.
+ *
+ * It can be overridden to constrain movement of m_widget only in one axis even when
+ * the user isn't constraining the movement with shift or control buttons, for example.
+ * The movement policy set here is applied whenever the widget is moved, being it
+ * moving it explicitly, or as a part of a selection but not receiving directly the
+ * mouse events.
+ *
+ * Default behaviour is move the widget to the new position using the diffs.
+ * @see constrainMovementForAllWidgets
+ *
+ * @param diffX The difference between current X position and new X position.
+ * @param diffY The difference between current Y position and new Y position.
+ */
+ virtual void moveWidgetBy(int diffX, int diffY);
+
+virtual UMLWidget* getWidget();
+
+
protected:
/**
@@ -193,6 +221,8 @@
*/
virtual void saveWidgetValues(QMouseEvent *me);
+
+
/**
* Checks if the mouse is in resize area (right bottom corner), and sets
* the cursor depending on that.
@@ -225,25 +255,8 @@
*/
virtual void resizeWidget(int newW, int newH);
- /**
- * Moves the widget to a new position using the difference between the
- * current position and the new position.
- * This method doesn't adjust associations. It only moves the widget.
- *
- * It can be overridden to constrain movement of m_widget only in one axis even when
- * the user isn't constraining the movement with shift or control buttons, for example.
- * The movement policy set here is applied whenever the widget is moved, being it
- * moving it explicitly, or as a part of a selection but not receiving directly the
- * mouse events.
- *
- * Default behaviour is move the widget to the new position using the diffs.
- * @see constrainMovementForAllWidgets
- *
- * @param diffX The difference between current X position and new X position.
- * @param diffY The difference between current Y position and new Y position.
- */
- virtual void moveWidgetBy(int diffX, int diffY);
+
/**
* Modifies the value of the diffX and diffY variables used to move the widgets.
*
More information about the umbrello-devel
mailing list