--- a/src/eric7/UI/BrowserModel.py Sun Dec 10 17:49:42 2023 +0100 +++ b/src/eric7/UI/BrowserModel.py Mon Dec 11 10:30:24 2023 +0100 @@ -31,16 +31,17 @@ from eric7.Utilities.ClassBrowsers import ClbrBaseClasses BrowserItemRoot = 0 -BrowserItemDirectory = 1 -BrowserItemSysPath = 2 -BrowserItemFile = 3 -BrowserItemClass = 4 -BrowserItemMethod = 5 -BrowserItemAttributes = 6 -BrowserItemAttribute = 7 -BrowserItemCoding = 8 -BrowserItemImports = 9 -BrowserItemImport = 10 +BrowserItemSimpleDirectory = 1 +BrowserItemDirectory = 2 +BrowserItemSysPath = 3 +BrowserItemFile = 4 +BrowserItemClass = 5 +BrowserItemMethod = 6 +BrowserItemAttributes = 7 +BrowserItemAttribute = 8 +BrowserItemCoding = 9 +BrowserItemImports = 10 +BrowserItemImport = 11 class BrowserModel(QAbstractItemModel): @@ -1049,6 +1050,76 @@ return self.symlink +class BrowserSimpleDirectoryItem(BrowserItem): + """ + Class implementing the data structure for browser simple directory items. + """ + + def __init__(self, parent, text, path=""): + """ + Constructor + + @param parent parent item + @param text text to be displayed (string) + @param path path of the directory (string) + """ + BrowserItem.__init__(self, parent, text) + + self.type_ = BrowserItemSimpleDirectory + + self._dirName = path + if not os.path.isdir(self._dirName): + self._dirName = os.path.dirname(self._dirName) + + if os.path.lexists(self._dirName) and os.path.islink(self._dirName): + self.symlink = True + self.icon = EricPixmapCache.getSymlinkIcon("dirClosed") + else: + self.icon = EricPixmapCache.getIcon("dirClosed") + + def setName(self, dinfo, full=True): # noqa: U100 + """ + Public method to set the directory name. + + @param dinfo dinfo is the string for the directory (string) + @param full flag indicating full path name should be displayed (boolean) + """ + self._dirName = os.path.abspath(dinfo) + self.itemData[0] = os.path.basename(self._dirName) + + def dirName(self): + """ + Public method returning the directory name. + + @return directory name (string) + """ + return self._dirName + + def name(self): + """ + Public method to return the name of the item. + + @return name of the item (string) + """ + return self._dirName + + def lessThan(self, other, column, order): + """ + Public method to check, if the item is less than the other one. + + @param other reference to item to compare against (BrowserItem) + @param column column number to use for the comparison (integer) + @param order sort order (Qt.SortOrder) (for special sorting) + @return true, if this item is less than other (boolean) + """ + if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( + "BrowsersListFoldersFirst" + ): + return order == Qt.SortOrder.AscendingOrder + + return BrowserItem.lessThan(self, other, column, order) + + class BrowserDirectoryItem(BrowserItem): """ Class implementing the data structure for browser directory items.