UI/BrowserModel.py

changeset 1227
c5db073a124f
parent 1131
7781e396c903
child 1303
6018d7ac3aec
equal deleted inserted replaced
1225:254ec677c775 1227:c5db073a124f
610 self._addItem(node, parentItem) 610 self._addItem(node, parentItem)
611 611
612 if len(cl.globals): 612 if len(cl.globals):
613 node = BrowserClassAttributesItem( 613 node = BrowserClassAttributesItem(
614 parentItem, cl.globals, 614 parentItem, cl.globals,
615 QApplication.translate("BrowserModel", "Attributes (global)")) 615 QApplication.translate("BrowserModel", "Class Attributes"),
616 True)
616 if repopulate: 617 if repopulate:
617 self.addItem(node, 618 self.addItem(node,
618 self.createIndex(parentItem.row(), 0, parentItem)) 619 self.createIndex(parentItem.row(), 0, parentItem))
619 else: 620 else:
620 self._addItem(node, parentItem) 621 self._addItem(node, parentItem)
657 Public method to populate a class attributes item's subtree. 658 Public method to populate a class attributes item's subtree.
658 659
659 @param parentItem reference to the class attributes item to be populated 660 @param parentItem reference to the class attributes item to be populated
660 @param repopulate flag indicating a repopulation (boolean) 661 @param repopulate flag indicating a repopulation (boolean)
661 """ 662 """
663 classAttributes = parentItem.isClassAttributes()
662 attributes = parentItem.attributes() 664 attributes = parentItem.attributes()
663 if not attributes: 665 if not attributes:
664 return 666 return
665 667
666 keys = list(attributes.keys()) 668 keys = list(attributes.keys())
667 if len(keys) > 0: 669 if len(keys) > 0:
668 if repopulate: 670 if repopulate:
669 self.beginInsertRows(self.createIndex(parentItem.row(), 0, parentItem), 671 self.beginInsertRows(self.createIndex(parentItem.row(), 0, parentItem),
670 0, len(keys) - 1) 672 0, len(keys) - 1)
671 for key in keys: 673 for key in keys:
672 node = BrowserClassAttributeItem(parentItem, attributes[key]) 674 node = BrowserClassAttributeItem(parentItem, attributes[key],
675 classAttributes)
673 self._addItem(node, parentItem) 676 self._addItem(node, parentItem)
674 if repopulate: 677 if repopulate:
675 self.endInsertRows() 678 self.endInsertRows()
676 679
677 680
1326 1329
1327 self.type_ = BrowserItemMethod 1330 self.type_ = BrowserItemMethod
1328 self.name = name 1331 self.name = name
1329 self._functionObject = fn 1332 self._functionObject = fn
1330 self._filename = filename 1333 self._filename = filename
1331 if self._functionObject.isPrivate(): 1334 if self._functionObject.modifier == \
1335 Utilities.ClassBrowsers.ClbrBaseClasses.Function.Static:
1336 self.icon = UI.PixmapCache.getIcon("method_static.png")
1337 elif self._functionObject.modifier == \
1338 Utilities.ClassBrowsers.ClbrBaseClasses.Function.Class:
1339 self.icon = UI.PixmapCache.getIcon("method_class.png")
1340 elif self._functionObject.isPrivate():
1332 self.icon = UI.PixmapCache.getIcon("method_private.png") 1341 self.icon = UI.PixmapCache.getIcon("method_private.png")
1333 elif self._functionObject.isProtected(): 1342 elif self._functionObject.isProtected():
1334 self.icon = UI.PixmapCache.getIcon("method_protected.png") 1343 self.icon = UI.PixmapCache.getIcon("method_protected.png")
1335 else: 1344 else:
1336 self.icon = UI.PixmapCache.getIcon("method.png") 1345 self.icon = UI.PixmapCache.getIcon("method.png")
1404 1413
1405 class BrowserClassAttributesItem(BrowserItem): 1414 class BrowserClassAttributesItem(BrowserItem):
1406 """ 1415 """
1407 Class implementing the data structure for browser class attributes items. 1416 Class implementing the data structure for browser class attributes items.
1408 """ 1417 """
1409 def __init__(self, parent, attributes, text): 1418 def __init__(self, parent, attributes, text, isClass=False):
1410 """ 1419 """
1411 Constructor 1420 Constructor
1412 1421
1413 @param parent parent item 1422 @param parent parent item
1414 @param attributes list of attributes 1423 @param attributes list of attributes
1415 @param text text to be shown by this item (string) 1424 @param text text to be shown by this item (string)
1425 @param isClass flag indicating class attributes (boolean)
1416 """ 1426 """
1417 BrowserItem.__init__(self, parent, text) 1427 BrowserItem.__init__(self, parent, text)
1418 1428
1419 self.type_ = BrowserItemAttributes 1429 self.type_ = BrowserItemAttributes
1420 self._attributes = attributes.copy() 1430 self._attributes = attributes.copy()
1421 self._populated = False 1431 self._populated = False
1422 self._lazyPopulation = True 1432 self._lazyPopulation = True
1423 self.icon = UI.PixmapCache.getIcon("attributes.png") 1433 if isClass:
1434 self.icon = UI.PixmapCache.getIcon("attributes_class.png")
1435 else:
1436 self.icon = UI.PixmapCache.getIcon("attributes.png")
1437 self.__isClass = isClass
1424 1438
1425 def attributes(self): 1439 def attributes(self):
1426 """ 1440 """
1427 Public method returning the attribute list. 1441 Public method returning the attribute list.
1428 1442
1429 @return reference to the list of attributes 1443 @return reference to the list of attributes
1430 """ 1444 """
1431 return self._attributes 1445 return self._attributes
1446
1447 def isClassAttributes(self):
1448 """
1449 Public method returning the attributes type.
1450
1451 @return flag indicating class attributes (boolean)
1452 """
1453 return self.__isClass
1432 1454
1433 def lessThan(self, other, column, order): 1455 def lessThan(self, other, column, order):
1434 """ 1456 """
1435 Public method to check, if the item is less than the other one. 1457 Public method to check, if the item is less than the other one.
1436 1458
1450 1472
1451 class BrowserClassAttributeItem(BrowserItem): 1473 class BrowserClassAttributeItem(BrowserItem):
1452 """ 1474 """
1453 Class implementing the data structure for browser class attribute items. 1475 Class implementing the data structure for browser class attribute items.
1454 """ 1476 """
1455 def __init__(self, parent, attribute): 1477 def __init__(self, parent, attribute, isClass=False):
1456 """ 1478 """
1457 Constructor 1479 Constructor
1458 1480
1459 @param parent parent item 1481 @param parent parent item
1460 @param attribute reference to the attribute object 1482 @param attribute reference to the attribute object
1483 @param isClass flag indicating a class attribute (boolean)
1461 """ 1484 """
1462 BrowserItem.__init__(self, parent, attribute.name) 1485 BrowserItem.__init__(self, parent, attribute.name)
1463 1486
1464 self.type_ = BrowserItemAttribute 1487 self.type_ = BrowserItemAttribute
1465 self._attributeObject = attribute 1488 self._attributeObject = attribute
1466 self.__public = attribute.isPublic() 1489 self.__public = attribute.isPublic()
1467 if attribute.isPrivate(): 1490 if isClass:
1491 self.icon = UI.PixmapCache.getIcon("attribute_class.png")
1492 elif attribute.isPrivate():
1468 self.icon = UI.PixmapCache.getIcon("attribute_private.png") 1493 self.icon = UI.PixmapCache.getIcon("attribute_private.png")
1469 elif attribute.isProtected(): 1494 elif attribute.isProtected():
1470 self.icon = UI.PixmapCache.getIcon("attribute_protected.png") 1495 self.icon = UI.PixmapCache.getIcon("attribute_protected.png")
1471 else: 1496 else:
1472 self.icon = UI.PixmapCache.getIcon("attribute.png") 1497 self.icon = UI.PixmapCache.getIcon("attribute.png")

eric ide

mercurial