Commit 9127127b authored by David Thompson's avatar David Thompson Committed by Kitware Robot

Merge topic 'phrase-icons'

c989675a Accept alternate qtReferenceItem membership icons.
Acked-by: Kitware Robot's avatarKitware Robot <>
Acked-by: Bob Obara's avatarBob Obara <>
Merge-request: !1515
parents 1be044d6 c989675a
Pipeline #133998 running with stage
## Qt extension changes
+ Now qtReferenceItem allows developers to override the visibility icons
with custom URLs. See qtReferenceItem::setSelectionIconPaths() and
doc/userguide/attribute/file-syntax.rst for details.
......@@ -561,8 +561,104 @@ Void Item Definition <Void>
Describe "void" items and how they are serialized
RootView Section <RootView>
Views Section <Views>
The Views section of an SBT file contains multiple <View> items,
one of which should be marked as a top-level view by adding the
TopLevel attribute to it. The top-level view is typically composed
of multiple other views, each of which may be defined in the
Views section.
Each <View> XML element has attributes and child elements that
configure the view.
The child elements may include information about which attributes
or classes of attributes to present as well as how individual items
inside those attributes should be presented to the user.
.. list-table:: Common XML Attributes for View Definition Elements
:widths: 10 40
:header-rows: 1
* - XML Attribute
- Description
* - Type
- An enumeration that specifies what information the view should
present and dictates the children XML elements it must or may contain.
Acceptable values include: "Group" (a view that groups child views
in tabs), "Instanced" (a view that displays attribute instances
specified by their names), "Attribute" (a view that displays all
attributes sharing a common definition and usually allows users to
manage instances by adding and removing them), "ModelEntity" (a view
that shows model entities and lets users choose an attribute to
associate with each one, optionally creating instances as needed),
"SimpleExpression", "Category", or "Selector".
* - Title
- A string that summarizes the view to a user.
When a view is tabbed inside another, the title string
serves as the label for the tab.
* - TopLevel
- Boolean value indicating whether the view is the root view
that should be presented to the user or (if TopLevel is
false or omitted) the view is a child that may be included
by the toplevel view.
.. todo::
Describe root views and how they are serialized
View configuration
Each view Type above may need configuration information
specified by child XML elements of the <View>.
The sections below define those child element types:
the first section covers how a view chooses what attributes
to show while the second section covers ways to customize
how those attributes' items are presented.
Attribute selection
.. todo::
Describe <InstancedAttributes>, <Attributes>, ... elements here.
Item Views
If you wish to customize how items of the chosen attributes are presented,
you should add an <ItemViews> child to the <Att> tags in the attribute selectors
covered in the previous section.
Inside <ItemViews> you can add a <View> tag for each item whose appearance you
wish to customize.
.. todo::
Describe <ItemsViews> children
.. list-table:: XML Attributes for Item View Elements
:widths: 10 40
:header-rows: 1
* - XML Attribute
- Description
* - Type
- The name of a widget you would like the application to use to present the
item (and potentially its children as well) to users.
SMTK provides "Box" (for showing a 3-D bounding box widget), "Point" (for
showing a 3-D handle widget), "Line", "Plane", "Sphere", "Spline".
These types usually only make sense for Group items.
* - ItemMemberIcon, ItemNonMemberIcon
- These attributes are only used for ReferenceItem, ResourceItem, and ComponentItem
classes. They specify paths (either on disk or, with a leading colon, to Qt resource files)
to images to use as icons that display whether a persistent object is a member
of the item or not.
......@@ -68,7 +68,11 @@ qtItem* qtReferenceItem::createItemWidget(const AttributeItemInfo& info)
: m_optional(nullptr)
, m_alreadyClosingPopup(false)
, m_qtModel(nullptr)
, m_qtDelegate(nullptr)
, m_modelObserverId()
, m_selectedIconURL(":/icons/display/selected.png")
, m_unselectedIconURL(":/icons/display/unselected.png")
......@@ -80,6 +84,14 @@ qtReferenceItem::qtReferenceItem(const AttributeItemInfo& info)
: Superclass(info)
, m_p(new qtReferenceItemData)
// Grab default icons from the configuration object if specified.
std::string selectedIconURL;
std::string unselectedIconURL;
if (info.component().attribute("ItemMemberIcon", selectedIconURL) &&
info.component().attribute("ItemNonMemberIcon", unselectedIconURL))
this->setSelectionIconPaths(selectedIconURL, unselectedIconURL);
......@@ -123,6 +135,29 @@ void qtReferenceItem::setLabelVisible(bool visible)
bool qtReferenceItem::setSelectionIconPaths(
const std::string& selectedIconPath, const std::string& unselectedIconPath)
if (m_p->m_selectedIconURL == selectedIconPath && m_p->m_unselectedIconURL == unselectedIconPath)
return false;
m_p->m_selectedIconURL = selectedIconPath;
m_p->m_unselectedIconURL = unselectedIconPath;
if (m_p->m_qtModel)
return true;
std::pair<std::string, std::string> qtReferenceItem::selectionIconPaths() const
return std::make_pair(m_p->m_selectedIconURL, m_p->m_unselectedIconURL);
void qtReferenceItem::updateItemData()
......@@ -380,8 +415,8 @@ void qtReferenceItem::updateUI()
[this](smtk::view::DescriptivePhrasePtr phr) { this->decorateWithMembership(phr); });
if (m_p->m_phraseModel)
m_p->m_phraseModel->addSource(rsrcMgr, operMgr, seln);
......@@ -49,6 +49,22 @@ public:
void setLabelVisible(bool) override;
/**\brief Set the paths (into qrc files or the local filesystem) of icons
* used to indicate which items are selected and which are not.
* This returns true if the values were modified and false otherwise.
* Note that calling this method will not result in re-renders of any
* views displaying the model; you are responsible for calling this
* method before rendering takes place or for causing a render if
* calling after the initial render.
bool setSelectionIconPaths(
const std::string& selectedIconPath, const std::string& unselectedIconPath);
/// Return the paths to icons used to display the membership in the item.
std::pair<std::string, std::string> selectionIconPaths() const;
protected slots:
void updateItemData() override;
......@@ -82,6 +82,10 @@ public:
smtk::extension::qtDescriptivePhraseDelegate* m_qtDelegate;
smtk::view::PhraseModelObservers::Key m_modelObserverId;
// Icons used to show item membership
std::string m_selectedIconURL;
std::string m_unselectedIconURL;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment