]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
According to "operation-widget_factory-property"
authornds <natalia.donis@opencascade.com>
Wed, 11 Jun 2014 15:10:25 +0000 (19:10 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 11 Jun 2014 15:10:25 +0000 (19:10 +0400)
remove dependency of widget fractory from operation

src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/XGUI/XGUI_Workshop.cpp

index 03a715f2357fc255141ae4933bd3c552b363844a..e83cd01fc642a6c637fe7d3c2609e613a138ebfe 100644 (file)
 #include <cfloat>
 #include <climits>
 
-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();
index 13f16601ba8d4188e0a489239677f3c439266531..aa7f6da76747bbc3a30c33c6b14408ce089e24e3 100644 (file)
 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<ModuleBase_ModelWidget*> myModelWidgets;
index 24fea8453e98aab44e834f9efca2895d1c39142e..26d1bb1d28e41a49a370f21cf113d23f2a951501 100644 (file)
@@ -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<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
-      QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
-      for (; anIt != aLast; anIt++) {
-        (*anIt)->storeValue(aOperation->feature());
+    QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+    QList<ModuleBase_ModelWidget*>::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());
       }
     }