]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Clean Property panel before starting of a new operation.
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 5 Jun 2014 11:41:13 +0000 (15:41 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 5 Jun 2014 11:41:13 +0000 (15:41 +0400)
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index ce30a89c1e61c31fc11f76982403f8acbddd69a8..2d2938a96ab7348cc9b986ab2a16d9744d91b35a 100644 (file)
@@ -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<ModuleBase_ModelWidget*>& theWidgets)
 {
   myWidgets = theWidgets;
index 67c9857c305f004482025fec025d18ec239abb86..5cc9b5faf9b5882e17b71b9c5b7699765d9549e0 100644 (file)
@@ -16,6 +16,7 @@
 #include <QList>
 
 class QKeyEvent;
+class QVBoxLayout;
 
 class XGUI_EXPORT XGUI_PropertyPanel: public QDockWidget
 {
@@ -27,6 +28,9 @@ public:
   QWidget* contentWidget();
   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
 
+  void cleanContent();
+
+protected:
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
 public slots:
@@ -45,6 +49,8 @@ private:
   QWidget* myCustomWidget;
 
   QList<ModuleBase_ModelWidget*> myWidgets;
+
+  QVBoxLayout* myMainLayout;
 };
 
 #endif /* XGUI_PROPERTYPANEL_H_ */
index 25f3b5317528e8e98678770a61d32f44ed91989c..cdf0c42a5cf06512e9937562b8755867ebcaa84d 100644 (file)
@@ -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<const Config_PointerMessage*>(theMessage);
   if (aPartSetMsg) {
+    // Clear previous content
+    myPropertyPanel->cleanContent();
     ModuleBase_Operation* anOperation =
         (ModuleBase_Operation*)(aPartSetMsg->pointer());