eric6/UI/BrowserModel.py

changeset 7533
88261c96484b
parent 7518
6dea4abd3097
child 7581
692838bf5d11
equal deleted inserted replaced
7532:1358e9d67a1c 7533:88261c96484b
824 self.childItems = [] 824 self.childItems = []
825 825
826 self.parentItem = parent 826 self.parentItem = parent
827 self.itemData = [data] 827 self.itemData = [data]
828 self.type_ = BrowserItemRoot 828 self.type_ = BrowserItemRoot
829 self.icon = UI.PixmapCache.getIcon("empty.png") 829 self.icon = UI.PixmapCache.getIcon("empty")
830 self._populated = True 830 self._populated = True
831 self._lazyPopulation = False 831 self._lazyPopulation = False
832 self.symlink = False 832 self.symlink = False
833 833
834 def appendChild(self, child): 834 def appendChild(self, child):
1004 not Utilities.isDrive(self._dirName) and 1004 not Utilities.isDrive(self._dirName) and
1005 os.path.lexists(self._dirName) and 1005 os.path.lexists(self._dirName) and
1006 os.path.islink(self._dirName) 1006 os.path.islink(self._dirName)
1007 ): 1007 ):
1008 self.symlink = True 1008 self.symlink = True
1009 self.icon = UI.PixmapCache.getSymlinkIcon("dirClosed.png") 1009 self.icon = UI.PixmapCache.getSymlinkIcon("dirClosed")
1010 else: 1010 else:
1011 self.icon = UI.PixmapCache.getIcon("dirClosed.png") 1011 self.icon = UI.PixmapCache.getIcon("dirClosed")
1012 self._populated = False 1012 self._populated = False
1013 self._lazyPopulation = True 1013 self._lazyPopulation = True
1014 1014
1015 def setName(self, dinfo, full=True): 1015 def setName(self, dinfo, full=True):
1016 """ 1016 """
1070 @param parent parent item 1070 @param parent parent item
1071 """ 1071 """
1072 BrowserItem.__init__(self, parent, "sys.path") 1072 BrowserItem.__init__(self, parent, "sys.path")
1073 1073
1074 self.type_ = BrowserItemSysPath 1074 self.type_ = BrowserItemSysPath
1075 self.icon = UI.PixmapCache.getIcon("filePython.png") 1075 self.icon = UI.PixmapCache.getIcon("filePython")
1076 self._populated = False 1076 self._populated = False
1077 self._lazyPopulation = True 1077 self._lazyPopulation = True
1078 1078
1079 def name(self): 1079 def name(self):
1080 """ 1080 """
1109 self._moduleName = '' 1109 self._moduleName = ''
1110 1110
1111 pixName = "" 1111 pixName = ""
1112 if self.isPython2File(): 1112 if self.isPython2File():
1113 if self.fileext == '.py': 1113 if self.fileext == '.py':
1114 pixName = "filePython.png" 1114 pixName = "filePython"
1115 else: 1115 else:
1116 pixName = "filePython2.png" 1116 pixName = "filePython2"
1117 self._populated = False 1117 self._populated = False
1118 self._lazyPopulation = True 1118 self._lazyPopulation = True
1119 self._moduleName = os.path.basename(finfo) 1119 self._moduleName = os.path.basename(finfo)
1120 elif self.isPython3File(): 1120 elif self.isPython3File():
1121 pixName = "filePython.png" 1121 pixName = "filePython"
1122 self._populated = False 1122 self._populated = False
1123 self._lazyPopulation = True 1123 self._lazyPopulation = True
1124 self._moduleName = os.path.basename(finfo) 1124 self._moduleName = os.path.basename(finfo)
1125 elif self.isRubyFile(): 1125 elif self.isRubyFile():
1126 pixName = "fileRuby.png" 1126 pixName = "fileRuby"
1127 self._populated = False 1127 self._populated = False
1128 self._lazyPopulation = True 1128 self._lazyPopulation = True
1129 self._moduleName = os.path.basename(finfo) 1129 self._moduleName = os.path.basename(finfo)
1130 elif self.isDesignerFile(): 1130 elif self.isDesignerFile():
1131 pixName = "fileDesigner.png" 1131 pixName = "fileDesigner"
1132 elif self.isLinguistFile(): 1132 elif self.isLinguistFile():
1133 if self.fileext == '.ts': 1133 if self.fileext == '.ts':
1134 pixName = "fileLinguist.png" 1134 pixName = "fileLinguist"
1135 else: 1135 else:
1136 pixName = "fileLinguist2.png" 1136 pixName = "fileLinguist2"
1137 elif self.isResourcesFile(): 1137 elif self.isResourcesFile():
1138 pixName = "fileResource.png" 1138 pixName = "fileResource"
1139 elif self.isProjectFile(): 1139 elif self.isProjectFile():
1140 pixName = "fileProject.png" 1140 pixName = "fileProject"
1141 elif self.isMultiProjectFile(): 1141 elif self.isMultiProjectFile():
1142 pixName = "fileMultiProject.png" 1142 pixName = "fileMultiProject"
1143 elif self.isIdlFile(): 1143 elif self.isIdlFile():
1144 pixName = "fileIDL.png" 1144 pixName = "fileIDL"
1145 self._populated = False 1145 self._populated = False
1146 self._lazyPopulation = True 1146 self._lazyPopulation = True
1147 self._moduleName = os.path.basename(finfo) 1147 self._moduleName = os.path.basename(finfo)
1148 elif self.isProtobufFile(): 1148 elif self.isProtobufFile():
1149 pixName = "protobuf.png" 1149 pixName = "protobuf"
1150 self._populated = False 1150 self._populated = False
1151 self._lazyPopulation = True 1151 self._lazyPopulation = True
1152 self._moduleName = os.path.basename(finfo) 1152 self._moduleName = os.path.basename(finfo)
1153 elif self.isSvgFile(): 1153 elif self.isSvgFile():
1154 pixName = "fileSvg.png" 1154 pixName = "fileSvg"
1155 elif self.isPixmapFile(): 1155 elif self.isPixmapFile():
1156 pixName = "filePixmap.png" 1156 pixName = "filePixmap"
1157 elif self.isDFile(): 1157 elif self.isDFile():
1158 pixName = "fileD.png" 1158 pixName = "fileD"
1159 elif self.isJavaScriptFile(): 1159 elif self.isJavaScriptFile():
1160 pixName = "fileJavascript.png" 1160 pixName = "fileJavascript"
1161 self._populated = False 1161 self._populated = False
1162 self._lazyPopulation = True 1162 self._lazyPopulation = True
1163 self._moduleName = os.path.basename(finfo) 1163 self._moduleName = os.path.basename(finfo)
1164 else: 1164 else:
1165 pixName = "fileMisc.png" 1165 pixName = "fileMisc"
1166 1166
1167 if os.path.lexists(self._filename) and os.path.islink(self._filename): 1167 if os.path.lexists(self._filename) and os.path.islink(self._filename):
1168 self.symlink = True 1168 self.symlink = True
1169 self.icon = UI.PixmapCache.getSymlinkIcon(pixName) 1169 self.icon = UI.PixmapCache.getSymlinkIcon(pixName)
1170 else: 1170 else:
1422 self.isenum = isinstance( 1422 self.isenum = isinstance(
1423 self._classObject, 1423 self._classObject,
1424 Utilities.ClassBrowsers.ClbrBaseClasses.Enum) 1424 Utilities.ClassBrowsers.ClbrBaseClasses.Enum)
1425 if self.isfunction: 1425 if self.isfunction:
1426 if cl.isPrivate(): 1426 if cl.isPrivate():
1427 self.icon = UI.PixmapCache.getIcon("method_private.png") 1427 self.icon = UI.PixmapCache.getIcon("method_private")
1428 elif cl.isProtected(): 1428 elif cl.isProtected():
1429 self.icon = UI.PixmapCache.getIcon("method_protected.png") 1429 self.icon = UI.PixmapCache.getIcon("method_protected")
1430 else: 1430 else:
1431 self.icon = UI.PixmapCache.getIcon("method.png") 1431 self.icon = UI.PixmapCache.getIcon("method")
1432 self.itemData[0] = "{0}({1})".format( 1432 self.itemData[0] = "{0}({1})".format(
1433 name, ", ".join(self._classObject.parameters)) 1433 name, ", ".join(self._classObject.parameters))
1434 if self._classObject.annotation: 1434 if self._classObject.annotation:
1435 self.itemData[0] = "{0} {1}".format( 1435 self.itemData[0] = "{0} {1}".format(
1436 self.itemData[0], self._classObject.annotation) 1436 self.itemData[0], self._classObject.annotation)
1437 ## if no defaults are wanted 1437 ## if no defaults are wanted
1438 ## ....format(name, 1438 ## ....format(name,
1439 ## ", ".join([e.split('=')[0].strip() \ 1439 ## ", ".join([e.split('=')[0].strip() \
1440 ## for e in self._classObject.parameters])) 1440 ## for e in self._classObject.parameters]))
1441 elif self.ismodule: 1441 elif self.ismodule:
1442 self.icon = UI.PixmapCache.getIcon("module.png") 1442 self.icon = UI.PixmapCache.getIcon("module")
1443 elif self.isenum: 1443 elif self.isenum:
1444 self.icon = UI.PixmapCache.getIcon("attribute.png") 1444 self.icon = UI.PixmapCache.getIcon("attribute")
1445 else: 1445 else:
1446 if cl.isPrivate(): 1446 if cl.isPrivate():
1447 self.icon = UI.PixmapCache.getIcon("class_private.png") 1447 self.icon = UI.PixmapCache.getIcon("class_private")
1448 elif cl.isProtected(): 1448 elif cl.isProtected():
1449 self.icon = UI.PixmapCache.getIcon("class_protected.png") 1449 self.icon = UI.PixmapCache.getIcon("class_protected")
1450 else: 1450 else:
1451 self.icon = UI.PixmapCache.getIcon("class.png") 1451 self.icon = UI.PixmapCache.getIcon("class")
1452 if ( 1452 if (
1453 self._classObject and 1453 self._classObject and
1454 (self._classObject.methods or 1454 (self._classObject.methods or
1455 self._classObject.classes or 1455 self._classObject.classes or
1456 self._classObject.attributes) 1456 self._classObject.attributes)
1555 self._filename = filename 1555 self._filename = filename
1556 if ( 1556 if (
1557 self._functionObject.modifier == 1557 self._functionObject.modifier ==
1558 Utilities.ClassBrowsers.ClbrBaseClasses.Function.Static 1558 Utilities.ClassBrowsers.ClbrBaseClasses.Function.Static
1559 ): 1559 ):
1560 self.icon = UI.PixmapCache.getIcon("method_static.png") 1560 self.icon = UI.PixmapCache.getIcon("method_static")
1561 elif ( 1561 elif (
1562 self._functionObject.modifier == 1562 self._functionObject.modifier ==
1563 Utilities.ClassBrowsers.ClbrBaseClasses.Function.Class 1563 Utilities.ClassBrowsers.ClbrBaseClasses.Function.Class
1564 ): 1564 ):
1565 self.icon = UI.PixmapCache.getIcon("method_class.png") 1565 self.icon = UI.PixmapCache.getIcon("method_class")
1566 elif self._functionObject.isPrivate(): 1566 elif self._functionObject.isPrivate():
1567 self.icon = UI.PixmapCache.getIcon("method_private.png") 1567 self.icon = UI.PixmapCache.getIcon("method_private")
1568 elif self._functionObject.isProtected(): 1568 elif self._functionObject.isProtected():
1569 self.icon = UI.PixmapCache.getIcon("method_protected.png") 1569 self.icon = UI.PixmapCache.getIcon("method_protected")
1570 else: 1570 else:
1571 self.icon = UI.PixmapCache.getIcon("method.png") 1571 self.icon = UI.PixmapCache.getIcon("method")
1572 self.itemData[0] = "{0}({1})".format( 1572 self.itemData[0] = "{0}({1})".format(
1573 name, ", ".join(self._functionObject.parameters)) 1573 name, ", ".join(self._functionObject.parameters))
1574 if self._functionObject.annotation: 1574 if self._functionObject.annotation:
1575 self.itemData[0] = "{0} {1}".format( 1575 self.itemData[0] = "{0} {1}".format(
1576 self.itemData[0], self._functionObject.annotation) 1576 self.itemData[0], self._functionObject.annotation)
1680 self.type_ = BrowserItemAttributes 1680 self.type_ = BrowserItemAttributes
1681 self._attributes = attributes.copy() 1681 self._attributes = attributes.copy()
1682 self._populated = False 1682 self._populated = False
1683 self._lazyPopulation = True 1683 self._lazyPopulation = True
1684 if isClass: 1684 if isClass:
1685 self.icon = UI.PixmapCache.getIcon("attributes_class.png") 1685 self.icon = UI.PixmapCache.getIcon("attributes_class")
1686 else: 1686 else:
1687 self.icon = UI.PixmapCache.getIcon("attributes.png") 1687 self.icon = UI.PixmapCache.getIcon("attributes")
1688 self.__isClass = isClass 1688 self.__isClass = isClass
1689 1689
1690 def name(self): 1690 def name(self):
1691 """ 1691 """
1692 Public method to return the name of the item. 1692 Public method to return the name of the item.
1747 1747
1748 self.type_ = BrowserItemAttribute 1748 self.type_ = BrowserItemAttribute
1749 self._attributeObject = attribute 1749 self._attributeObject = attribute
1750 self.__public = attribute.isPublic() 1750 self.__public = attribute.isPublic()
1751 if isClass: 1751 if isClass:
1752 self.icon = UI.PixmapCache.getIcon("attribute_class.png") 1752 self.icon = UI.PixmapCache.getIcon("attribute_class")
1753 elif attribute.isPrivate(): 1753 elif attribute.isPrivate():
1754 self.icon = UI.PixmapCache.getIcon("attribute_private.png") 1754 self.icon = UI.PixmapCache.getIcon("attribute_private")
1755 elif attribute.isProtected(): 1755 elif attribute.isProtected():
1756 self.icon = UI.PixmapCache.getIcon("attribute_protected.png") 1756 self.icon = UI.PixmapCache.getIcon("attribute_protected")
1757 else: 1757 else:
1758 self.icon = UI.PixmapCache.getIcon("attribute.png") 1758 self.icon = UI.PixmapCache.getIcon("attribute")
1759 1759
1760 def isPublic(self): 1760 def isPublic(self):
1761 """ 1761 """
1762 Public method returning the public visibility status. 1762 Public method returning the public visibility status.
1763 1763
1845 @param text text to be shown by this item (string) 1845 @param text text to be shown by this item (string)
1846 """ 1846 """
1847 BrowserItem.__init__(self, parent, text) 1847 BrowserItem.__init__(self, parent, text)
1848 1848
1849 self.type_ = BrowserItemCoding 1849 self.type_ = BrowserItemCoding
1850 self.icon = UI.PixmapCache.getIcon("textencoding.png") 1850 self.icon = UI.PixmapCache.getIcon("textencoding")
1851 1851
1852 def lessThan(self, other, column, order): 1852 def lessThan(self, other, column, order):
1853 """ 1853 """
1854 Public method to check, if the item is less than the other one. 1854 Public method to check, if the item is less than the other one.
1855 1855
1879 @param text text to be shown by this item (string) 1879 @param text text to be shown by this item (string)
1880 """ 1880 """
1881 BrowserItem.__init__(self, parent, text) 1881 BrowserItem.__init__(self, parent, text)
1882 1882
1883 self.type_ = BrowserItemImports 1883 self.type_ = BrowserItemImports
1884 self.icon = UI.PixmapCache.getIcon("imports.png") 1884 self.icon = UI.PixmapCache.getIcon("imports")
1885 1885
1886 def lessThan(self, other, column, order): 1886 def lessThan(self, other, column, order):
1887 """ 1887 """
1888 Public method to check, if the item is less than the other one. 1888 Public method to check, if the item is less than the other one.
1889 1889
1922 self.__filename = filename 1922 self.__filename = filename
1923 self.__linenos = lineNumbers[:] 1923 self.__linenos = lineNumbers[:]
1924 1924
1925 self.type_ = BrowserItemImport 1925 self.type_ = BrowserItemImport
1926 if isModule: 1926 if isModule:
1927 self.icon = UI.PixmapCache.getIcon("importedModule.png") 1927 self.icon = UI.PixmapCache.getIcon("importedModule")
1928 else: 1928 else:
1929 self.icon = UI.PixmapCache.getIcon("importedName.png") 1929 self.icon = UI.PixmapCache.getIcon("importedName")
1930 1930
1931 def fileName(self): 1931 def fileName(self):
1932 """ 1932 """
1933 Public method returning the filename. 1933 Public method returning the filename.
1934 1934

eric ide

mercurial