Commit 0c963ead authored by David Thompson's avatar David Thompson
Browse files

Fix cases where widget interaction did not update item values.

Also, properly avoid updating the item during interaction (drag)
events and properly signal modification to parent view.
parent 023095eb
Pipeline #188297 running with stages
in 18 minutes and 48 seconds
......@@ -243,22 +243,13 @@ void pqSMTKAttributeItemWidget::updateItemFromWidget()
{
m_p->m_state = Internal::State::UpdatingFromAttribute;
this->updateItemFromWidgetInternal();
m_p->m_state = Internal::State::DoneUpdatingFromAttribute;
emit this->modified();
m_p->m_state = Internal::State::Idle;
}
}
void pqSMTKAttributeItemWidget::updateWidgetFromItem()
{
if (m_p->m_state == Internal::State::DoneUpdatingFromAttribute)
{
// This happens when updateItemFromWidget() causes a modification to the
// attribute, resulting in a Signal operation that triggers this method.
// We complete the update from widget to item by resetting the state to
// idle.
m_p->m_state = Internal::State::Idle;
return;
}
if (m_p->m_state == Internal::State::Idle)
{
m_p->m_state = Internal::State::UpdatingFromUI;
......@@ -311,9 +302,19 @@ void pqSMTKAttributeItemWidget::updateItemData()
this->qtItem::updateItemData();
}
void pqSMTKAttributeItemWidget::ignoreWidgetValues()
{
m_p->m_state = Internal::State::Interacting;
}
void pqSMTKAttributeItemWidget::acceptWidgetValues()
{
this->m_p->m_pvwidget->apply();
if (m_p->m_state == Internal::State::Interacting)
{
m_p->m_state = Internal::State::Idle;
this->updateItemFromWidget();
}
}
bool pqSMTKAttributeItemWidget::eventFilter(QObject* obj, QEvent* event)
......@@ -477,8 +478,9 @@ void pqSMTKAttributeItemWidget::createEditor()
pvwidget->setView(actives.activeView());
m_p->m_pvwidget = pvwidget;
// When the user is done interacting with the widget, update the attribute values
QObject::connect(pvwidget, SIGNAL(startInteraction()), this, SLOT(ignoreWidgetValues()));
QObject::connect(pvwidget, SIGNAL(endInteraction()), this, SLOT(acceptWidgetValues()));
QObject::connect(pvwidget, SIGNAL(endInteraction()), this, SLOT(updateItemFromWidget()));
QObject::connect(pvwidget, SIGNAL(changeAvailable()), this, SLOT(updateItemFromWidget()));
// When the active view changes, move the widget to that view.
QObject::connect(&actives, SIGNAL(viewChanged(pqView*)), pvwidget, SLOT(setView(pqView*)));
......
......@@ -105,6 +105,7 @@ public slots:
protected slots:
void updateItemData() override;
virtual void ignoreWidgetValues();
virtual void acceptWidgetValues();
virtual void updateItemFromWidgetInternal() = 0;
virtual void updateWidgetFromItemInternal() {}
......
......@@ -37,11 +37,10 @@ class pqSMTKAttributeItemWidget::Internal
public:
enum class State
{
Idle, //!< Widget is not being manipulated by attribute system or user
UpdatingFromUI, //!< Widget is being manipulated by user.
UpdatingFromAttribute, //!< Widget is being manipulated by attribute system.
DoneUpdatingFromAttribute, //!< Widget was manipulated by UI, resulting in a signal
//!< from attribute system.
Idle, //!< Widget is not being manipulated by attribute system or user.
UpdatingFromUI, //!< Widget was manipulated by user.
UpdatingFromAttribute, //!< Widget was manipulated by attribute system.
Interacting //!< Widget is being manipulated by user; do not update item yet.
};
Internal(smtk::attribute::ItemPtr itm, QWidget* p, smtk::extension::qtBaseView* bview,
......
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