mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 08:54:53 +01:00
added role for sort value
This commit is contained in:
parent
7c6e2e52df
commit
a7033e024b
2 changed files with 10 additions and 3 deletions
|
|
@ -2,8 +2,10 @@ from Qt import QtCore
|
|||
|
||||
|
||||
INSTANCE_ID_ROLE = QtCore.Qt.UserRole + 1
|
||||
SORT_VALUE_ROLE = QtCore.Qt.UserRole + 2
|
||||
|
||||
|
||||
__all__ = (
|
||||
"INSTANCE_ID_ROLE",
|
||||
"SORT_VALUE_ROLE"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import collections
|
|||
from Qt import QtWidgets, QtCore, QtGui
|
||||
|
||||
from openpype.widgets.attribute_defs import create_widget_for_attr_def
|
||||
from constants import INSTANCE_ID_ROLE
|
||||
from constants import (
|
||||
INSTANCE_ID_ROLE,
|
||||
SORT_VALUE_ROLE
|
||||
)
|
||||
|
||||
SEPARATORS = ("---separator---", "---")
|
||||
|
||||
|
|
@ -1034,11 +1037,11 @@ class InstanceListView(_AbstractInstanceView):
|
|||
instance_model = QtGui.QStandardItemModel()
|
||||
|
||||
proxy_model = QtCore.QSortFilterProxyModel()
|
||||
proxy_model.setSourceModel(instance_model)
|
||||
proxy_model.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
||||
proxy_model.setSortRole(SORT_VALUE_ROLE)
|
||||
proxy_model.setFilterKeyColumn(0)
|
||||
proxy_model.setDynamicSortFilter(True)
|
||||
proxy_model.setSortRole(QtCore.Qt.DisplayRole)
|
||||
proxy_model.setSourceModel(instance_model)
|
||||
|
||||
instance_view.setModel(proxy_model)
|
||||
|
||||
|
|
@ -1070,6 +1073,7 @@ class InstanceListView(_AbstractInstanceView):
|
|||
continue
|
||||
|
||||
group_item = QtGui.QStandardItem(family)
|
||||
group_item.setData(family, SORT_VALUE_ROLE)
|
||||
group_item.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
self._group_items[family] = group_item
|
||||
new_group_items.append(group_item)
|
||||
|
|
@ -1110,6 +1114,7 @@ class InstanceListView(_AbstractInstanceView):
|
|||
continue
|
||||
|
||||
item = QtGui.QStandardItem()
|
||||
item.setData(instance.data["subset"], SORT_VALUE_ROLE)
|
||||
item.setData(instance.data["uuid"], INSTANCE_ID_ROLE)
|
||||
new_items.append(item)
|
||||
items_with_instance.append((item, instance))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue