Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
1 /*
2  * XGUI_PropertyPanel.cpp
3  *
4  *  Created on: Apr 29, 2014
5  *      Author: sbh
6  */
7
8 #include <XGUI_Constants.h>
9 #include <XGUI_PropertyPanel.h>
10
11 #include <QWidget>
12 #include <QVBoxLayout>
13 #include <QFrame>
14 #include <QPushButton>
15 #include <QIcon>
16 #include <QVBoxLayout>
17
18 #ifdef _DEBUG
19 #include <iostream>
20 #endif
21
22 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
23 {
24   this->setWindowTitle(tr("Property Panel"));
25   QAction* aViewAct = this->toggleViewAction();
26   this->setObjectName(XGUI::PROP_PANEL);
27   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
28
29   QWidget* aContent = new QWidget(this);
30   QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
31   aMainLay->setContentsMargins(3, 3, 3, 3);
32   this->setWidget(aContent);
33
34   QFrame* aFrm = new QFrame(aContent);
35   aFrm->setFrameStyle(QFrame::Sunken);
36   aFrm->setFrameShape(QFrame::Panel);
37   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
38   aBtnLay->setContentsMargins(0, 0, 0, 0);
39   aMainLay->addWidget(aFrm);
40
41   QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
42   aBtn->setFlat(true);
43   aBtnLay->addWidget(aBtn);
44   aBtnLay->addStretch(1);
45   aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
46   aBtn->setObjectName(XGUI::PROP_PANEL_OK);
47   aBtn->setFlat(true);
48   aBtnLay->addWidget(aBtn);
49   aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
50   aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
51   aBtn->setFlat(true);
52   aBtnLay->addWidget(aBtn);
53
54   myCustomWidget = new QWidget(aContent);
55   aMainLay->addWidget(myCustomWidget);
56   aMainLay->addStretch(1);
57 }
58
59 XGUI_PropertyPanel::~XGUI_PropertyPanel()
60 {
61 }
62
63 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
64 {
65   myWidgets = theWidgets;
66 }
67
68 QWidget* XGUI_PropertyPanel::contentWidget()
69 {
70   return myCustomWidget;
71 }
72
73 void XGUI_PropertyPanel::updateContentWidget(boost::shared_ptr<ModelAPI_Feature> theFeature)
74 {
75   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
76     eachWidget->restoreValue(theFeature);
77   }
78   // the repaint is used here to immediatelly react in GUI to the values change.
79   repaint();
80 }