# Copyright (c) 2023, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#

import omni.ui as ui


class PropertyFilter:
    """User defined filters for properties. For now, just a substring filter on property names"""

    def __init__(self):
        self._name = ui.SimpleStringModel()

    def matches(self, name: str) -> bool:
        """Returns True if name matches filter, so property should be visible"""
        return not self.name or self.name.lower() in name.lower()

    @property
    def name_model(self):
        return self._name

    @property
    def name(self):
        return self._name.as_string

    @name.setter
    def name(self, n):
        self._name.as_string = n
