Krita Source Code Documentation
Loading...
Searching...
No Matches
filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel Class Reference
+ Inheritance diagram for filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel:

Public Member Functions

 __init__ (self, uiFilterManager, parent=None)
 
 columnCount (self, parent)
 
 data (self, index, role)
 
 flags (self, index)
 
 headerData (self, section, orientation, role)
 
 index (self, row, column, parent)
 
 parent (self, index)
 
 rowCount (self, parent)
 

Public Attributes

 DOCUMENT_COLUMN
 
 NODE_COLUMN
 
 rootItem
 
 TYPE_COLUMN
 
 uiFilterManager
 

Static Public Attributes

int DOCUMENT_COLUMN = 4
 
int NODE_COLUMN = 3
 
int TYPE_COLUMN = 1
 

Protected Member Functions

 _addSubNodes (self, nodes, parent, documentIndex)
 
 _loadTreeModel (self, parent)
 

Detailed Description

Definition at line 13 of file filtermanagertreemodel.py.

Constructor & Destructor Documentation

◆ __init__()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.__init__ ( self,
uiFilterManager,
parent = None )

Definition at line 19 of file filtermanagertreemodel.py.

19 def __init__(self, uiFilterManager, parent=None):
20 super(FilterManagerTreeModel, self).__init__(parent)
21
22 self.rootItem = filtermanagertreeitem.FilterManagerTreeItem(
23 (i18n("Name"), i18n("Type"), i18n("Thumbnail")))
24 self.uiFilterManager = uiFilterManager
25 self._loadTreeModel(self.rootItem)
26

References filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.__init__().

Member Function Documentation

◆ _addSubNodes()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel._addSubNodes ( self,
nodes,
parent,
documentIndex )
protected

Definition at line 118 of file filtermanagertreemodel.py.

118 def _addSubNodes(self, nodes, parent, documentIndex):
119 for node in nodes:
120 nodeName = node.name()
121 nodeType = node.type()
122 columnData = ("Unnamed" if nodeName == '' else nodeName,
123 "Untyped" if nodeType == '' else nodeType,
124 QPixmap.fromImage(node.thumbnail(30, 30)),
125 node, documentIndex)
126 item = filtermanagertreeitem.FilterManagerTreeItem(
127 columnData, parent)
128 parent.appendChild(item)
129
130 childNodes = node.childNodes()
131 if len(childNodes):
132 self._addSubNodes(childNodes[::-1], item, documentIndex)

References filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel._addSubNodes().

◆ _loadTreeModel()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel._loadTreeModel ( self,
parent )
protected

Definition at line 103 of file filtermanagertreemodel.py.

103 def _loadTreeModel(self, parent):
104 for index, document in enumerate(self.uiFilterManager.documents):
105 rootNode = document.rootNode()
106 columnData = (document.fileName(),
107 "Document",
108 QPixmap.fromImage(document.thumbnail(30, 30)),
109 rootNode, index)
110 item = filtermanagertreeitem.FilterManagerTreeItem(
111 columnData, parent)
112 parent.appendChild(item)
113
114 childNodes = rootNode.childNodes()
115 if len(childNodes):
116 self._addSubNodes(childNodes[::-1], item, index)
117

References filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel._addSubNodes(), filtermanager.components.filtercombobox.FilterComboBox.uiFilterManager, and filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.uiFilterManager.

◆ columnCount()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.columnCount ( self,
parent )

Definition at line 65 of file filtermanagertreemodel.py.

65 def columnCount(self, parent):
66 if parent.isValid():
67 return parent.internalPointer().columnCount()
68 else:
69 return self.rootItem.columnCount()
70

References filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.columnCount(), filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rootItem, and lastdocumentsdocker.lastdocumentslistmodel.LastDocumentsListModel.rootItem.

◆ data()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.data ( self,
index,
role )

Definition at line 71 of file filtermanagertreemodel.py.

