Corrected an issue related to the external creation of non-managed files. eric7

Fri, 12 Jul 2024 17:47:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 12 Jul 2024 17:47:25 +0200
branch
eric7
changeset 10842
d7fe0566dfa8
parent 10841
f06e4123cb1c
child 10843
5184f7a9a244

Corrected an issue related to the external creation of non-managed files.

src/eric7/Project/ProjectBrowserModel.py file | annotate | diff | comparison | revisions
src/eric7/UI/BrowserModel.py file | annotate | diff | comparison | revisions
--- a/src/eric7/Project/ProjectBrowserModel.py	Fri Jul 12 17:11:28 2024 +0200
+++ b/src/eric7/Project/ProjectBrowserModel.py	Fri Jul 12 17:47:25 2024 +0200
@@ -253,6 +253,7 @@
         watcher.directoryDeleted.connect(lambda x: self.entryDeleted(x, isDir=True))
         watcher.fileCreated.connect(lambda x: self.entryCreated(x, isDir=False))
         watcher.fileDeleted.connect(lambda x: self.entryDeleted(x, isDir=False))
+        watcher.fileMoved.connect(self.entryMoved)
 
         self.inRefresh = False
 
@@ -845,11 +846,25 @@
         @type str
         @param isDir flag indicating a deleted directory (defaults to False)
         @type bool (optional)
+        @return flag indicating a deletion
+        @rtype bool
         """
         if not self.__watcherActive:
-            return
+            return False
+
+        return super().entryDeleted(path, isDir=isDir)
+
+    def entryMoved(self, srcPath, tgtPath):
+        """
+        Public slot handling the renaming of a non-managed file.
 
-        super().entryDeleted(path, isDir=isDir)
+        @param srcPath original name
+        @type str
+        @param tgtPath new name
+        @type str
+        """
+        if self.entryDeleted(srcPath, isDir=False):
+            self.entryCreated(tgtPath, isDir=False)
 
     def __addVCSStatus(self, item, name):
         """
--- a/src/eric7/UI/BrowserModel.py	Fri Jul 12 17:11:28 2024 +0200
+++ b/src/eric7/UI/BrowserModel.py	Fri Jul 12 17:47:25 2024 +0200
@@ -420,6 +420,8 @@
         @type str
         @param isDir flag indicating a deleted directory (defaults to False) (unused)
         @type bool (optional)
+        @return flag indicating a deletion
+        @rtype bool
         """
         parentPath = os.path.dirname(path)
         if parentPath not in self.watchedDirItems:
@@ -434,7 +436,9 @@
                     self.beginRemoveRows(self.createIndex(itm.row(), 0, itm), row, row)
                     itm.removeChild(child)
                     self.endRemoveRows()
-                    break
+                    return True
+
+        return False
 
     def __populateModel(self):
         """

eric ide

mercurial