src/eric7/UI/BrowserModel.py

branch
eric7
changeset 9612
93b496cc3c88
parent 9609
c2f9c10c47cc
child 9624
b47dfa7a137d
equal deleted inserted replaced
9611:af03537d56b2 9612:93b496cc3c88
24 from PyQt6.QtGui import QFont, QImageReader 24 from PyQt6.QtGui import QFont, QImageReader
25 from PyQt6.QtWidgets import QApplication 25 from PyQt6.QtWidgets import QApplication
26 26
27 from eric7 import Preferences, Utilities 27 from eric7 import Preferences, Utilities
28 from eric7.EricGui import EricPixmapCache 28 from eric7.EricGui import EricPixmapCache
29 from eric7.Utilities import ClassBrowsers
29 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses 30 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses
30 31
31 BrowserItemRoot = 0 32 BrowserItemRoot = 0
32 BrowserItemDirectory = 1 33 BrowserItemDirectory = 1
33 BrowserItemSysPath = 2 34 BrowserItemSysPath = 2
1193 pixName = "fileResource" 1194 pixName = "fileResource"
1194 elif self.isProjectFile(): 1195 elif self.isProjectFile():
1195 pixName = "fileProject" 1196 pixName = "fileProject"
1196 elif self.isMultiProjectFile(): 1197 elif self.isMultiProjectFile():
1197 pixName = "fileMultiProject" 1198 pixName = "fileMultiProject"
1198 # TODO: delegate to the plugin
1199 elif self.isIdlFile():
1200 pixName = "fileIDL"
1201 self._populated = False
1202 self._lazyPopulation = True
1203 self._moduleName = os.path.basename(finfo)
1204 # TODO: delegate to the plugin
1205 elif self.isProtobufFile():
1206 pixName = "protobuf"
1207 self._populated = False
1208 self._lazyPopulation = True
1209 self._moduleName = os.path.basename(finfo)
1210 elif self.isSvgFile(): 1199 elif self.isSvgFile():
1211 pixName = "fileSvg" 1200 pixName = "fileSvg"
1212 elif self.isPixmapFile(): 1201 elif self.isPixmapFile():
1213 pixName = "filePixmap" 1202 pixName = "filePixmap"
1214 elif self.isDFile(): 1203 elif self.isDFile():
1218 self._populated = False 1207 self._populated = False
1219 self._lazyPopulation = True 1208 self._lazyPopulation = True
1220 self._moduleName = os.path.basename(finfo) 1209 self._moduleName = os.path.basename(finfo)
1221 elif self.isEricGraphicsFile(): 1210 elif self.isEricGraphicsFile():
1222 pixName = "fileUML" 1211 pixName = "fileUML"
1212 elif self.isParsableFile():
1213 pixName = ClassBrowsers.getIcon(self._filename)
1214 self._populated = False
1215 self._lazyPopulation = True
1216 self._moduleName = os.path.basename(finfo)
1223 else: 1217 else:
1224 pixName = "fileMisc" 1218 pixName = "fileMisc"
1225 1219
1226 if os.path.lexists(self._filename) and os.path.islink(self._filename): 1220 if os.path.lexists(self._filename) and os.path.islink(self._filename):
1227 self.symlink = True 1221 self.symlink = True
1236 @param finfo the string for the file (string) 1230 @param finfo the string for the file (string)
1237 @param full flag indicating full pathname should be displayed (boolean) 1231 @param full flag indicating full pathname should be displayed (boolean)
1238 """ 1232 """
1239 self._filename = os.path.abspath(finfo) 1233 self._filename = os.path.abspath(finfo)
1240 self.itemData[0] = os.path.basename(finfo) 1234 self.itemData[0] = os.path.basename(finfo)
1241 if ( 1235 self.fileext = os.path.splitext(finfo)[1].lower()
1242 self.isPython3File() 1236 if self.isPython3File() or self.isRubyFile() or self.isParsableFile():
1243 or self.isRubyFile()
1244 # TODO: delegate to the plugin
1245 or self.isIdlFile()
1246 # TODO: delegate to the plugin
1247 or self.isProtobufFile()
1248 ):
1249 self._dirName = os.path.dirname(finfo) 1237 self._dirName = os.path.dirname(finfo)
1250 self._moduleName = os.path.basename(finfo) 1238 self._moduleName = os.path.basename(finfo)
1251 1239
1252 def fileName(self): 1240 def fileName(self):
1253 """ 1241 """
1370 @return flag indicating an eric project file 1358 @return flag indicating an eric project file
1371 @rtype bool 1359 @rtype bool
1372 """ 1360 """
1373 return self.fileext in (".emj", ".e4m", ".e5m") 1361 return self.fileext in (".emj", ".e4m", ".e5m")
1374 1362
1375 # TODO: delegate to the plugin
1376 def isIdlFile(self):
1377 """
1378 Public method to check, if this file is a CORBA IDL file.
1379
1380 @return flag indicating a CORBA IDL file
1381 @rtype bool
1382 """
1383 return self.fileext == ".idl"
1384
1385 # TODO: delegate to the plugin
1386 def isProtobufFile(self):
1387 """
1388 Public method to check, if this file is a Google Protocol Buffer file.
1389
1390 @return flag indicating a protobuf file
1391 @rtype bool
1392 """
1393 return self.fileext == ".proto"
1394
1395 def isJavaScriptFile(self): 1363 def isJavaScriptFile(self):
1396 """ 1364 """
1397 Public method to check, if this file is a JavaScript file. 1365 Public method to check, if this file is a JavaScript file.
1398 1366
1399 @return flag indicating a JavaScript file 1367 @return flag indicating a JavaScript file
1435 1403
1436 @return flag indicating an eric graphics file 1404 @return flag indicating an eric graphics file
1437 @rtype bool 1405 @rtype bool
1438 """ 1406 """
1439 return self.fileext in (".egj", ".e5g") 1407 return self.fileext in (".egj", ".e5g")
1408
1409 def isParsableFile(self):
1410 """
1411 Public method to check, if the file is supported by class browsers.
1412
1413 @return flag indicating a supported file
1414 @rtype bool
1415 """
1416 return ClassBrowsers.isSupportedType(self.fileext)
1440 1417
1441 def lessThan(self, other, column, order): 1418 def lessThan(self, other, column, order):
1442 """ 1419 """
1443 Public method to check, if the item is less than the other one. 1420 Public method to check, if the item is less than the other one.
1444 1421

eric ide

mercurial