"""
The definition of the IAttributeView interface.
"""
#
# Copyright Qualcomm Technologies Inc, 2019.
# All Rights Reserved
#
# Python imports
# Thirdparty imports
from zope.interface import Interface, Attribute
# Zope interface bends the rules slightly, so ignore these pylint warnings:
# pylint: disable=no-self-argument,inherit-non-class,no-method-argument
[docs]class IAttributeView(Interface):
"""This adapter defines the interface to a view object that creates
and manages the widgets that display and edit the attribute which
are contained in a ConfigContainer.
The code that creates instances of this interface is done by
runnng something like this::
from qct_interfaces import make_registered_named_instance
from qct_interfaces.attributeviews import IAttributeView
...
check_box_view = make_registered_named_instance(IAttributeView,
'view:qtcheckbox',
config_attribute=attr)
check_box_view.create()
Note the use of the ``name`` in this call. The container
implementation will look for the attribute view using the most
specific to the least specific binding. This means that the code
will look for an IAttributeView implmentation registered with the
name::
'item:' + attr.attr_key
first (e.g. ``item:bluetooth_disable_role_switching``), and if
that doesn't exist then::
'class:' + attr.attr_type
next (e.g. ``class:bool``), and then finally with the view name
defined in the attribute::
'view:' + attr.attr_view
(e.g. ``view:qtcheckbox``).
Plugins can choose to implement their own version of these
implementations at whatever level they need to, and so change the
presentation layer of the user interface.
"""
config_attribute = Attribute("""The ConfigDomain attribute which the widget
should be editing.""")
self_labelled = Attribute("""Boolean value to indicate whether the view
contructs its own label.""")
widget = Attribute("""The top-level widget of this view. It is only valid
after the ``create`` method is called.""")
def create() -> None:
"""This method should construct the widget(s) required for displaying
the attribute, which can be accessed by the ``widget``
attribute. The caller can then add the widget to the layout of
the panel.
"""
def update() -> None:
"""This method updates the enabled state of the widget(s) associated
with the view. This method gets called on all visible
attributes whenever one of them is changed.
"""