Changed the diagrams to show a better diagram title when printed.

Wed, 05 Sep 2012 20:07:02 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 05 Sep 2012 20:07:02 +0200
changeset 2025
8bb085c59cd2
parent 2024
717b72b32420
child 2026
18f2b30ed046

Changed the diagrams to show a better diagram title when printed.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.ImportsDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.PackageDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.UMLClassDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Project.Project.html file | annotate | diff | comparison | revisions
Graphics/ApplicationDiagram.py file | annotate | diff | comparison | revisions
Graphics/ImportsDiagram.py file | annotate | diff | comparison | revisions
Graphics/PackageDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLClassDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLGraphicsView.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
Project/ProjectSourcesBrowser.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Wed Sep 05 19:19:16 2012 +0200
+++ b/APIs/Python3/eric5.api	Wed Sep 05 20:07:02 2012 +0200
@@ -1647,7 +1647,7 @@
 eric5.Graphics.GraphicsUtilities.sort?4(nodes, routes, noRecursion=False)
 eric5.Graphics.ImportsDiagram.ImportsDiagram.relayout?4()
 eric5.Graphics.ImportsDiagram.ImportsDiagram.show?4()
-eric5.Graphics.ImportsDiagram.ImportsDiagram?1(package, parent=None, name=None, showExternalImports=False)
+eric5.Graphics.ImportsDiagram.ImportsDiagram?1(project, package, parent=None, name=None, showExternalImports=False)
 eric5.Graphics.ModuleItem.ModuleItem.paint?4(painter, option, widget=None)
 eric5.Graphics.ModuleItem.ModuleItem.setModel?4(model)
 eric5.Graphics.ModuleItem.ModuleItem?1(model=None, x=0, y=0, rounded=False, parent=None, scene=None)
@@ -1657,7 +1657,7 @@
 eric5.Graphics.ModuleItem.ModuleModel?1(name, classlist=[])
 eric5.Graphics.PackageDiagram.PackageDiagram.relayout?4()
 eric5.Graphics.PackageDiagram.PackageDiagram.show?4()
-eric5.Graphics.PackageDiagram.PackageDiagram?1(package, parent=None, name=None, noAttrs=False)
+eric5.Graphics.PackageDiagram.PackageDiagram?1(project, package, parent=None, name=None, noAttrs=False)
 eric5.Graphics.PackageItem.PackageItem.paint?4(painter, option, widget=None)
 eric5.Graphics.PackageItem.PackageItem.setModel?4(model)
 eric5.Graphics.PackageItem.PackageItem?1(model=None, x=0, y=0, rounded=False, noModules=False, parent=None, scene=None)
@@ -1678,7 +1678,7 @@
 eric5.Graphics.SvgDiagram.SvgDiagram?1(svgFile, parent=None, name=None)
 eric5.Graphics.UMLClassDiagram.UMLClassDiagram.relayout?4()
 eric5.Graphics.UMLClassDiagram.UMLClassDiagram.show?4()
-eric5.Graphics.UMLClassDiagram.UMLClassDiagram?1(file, parent=None, name=None, noAttrs=False)
+eric5.Graphics.UMLClassDiagram.UMLClassDiagram?1(project, file, parent=None, name=None, noAttrs=False)
 eric5.Graphics.UMLDialog.UMLDialog?1(diagramName="Unnamed", parent=None, name=None)
 eric5.Graphics.UMLGraphicsView.UMLGraphicsView.event?4(evt)
 eric5.Graphics.UMLGraphicsView.UMLGraphicsView.filteredItems?4(items)
@@ -5691,6 +5691,7 @@
 eric5.Project.Project.Project.getProjectFile?4()
 eric5.Project.Project.Project.getProjectLanguage?4()
 eric5.Project.Project.Project.getProjectManagementDir?4()
+eric5.Project.Project.Project.getProjectName?4()
 eric5.Project.Project.Project.getProjectPath?4()
 eric5.Project.Project.Project.getProjectSpellLanguage?4()
 eric5.Project.Project.Project.getProjectType?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Wed Sep 05 19:19:16 2012 +0200
+++ b/Documentation/Help/source.qhp	Wed Sep 05 20:07:02 2012 +0200
@@ -7712,6 +7712,7 @@
       <keyword name="Project.getProjectFile" id="Project.getProjectFile" ref="eric5.Project.Project.html#Project.getProjectFile" />
       <keyword name="Project.getProjectLanguage" id="Project.getProjectLanguage" ref="eric5.Project.Project.html#Project.getProjectLanguage" />
       <keyword name="Project.getProjectManagementDir" id="Project.getProjectManagementDir" ref="eric5.Project.Project.html#Project.getProjectManagementDir" />
+      <keyword name="Project.getProjectName" id="Project.getProjectName" ref="eric5.Project.Project.html#Project.getProjectName" />
       <keyword name="Project.getProjectPath" id="Project.getProjectPath" ref="eric5.Project.Project.html#Project.getProjectPath" />
       <keyword name="Project.getProjectSpellLanguage" id="Project.getProjectSpellLanguage" ref="eric5.Project.Project.html#Project.getProjectSpellLanguage" />
       <keyword name="Project.getProjectType" id="Project.getProjectType" ref="eric5.Project.Project.html#Project.getProjectType" />
--- a/Documentation/Source/eric5.Graphics.ImportsDiagram.html	Wed Sep 05 19:19:16 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.ImportsDiagram.html	Wed Sep 05 20:07:02 2012 +0200
@@ -89,11 +89,14 @@
 </table>
 <a NAME="ImportsDiagram.__init__" ID="ImportsDiagram.__init__"></a>
 <h4>ImportsDiagram (Constructor)</h4>
-<b>ImportsDiagram</b>(<i>package, parent=None, name=None, showExternalImports=False</i>)
+<b>ImportsDiagram</b>(<i>project, package, parent=None, name=None, showExternalImports=False</i>)
 <p>
         Constructor
 </p><dl>
-<dt><i>package</i></dt>
+<dt><i>project</i></dt>
+<dd>
+reference to the project object
+</dd><dt><i>package</i></dt>
 <dd>
 name of a python package to show the import
             relationships (string)
--- a/Documentation/Source/eric5.Graphics.PackageDiagram.html	Wed Sep 05 19:19:16 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.PackageDiagram.html	Wed Sep 05 20:07:02 2012 +0200
@@ -95,11 +95,14 @@
 </table>
 <a NAME="PackageDiagram.__init__" ID="PackageDiagram.__init__"></a>
 <h4>PackageDiagram (Constructor)</h4>
-<b>PackageDiagram</b>(<i>package, parent=None, name=None, noAttrs=False</i>)
+<b>PackageDiagram</b>(<i>project, package, parent=None, name=None, noAttrs=False</i>)
 <p>
         Constructor
 </p><dl>
-<dt><i>package</i></dt>
+<dt><i>project</i></dt>
+<dd>
+reference to the project object
+</dd><dt><i>package</i></dt>
 <dd>
 name of a python package to be shown (string)
 </dd><dt><i>parent</i></dt>
--- a/Documentation/Source/eric5.Graphics.UMLClassDiagram.html	Wed Sep 05 19:19:16 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.UMLClassDiagram.html	Wed Sep 05 20:07:02 2012 +0200
@@ -92,11 +92,14 @@
 </table>
 <a NAME="UMLClassDiagram.__init__" ID="UMLClassDiagram.__init__"></a>
 <h4>UMLClassDiagram (Constructor)</h4>
-<b>UMLClassDiagram</b>(<i>file, parent=None, name=None, noAttrs=False</i>)
+<b>UMLClassDiagram</b>(<i>project, file, parent=None, name=None, noAttrs=False</i>)
 <p>
         Constructor
 </p><dl>
-<dt><i>file</i></dt>
+<dt><i>project</i></dt>
+<dd>
+reference to the project object
+</dd><dt><i>file</i></dt>
 <dd>
 filename of a python module to be shown (string)
 </dd><dt><i>parent</i></dt>
--- a/Documentation/Source/eric5.Project.Project.html	Wed Sep 05 19:19:16 2012 +0200
+++ b/Documentation/Source/eric5.Project.Project.html	Wed Sep 05 20:07:02 2012 +0200
@@ -456,6 +456,9 @@
 <td><a href="#Project.getProjectManagementDir">getProjectManagementDir</a></td>
 <td>Public method to get the path of the management directory.</td>
 </tr><tr>