71 def data(self, index, role):
72 if not index.isValid():
73 return None
74
75 item = index.internalPointer()
76
77 if role == Qt.ItemDataRole.UserRole + 1:
78 return item.data(self.NODE_COLUMN)
79
80 if role == Qt.ItemDataRole.UserRole + 2:
81 return item.data(self.DOCUMENT_COLUMN)
82
83 if role == Qt.ItemDataRole.UserRole + 3:
84 return item.data(self.TYPE_COLUMN)
85
86 if role != Qt.ItemDataRole.DisplayRole and role != Qt.ItemDataRole.DecorationRole:
87 return None
88
89 return item.data(index.column())
90

◆ flags()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.flags ( self,
index )

Definition at line 91 of file filtermanagertreemodel.py.

91 def flags(self, index):
92 if not index.isValid():
93 return Qt.ItemFlag.NoItemFlags
94
95 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
96

◆ headerData()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.headerData ( self,
section,
orientation,
role )

Definition at line 97 of file filtermanagertreemodel.py.

97 def headerData(self, section, orientation, role):
98 if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:
99 return self.rootItem.data(section)
100
101 return None
102

References filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.data(), filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rootItem, and lastdocumentsdocker.lastdocumentslistmodel.LastDocumentsListModel.rootItem.

◆ index()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.index ( self,
row,
column,
parent )

Definition at line 27 of file filtermanagertreemodel.py.

27 def index(self, row, column, parent):
28 if not self.hasIndex(row, column, parent):
29 return QModelIndex()
30
31 if parent.isValid():
32 parentItem = parent.internalPointer()
33 else:
34 parentItem = self.rootItem
35
36 # It's a FilterManagerTreeItem
37 childItem = parentItem.child(row)
38 if childItem:
39 return self.createIndex(row, column, childItem)
40 else:
41 return QModelIndex()
42

References KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rootItem, and lastdocumentsdocker.lastdocumentslistmodel.LastDocumentsListModel.rootItem.

◆ parent()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.parent ( self,
index )

Definition at line 43 of file filtermanagertreemodel.py.

43 def parent(self, index):
44 if not index.isValid():
45 return QModelIndex()
46
47 childItem = index.internalPointer()
48 parentItem = childItem.parent()
49
50 if parentItem == self.rootItem:
51 return QModelIndex()
52
53 return self.createIndex(parentItem.row(), 0, parentItem)
54

References KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rootItem, and lastdocumentsdocker.lastdocumentslistmodel.LastDocumentsListModel.rootItem.

◆ rowCount()

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rowCount ( self,
parent )

Definition at line 55 of file filtermanagertreemodel.py.

55 def rowCount(self, parent):
56 if parent.column() > 0:
57 return 0
58
59 if not parent.isValid():
60 parentItem = self.rootItem
61 else:
62 parentItem = parent.internalPointer()
63 return parentItem.childCount()
64

References filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rootItem, and lastdocumentsdocker.lastdocumentslistmodel.LastDocumentsListModel.rootItem.

Member Data Documentation

◆ DOCUMENT_COLUMN [1/2]

int filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.DOCUMENT_COLUMN = 4
static

Definition at line 17 of file filtermanagertreemodel.py.

◆ DOCUMENT_COLUMN [2/2]

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.DOCUMENT_COLUMN

Definition at line 81 of file filtermanagertreemodel.py.

◆ NODE_COLUMN [1/2]

int filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.NODE_COLUMN = 3
static

Definition at line 16 of file filtermanagertreemodel.py.

◆ NODE_COLUMN [2/2]

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.NODE_COLUMN

Definition at line 78 of file filtermanagertreemodel.py.

◆ rootItem

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.rootItem

Definition at line 22 of file filtermanagertreemodel.py.

◆ TYPE_COLUMN [1/2]

int filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.TYPE_COLUMN = 1
static

Definition at line 15 of file filtermanagertreemodel.py.

◆ TYPE_COLUMN [2/2]

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.TYPE_COLUMN

Definition at line 84 of file filtermanagertreemodel.py.

◆ uiFilterManager

filtermanager.components.filtermanagertreemodel.FilterManagerTreeModel.uiFilterManager

Definition at line 24 of file filtermanagertreemodel.py.


The documentation for this class was generated from the following file: