X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetToolbox.cpp;h=c1f35c987cae6f5b192a32ff2d033d820e5f5afb;hb=f96e7958a6b68c45e722aea764ecc075d0797233;hp=616a5c357972c3468911cdf69d6017799ec64d66;hpb=31e91a8d11e03ddce87e8c2aa04695961a266a97;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetToolbox.cpp b/src/ModuleBase/ModuleBase_WidgetToolbox.cpp index 616a5c357..c1f35c987 100644 --- a/src/ModuleBase/ModuleBase_WidgetToolbox.cpp +++ b/src/ModuleBase/ModuleBase_WidgetToolbox.cpp @@ -7,21 +7,25 @@ #include #include +#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_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData) +: ModuleBase_PagedContainer(theParent, theData) { QVBoxLayout* aMainLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aMainLayout); - myToolBox = new QToolBox(this); + myToolBox = new ModuleBase_ToolBox(this); // Dark-grey rounded tabs with button-like border #and bold font + // TODO: apply style to custom widget QString css = "QToolBox::tab{background-color:#c8c8c8;" "border-radius:5px;" "border:1px inset;" @@ -39,69 +43,28 @@ ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox() } int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage, - const QString& theName, const QString& theCaseId) + const QString& theName, + const QString& theCaseId, + const QPixmap& theIcon ) { - myCaseIds << theCaseId; - myPages << thePage; + ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon); QFrame* aFrame = dynamic_cast(thePage); aFrame->setFrameShape(QFrame::Box); aFrame->setFrameStyle(QFrame::Sunken); - return myToolBox->addItem(aFrame, theName); + myToolBox->addItem(aFrame, theName, theIcon ); + 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); - focusTo(); - return true; -} - -QList ModuleBase_WidgetToolbox::getControls() const -{ - QList aList; - aList << myToolBox; - return aList; -} - -bool ModuleBase_WidgetToolbox::focusTo() -{ - int idx = myToolBox->currentIndex(); - if (idx > myPages.count()) - return false; - myPages[idx]->takeFocus(); - repaint(); - return true; + return myToolBox->currentIndex(); } -void ModuleBase_WidgetToolbox::activateCustom() +void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex) { + 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(); - focusTo(); -}