From 50d6c6b3c8d2e31bc7e02ad830e2249a92d874bf Mon Sep 17 00:00:00 2001 From: Swann Date: Wed, 19 May 2021 15:59:36 +0200 Subject: [PATCH] fix: filter --- multi_user/preferences.py | 5 +++++ multi_user/ui.py | 36 +++++++++++++++++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/multi_user/preferences.py b/multi_user/preferences.py index 2e614cd..e31812c 100644 --- a/multi_user/preferences.py +++ b/multi_user/preferences.py @@ -491,6 +491,11 @@ class SessionProps(bpy.types.PropertyGroup): description='Show only owned datablocks', default=True ) + filter_name: bpy.props.StringProperty( + name="filter_name", + default="", + description='Node name filter', + ) admin: bpy.props.BoolProperty( name="admin", description='Connect as admin', diff --git a/multi_user/ui.py b/multi_user/ui.py index 4853333..2e8a665 100644 --- a/multi_user/ui.py +++ b/multi_user/ui.py @@ -540,35 +540,33 @@ class SESSION_PT_repository(bpy.types.Panel): else: row.operator('session.save', icon="FILE_TICK") - flow = layout.grid_flow( - row_major=True, - columns=0, - even_columns=True, - even_rows=False, - align=True) - - for item in settings.supported_datablocks: - col = flow.column(align=True) - col.prop(item, "use_as_filter", text="", icon=item.icon) - - row = layout.row(align=True) - row.prop(runtime_settings, "filter_owned", text="Show only owned") - - row = layout.row(align=True) + box = layout.box() + row = box.row() + row.prop(runtime_settings, "filter_owned", text="Show only owned Nodes", icon_only=True, icon="DECORATE_UNLOCKED") + row = box.row() + row.prop(runtime_settings, "filter_name", text="Filter") + row = box.row() # Properties types_filter = [t.type_name for t in settings.supported_datablocks if t.use_as_filter] - client_keys = session.list() + filtered_node = session.list(filter_owner=settings.username) if runtime_settings.filter_owned else session.list() - if client_keys: + if runtime_settings.filter_name: + for node_id in filtered_node: + node_instance = session.repository.get_node(node_id) + name = node_instance.data.get('name') + if runtime_settings.filter_name not in name: + filtered_node.remove(node_id) + + if filtered_node: col = layout.column(align=True) - for key in client_keys: + for key in filtered_node: draw_property(context, col, key) else: - row.label(text="Empty") + layout.row().label(text="Empty") elif session.state == STATE_LOBBY and usr and usr['admin']: row.operator("session.init", icon='TOOL_SETTINGS', text="Init")