[Uml-devel] KDE/kdesdk/umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Sun Sep 23 08:23:18 UTC 2012


SVN commit 1317478 by fischer:

Background grid from gsoc-branch added.

 M  +1 -0      CMakeLists.txt  
 M  +17 -21    umlscene.cpp  
 M  +7 -12     umlscene.h  
 A             widgets/layoutgrid.cpp   [License: GPL (v2+)]
 A             widgets/layoutgrid.h   [License: GPL (v2+)]


--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1317477:1317478
@@ -373,6 +373,7 @@
     widgets/floatingdashlinewidget.cpp
     widgets/floatingtextwidget.cpp
     widgets/forkjoinwidget.cpp
+    widgets/layoutgrid.cpp
     widgets/linkwidget.cpp
     widgets/messagewidget.cpp
     widgets/nodewidget.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.cpp #1317477:1317478
@@ -37,6 +37,7 @@
 #include "forkjoinwidget.h"
 #include "idchangelog.h"
 #include "layoutgenerator.h"
+#include "layoutgrid.h"
 #include "listpopupmenu.h"
 #include "messagewidget.h"
 #include "model_utils.h"
@@ -96,7 +97,7 @@
 */
 
 // system includes
-#include <cmath>
+#include <cmath>  // for ceil
 
 // static members
 const UMLSceneValue UMLScene::defaultCanvasSize = 5000;
@@ -117,9 +118,6 @@
     m_bUseSnapToGrid(false),
     m_bUseSnapComponentSizeToGrid(false),
     m_isOpen(true),
-    m_nSnapX(10),
-    m_nSnapY(10),
-    m_bShowSnapGrid(false),
     m_nCollaborationId(0),
     m_bCreateObject(false),
     m_bDrawSelectedOnly(false),
@@ -151,6 +149,11 @@
 
     m_doc = UMLApp::app()->document();
 
+//    // settings for background
+//    setBackgroundBrush(QColor(195, 195, 195));
+    m_layoutGrid = new LayoutGrid();
+    addItem(m_layoutGrid);
+
     DEBUG_REGISTER(DBG_SRC);
 }
 
@@ -1610,7 +1613,6 @@
                 static_cast<FloatingTextWidget*>(widget)->textRole() != Uml::TextRole::Floating) {
             m_selectedList.removeAt(m_selectedList.indexOf(widget));
             widget->hide();
-
         } else {
             removeWidget(widget);
         }
@@ -1864,7 +1866,6 @@
 
     setSnapGridVisible(showSnapGrid);
 
