From ac8b1dc043f53cbf4f9c2a368e0c214669c21176 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 5 Jun 2014 15:41:13 +0400 Subject: [PATCH] Clean Property panel before starting of a new operation. --- src/XGUI/XGUI_PropertyPanel.cpp | 25 ++++++++++++++++++++----- src/XGUI/XGUI_PropertyPanel.h | 6 ++++++ src/XGUI/XGUI_Workshop.cpp | 2 ++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index ce30a89c1..2d2938a96 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -29,8 +29,8 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }"); QWidget* aContent = new QWidget(this); - QVBoxLayout* aMainLay = new QVBoxLayout(aContent); - aMainLay->setContentsMargins(3, 3, 3, 3); + myMainLayout = new QVBoxLayout(aContent); + myMainLayout->setContentsMargins(3, 3, 3, 3); this->setWidget(aContent); QFrame* aFrm = new QFrame(aContent); @@ -38,7 +38,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) aFrm->setFrameShape(QFrame::Panel); QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm); aBtnLay->setContentsMargins(0, 0, 0, 0); - aMainLay->addWidget(aFrm); + myMainLayout->addWidget(aFrm); QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm); aBtn->setFlat(true); @@ -58,8 +58,8 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) aBtnLay->addWidget(aBtn); myCustomWidget = new QWidget(aContent); - aMainLay->addWidget(myCustomWidget); - aMainLay->addStretch(1); + myMainLayout->addWidget(myCustomWidget); + myMainLayout->addStretch(1); aBtn->installEventFilter(this); } @@ -68,6 +68,21 @@ XGUI_PropertyPanel::~XGUI_PropertyPanel() { } +void XGUI_PropertyPanel::cleanContent() +{ + myWidgets.clear(); + + QLayoutItem* aItem = myMainLayout->takeAt(myMainLayout->count() - 1); + delete aItem; + + myMainLayout->removeWidget(myCustomWidget); + delete myCustomWidget; + + myCustomWidget = new QWidget(widget()); + myMainLayout->addWidget(myCustomWidget); + myMainLayout->addStretch(1); +} + void XGUI_PropertyPanel::setModelWidgets(const QList& theWidgets) { myWidgets = theWidgets; diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 67c9857c3..5cc9b5faf 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -16,6 +16,7 @@ #include class QKeyEvent; +class QVBoxLayout; class XGUI_EXPORT XGUI_PropertyPanel: public QDockWidget { @@ -27,6 +28,9 @@ public: QWidget* contentWidget(); void setModelWidgets(const QList& theWidgets); + void cleanContent(); + +protected: virtual bool eventFilter(QObject *theObject, QEvent *theEvent); public slots: @@ -45,6 +49,8 @@ private: QWidget* myCustomWidget; QList myWidgets; + + QVBoxLayout* myMainLayout; }; #endif /* XGUI_PROPERTYPANEL_H_ */ diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 25f3b5317..cdf0c42a5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -264,6 +264,8 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //An operation passed by message. Start it, process and commit. const Config_PointerMessage* aPartSetMsg = dynamic_cast(theMessage); if (aPartSetMsg) { + // Clear previous content + myPropertyPanel->cleanContent(); ModuleBase_Operation* anOperation = (ModuleBase_Operation*)(aPartSetMsg->pointer()); -- 2.39.2