From b85bea0b11244b4344b57f1a812bf9f9435acc19 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 11 Jun 2014 19:10:25 +0400 Subject: [PATCH] According to "operation-widget_factory-property" remove dependency of widget fractory from operation --- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 17 ++++------------- src/ModuleBase/ModuleBase_WidgetFactory.h | 4 +--- src/XGUI/XGUI_Workshop.cpp | 18 +++++++++++------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 03a715f23..e83cd01fc 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -35,11 +35,11 @@ #include #include -ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop) - : myOperation(theOperation), myWorkshop(theWorkshop) +ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(const std::string& theXmlRepresentation, + ModuleBase_IWorkshop* theWorkshop) + : myWorkshop(theWorkshop) { - QString aXml = myOperation->getDescription()->xmlRepresentation(); - myWidgetApi = new Config_WidgetAPI(aXml.toStdString()); + myWidgetApi = new Config_WidgetAPI(theXmlRepresentation); } ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory() @@ -151,8 +151,6 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent) { ModuleBase_WidgetDoubleValue* aDblWgt = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi); - QObject::connect(aDblWgt, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue())); - myModelWidgets.append(aDblWgt); return aDblWgt->getControl(); @@ -161,8 +159,6 @@ QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent) QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent) { ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent, myWidgetApi); - QObject::connect(aWidget, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue())); - myModelWidgets.append(aWidget); return aWidget->getControl(); } @@ -176,9 +172,6 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent) { ModuleBase_WidgetSelector* aSelector = new ModuleBase_WidgetSelector(theParent, myWorkshop, myWidgetApi); - - QObject::connect(aSelector, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue())); - myModelWidgets.append(aSelector); return aSelector->getControl(); } @@ -187,8 +180,6 @@ QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent) QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent) { ModuleBase_WidgetBoolValue* aBoolWgt = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi); - QObject::connect(aBoolWgt, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue())); - myModelWidgets.append(aBoolWgt); return aBoolWgt->getControl(); diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 13f16601b..aa7f6da76 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -17,13 +17,12 @@ class QObject; class QWidget; class Config_WidgetAPI; -class ModuleBase_Operation; class ModuleBase_IWorkshop; class MODULEBASE_EXPORT ModuleBase_WidgetFactory { public: - ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop); + ModuleBase_WidgetFactory(const std::string& theXmlRepresentation, ModuleBase_IWorkshop* theWorkshop); virtual ~ModuleBase_WidgetFactory(); void createWidget(QWidget* theParent); @@ -47,7 +46,6 @@ protected: private: Config_WidgetAPI* myWidgetApi; - ModuleBase_Operation* myOperation; ModuleBase_IWorkshop* myWorkshop; QList myModelWidgets; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 24fea8453..26d1bb1d2 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -313,17 +313,21 @@ void XGUI_Workshop::onOperationStarted() showPropertyPanel(); - ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation, myModuleConnector); + QString aXmlRepr = aOperation->getDescription()->xmlRepresentation(); + ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), myModuleConnector); QWidget* aContent = myPropertyPanel->contentWidget(); qDeleteAll(aContent->children()); aFactory.createWidget(aContent); - // Init default values - if (!aOperation->isEditOperation()) { - QList aWidgets = aFactory.getModelWidgets(); - QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); - for (; anIt != aLast; anIt++) { - (*anIt)->storeValue(aOperation->feature()); + QList aWidgets = aFactory.getModelWidgets(); + QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); + ModuleBase_ModelWidget* aWidget; + for (; anIt != aLast; anIt++) { + aWidget = *anIt; + QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue())); + // Init default values + if (!aOperation->isEditOperation()) { + aWidget->storeValue(aOperation->feature()); } } -- 2.39.2