-    setAllChanged();
     //select again
     foreach(UMLWidget* widget, selected) {
         widget->setSelected(true);
@@ -3777,7 +3778,7 @@
  */
 int UMLScene::snapX() const
 {
-    return m_nSnapX;
+    return m_layoutGrid->gridSpacingX();
 }
 
 /**
@@ -3785,7 +3786,7 @@
  */
 int UMLScene::snapY() const
 {
-    return m_nSnapY;
+    return m_layoutGrid->gridSpacingY();
 }
 
 /**
@@ -3793,9 +3794,7 @@
  */
 void UMLScene::setSnapSpacing(int x, int y)
 {
-    m_nSnapX = x;
-    m_nSnapY = y;
-    setAllChanged();
+    m_layoutGrid->setGridSpacing(x, y);
 }
 
 /**
@@ -3835,7 +3834,7 @@
  */
 bool UMLScene::isSnapGridVisible() const
 {
-    return m_bShowSnapGrid;
+    return m_layoutGrid->isVisible();
 }
 
 /**
@@ -3843,9 +3842,8 @@
  */
 void UMLScene::setSnapGridVisible(bool bShow)
 {
-    m_bShowSnapGrid = bShow;
+    m_layoutGrid->setVisible(bShow);
     emit sigShowGridToggled(bShow);
-    setAllChanged();
 }
 
 /**
@@ -3954,11 +3952,11 @@
     Settings::saveToXMI(viewElement, m_Options);
     //misc
     viewElement.setAttribute("localid", ID2STR(m_nLocalID));
-    viewElement.setAttribute("showgrid", m_bShowSnapGrid);
+    viewElement.setAttribute("showgrid", m_layoutGrid->isVisible());
     viewElement.setAttribute("snapgrid", m_bUseSnapToGrid);
     viewElement.setAttribute("snapcsgrid", m_bUseSnapComponentSizeToGrid);
-    viewElement.setAttribute("snapx", m_nSnapX);
-    viewElement.setAttribute("snapy", m_nSnapY);
+    viewElement.setAttribute("snapx", m_layoutGrid->gridSpacingX());
+    viewElement.setAttribute("snapy", m_layoutGrid->gridSpacingY());
     // FIXME: move to UMLView
     viewElement.setAttribute("zoom", activeView()->zoom());
     viewElement.setAttribute("canvasheight", height());
@@ -4027,7 +4025,7 @@
     setGridDotColor(m_Options.uiState.gridDotColor);
     //misc
     QString showgrid = qElement.attribute("showgrid", "0");
-    m_bShowSnapGrid = (bool)showgrid.toInt();
+    m_layoutGrid->setVisible((bool)showgrid.toInt());
 
     QString snapgrid = qElement.attribute("snapgrid", "0");
     m_bUseSnapToGrid = (bool)snapgrid.toInt();
@@ -4036,10 +4034,8 @@
     m_bUseSnapComponentSizeToGrid = (bool)snapcsgrid.toInt();
 
     QString snapx = qElement.attribute("snapx", "10");
-    m_nSnapX = snapx.toInt();
-
     QString snapy = qElement.attribute("snapy", "10");
-    m_nSnapY = snapy.toInt();
+    m_layoutGrid->setGridSpacing(snapx.toInt(), snapy.toInt());
 
     QString zoom = qElement.attribute("zoom", "100");
     activeView()->setZoom(zoom.toInt());
--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.h #1317477:1317478
@@ -34,9 +34,12 @@
 // forward declarations
 class ClassOptionsPage;
 class IDChangeLog;
+class LayoutGrid;
 class ListPopupMenu;
 class FloatingTextWidget;
 class ObjectWidget;
+class ToolBarState;
+class ToolBarStateFactory;
 class UMLFolder;
 class UMLApp;
 class UMLDoc;
@@ -47,8 +50,6 @@
 class UMLForeignKeyConstraint;
 class UMLEntity;
 class UMLView;
-class ToolBarState;
-class ToolBarStateFactory;
 
 class QCloseEvent;
 class QDragEnterEvent;
@@ -512,7 +513,6 @@
 
 protected:
 
-    void setAllChanged() {}
     // Methods and members related to loading/saving
 
     bool loadWidgetsFromXMI(QDomElement & qElement);
@@ -540,12 +540,6 @@
     bool m_bUseSnapComponentSizeToGrid;  ///< Flag to use snap to grid for component size. The default is off.
     bool m_isOpen;  ///< Flag is set to true when diagram is open, i.e. shown to the user.
 
-    int m_nSnapX;  ///< The snap to grid x size.
-    int m_nSnapY;  ///< The snap to grid y size.
-    bool m_bShowSnapGrid;  ///< Determines whether to show the snap grid. The default will be on if the grid is on.
-    int m_nCanvasWidth;    ///< Width of canvas in pixels.
-    int m_nCanvasHeight;   ///< Height of canvas in pixels.
-
     // End of methods and members related to loading/saving
     ////////////////////////////////////////////////////////////////////////
 
@@ -586,14 +580,15 @@
     UMLView *m_view;   ///< The view to which this scene is related.
     UMLFolder *m_pFolder;  ///< The folder in which this UMLView is contained.
 
+    ToolBarStateFactory* m_pToolBarStateFactory;
+    ToolBarState* m_pToolBarState;
     IDChangeLog * m_pIDChangesLog;  ///< LocalID Changes Log for paste actions
     bool m_isActivated;             ///< True if the view was activated after the serialization(load).
     bool m_bPopupShowing;           ///< Status of a popupmenu on view. True - a popup is on view.
     UMLScenePoint m_PastePoint;     ///< The offset at which to paste the clipboard.
     UMLDoc* m_doc;                  ///< Pointer to the UMLDoc.
     UMLViewImageExporter* m_pImageExporter;  ///< Used to export the view.
-    ToolBarState *m_pToolBarState;
-    ToolBarStateFactory *m_pToolBarStateFactory;
+    LayoutGrid*  m_layoutGrid;      ///< layout grid in the background
 
     void createAutoAttributeAssociation(UMLClassifier *type,
                                         UMLAttribute *attr,
@@ -644,4 +639,4 @@
 
 QDebug operator<<(QDebug dbg, UMLScene *item);
 
-#endif
+#endif // UMLSCENE_H




More information about the umbrello-devel mailing list