X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_PropertyPanel.cpp;h=888d96c3e4a28b94ce7def47fad9efaec95da831;hb=13d3f0d8b46a06931cbe8620b8563049eff4a9f6;hp=355614b7687d4a055ecb68f8f4de17199843d2b9;hpb=b69a4c4ae0f7eb0e9c17d3db0229b04b1fe77ecf;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 355614b76..888d96c3e 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -11,6 +11,9 @@ #include //#include #include +#include +#include +#include #include #include @@ -19,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,7 +33,9 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) : ModuleBase_IPropertyPanel(theParent), - myActiveWidget(NULL) + myActiveWidget(NULL), + myPreselectionWidget(NULL), + myPanelPage(NULL) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -38,16 +43,20 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }"); QWidget* aContent = new QWidget(this); - myMainLayout = new QVBoxLayout(aContent); - myMainLayout->setContentsMargins(3, 3, 3, 3); + QGridLayout* aMainLayout = new QGridLayout(aContent); + const int kPanelColumn = 0; + int aPanelRow = 0; + aMainLayout->setContentsMargins(3, 3, 3, 3); this->setWidget(aContent); QFrame* aFrm = new QFrame(aContent); - aFrm->setFrameStyle(QFrame::Sunken); + aFrm->setFrameStyle(QFrame::Raised); aFrm->setFrameShape(QFrame::Panel); QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm); - aBtnLay->setContentsMargins(0, 0, 0, 0); - myMainLayout->addWidget(aFrm); + ModuleBase_Tools::zeroMargins(aBtnLay); + aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn); + + myHeaderWidget = aFrm; QStringList aBtnNames; aBtnNames << QString(PROP_PANEL_HELP) @@ -60,11 +69,10 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) aBtnLay->addWidget(aBtn); } aBtnLay->insertStretch(1, 1); - // aBtn->setShortcut(QKeySequence(Qt::Key_Escape)); - myCustomWidget = new QWidget(aContent); - myMainLayout->addWidget(myCustomWidget); - setStretchEnabled(true); + myPanelPage = new ModuleBase_PageWidget(aContent); + myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn); } XGUI_PropertyPanel::~XGUI_PropertyPanel() @@ -76,7 +84,7 @@ void XGUI_PropertyPanel::cleanContent() if (myActiveWidget) myActiveWidget->deactivate(); myWidgets.clear(); - qDeleteAll(myCustomWidget->children()); + myPanelPage->clearPage(); myActiveWidget = NULL; setWindowTitle(tr("Property Panel")); } @@ -85,32 +93,14 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t { myWidgets = theWidgets; if (theWidgets.empty()) return; - bool isEnableStretch = true; - QList::const_iterator anIt = theWidgets.begin(), aLast = - theWidgets.end(); - for (; anIt != aLast; anIt++) { - connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); - connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), - this, SLOT(activateNextWidget(ModuleBase_ModelWidget*))); - connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)), - this, SLOT(activateWidget(ModuleBase_ModelWidget*))); - - //ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast(*anIt); - //if (aPointWidget) - // connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this, - // SIGNAL(storedPoint2D(ObjectPtr, const std::string&))) - //} - - if (!isEnableStretch) continue; - foreach(QWidget* eachWidget, (*anIt)->getControls()) { - QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy(); - if(aVPolicy == QSizePolicy::Expanding || - aVPolicy == QSizePolicy::MinimumExpanding) { - isEnableStretch = false; - } - } + foreach (ModuleBase_ModelWidget* aWidget, theWidgets) { + connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)), + this, SLOT(activateWidget(ModuleBase_ModelWidget*))); + connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), + this, SLOT(activateNextWidget(ModuleBase_ModelWidget*))); + connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)), + this, SIGNAL(keyReleased(QKeyEvent*))); } - setStretchEnabled(isEnableStretch); ModuleBase_ModelWidget* aLastWidget = theWidgets.last(); if (aLastWidget) { QList aControls = aLastWidget->getControls(); @@ -131,9 +121,10 @@ const QList& XGUI_PropertyPanel::modelWidgets() const return myWidgets; } -QWidget* XGUI_PropertyPanel::contentWidget() +ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget() { - return myCustomWidget; + + return static_cast(myPanelPage); } void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature) @@ -143,9 +134,9 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature) return; if (theFeature->isAction() || !theFeature->data()) return; - foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) - { - eachWidget->setFeature(theFeature); + foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) { + if (!eachWidget->feature().get()) + eachWidget->setFeature(theFeature); eachWidget->restoreValue(); } // the repaint is used here to immediately react in GUI to the values change. @@ -162,6 +153,7 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) ModuleBase_ModelWidget* aNextWidget = 0; QList::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end(); bool isFoundWidget = false; + activateWindow(); for (; anIt != aLast && !aNextWidget; anIt++) { if (isFoundWidget || !theWidget) { if ((*anIt)->focusTo()) { @@ -172,23 +164,8 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) } // Normaly focusTo is enough to activate widget // here is a special case on mouse click in the viewer - //if(aNextWidget == NULL) { + if(aNextWidget == NULL) { activateWidget(aNextWidget); - //} -} - -void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled) -{ - if (myMainLayout->count() == 0) - return; - int aStretchIdx = myMainLayout->count() - 1; - bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL; - QLayoutItem* aChild; - if (isEnabled) { - if (!hasStretch) myMainLayout->addStretch(1); - } else if (hasStretch) { - aChild = myMainLayout->takeAt(aStretchIdx); - delete aChild; } } @@ -200,23 +177,24 @@ void XGUI_PropertyPanel::activateNextWidget() void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) { // Avoid activation of already actve widget. It could happen on focusIn event many times - if (theWidget == myActiveWidget) + if (theWidget == myActiveWidget) { return; + } if(myActiveWidget) { myActiveWidget->deactivate(); myActiveWidget->setHighlighted(false); } if(theWidget) { - if (theWidget) - emit beforeWidgetActivated(theWidget); - theWidget->activate(); + emit beforeWidgetActivated(theWidget); theWidget->setHighlighted(true); + theWidget->activate(); } myActiveWidget = theWidget; - if (myActiveWidget) + if (myActiveWidget) { emit widgetActivated(theWidget); - else if (!isEditingMode()) + } else if (!isEditingMode()) { emit noMoreWidgets(); + } } void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled) @@ -251,3 +229,13 @@ void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr) aBtn->setDefaultAction(anAct); } } + +ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const +{ + return myPreselectionWidget; +} + +void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget) +{ + myPreselectionWidget = theWidget; +}