src/eric7/ViewManager/ViewManager.py

branch
eric7
changeset 10679
4d3e0ce54322
parent 10677
6ee2e475490c
child 10680
306373ccf8fd
child 10685
a9134b4e8ed0
equal deleted inserted replaced
10678:665f1084ebf9 10679:4d3e0ce54322
13 import re 13 import re
14 14
15 from PyQt6.Qsci import QsciScintilla 15 from PyQt6.Qsci import QsciScintilla
16 from PyQt6.QtCore import ( 16 from PyQt6.QtCore import (
17 QCoreApplication, 17 QCoreApplication,
18 QFileSystemWatcher,
19 QPoint, 18 QPoint,
20 QSignalMapper, 19 QSignalMapper,
21 Qt, 20 Qt,
22 pyqtSignal, 21 pyqtSignal,
23 pyqtSlot, 22 pyqtSlot,
24 ) 23 )
25 from PyQt6.QtGui import QKeySequence, QPixmap 24 from PyQt6.QtGui import QKeySequence, QPixmap
26 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget 25 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget
27 26
28 from eric7 import Preferences 27 from eric7 import Preferences
28 from eric7.EricCore import EricFileSystemWatcher
29 from eric7.EricGui import EricPixmapCache 29 from eric7.EricGui import EricPixmapCache
30 from eric7.EricGui.EricAction import EricAction, createActionGroup 30 from eric7.EricGui.EricAction import EricAction, createActionGroup
31 from eric7.EricWidgets import EricFileDialog, EricMessageBox 31 from eric7.EricWidgets import EricFileDialog, EricMessageBox
32 from eric7.EricWidgets.EricApplication import ericApp 32 from eric7.EricWidgets.EricApplication import ericApp
33 from eric7.Globals import recentNameFiles 33 from eric7.Globals import recentNameFiles
143 self.__cooperationClient = None 143 self.__cooperationClient = None
144 144
145 self.__lastFocusWidget = None 145 self.__lastFocusWidget = None
146 146
147 # initialize the file system watcher 147 # initialize the file system watcher
148 self.__watcher = QFileSystemWatcher(self) 148 watcher = EricFileSystemWatcher.instance()
149 self.__watcher.fileChanged.connect(self.__watchedFileChanged) 149 watcher.fileModified.connect(self.__watchedFileChanged)
150
151 self.__watchedFilePaths = []
150 152
151 def setReferences(self, ui, dbs): 153 def setReferences(self, ui, dbs):
152 """ 154 """
153 Public method to set some references needed later on. 155 Public method to set some references needed later on.
154 156
8070 Public method to add a file to the list of monitored files. 8072 Public method to add a file to the list of monitored files.
8071 8073
8072 @param filePath path of the file to be added 8074 @param filePath path of the file to be added
8073 @type str 8075 @type str
8074 """ 8076 """
8075 if filePath and FileSystemUtilities.isPlainFileName(filePath): 8077 if (
8076 self.__watcher.addPath(filePath) 8078 filePath
8079 and FileSystemUtilities.isPlainFileName(filePath)
8080 and filePath not in self.__watchedFilePaths
8081 ):
8082 watcher = EricFileSystemWatcher.instance()
8083 watcher.addPath(filePath)
8084 self.__watchedFilePaths.append(filePath)
8077 8085
8078 def removeWatchedFilePath(self, filePath): 8086 def removeWatchedFilePath(self, filePath):
8079 """ 8087 """
8080 Public method to remove a file from the list of monitored files. 8088 Public method to remove a file from the list of monitored files.
8081 8089
8082 @param filePath path of the file to be removed 8090 @param filePath path of the file to be removed
8083 @type str 8091 @type str
8084 """ 8092 """
8085 if self.getOpenEditorCount( 8093 if (
8086 filePath 8094 filePath
8087 ) == 0 and FileSystemUtilities.isPlainFileName(filePath): 8095 and self.getOpenEditorCount(filePath) == 0
8088 self.__watcher.removePath(filePath) 8096 and FileSystemUtilities.isPlainFileName(filePath)
8097 and filePath in self.__watchedFilePaths
8098 ):
8099 watcher = EricFileSystemWatcher.instance()
8100 watcher.removePath(filePath)
8101 self.__watchedFilePaths.remove(filePath)
8089 8102
8090 ################################################################## 8103 ##################################################################
8091 ## Below are protected utility methods 8104 ## Below are protected utility methods
8092 ################################################################## 8105 ##################################################################
8093 8106

eric ide

mercurial