--- a/src/eric7/Project/ProjectBrowserModel.py Sun Jul 14 17:24:03 2024 +0200 +++ b/src/eric7/Project/ProjectBrowserModel.py Sun Jul 14 17:38:30 2024 +0200 @@ -624,7 +624,7 @@ return None - def addNewItem(self, typeString, name, additionalTypeStrings=None): + def addNewItem(self, typeString, name, additionalTypeStrings=None, simple=False): """ Public method to add a new item to the model. @@ -632,12 +632,15 @@ @type str @param name name of the new item @type str - @param additionalTypeStrings names of additional types - @type list of str + @param additionalTypeStrings names of additional types (defaults to None) + @type list of str (optional) + @param simple flag indicating to create a simple directory item and/or not + highlight the entry (defaults to False) + @type bool (optional) """ # Show the entry in bold in the others browser to make it more # distinguishable - bold = typeString == "OTHERS" + bold = typeString == "OTHERS" and not simple fname = os.path.join(self.project.ppath, name) parentItem, _dt = self.findParentItemByName( @@ -659,13 +662,23 @@ self.removeItem(name) if os.path.isdir(fname): - itm = ProjectBrowserDirectoryItem( - parentItem, - fname, - self.__projectBrowser.getProjectBrowserFilter(typeString), - False, - bold, - fsInterface=self.__remotefsInterface, + itm = ( + ProjectBrowserSimpleDirectoryItem( + parentItem, + self.__projectBrowser.getProjectBrowserFilter(typeString), + os.path.basename(name), + fname, + fsInterface=self.__remotefsInterface, + ) + if simple + else ProjectBrowserDirectoryItem( + parentItem, + fname, + self.__projectBrowser.getProjectBrowserFilter(typeString), + False, + bold, + fsInterface=self.__remotefsInterface, + ) ) else: if typeString == "SOURCES": @@ -817,26 +830,29 @@ return for itm in self.watchedDirItems[parentPath]: - cnt = itm.childCount() - self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt) - node = ( - ProjectBrowserDirectoryItem( - itm, - FileSystemUtilities.toNativeSeparators(path), - itm.getProjectTypes()[0], - False, - fsInterface=self.__remotefsInterface, + name = os.path.basename(path) + child = self.findChildItem(name, 0, parentItem=itm) + if child is None: + cnt = itm.childCount() + self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt) + node = ( + ProjectBrowserDirectoryItem( + itm, + FileSystemUtilities.toNativeSeparators(path), + itm.getProjectTypes()[0], + False, + fsInterface=self.__remotefsInterface, + ) + if isDir + else ProjectBrowserFileItem( + itm, + FileSystemUtilities.toNativeSeparators(path), + itm.getProjectTypes()[0], + fsInterface=self.__remotefsInterface, + ) ) - if isDir - else ProjectBrowserFileItem( - itm, - FileSystemUtilities.toNativeSeparators(path), - itm.getProjectTypes()[0], - fsInterface=self.__remotefsInterface, - ) - ) - self._addItem(node, itm) - self.endInsertRows() + self._addItem(node, itm) + self.endInsertRows() def entryDeleted(self, path, isDir=False): """