From: sbh Date: Thu, 19 Mar 2015 16:42:05 +0000 (+0300) Subject: Set default value for case id attribute of Paged Containers (like Toolbox) X-Git-Tag: V_1.1.0~104^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8d1e5f9c51d0acd4b39ef3ad24b1daae43756e16;p=modules%2Fshaper.git Set default value for case id attribute of Paged Containers (like Toolbox) --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index c16c0b13f..130e89404 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -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(); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 6d3437fe1..8adb5bc76 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -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) diff --git a/src/ModuleBase/ModuleBase_PagedContainer.cpp b/src/ModuleBase/ModuleBase_PagedContainer.cpp index 29cdd56ea..43fb4de22 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.cpp +++ b/src/ModuleBase/ModuleBase_PagedContainer.cpp @@ -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(); }