eric6/Project/Project.py

changeset 7518
6dea4abd3097
parent 7360
9190402e4505
child 7533
88261c96484b
--- a/eric6/Project/Project.py	Fri Apr 10 14:39:13 2020 +0200
+++ b/eric6/Project/Project.py	Fri Apr 10 14:48:05 2020 +0200
@@ -711,6 +711,18 @@
         @return reference to the project browser model (ProjectBrowserModel)
         """
         return self.__model
+    
+    def startFileSystemMonitoring(self):
+        """
+        Public method to (re)start monitoring the project file system.
+        """
+        self.__model.startFileSystemMonitoring()
+    
+    def stopFileSystemMonitoring(self):
+        """
+        Public method to stop monitoring the project file system.
+        """
+        self.__model.stopFileSystemMonitoring()
         
     def getVcs(self):
         """
@@ -2017,8 +2029,9 @@
         """
         fn = self.getRelativePath(oldname)
         if os.path.dirname(oldname) == os.path.dirname(newname):
-            self.removeFile(oldname, False)
-            self.appendFile(newname, isSourceFile, False)
+            if self.__isInPdata(oldname):
+                self.removeFile(oldname, False)
+                self.appendFile(newname, isSourceFile, False)
             self.__model.renameItem(fn, newname)
         else:
             self.removeFile(oldname)
@@ -2125,11 +2138,15 @@
             else:
                 if newdn not in self.subdirs:
                     self.subdirs.append(newdn)
-        self.setDirty(True)
-        typeString = typeStrings[0]
-        del typeStrings[0]
-        self.__model.removeItem(olddn)
-        self.__model.addNewItem(typeString, newdn, typeStrings)
+        if typeStrings:
+            # the directory is controlled by the project
+            self.setDirty(True)
+            self.__model.removeItem(olddn)
+            typeString = typeStrings[0]
+            del typeStrings[0]
+            self.__model.addNewItem(typeString, newdn, typeStrings)
+        else:
+            self.__model.renameItem(olddn, self.getAbsolutePath(newdn))
         self.directoryRemoved.emit(olddn)
         
     def removeFile(self, fn, updateModel=True):
@@ -3721,7 +3738,25 @@
         @rtype str
         """
         return self.pdata["DESCRIPTION"]
-        
+    
+    def __isInPdata(self, fn):
+        """
+        Private method used to check, if the passed in filename is project
+        controlled..
+        
+        @param fn filename to be checked
+        @type str
+        @return flag indicating membership
+        @rtype bool
+        """
+        newfn = os.path.abspath(fn)
+        newfn = self.getRelativePath(newfn)
+        for group in ["SOURCES", "FORMS", "INTERFACES", "PROTOCOLS",
+                      "RESOURCES", "TRANSLATIONS", "OTHERS"]:
+            if newfn in self.pdata[group]:
+                return True
+        return False
+    
     def isProjectFile(self, fn):
         """
         Public method used to check, if the passed in filename belongs to the

eric ide

mercurial