src/eric7/ViewManager/ViewManager.py

branch
eric7
changeset 10973
484b5440fd1e
parent 10876
ec224611090e
child 10986
39a97ad73ee5
equal deleted inserted replaced
10972:2178804b1df8 10973:484b5440fd1e
129 self.untitledCount = 0 129 self.untitledCount = 0
130 self.srHistory = {"search": [], "replace": []} 130 self.srHistory = {"search": [], "replace": []}
131 self.editorsCheckFocusIn = True 131 self.editorsCheckFocusIn = True
132 132
133 self.recent = [] 133 self.recent = []
134 self.__loadRecent() 134 ##self.__loadRecent()
135 135
136 self.bookmarked = [] 136 self.bookmarked = []
137 bs = Preferences.getSettings().value("Bookmarked/Sources") 137 bs = Preferences.getSettings().value("Bookmarked/Sources")
138 if bs is not None: 138 if bs is not None:
139 self.bookmarked = bs 139 self.bookmarked = bs
165 """ 165 """
166 from eric7.QScintilla.SearchReplaceWidget import SearchReplaceSlidingWidget 166 from eric7.QScintilla.SearchReplaceWidget import SearchReplaceSlidingWidget
167 167
168 self.ui = ui 168 self.ui = ui
169 self.dbs = dbs 169 self.dbs = dbs
170
171 self.__remoteServer = remoteServerInterface
170 self.__remotefsInterface = remoteServerInterface.getServiceInterface( 172 self.__remotefsInterface = remoteServerInterface.getServiceInterface(
171 "FileSystem" 173 "FileSystem"
172 ) 174 )
173 175
174 self.__searchReplaceWidget = SearchReplaceSlidingWidget(self, ui) 176 self.__searchReplaceWidget = SearchReplaceSlidingWidget(self, ui)
175 177
176 self.editorClosedEd.connect(self.__searchReplaceWidget.editorClosed) 178 self.editorClosedEd.connect(self.__searchReplaceWidget.editorClosed)
177 self.checkActions.connect(self.__searchReplaceWidget.updateSelectionCheckBox) 179 self.checkActions.connect(self.__searchReplaceWidget.updateSelectionCheckBox)
180
181 self.__loadRecent()
178 182
179 def searchReplaceWidget(self): 183 def searchReplaceWidget(self):
180 """ 184 """
181 Public method to get a reference to the search widget. 185 Public method to get a reference to the search widget.
182 186
192 self.recent = [] 196 self.recent = []
193 Preferences.Prefs.rsettings.sync() 197 Preferences.Prefs.rsettings.sync()
194 rs = Preferences.Prefs.rsettings.value(recentNameFiles) 198 rs = Preferences.Prefs.rsettings.value(recentNameFiles)
195 if rs is not None: 199 if rs is not None:
196 for f in EricUtilities.toList(rs): 200 for f in EricUtilities.toList(rs):
197 if pathlib.Path(f).exists(): 201 if (
202 FileSystemUtilities.isRemoteFileName(f)
203 and (
204 not self.__remoteServer.isServerConnected()
205 or self.__remotefsInterface.exists(f)
206 )
207 ) or pathlib.Path(f).exists():
198 self.recent.append(f) 208 self.recent.append(f)
199 209
200 def __saveRecent(self): 210 def __saveRecent(self):
201 """ 211 """
202 Private method to save the list of recently opened filenames. 212 Private method to save the list of recently opened filenames.
5977 5987
5978 @param fn name of the file to be added 5988 @param fn name of the file to be added
5979 @type str 5989 @type str
5980 """ 5990 """
5981 for recent in self.recent[:]: 5991 for recent in self.recent[:]:
5982 if FileSystemUtilities.samepath(fn, recent): 5992 if (
5993 FileSystemUtilities.isRemoteFileName(recent) and recent == fn
5994 ) or FileSystemUtilities.samepath(fn, recent):
5983 self.recent.remove(recent) 5995 self.recent.remove(recent)
5984 self.recent.insert(0, fn) 5996 self.recent.insert(0, fn)
5985 maxRecent = Preferences.getUI("RecentNumber") 5997 maxRecent = Preferences.getUI("RecentNumber")
5986 if len(self.recent) > maxRecent: 5998 if len(self.recent) > maxRecent:
5987 self.recent = self.recent[:maxRecent] 5999 self.recent = self.recent[:maxRecent]
6585 6597
6586 for idx, rs in enumerate(self.recent, start=1): 6598 for idx, rs in enumerate(self.recent, start=1):
6587 formatStr = "&{0:d}. {1}" if idx < 10 else "{0:d}. {1}" 6599 formatStr = "&{0:d}. {1}" if idx < 10 else "{0:d}. {1}"
6588 act = self.recentMenu.addAction( 6600 act = self.recentMenu.addAction(
6589 formatStr.format( 6601 formatStr.format(
6590 idx, FileSystemUtilities.compactPath(rs, self.ui.maxMenuFilePathLen) 6602 idx,
6603 (
6604 self.__remotefsInterface.compactPath(
6605 rs, self.ui.maxMenuFilePathLen
6606 )
6607 if FileSystemUtilities.isRemoteFileName(rs)
6608 else FileSystemUtilities.compactPath(
6609 rs, self.ui.maxMenuFilePathLen
6610 )
6611 ),
6591 ) 6612 )
6592 ) 6613 )
6593 act.setData(rs) 6614 act.setData(rs)
6594 act.setEnabled(pathlib.Path(rs).exists()) 6615 if FileSystemUtilities.isRemoteFileName(rs):
6616 act.setEnabled(
6617 self.__remoteServer.isServerConnected
6618 and self.__remotefsInterface.exists(rs)
6619 )
6620 else:
6621 act.setEnabled(pathlib.Path(rs).exists())
6595 6622
6596 self.recentMenu.addSeparator() 6623 self.recentMenu.addSeparator()
6597 self.recentMenu.addAction( 6624 self.recentMenu.addAction(
6598 QCoreApplication.translate("ViewManager", "&Clear"), self.clearRecent 6625 QCoreApplication.translate("ViewManager", "&Clear"), self.clearRecent
6599 ) 6626 )

eric ide

mercurial