X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetToolbox.cpp;h=6a16aa3d2647d6d4057e6352971f686ad02e1a06;hb=c93898acb58bc77dbfef4f5cba260885d31379fe;hp=aeab11bbb0738f6402ea3fe7e44f5f6ca9224a2f;hpb=2734393c7c19899fca7e7c36577b31317887a9c9;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetToolbox.cpp b/src/ModuleBase/ModuleBase_WidgetToolbox.cpp index aeab11bbb..6a16aa3d2 100644 --- a/src/ModuleBase/ModuleBase_WidgetToolbox.cpp +++ b/src/ModuleBase/ModuleBase_WidgetToolbox.cpp @@ -7,16 +7,18 @@ #include #include +#include #include #include #include +#include #include ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId) +: ModuleBase_PagedContainer(theParent, theData, theParentId) { QVBoxLayout* aMainLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aMainLayout); @@ -29,9 +31,6 @@ ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Con "border-color:#fff #505050 #505050 #fff;}"; myToolBox->setStyleSheet(css); // default vertical size policy is preferred - QSizePolicy aSizePolicy = myToolBox->sizePolicy(); - aSizePolicy.setVerticalPolicy(QSizePolicy::MinimumExpanding); - myToolBox->setSizePolicy(aSizePolicy); aMainLayout->addWidget(myToolBox); connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged())); @@ -41,55 +40,27 @@ ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox() { } -int ModuleBase_WidgetToolbox::addPage(QWidget* theWidget, +int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage, const QString& theName, const QString& theCaseId) { - myCaseIds << theCaseId; - return myToolBox->addItem(theWidget, theName); + ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId); + QFrame* aFrame = dynamic_cast(thePage); + aFrame->setFrameShape(QFrame::Box); + aFrame->setFrameStyle(QFrame::Sunken); + myToolBox->addItem(aFrame, theName); + return myToolBox->count(); } -bool ModuleBase_WidgetToolbox::restoreValue() +int ModuleBase_WidgetToolbox::currentPageIndex() const { - // A rare case when plugin was not loaded. - if(!myFeature) - return false; - DataPtr aData = myFeature->data(); - AttributeStringPtr aStringAttr = aData->string(attributeID()); - QString aCaseId = QString::fromStdString(aStringAttr->value()); - int idx = myCaseIds.indexOf(aCaseId); - if (idx == -1) - return false; - bool isSignalsBlocked = myToolBox->blockSignals(true); - myToolBox->setCurrentIndex(idx); - myToolBox->blockSignals(isSignalsBlocked); - return true; -} - -QList ModuleBase_WidgetToolbox::getControls() const -{ - QList aList; - aList << myToolBox; - return aList; + return myToolBox->currentIndex(); } -bool ModuleBase_WidgetToolbox::focusTo() +void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex) { - return false; + bool isSignalsBlocked = myToolBox->blockSignals(true); + myToolBox->setCurrentIndex(theIndex); + myToolBox->blockSignals(isSignalsBlocked); } -bool ModuleBase_WidgetToolbox::storeValueCustom() const -{ - // A rare case when plugin was not loaded. - if(!myFeature) - return false; - DataPtr aData = myFeature->data(); - AttributeStringPtr aStringAttr = aData->string(attributeID()); - QString aWidgetValue = myCaseIds.at(myToolBox->currentIndex()); - aStringAttr->setValue(aWidgetValue.toStdString()); - return true; -} -void ModuleBase_WidgetToolbox::onPageChanged() -{ - storeValue(); -}