src/eric7/UI/BrowserModel.py

branch
eric7
changeset 10831
f6be97f4d96a
parent 10704
27d21e5163b8
child 10832
479cf39ac9cb
equal deleted inserted replaced
10830:8282a605d3f0 10831:f6be97f4d96a
1230 @type str 1230 @type str
1231 @param fsInterface reference to the 'eric-ide' server file system interface 1231 @param fsInterface reference to the 'eric-ide' server file system interface
1232 (defaults to None) 1232 (defaults to None)
1233 @type EricServerFileSystemInterface (optional) 1233 @type EricServerFileSystemInterface (optional)
1234 """ 1234 """
1235 BrowserItem.__init__(self, parent, text) 1235 super().__init__(parent, text)
1236 1236
1237 self.__fsInterface = fsInterface 1237 self.__fsInterface = fsInterface
1238 1238
1239 self.type_ = BrowserItemType.SimpleDirectory 1239 self.type_ = BrowserItemType.SimpleDirectory
1240 1240
1306 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( 1306 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI(
1307 "BrowsersListFoldersFirst" 1307 "BrowsersListFoldersFirst"
1308 ): 1308 ):
1309 return order == Qt.SortOrder.AscendingOrder 1309 return order == Qt.SortOrder.AscendingOrder
1310 1310
1311 return BrowserItem.lessThan(self, other, column, order) 1311 return super().lessThan(other, column, order)
1312 1312
1313 1313
1314 class BrowserDirectoryItem(BrowserItem): 1314 class BrowserDirectoryItem(BrowserItem):
1315 """ 1315 """
1316 Class implementing the data structure for browser directory items. 1316 Class implementing the data structure for browser directory items.
1336 self._dirName = dinfo 1336 self._dirName = dinfo
1337 dn = self._dirName if full else self.__fsInterface.basename(self._dirName) 1337 dn = self._dirName if full else self.__fsInterface.basename(self._dirName)
1338 else: 1338 else:
1339 self._dirName = os.path.abspath(dinfo) 1339 self._dirName = os.path.abspath(dinfo)
1340 dn = self._dirName if full else os.path.basename(self._dirName) 1340 dn = self._dirName if full else os.path.basename(self._dirName)
1341 BrowserItem.__init__(self, parent, dn) 1341 super().__init__(parent, dn)
1342 1342
1343 self.type_ = BrowserItemType.Directory 1343 self.type_ = BrowserItemType.Directory
1344 if ( 1344 if (
1345 FileSystemUtilities.isPlainFileName(self._dirName) 1345 FileSystemUtilities.isPlainFileName(self._dirName)
1346 and not FileSystemUtilities.isDrive(self._dirName) 1346 and not FileSystemUtilities.isDrive(self._dirName)
1407 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( 1407 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI(
1408 "BrowsersListFoldersFirst" 1408 "BrowsersListFoldersFirst"
1409 ): 1409 ):
1410 return order == Qt.SortOrder.AscendingOrder 1410 return order == Qt.SortOrder.AscendingOrder
1411 1411
1412 return BrowserItem.lessThan(self, other, column, order) 1412 return super().lessThan(other, column, order)
1413 1413
1414 1414
1415 class BrowserSysPathItem(BrowserItem): 1415 class BrowserSysPathItem(BrowserItem):
1416 """ 1416 """
1417 Class implementing the data structure for browser sys.path items. 1417 Class implementing the data structure for browser sys.path items.
1422 Constructor 1422 Constructor
1423 1423
1424 @param parent parent item 1424 @param parent parent item
1425 @type BrowserItem 1425 @type BrowserItem
1426 """ 1426 """
1427 BrowserItem.__init__(self, parent, "sys.path") 1427 super().__init__(parent, "sys.path")
1428 1428
1429 self.type_ = BrowserItemType.SysPath 1429 self.type_ = BrowserItemType.SysPath
1430 self.icon = EricPixmapCache.getIcon("filePython") 1430 self.icon = EricPixmapCache.getIcon("filePython")
1431 self._populated = False 1431 self._populated = False
1432 self._lazyPopulation = True 1432 self._lazyPopulation = True
1471 else: 1471 else:
1472 dirname, basename = os.path.split(finfo) 1472 dirname, basename = os.path.split(finfo)
1473 self.fileext = os.path.splitext(finfo)[1].lower() 1473 self.fileext = os.path.splitext(finfo)[1].lower()
1474 self._filename = os.path.abspath(finfo) 1474 self._filename = os.path.abspath(finfo)
1475 1475
1476 BrowserItem.__init__(self, parent, basename) 1476 super().__init__(parent, basename)
1477 1477
1478 self._dirName = dirname 1478 self._dirName = dirname
1479 self.type_ = BrowserItemType.File 1479 self.type_ = BrowserItemType.File
1480 self.sourceLanguage = sourceLanguage 1480 self.sourceLanguage = sourceLanguage
1481 1481
1797 if sinit and not oinit: 1797 if sinit and not oinit:
1798 return order == Qt.SortOrder.AscendingOrder 1798 return order == Qt.SortOrder.AscendingOrder
1799 if not sinit and oinit: 1799 if not sinit and oinit:
1800 return order == Qt.SortOrder.DescendingOrder 1800 return order == Qt.SortOrder.DescendingOrder
1801 1801
1802 return BrowserItem.lessThan(self, other, column, order) 1802 return super().lessThan(other, column, order)
1803 1803
1804 1804
1805 class BrowserClassItem(BrowserItem): 1805 class BrowserClassItem(BrowserItem):
1806 """ 1806 """
1807 Class implementing the data structure for browser class items. 1807 Class implementing the data structure for browser class items.
1829 except AttributeError: 1829 except AttributeError:
1830 sname = sup 1830 sname = sup
1831 supers.append(sname) 1831 supers.append(sname)
1832 name += "({0})".format(", ".join(supers)) 1832 name += "({0})".format(", ".join(supers))
1833 1833
1834 BrowserItem.__init__(self, parent, name) 1834 super().__init__(parent, name)
1835 1835
1836 self.type_ = BrowserItemType.Class 1836 self.type_ = BrowserItemType.Class
1837 self._name = name 1837 self._name = name
1838 self._classObject = cl 1838 self._classObject = cl
1839 self._filename = filename 1839 self._filename = filename
1953 if order == Qt.SortOrder.AscendingOrder: 1953 if order == Qt.SortOrder.AscendingOrder:
1954 return self.lineno() < other.lineno() 1954 return self.lineno() < other.lineno()
1955 else: 1955 else:
1956 return self.lineno() > other.lineno() 1956 return self.lineno() > other.lineno()
1957 1957
1958 return BrowserItem.lessThan(self, other, column, order) 1958 return super().lessThan(other, column, order)
1959 1959
1960 def isPublic(self): 1960 def isPublic(self):
1961 """ 1961 """
1962 Public method returning the public visibility status. 1962 Public method returning the public visibility status.
1963 1963
1982 @type Function 1982 @type Function
1983 @param filename filename of the file defining this class 1983 @param filename filename of the file defining this class
1984 @type str 1984 @type str
1985 """ 1985 """
1986 name = fn.name 1986 name = fn.name
1987 BrowserItem.__init__(self, parent, name) 1987 super().__init__(parent, name)
1988 1988
1989 self.type_ = BrowserItemType.Method 1989 self.type_ = BrowserItemType.Method
1990 self._name = name 1990 self._name = name
1991 self._functionObject = fn 1991 self._functionObject = fn
1992 self._filename = filename 1992 self._filename = filename
2098 if order == Qt.SortOrder.AscendingOrder: 2098 if order == Qt.SortOrder.AscendingOrder:
2099 return self.lineno() < other.lineno() 2099 return self.lineno() < other.lineno()
2100 else: 2100 else:
2101 return self.lineno() > other.lineno() 2101 return self.lineno() > other.lineno()
2102 2102
2103 return BrowserItem.lessThan(self, other, column, order) 2103 return super().lessThan(other, column, order)
2104 2104
2105 def isPublic(self): 2105 def isPublic(self):
2106 """ 2106 """
2107 Public method returning the public visibility status. 2107 Public method returning the public visibility status.
2108 2108
2128 @param text text to be shown by this item 2128 @param text text to be shown by this item
2129 @type str 2129 @type str
2130 @param isClass flag indicating class attributes 2130 @param isClass flag indicating class attributes
2131 @type bool 2131 @type bool
2132 """ 2132 """
2133 BrowserItem.__init__(self, parent, text) 2133 super().__init__(parent, text)
2134 2134
2135 self.type_ = BrowserItemType.Attributes 2135 self.type_ = BrowserItemType.Attributes
2136 self._attributes = attributes.copy() 2136 self._attributes = attributes.copy()
2137 self._populated = False 2137 self._populated = False
2138 self._lazyPopulation = True 2138 self._lazyPopulation = True
2185 if issubclass(other.__class__, BrowserCodingItem): 2185 if issubclass(other.__class__, BrowserCodingItem):
2186 return order == Qt.SortOrder.DescendingOrder 2186 return order == Qt.SortOrder.DescendingOrder
2187 elif issubclass(other.__class__, (BrowserClassItem, BrowserMethodItem)): 2187 elif issubclass(other.__class__, (BrowserClassItem, BrowserMethodItem)):
2188 return order == Qt.SortOrder.AscendingOrder 2188 return order == Qt.SortOrder.AscendingOrder
2189 2189
2190 return BrowserItem.lessThan(self, other, column, order) 2190 return super().lessThan(other, column, order)
2191 2191
2192 2192
2193 class BrowserClassAttributeItem(BrowserItem): 2193 class BrowserClassAttributeItem(BrowserItem):
2194 """ 2194 """
2195 Class implementing the data structure for browser class attribute items. 2195 Class implementing the data structure for browser class attribute items.
2204 @param attribute reference to the attribute object 2204 @param attribute reference to the attribute object
2205 @type Attribute 2205 @type Attribute
2206 @param isClass flag indicating a class attribute 2206 @param isClass flag indicating a class attribute
2207 @type bool 2207 @type bool
2208 """ 2208 """
2209 BrowserItem.__init__(self, parent, attribute.name) 2209 super().__init__(parent, attribute.name)
2210 2210
2211 self.type_ = BrowserItemType.Attribute 2211 self.type_ = BrowserItemType.Attribute
2212 self._attributeObject = attribute 2212 self._attributeObject = attribute
2213 self.__public = attribute.isPublic() 2213 self.__public = attribute.isPublic()
2214 if isClass: 2214 if isClass:
2291 if order == Qt.SortOrder.AscendingOrder: 2291 if order == Qt.SortOrder.AscendingOrder:
2292 return self.lineno() < other.lineno() 2292 return self.lineno() < other.lineno()
2293 else: 2293 else:
2294 return self.lineno() > other.lineno() 2294 return self.lineno() > other.lineno()
2295 2295
2296 return BrowserItem.lessThan(self, other, column, order) 2296 return super().lessThan(other, column, order)
2297 2297
2298 2298
2299 class BrowserGlobalsItem(BrowserClassAttributesItem): 2299 class BrowserGlobalsItem(BrowserClassAttributesItem):
2300 """ 2300 """
2301 Class implementing the data structure for browser globals items. 2301 Class implementing the data structure for browser globals items.
2329 @param text text to be shown by this item 2329 @param text text to be shown by this item
2330 @type str 2330 @type str
2331 @param linenumber line number of the coding line 2331 @param linenumber line number of the coding line
2332 @type int 2332 @type int
2333 """ 2333 """
2334 BrowserItem.__init__(self, parent, text) 2334 super().__init__(parent, text)
2335 2335
2336 self.type_ = BrowserItemType.Coding 2336 self.type_ = BrowserItemType.Coding
2337 self.icon = EricPixmapCache.getIcon("textencoding") 2337 self.icon = EricPixmapCache.getIcon("textencoding")
2338 2338
2339 self.__lineno = linenumber 2339 self.__lineno = linenumber
2364 other.__class__, 2364 other.__class__,
2365 (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem), 2365 (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem),
2366 ): 2366 ):
2367 return order == Qt.SortOrder.AscendingOrder 2367 return order == Qt.SortOrder.AscendingOrder
2368 2368
2369 return BrowserItem.lessThan(self, other, column, order) 2369 return super().lessThan(other, column, order)
2370 2370
2371 2371
2372 class BrowserImportsItem(BrowserItem): 2372 class BrowserImportsItem(BrowserItem):
2373 """ 2373 """
2374 Class implementing the data structure for browser import items. 2374 Class implementing the data structure for browser import items.
2381 @param parent parent item 2381 @param parent parent item
2382 @type BrowserItem 2382 @type BrowserItem
2383 @param text text to be shown by this item 2383 @param text text to be shown by this item
2384 @type str 2384 @type str
2385 """ 2385 """
2386 BrowserItem.__init__(self, parent, text) 2386 super().__init__(parent, text)
2387 2387
2388 self.type_ = BrowserItemType.Imports 2388 self.type_ = BrowserItemType.Imports
2389 self.icon = EricPixmapCache.getIcon("imports") 2389 self.icon = EricPixmapCache.getIcon("imports")
2390 2390
2391 def lessThan(self, other, column, order): 2391 def lessThan(self, other, column, order):
2402 @rtype bool 2402 @rtype bool
2403 """ 2403 """
2404 if issubclass(other.__class__, (BrowserClassItem, BrowserClassAttributesItem)): 2404 if issubclass(other.__class__, (BrowserClassItem, BrowserClassAttributesItem)):
2405 return order == Qt.SortOrder.AscendingOrder 2405 return order == Qt.SortOrder.AscendingOrder
2406 2406
2407 return BrowserItem.lessThan(self, other, column, order) 2407 return super().lessThan(other, column, order)
2408 2408
2409 2409
2410 class BrowserImportItem(BrowserItem): 2410 class BrowserImportItem(BrowserItem):
2411 """ 2411 """
2412 Class implementing the data structure for browser imported module and 2412 Class implementing the data structure for browser imported module and
2426 @param lineNumbers list of line numbers of the import statement 2426 @param lineNumbers list of line numbers of the import statement
2427 @type list of int 2427 @type list of int
2428 @param isModule flag indicating a module item entry 2428 @param isModule flag indicating a module item entry
2429 @type bool 2429 @type bool
2430 """ 2430 """
2431 BrowserItem.__init__(self, parent, text) 2431 super().__init__(parent, text)
2432 2432
2433 self.__filename = filename 2433 self.__filename = filename
2434 self.__linenos = lineNumbers[:] 2434 self.__linenos = lineNumbers[:]
2435 2435
2436 self.type_ = BrowserItemType.Import 2436 self.type_ = BrowserItemType.Import
2483 if order == Qt.SortOrder.AscendingOrder: 2483 if order == Qt.SortOrder.AscendingOrder:
2484 return self.lineno() < other.lineno() 2484 return self.lineno() < other.lineno()
2485 else: 2485 else:
2486 return self.lineno() > other.lineno() 2486 return self.lineno() > other.lineno()
2487 2487
2488 return BrowserItem.lessThan(self, other, column, order) 2488 return super().lessThan(other, column, order)

eric ide

mercurial