+<td><a href="#Project.getProjectName">getProjectName</a></td>
+<td>Public method to get the name of the project.</td>
+</tr><tr>
 <td><a href="#Project.getProjectPath">getProjectPath</a></td>
 <td>Public method to get the project path.</td>
 </tr><tr>
@@ -1532,6 +1535,18 @@
 <dd>
 path of the management directory (string)
 </dd>
+</dl><a NAME="Project.getProjectName" ID="Project.getProjectName"></a>
+<h4>Project.getProjectName</h4>
+<b>getProjectName</b>(<i></i>)
+<p>
+        Public method to get the name of the project.
+</p><p>
+        The project name is determined from the name of the project file.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+name of the project (string)
+</dd>
 </dl><a NAME="Project.getProjectPath" ID="Project.getProjectPath"></a>
 <h4>Project.getProjectPath</h4>
 <b>getProjectPath</b>(<i></i>)
--- a/Graphics/ApplicationDiagram.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Graphics/ApplicationDiagram.py	Wed Sep 05 20:07:02 2012 +0200
@@ -39,7 +39,7 @@
         self.project = project
         self.noModules = noModules
         
-        UMLDialog.__init__(self, self.project.ppath, parent)
+        UMLDialog.__init__(self, self.project.getProjectName(), parent)
         
         if not name:
             self.setObjectName("ApplicationDiagram")
--- a/Graphics/ImportsDiagram.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Graphics/ImportsDiagram.py	Wed Sep 05 20:07:02 2012 +0200
@@ -28,10 +28,12 @@
     Note: Only package internal imports are show in order to maintain
     some readability.
     """
-    def __init__(self, package, parent=None, name=None, showExternalImports=False):
+    def __init__(self, project, package, parent=None, name=None,
+                 showExternalImports=False):
         """
         Constructor
         
+        @param project reference to the project object
         @param package name of a python package to show the import
             relationships (string)
         @param parent parent widget of the view (QWidget)
@@ -49,7 +51,12 @@
             hasInit = len(glob.glob(os.path.join(ppath, '__init__.*'))) > 0
         self.shortPackage = self.packagePath.replace(ppath, '').replace(os.sep, '.')[1:]
         
-        UMLDialog.__init__(self, self.packagePath, parent)
+        pname = project.getProjectName()
+        if pname:
+            name = "{0}: {1}".format(pname, project.getRelativePath(self.packagePath))
+        else:
+            name = self.packagePath
+        UMLDialog.__init__(self, name, parent)
         
         if not name:
             self.setObjectName("ImportsDiagram")
--- a/Graphics/PackageDiagram.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Graphics/PackageDiagram.py	Wed Sep 05 20:07:02 2012 +0200
@@ -27,10 +27,11 @@
     """
     Class implementing a dialog showing a UML like class diagram of a package.
     """
-    def __init__(self, package, parent=None, name=None, noAttrs=False):
+    def __init__(self, project, package, parent=None, name=None, noAttrs=False):
         """
         Constructor
         
+        @param project reference to the project object
         @param package name of a python package to be shown (string)
         @param parent parent widget of the view (QWidget)
         @param name name of the view widget (string)
@@ -40,7 +41,12 @@
         self.allClasses = {}
         self.noAttrs = noAttrs
         
-        UMLDialog.__init__(self, self.package, parent)
+        pname = project.getProjectName()
+        if pname:
+            name = "{0}: {1}".format(pname, project.getRelativePath(self.package))
+        else:
+            name = self.package
+        UMLDialog.__init__(self, name, parent)
         
         if not name:
             self.setObjectName("PackageDiagram")
--- a/Graphics/UMLClassDiagram.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Graphics/UMLClassDiagram.py	Wed Sep 05 20:07:02 2012 +0200
@@ -24,10 +24,11 @@
     """
     Class implementing a dialog showing a UML like class diagram.
     """
-    def __init__(self, file, parent=None, name=None, noAttrs=False):
+    def __init__(self, project, file, parent=None, name=None, noAttrs=False):
         """
         Constructor
         
+        @param project reference to the project object
         @param file filename of a python module to be shown (string)
         @param parent parent widget of the view (QWidget)
         @param name name of the view widget (string)
@@ -36,7 +37,12 @@
         self.file = file
         self.noAttrs = noAttrs
         
