ViewManager/ViewManager.py

branch
maintenance
changeset 6273
0daf79d65080
parent 6166
bace7fb85a01
parent 6247
5c677a7f7d51
child 6319
df201b9fbad4
diff -r 0a74c1efab70 -r 0daf79d65080 ViewManager/ViewManager.py
--- a/ViewManager/ViewManager.py	Mon Apr 02 12:04:56 2018 +0200
+++ b/ViewManager/ViewManager.py	Tue May 01 12:03:52 2018 +0200
@@ -4419,12 +4419,15 @@
 
     def checkDirty(self, editor, autosave=False):
         """
-        Public method to check dirty status and open a message window.
+        Public method to check the dirty status and open a message window.
         
         @param editor editor window to check
+        @type Editor
         @param autosave flag indicating that the file should be saved
-            automatically (boolean)
-        @return flag indicating successful reset of the dirty flag (boolean)
+            automatically
+        @type bool
+        @return flag indicating successful reset of the dirty flag
+        @rtype bool
         """
         if editor.isModified():
             fn = editor.getFileName()
@@ -4457,7 +4460,8 @@
         """
         Public method to check the dirty status of all editors.
         
-        @return flag indicating successful reset of all dirty flags (boolean)
+        @return flag indicating successful reset of all dirty flags
+        @rtype bool
         """
         for editor in self.editors:
             if not self.checkDirty(editor):
@@ -4465,15 +4469,38 @@
         
         return True
         
-    def closeEditor(self, editor):
+    def checkFileDirty(self, fn):
+        """
+        Public method to check the dirty status of an editor given its file
+        name and open a message window.
+        
+        @param fn file name of editor to be checked
+        @type str
+        @return flag indicating successful reset of the dirty flag
+        @rtype bool
+        """
+        for editor in self.editors:
+            if Utilities.samepath(fn, editor.getFileName()):
+                break
+        else:
+            return True
+        
+        res = self.checkDirty(editor)
+        return res
+        
+    def closeEditor(self, editor, ignoreDirty=False):
         """
         Public method to close an editor window.
         
         @param editor editor window to be closed
-        @return flag indicating success (boolean)
+        @type Editor
+        @param ignoreDirty flag indicating to ignore the 'dirty' status
+        @type bool
+        @return flag indicating success
+        @rtype bool
         """
         # save file if necessary
-        if not self.checkDirty(editor):
+        if not ignoreDirty and not self.checkDirty(editor):
             return False
         
         # get the filename of the editor for later use
@@ -4522,12 +4549,16 @@
         for editor in savedEditors:
             self.closeEditor(editor)
         
-    def closeWindow(self, fn):
+    def closeWindow(self, fn, ignoreDirty=False):
         """
         Public method to close an arbitrary source editor.
         
-        @param fn filename of editor to be closed
-        @return flag indicating success (boolean)
+        @param fn file name of the editor to be closed
+        @type str
+        @param ignoreDirty flag indicating to ignore the 'dirty' status
+        @type bool
+        @return flag indicating success
+        @rtype bool
         """
         for editor in self.editors:
             if Utilities.samepath(fn, editor.getFileName()):
@@ -4535,7 +4566,7 @@
         else:
             return True
         
-        res = self.closeEditor(editor)
+        res = self.closeEditor(editor, ignoreDirty=ignoreDirty)
         if res and editor == self.currentEditor:
             self.currentEditor = None
         
@@ -4822,9 +4853,12 @@
         self.sbEnc.setText(encoding)
         
         if language is None:
-            language = ''
-        import QScintilla.Lexers
-        pixmap = QScintilla.Lexers.getLanguageIcon(language, True)
+            pixmap = QPixmap()
+        elif language == "":
+            pixmap = UI.PixmapCache.getPixmap("fileText.png")
+        else:
+            import QScintilla.Lexers
+            pixmap = QScintilla.Lexers.getLanguageIcon(language, True)
         self.sbLang.setPixmap(pixmap)
         if pixmap.isNull():
             self.sbLang.setText(language)
@@ -5796,7 +5830,7 @@
         line, index = aw.getCursorPosition()
         text = aw.text(line)
         
-        reg = QRegExp('[^\w_]')
+        reg = QRegExp(r'[^\w_]')
         end = reg.indexIn(text, index)
         if end > index:
             ext = text[index:end]
@@ -6999,7 +7033,7 @@
         if self.activeWindow() is not None and \
            self.activeWindow().getFileName():
             ext = os.path.splitext(self.activeWindow().getFileName())[1]
-            rx = QRegExp(".*\*\.{0}[ )].*".format(ext[1:]))
+            rx = QRegExp(r".*\*\.{0}[ )].*".format(ext[1:]))
             import QScintilla.Lexers
             filters = QScintilla.Lexers.getOpenFileFiltersList()
             index = -1

eric ide

mercurial