E5Gui/E5TreeSortFilterProxyModel.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1131
7781e396c903
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
8 """ 8 """
9 9
10 from PyQt4.QtCore import Qt, QModelIndex 10 from PyQt4.QtCore import Qt, QModelIndex
11 from PyQt4.QtGui import QSortFilterProxyModel 11 from PyQt4.QtGui import QSortFilterProxyModel
12 12
13
13 class E5TreeSortFilterProxyModel(QSortFilterProxyModel): 14 class E5TreeSortFilterProxyModel(QSortFilterProxyModel):
14 """ 15 """
15 Class implementing a modified QSortFilterProxyModel. 16 Class implementing a modified QSortFilterProxyModel.
16 17
17 It always accepts the root nodes in the tree so filtering is only done 18 It always accepts the root nodes in the tree so filtering is only done
18 on the children. 19 on the children.
19 """ 20 """
20 def __init__(self, parent = None): 21 def __init__(self, parent=None):
21 """ 22 """
22 Constructor 23 Constructor
23 24
24 @param parent reference to the parent object (QObject) 25 @param parent reference to the parent object (QObject)
25 """ 26 """
39 if self.sourceModel().hasChildren(idx): 40 if self.sourceModel().hasChildren(idx):
40 return True 41 return True
41 42
42 return QSortFilterProxyModel.filterAcceptsRow(self, sourceRow, sourceParent) 43 return QSortFilterProxyModel.filterAcceptsRow(self, sourceRow, sourceParent)
43 44
44 def hasChildren(self, parent = QModelIndex()): 45 def hasChildren(self, parent=QModelIndex()):
45 """ 46 """
46 Public method to check, if a parent node has some children. 47 Public method to check, if a parent node has some children.
47 48
48 @param parent index of the parent node (QModelIndex) 49 @param parent index of the parent node (QModelIndex)
49 @return flag indicating the presence of children (boolean) 50 @return flag indicating the presence of children (boolean)

eric ide

mercurial