Commit 285e86bc authored by Bob Obara's avatar Bob Obara Committed by Kitware Robot

Merge topic 'addingReadOnlyItemsInUI'

3ef41f67 ENH: Added ability to mark items defined in a view as read only.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: John Tourtellott's avatarJohn Tourtellott <john.tourtellott@kitware.com>
Merge-request: !1497
parents a833424d 3ef41f67
Pipeline #132115 running with stage
......@@ -31,3 +31,19 @@ The following is an example of a Analysis View:
#Changes to UIManager
* Added the ability to enable/disable category filtering
* Added support for top-level categories
#ReadOnly View Items
Added a new ReadOnly Option to Item Views. In the following example the item, absolute-zero, in the attribute physical-constants has been made read only. The current implementation disables the widgets defined by the read only item from being modified but will still display them.
```xml
<View Type="Instanced" Title="Global Constants">
<InstancedAttributes>
<Att Name="physics" Type="physics" />
<Att Name="physical-constants" Type="physical-constants">
<ItemViews>
<View Item="absolute-zero" Type="Default" ReadOnly="true"/>
</ItemViews>
</Att>
</InstancedAttributes>
</View>
```
......@@ -247,6 +247,11 @@ void qtAttributeRefItem::createWidget()
this->clearChildItems();
this->Internals->comboBoxes.clear();
m_widget = new QFrame(m_itemInfo.parentWidget());
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
m_widget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
std::size_t i, n = item->numberOfValues();
......
......@@ -382,6 +382,10 @@ void qtDateTimeItem::updateUI()
}
m_widget = new QFrame(m_itemInfo.parentWidget());
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
this->Internals->EntryLayout = new QGridLayout(m_widget);
this->Internals->EntryLayout->setMargin(0);
this->Internals->EntryLayout->setSpacing(0);
......
......@@ -709,6 +709,10 @@ void qtFileItem::updateUI()
}
m_widget = new QFrame(m_itemInfo.parentWidget());
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
this->Internals->EntryLayout = new QGridLayout(m_widget);
this->Internals->EntryLayout->setMargin(0);
this->Internals->EntryLayout->setSpacing(0);
......
......@@ -98,6 +98,10 @@ void qtGroupItem::createWidget()
QString title = item->label().empty() ? item->name().c_str() : item->label().c_str();
QGroupBox* groupBox = new QGroupBox(title, m_itemInfo.parentWidget());
m_widget = groupBox;
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
// Instantiate a layout for the widget, but do *not* assign it to a variable.
// because that would cause a compiler warning, since the layout is not
// explicitly referenced anywhere in this scope. (There is no memory
......
......@@ -366,6 +366,10 @@ void qtInputsItem::updateUI()
}
m_widget = new QFrame(this->parentWidget());
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
this->Internals->EntryLayout = new QGridLayout(m_widget);
this->Internals->EntryLayout->setMargin(0);
this->Internals->EntryLayout->setSpacing(0);
......
......@@ -47,6 +47,7 @@ qtItem::qtItem(const AttributeItemInfo& info)
this->m_widget = NULL;
this->m_isLeafItem = false;
m_useSelectionManager = false;
m_readOnly = m_itemInfo.component().attributeAsBool("ReadOnly");
}
qtItem::~qtItem()
......
......@@ -119,6 +119,8 @@ public:
bool passAdvancedCheck();
void showAdvanceLevelOverlay(bool);
bool useSelectionManager() const { return m_useSelectionManager; }
void setReadOnly(bool mode) { m_readOnly = mode; }
bool isReadOnly() const { return m_readOnly; }
public slots:
// Controls whether the Selection Manager should be used for setting model
......@@ -143,6 +145,7 @@ protected:
QWidget* m_widget;
bool m_isLeafItem;
bool m_useSelectionManager;
bool m_readOnly;
AttributeItemInfo m_itemInfo;
QList<smtk::extension::qtItem*> m_childItems;
......
......@@ -393,6 +393,10 @@ void qtReferenceItem::updateUI()
// Create a container for the item:
m_widget = new QFrame(m_itemInfo.parentWidget());
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
m_widget->installEventFilter(this);
m_p->m_grid = new QGridLayout(m_widget);
m_p->m_grid->setMargin(0);
......
......@@ -71,6 +71,10 @@ void qtVoidItem::createWidget()
this->clearChildItems();
m_widget = new QFrame(this->parentWidget());
if (this->isReadOnly())
{
m_widget->setEnabled(false);
}
new QVBoxLayout(m_widget);
m_widget->layout()->setMargin(0);
m_widget->layout()->setSpacing(0);
......
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