From 5197568a9c9c7aaff44616249c556e40648a8b17 Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Wed, 6 Dec 2017 15:37:18 +0100 Subject: [PATCH] Fix in GroupItem signaling on data changed. --- GUI/coregui/Models/GroupItem.cpp | 26 ++++++++++++-------------- GUI/coregui/Models/GroupItem.h | 1 + GUI/coregui/Views/SessionModelView.cpp | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/GUI/coregui/Models/GroupItem.cpp b/GUI/coregui/Models/GroupItem.cpp index cb00a25e6d6..d54e2d1915b 100644 --- a/GUI/coregui/Models/GroupItem.cpp +++ b/GUI/coregui/Models/GroupItem.cpp @@ -21,16 +21,6 @@ #include "GUIHelpers.h" namespace { -//QVariant createCombo(const GroupInfo& groupInfo) -//{ -// ComboProperty result; -// result.setValues(groupInfo.itemLabels()); - -// int index = groupInfo.itemTypes().indexOf(groupInfo.defaultType()); -// result.setCurrentIndex(index); -// return result.variant(); -//} - QVariant createCombo(GroupProperty_t groupProperty) { ComboProperty result; @@ -61,8 +51,8 @@ void GroupItem::setGroupInfo(const GroupInfo& groupInfo) prop->setGroupItem(this); m_groupProperty = prop; - setValue(createCombo(groupProperty())); - emitDataChanged(); // necessary because ComboProperty variant comparators are disabled + + updateValue(); // setValue(QVariant::fromValue(groupProperty)); } @@ -88,8 +78,7 @@ SessionItem* GroupItem::setCurrentType(const QString& modelType) qDebug() << "GroupItem::setCurrentType -> current" << groupProperty()->currentType() << groupProperty()->currentIndex(); - setValue(createCombo(groupProperty())); - emitDataChanged(); // necessary because ComboProperty variant comparators are disabled + updateValue(); return currentItem(); } @@ -126,6 +115,15 @@ void GroupItem::onValueChange() if (property.currentIndex() != m_groupProperty->currentIndex()) { qDebug() << "GroupItem::onValueChange() -> setting index" << property.currentIndex(); m_groupProperty->setCurrentIndex(property.currentIndex()); + // because of the delay between ComboProperty change and the change in GroupItem here, + // we have to emit signals once again to inform other views (i.e. views other than the view + // were property was changed + emitDataChanged(Qt::DisplayRole | Qt::EditRole); } } +void GroupItem::updateValue() +{ + setValue(createCombo(groupProperty())); +} + diff --git a/GUI/coregui/Models/GroupItem.h b/GUI/coregui/Models/GroupItem.h index 7c08b05c718..3da67a8a58d 100644 --- a/GUI/coregui/Models/GroupItem.h +++ b/GUI/coregui/Models/GroupItem.h @@ -43,6 +43,7 @@ public: private: void onValueChange(); + void updateValue(); GroupProperty_t groupProperty() const; GroupProperty_t m_groupProperty; }; diff --git a/GUI/coregui/Views/SessionModelView.cpp b/GUI/coregui/Views/SessionModelView.cpp index be0808f13c3..e04d7c953cc 100644 --- a/GUI/coregui/Views/SessionModelView.cpp +++ b/GUI/coregui/Views/SessionModelView.cpp @@ -29,7 +29,7 @@ #include <QVBoxLayout> namespace { -const bool show_test_view = false; +const bool show_test_view = true; } SessionModelView::SessionModelView(MainWindow *mainWindow) -- GitLab