Salome HOME
Set default value for case id attribute of Paged Containers (like Toolbox)
authorsbh <sergey.belash@opencascade.com>
Thu, 19 Mar 2015 16:42:05 +0000 (19:42 +0300)
committersbh <sergey.belash@opencascade.com>
Thu, 19 Mar 2015 16:42:05 +0000 (19:42 +0300)
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_PagedContainer.cpp

index c16c0b13f597d2911b9e6b1e35ac56d44c27d5e7..130e8940476f581a582483dffa5778fbacc0968d 100644 (file)
@@ -124,6 +124,11 @@ void ModuleBase_ModelWidget::activate()
   activateCustom();
 }
 
+void ModuleBase_ModelWidget::setDefaultValue(const std::string& theValue)
+{
+  myDefaultValue = theValue;
+}
+
 bool ModuleBase_ModelWidget::storeValue()
 {
   emit beforeValuesChanged();
index 6d3437fe18c91f703c4a5087cab1539f059c60c1..8adb5bc7682306b89c2037bff1b43af353ecc8a0 100644 (file)
@@ -158,6 +158,9 @@ signals:
   void focusOutWidget(ModuleBase_ModelWidget* theWidget);
 
  protected:
+  /// Sets default value of widget. Nornaly, widget should fetch this value 
+  /// from the xml. However, some widgets derived widgets could define it
+  void setDefaultValue(const std::string& theValue);
   /// \brief Set the attribute name
   /// \param theAttribute the string value with attribute name
   void setAttributeID(const std::string& theAttribute)
index 29cdd56eaa51dad616f853ad54df83d0c82f5386..43fb4de2233308b7a25717dea526759092753668 100644 (file)
@@ -31,9 +31,12 @@ ModuleBase_PagedContainer::~ModuleBase_PagedContainer()
 int ModuleBase_PagedContainer::addPage(ModuleBase_PageBase* thePage,
                                       const QString& theName, const QString& theCaseId)
 {
+  if (!myPages.count()) {
+    setDefaultValue(theCaseId.toStdString());
+  }
   myCaseIds << theCaseId;
   myPages << thePage;
-  storeValueCustom(); // to store the initial state
+
   return myPages.count();
 }