-        UMLDialog.__init__(self, self.file, parent)
+        pname = project.getProjectName()
+        if pname and project.isProjectSource(self.file):
+            name = "{0}: {1}".format(pname, project.getRelativePath(self.file))
+        else:
+            name = self.file
+        UMLDialog.__init__(self, name, parent)
         
         if not name:
             self.setObjectName("UMLClassDiagram")
--- a/Graphics/UMLGraphicsView.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Graphics/UMLGraphicsView.py	Wed Sep 05 20:07:02 2012 +0200
@@ -418,7 +418,8 @@
         printer.setPrinterName(Preferences.getPrinter("PrinterName"))
         
         preview = QPrintPreviewDialog(printer, self)
-        preview.paintRequested[QPrinter].connect(self.printDiagram)
+        preview.paintRequested[QPrinter].connect(
+            lambda x: self.printDiagram(x, self.diagramName))
         preview.exec_()
         
     def __zoom(self):
--- a/Project/Project.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Project/Project.py	Wed Sep 05 20:07:02 2012 +0200
@@ -2760,6 +2760,20 @@
         """
         return self.pfile
         
+    def getProjectName(self):
+        """
+        Public method to get the name of the project.
+        
+        The project name is determined from the name of the project file.
+        
+        @return name of the project (string)
+        """
+        if self.pfile:
+            name = os.path.splitext(self.pfile)[0]
+            return os.path.basename(name)
+        else:
+            return ""
+        
     def getProjectManagementDir(self):
         """
         Public method to get the path of the management directory.
--- a/Project/ProjectSourcesBrowser.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/Project/ProjectSourcesBrowser.py	Wed Sep 05 20:07:02 2012 +0200
@@ -861,7 +861,7 @@
             self.trUtf8("Class Diagram"),
             self.trUtf8("""Include class attributes?"""),
             yesDefault=True)
-        self.classDiagram = UMLClassDiagram(fn, self, noAttrs=not res)
+        self.classDiagram = UMLClassDiagram(self.project, fn, self, noAttrs=not res)
         self.classDiagram.show()
         
     def __showImportsDiagram(self):
@@ -877,7 +877,7 @@
         res = E5MessageBox.yesNo(self,
             self.trUtf8("Imports Diagram"),
             self.trUtf8("""Include imports from external modules?"""))
-        self.importsDiagram = ImportsDiagram(package, self,
+        self.importsDiagram = ImportsDiagram(self.project, package, self,
             showExternalImports=res)
         self.importsDiagram.show()
         
@@ -895,7 +895,7 @@
             self.trUtf8("Package Diagram"),
             self.trUtf8("""Include class attributes?"""),
             yesDefault=True)
-        self.packageDiagram = PackageDiagram(package, self, noAttrs=not res)
+        self.packageDiagram = PackageDiagram(self.project, package, self, noAttrs=not res)
         self.packageDiagram.show()
         
     def __showApplicationDiagram(self):
--- a/QScintilla/Editor.py	Wed Sep 05 19:19:16 2012 +0200
+++ b/QScintilla/Editor.py	Wed Sep 05 20:07:02 2012 +0200
@@ -5796,7 +5796,8 @@
         if not self.checkDirty():
             return
         
-        self.classDiagram = UMLClassDiagram(self.fileName, self, noAttrs=False)
+        self.classDiagram = UMLClassDiagram(self.project, self.fileName,
+            self, noAttrs=False)
         self.classDiagram.show()
         
     def __showPackageDiagram(self):
@@ -5813,7 +5814,7 @@
             self.trUtf8("Package Diagram"),
             self.trUtf8("""Include class attributes?"""),
             yesDefault=True)
-        self.packageDiagram = PackageDiagram(package, self, noAttrs=not res)
+        self.packageDiagram = PackageDiagram(self.project, package, self, noAttrs=not res)
         self.packageDiagram.show()
         
     def __showImportsDiagram(self):
@@ -5829,7 +5830,7 @@
         res = E5MessageBox.yesNo(self,
             self.trUtf8("Imports Diagram"),
             self.trUtf8("""Include imports from external modules?"""))
-        self.importsDiagram = ImportsDiagram(package, self,
+        self.importsDiagram = ImportsDiagram(self.project, package, self,
             showExternalImports=res)
         self.importsDiagram.show()
         

eric ide

mercurial