src/eric7/UI/BrowserModel.py

branch
eric7
changeset 10398
ef1ea18994d5
parent 10378
cbbcecf9b25e
child 10433
328f3ec4b77a
equal deleted inserted replaced
10397:f60464a5f7ea 10398:ef1ea18994d5
29 from eric7.SystemUtilities import FileSystemUtilities 29 from eric7.SystemUtilities import FileSystemUtilities
30 from eric7.Utilities import ClassBrowsers 30 from eric7.Utilities import ClassBrowsers
31 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses 31 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses
32 32
33 BrowserItemRoot = 0 33 BrowserItemRoot = 0
34 BrowserItemDirectory = 1 34 BrowserItemSimpleDirectory = 1
35 BrowserItemSysPath = 2 35 BrowserItemDirectory = 2
36 BrowserItemFile = 3 36 BrowserItemSysPath = 3
37 BrowserItemClass = 4 37 BrowserItemFile = 4
38 BrowserItemMethod = 5 38 BrowserItemClass = 5
39 BrowserItemAttributes = 6 39 BrowserItemMethod = 6
40 BrowserItemAttribute = 7 40 BrowserItemAttributes = 7
41 BrowserItemCoding = 8 41 BrowserItemAttribute = 8
42 BrowserItemImports = 9 42 BrowserItemCoding = 9
43 BrowserItemImport = 10 43 BrowserItemImports = 10
44 BrowserItemImport = 11
44 45
45 46
46 class BrowserModel(QAbstractItemModel): 47 class BrowserModel(QAbstractItemModel):
47 """ 48 """
48 Class implementing the browser model. 49 Class implementing the browser model.
1047 @return flag indicating a symbolic link (boolean) 1048 @return flag indicating a symbolic link (boolean)
1048 """ 1049 """
1049 return self.symlink 1050 return self.symlink
1050 1051
1051 1052
1053 class BrowserSimpleDirectoryItem(BrowserItem):
1054 """
1055 Class implementing the data structure for browser simple directory items.
1056 """
1057
1058 def __init__(self, parent, text, path=""):
1059 """
1060 Constructor
1061
1062 @param parent parent item
1063 @param text text to be displayed (string)
1064 @param path path of the directory (string)
1065 """
1066 BrowserItem.__init__(self, parent, text)
1067
1068 self.type_ = BrowserItemSimpleDirectory
1069
1070 self._dirName = path
1071 if not os.path.isdir(self._dirName):
1072 self._dirName = os.path.dirname(self._dirName)
1073
1074 if os.path.lexists(self._dirName) and os.path.islink(self._dirName):
1075 self.symlink = True
1076 self.icon = EricPixmapCache.getSymlinkIcon("dirClosed")
1077 else:
1078 self.icon = EricPixmapCache.getIcon("dirClosed")
1079
1080 def setName(self, dinfo, full=True): # noqa: U100
1081 """
1082 Public method to set the directory name.
1083
1084 @param dinfo dinfo is the string for the directory (string)
1085 @param full flag indicating full path name should be displayed (boolean)
1086 """
1087 self._dirName = os.path.abspath(dinfo)
1088 self.itemData[0] = os.path.basename(self._dirName)
1089
1090 def dirName(self):
1091 """
1092 Public method returning the directory name.
1093
1094 @return directory name (string)
1095 """
1096 return self._dirName
1097
1098 def name(self):
1099 """
1100 Public method to return the name of the item.
1101
1102 @return name of the item (string)
1103 """
1104 return self._dirName
1105
1106 def lessThan(self, other, column, order):
1107 """
1108 Public method to check, if the item is less than the other one.
1109
1110 @param other reference to item to compare against (BrowserItem)
1111 @param column column number to use for the comparison (integer)
1112 @param order sort order (Qt.SortOrder) (for special sorting)
1113 @return true, if this item is less than other (boolean)
1114 """
1115 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI(
1116 "BrowsersListFoldersFirst"
1117 ):
1118 return order == Qt.SortOrder.AscendingOrder
1119
1120 return BrowserItem.lessThan(self, other, column, order)
1121
1122
1052 class BrowserDirectoryItem(BrowserItem): 1123 class BrowserDirectoryItem(BrowserItem):
1053 """ 1124 """
1054 Class implementing the data structure for browser directory items. 1125 Class implementing the data structure for browser directory items.
1055 """ 1126 """
1056 1127

eric ide

mercurial