diff --git a/GUI/coregui/Models/ComponentProxyStrategy.cpp b/GUI/coregui/Models/ComponentProxyStrategy.cpp index 50d541a1835a314b584e92eed7bab5e0edea21b2..1afe7f9f35d7e0a20e4d134a58d98788ebd5a349 100644 --- a/GUI/coregui/Models/ComponentProxyStrategy.cpp +++ b/GUI/coregui/Models/ComponentProxyStrategy.cpp @@ -33,12 +33,19 @@ bool ComponentProxyStrategy::processSourceIndex(const QModelIndex& index) SessionItem* item = m_source->itemForIndex(index); + QString tag; + if (item->parent()) + tag = item->parent()->tagFromItem(item); + if ( !isPropertyRelated(item)) return false; // not going to visit non-property items if (isNewRootItem(item)) { processRootItem(item, sourceIndex); + } else if (isSubGroup(item)) { + processSubGroupItem(item, sourceIndex); + } else if (isGroupChildren(item)) { processGroupItem(item, sourceIndex); @@ -82,6 +89,19 @@ void ComponentProxyStrategy::processRootItem(SessionItem* item, m_proxySourceParent.insert(proxyIndex, QModelIndex()); // new parent will be root } +//! Returns true if item is a group property which in turn is inside of another group property. + +bool ComponentProxyStrategy::isSubGroup(SessionItem* item) +{ + const SessionItem* ancestor = ModelPath::ancestor(item->parent(), Constants::GroupItemType); + if (item->modelType() == Constants::GroupItemType && ancestor && + ancestor->modelType() == Constants::GroupItemType) { + return true; + } + + return false; +} + //! Returns true if item is a children/grandchildrent of some group item. bool ComponentProxyStrategy::isGroupChildren(SessionItem* item) @@ -107,7 +127,27 @@ void ComponentProxyStrategy::processGroupItem(SessionItem* item, return; auto groupItem = dynamic_cast<const GroupItem*>(ancestor); - if (item->parent() == groupItem->currentItem() && item->isVisible()) { + if (item->parent() == groupItem->currentItem()) { + QPersistentModelIndex proxyIndex + = createProxyIndex(SessionItemUtils::ParentVisibleRow(*item), sourceIndex.column(), sourceIndex.internalPointer()); + + m_sourceToProxy.insert(sourceIndex, proxyIndex); + m_proxySourceParent.insert(proxyIndex, groupItem->index()); + } + + } +} + + +//! Process group property which is inside of other group property. + +void ComponentProxyStrategy::processSubGroupItem(SessionItem* item, + const QPersistentModelIndex& sourceIndex) +{ + if(const SessionItem* ancestor = ModelPath::ancestor(item->parent(), Constants::GroupItemType)) { + auto groupItem = dynamic_cast<const GroupItem*>(ancestor); + + if (item->parent() == groupItem->currentItem()) { QPersistentModelIndex proxyIndex = createProxyIndex(SessionItemUtils::ParentVisibleRow(*item), sourceIndex.column(), sourceIndex.internalPointer()); @@ -116,6 +156,7 @@ void ComponentProxyStrategy::processGroupItem(SessionItem* item, } } + } void ComponentProxyStrategy::processDefaultItem(SessionItem* item, diff --git a/GUI/coregui/Models/ComponentProxyStrategy.h b/GUI/coregui/Models/ComponentProxyStrategy.h index 52ac0e2a23baa30b998adb51d51521b6ea68495d..e06010e7c64dab7b07e3a67e55e0cf750de03415 100644 --- a/GUI/coregui/Models/ComponentProxyStrategy.h +++ b/GUI/coregui/Models/ComponentProxyStrategy.h @@ -30,8 +30,10 @@ private: bool isPropertyRelated(SessionItem* item); bool isNewRootItem(SessionItem* item); void processRootItem(SessionItem* item, const QPersistentModelIndex& sourceIndex); + bool isSubGroup(SessionItem* item); bool isGroupChildren(SessionItem* item); void processGroupItem(SessionItem* item, const QPersistentModelIndex& sourceIndex); + void processSubGroupItem(SessionItem* item, const QPersistentModelIndex& sourceIndex); void processDefaultItem(SessionItem* item, const QPersistentModelIndex& sourceIndex); }; diff --git a/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp b/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp index a0a620f864e2ae66f613112273897619d28fe5be..01a4af89fd88ba41b696c5a2392bad71ad3a84a0 100644 --- a/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp +++ b/GUI/coregui/Views/PropertyEditor/TestComponentView.cpp @@ -123,7 +123,7 @@ void TestComponentView::onExpandRequest() void TestComponentView::init_source() { SampleBuilderFactory factory; - const std::unique_ptr<MultiLayer> sample(factory.createSample("CylindersAndPrismsBuilder")); + const std::unique_ptr<MultiLayer> sample(factory.createSample("CylindersWithSizeDistributionBuilder")); GUIObjectBuilder::populateSampleModel(m_sampleModel, m_materialModel, *sample); m_sampleModel->insertNewItem(Constants::VectorType); m_sampleModel->insertNewItem(Constants::BeamType); diff --git a/GUI/coregui/Views/TestView.cpp b/GUI/coregui/Views/TestView.cpp index 380ef195d38843589662a40f8378bd4814f8a951..7ad4ada3ef75e577f9cb5c25c3c52dd9bf452c80 100644 --- a/GUI/coregui/Views/TestView.cpp +++ b/GUI/coregui/Views/TestView.cpp @@ -47,13 +47,13 @@ TestView::TestView(MainWindow *mainWindow) : QWidget(mainWindow) , m_mainWindow(mainWindow) { -// test_ComponentProxyModel(); + test_ComponentProxyModel(); // test_MaterialEditor(); // test_MinimizerSettings(); // test_AccordionWidget(); // test_RunFitWidget(); // test_ba3d(); - test_specular_data_widget(); +// test_specular_data_widget(); } void TestView::test_ComponentProxyModel()