mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
view has defined some default widths of columns
This commit is contained in:
parent
3ddefade0d
commit
b3aa86bb54
1 changed files with 34 additions and 8 deletions
|
|
@ -86,6 +86,27 @@ class HierarchyView(QtWidgets.QTreeView):
|
|||
"pixelAspect": NumberDef(0, decimals=2),
|
||||
"tools_env": ToolsDef()
|
||||
}
|
||||
|
||||
columns_sizes = {
|
||||
"default": {
|
||||
"stretch": QtWidgets.QHeaderView.ResizeToContents
|
||||
},
|
||||
"name": {
|
||||
"stretch": QtWidgets.QHeaderView.Stretch
|
||||
},
|
||||
"type": {
|
||||
"stretch": QtWidgets.QHeaderView.Interactive,
|
||||
"width": 100
|
||||
},
|
||||
"tools_env": {
|
||||
"stretch": QtWidgets.QHeaderView.Interactive,
|
||||
"width": 140
|
||||
},
|
||||
"pixelAspect": {
|
||||
"stretch": QtWidgets.QHeaderView.Interactive,
|
||||
"width": 80
|
||||
}
|
||||
}
|
||||
persistent_columns = {
|
||||
"type",
|
||||
"frameStart",
|
||||
|
|
@ -157,16 +178,21 @@ class HierarchyView(QtWidgets.QTreeView):
|
|||
def header_init(self):
|
||||
header = self.header()
|
||||
header.setStretchLastSection(False)
|
||||
|
||||
default_behavior = self.columns_sizes["default"]
|
||||
widths_by_idx = {}
|
||||
for idx in range(header.count()):
|
||||
key = self._source_model.columns[idx]
|
||||
behavior = self.columns_sizes.get(key, default_behavior)
|
||||
logical_index = header.logicalIndex(idx)
|
||||
if idx == 0:
|
||||
header.setSectionResizeMode(
|
||||
logical_index, QtWidgets.QHeaderView.Stretch
|
||||
)
|
||||
else:
|
||||
header.setSectionResizeMode(
|
||||
logical_index, QtWidgets.QHeaderView.ResizeToContents
|
||||
)
|
||||
stretch = behavior["stretch"]
|
||||
header.setSectionResizeMode(logical_index, stretch)
|
||||
width = behavior.get("width")
|
||||
if width is not None:
|
||||
widths_by_idx[idx] = width
|
||||
|
||||
for idx, width in widths_by_idx.items():
|
||||
self.setColumnWidth(idx, width)
|
||||
|
||||
def set_project(self, project_name):
|
||||
# Trigger helpers first
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue