Some fixes for the Graphics dialogs. 5_2_x

Sat, 08 Sep 2012 18:28:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 08 Sep 2012 18:28:46 +0200
branch
5_2_x
changeset 2029
51e8278f2c3d
parent 2022
674ef50b5004
child 2043
77954c09aacc

Some fixes for the Graphics dialogs.

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric5.E5Graphics.E5GraphicsView.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.E5Gui.E5MessageBox.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.UMLDialog.html file | annotate | diff | comparison | revisions
E5Graphics/E5GraphicsView.py file | annotate | diff | comparison | revisions
Graphics/PackageDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLClassDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLDialog.py file | annotate | diff | comparison | revisions
Graphics/UMLGraphicsView.py file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric5.E5Graphics.E5GraphicsView.html	Tue Sep 04 11:41:07 2012 +0200
+++ b/Documentation/Source/eric5.E5Graphics.E5GraphicsView.html	Sat Sep 08 18:28:46 2012 +0200
@@ -238,10 +238,10 @@
 </p><dl>
 <dt><i>width</i></dt>
 <dd>
-width for the scene (integer)
+width for the scene (float)
 </dd><dt><i>height</i></dt>
 <dd>
-height for the scene (integer)
+height for the scene (float)
 </dd>
 </dl><a NAME="E5GraphicsView.setZoom" ID="E5GraphicsView.setZoom"></a>
 <h4>E5GraphicsView.setZoom</h4>
--- a/Documentation/Source/eric5.E5Gui.E5MessageBox.html	Tue Sep 04 11:41:07 2012 +0200
+++ b/Documentation/Source/eric5.E5Gui.E5MessageBox.html	Sat Sep 08 18:28:46 2012 +0200
@@ -26,7 +26,7 @@
 </p>
 <h3>Global Attributes</h3>
 <table>
-<tr><td>Abort</td></tr><tr><td>AcceptRole</td></tr><tr><td>ActionRole</td></tr><tr><td>Apply</td></tr><tr><td>ApplyRole</td></tr><tr><td>Cancel</td></tr><tr><td>Close</td></tr><tr><td>Critical</td></tr><tr><td>DestructiveRole</td></tr><tr><td>Discard</td></tr><tr><td>Help</td></tr><tr><td>HelpRole</td></tr><tr><td>Ignore</td></tr><tr><td>Information</td></tr><tr><td>InvalidRole</td></tr><tr><td>No</td></tr><tr><td>NoButton</td></tr><tr><td>NoRole</td></tr><tr><td>NoToAll</td></tr><tr><td>Ok</td></tr><tr><td>Open</td></tr><tr><td>Question</td></tr><tr><td>RejectRole</td></tr><tr><td>Reset</td></tr><tr><td>ResetRole</td></tr><tr><td>RestoreDefaults</td></tr><tr><td>Retry</td></tr><tr><td>Save</td></tr><tr><td>SaveAll</td></tr><tr><td>StandardButtons</td></tr><tr><td>Warning</td></tr><tr><td>Yes</td></tr><tr><td>YesRole</td></tr><tr><td>YesToAll</td></tr><tr><td>about</td></tr><tr><td>aboutQt</td></tr>
+<tr><td>Abort</td></tr><tr><td>AcceptRole</td></tr><tr><td>ActionRole</td></tr><tr><td>Apply</td></tr><tr><td>ApplyRole</td></tr><tr><td>Cancel</td></tr><tr><td>Close</td></tr><tr><td>Critical</td></tr><tr><td>DestructiveRole</td></tr><tr><td>Discard</td></tr><tr><td>Help</td></tr><tr><td>HelpRole</td></tr><tr><td>Ignore</td></tr><tr><td>Information</td></tr><tr><td>InvalidRole</td></tr><tr><td>No</td></tr><tr><td>NoButton</td></tr><tr><td>NoIcon</td></tr><tr><td>NoRole</td></tr><tr><td>NoToAll</td></tr><tr><td>Ok</td></tr><tr><td>Open</td></tr><tr><td>Question</td></tr><tr><td>RejectRole</td></tr><tr><td>Reset</td></tr><tr><td>ResetRole</td></tr><tr><td>RestoreDefaults</td></tr><tr><td>Retry</td></tr><tr><td>Save</td></tr><tr><td>SaveAll</td></tr><tr><td>StandardButtons</td></tr><tr><td>Warning</td></tr><tr><td>Yes</td></tr><tr><td>YesRole</td></tr><tr><td>YesToAll</td></tr><tr><td>about</td></tr><tr><td>aboutQt</td></tr>
 </table>
 <h3>Classes</h3>
 <table>
--- a/Documentation/Source/eric5.Graphics.UMLDialog.html	Tue Sep 04 11:41:07 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.UMLDialog.html	Sat Sep 08 18:28:46 2012 +0200
@@ -72,7 +72,10 @@
 <p>
         Constructor
 </p><dl>
-<dt><i>parent</i></dt>
+<dt><i>diagramName</i></dt>
+<dd>
+name of the diagram (string)
+</dd><dt><i>parent</i></dt>
 <dd>
 parent widget of the view (QWidget)
 </dd><dt><i>name</i></dt>
--- a/E5Graphics/E5GraphicsView.py	Tue Sep 04 11:41:07 2012 +0200
+++ b/E5Graphics/E5GraphicsView.py	Sat Sep 08 18:28:46 2012 +0200
@@ -35,12 +35,7 @@
         self.setAlignment(Qt.Alignment(Qt.AlignLeft | Qt.AlignTop))
         self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
         self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
-        
-        # available as of Qt 4.3
-        try:
-            self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate)
-        except AttributeError:
-            pass
+        self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate)
         
         self.setWhatsThis(self.trUtf8("<b>Graphics View</b>\n"
             "<p>This graphics view is used to show a diagram. \n"
@@ -119,13 +114,13 @@
         """
         Public method to set the scene size.
         
-        @param width width for the scene (integer)
-        @param height height for the scene (integer)
+        @param width width for the scene (float)
+        @param height height for the scene (float)
         """
         rect = self.scene().sceneRect()
         rect.setHeight(height)
         rect.setWidth(width)
-        self.setSceneRect(rect)
+        self.scene().setSceneRect(rect)
         
     def _getDiagramRect(self, border=0):
         """
--- a/Graphics/PackageDiagram.py	Tue Sep 04 11:41:07 2012 +0200
+++ b/Graphics/PackageDiagram.py	Sat Sep 08 18:28:46 2012 +0200
@@ -224,9 +224,10 @@
             
         # add in some whitespace
         width = width * whiteSpaceFactor
-        rawHeight = height
+##        rawHeight = height
         height = height * whiteSpaceFactor - 20
-        verticalWhiteSpace = (height - rawHeight) / (len(generations) - 1.0 or 2.0)
+##        verticalWhiteSpace = (height - rawHeight) / (len(generations) - 1.0 or 2.0)
+        verticalWhiteSpace = 40
         
         sceneRect = self.umlView.sceneRect()
         width += 50.0
--- a/Graphics/UMLClassDiagram.py	Tue Sep 04 11:41:07 2012 +0200
+++ b/Graphics/UMLClassDiagram.py	Sat Sep 08 18:28:46 2012 +0200
@@ -174,9 +174,10 @@
         
         # add in some whitespace
         width = width * whiteSpaceFactor
-        rawHeight = height
+##        rawHeight = height
         height = height * whiteSpaceFactor - 20
-        verticalWhiteSpace = (height - rawHeight) / (len(generations) - 1.0 or 2.0)
+##        verticalWhiteSpace = (height - rawHeight) / (len(generations) - 1.0 or 2.0)
+        verticalWhiteSpace = 40
         
         sceneRect = self.umlView.sceneRect()
         width += 50.0
--- a/Graphics/UMLDialog.py	Tue Sep 04 11:41:07 2012 +0200
+++ b/Graphics/UMLDialog.py	Sat Sep 08 18:28:46 2012 +0200
@@ -24,6 +24,7 @@
         """
         Constructor
         
+        @param diagramName name of the diagram (string)
         @param parent parent widget of the view (QWidget)
         @param name name of the view widget (string)
         """
--- a/Graphics/UMLGraphicsView.py	Tue Sep 04 11:41:07 2012 +0200
+++ b/Graphics/UMLGraphicsView.py	Sat Sep 08 18:28:46 2012 +0200
@@ -8,7 +8,7 @@
 """
 
 from PyQt4.QtCore import pyqtSignal, Qt, QSignalMapper, QFileInfo, QEvent
-from PyQt4.QtGui import QAction, QToolBar, QDialog, QPrinter, QPrintDialog
+from PyQt4.QtGui import QAction, QToolBar, QDialog, QPrinter, QPrintDialog, QGraphicsView
 
 from E5Graphics.E5GraphicsView import E5GraphicsView
 
@@ -45,6 +45,7 @@
         E5GraphicsView.__init__(self, scene, parent)
         if name:
             self.setObjectName(name)
+        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
         
         self.diagramName = diagramName
         
@@ -180,11 +181,11 @@
         """
         diagramSize = self._getDiagramSize(10)
         sceneRect = self.scene().sceneRect()
-        if (sceneRect.width() - self.deltaSize) <= diagramSize.width():
+        if (sceneRect.width() - self.deltaSize) < diagramSize.width():
             self.decWidthAct.setEnabled(False)
         else:
             self.decWidthAct.setEnabled(True)
-        if (sceneRect.height() - self.deltaSize) <= diagramSize.height():
+        if (sceneRect.height() - self.deltaSize) < diagramSize.height():
             self.decHeightAct.setEnabled(False)
         else:
             self.decHeightAct.setEnabled(True)
@@ -200,6 +201,19 @@
         else:
             self.deleteShapeAct.setEnabled(False)
         
+        sceneRect = self.scene().sceneRect()
+        newWidth = width = sceneRect.width()
+        newHeight = height = sceneRect.height()
+        rect = self._getDiagramRect(10)
+        if width < rect.width():
+            newWidth = rect.width()
+        if height < rect.height():
+            newHeight = rect.height()
+        
+        if newHeight != height or newWidth != width:
+            self.setSceneSize(newWidth, newHeight)
+            self.__checkSizeActions()
+        
     def initToolBar(self):
         """
         Public method to populate a toolbar with our actions.
@@ -359,10 +373,7 @@
         """
         Private method to handle the re-layout context menu entry.
         """
-        scene = self.scene()
-        for itm in list(scene.items())[:]:
-            if itm.scene() == scene:
-                scene.removeItem(itm)
+        self.scene().clear()
         self.relayout.emit()
         
     def __printDiagram(self):

eric ide

mercurial