]> SALOME platform Git repositories - modules/yacs.git/blob - src/genericgui/FormContainer.cxx
Salome HOME
e649ecfbb4b2c5ecee06f97620b51eafa9cf7dd4
[modules/yacs.git] / src / genericgui / FormContainer.cxx
1 // Copyright (C) 2006-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "FormContainer.hxx"
21 #include "FormAdvParamContainer.hxx"
22 #include "Container.hxx"
23 //#define _DEVDEBUG_
24 #include "YacsTrace.hxx"
25
26 #include <QComboBox>
27 #include <QList>
28
29 #include <sstream>
30
31 using namespace std;
32
33 FormContainer::FormContainer(QWidget *parent):FormContainerBase(parent),cb_type(new QComboBox(this))
34
35   gridLayout_2_2->addWidget(cb_type);
36   FormContainer::FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection
37   connect(cb_type, SIGNAL(activated(const QString&)),this, SLOT(onModifyType(const QString&)));
38   connect(ch_aoc,SIGNAL(stateChanged(int)),this,SLOT(onModifyAOC(int)));
39   connect(ch_pycache,SIGNAL(stateChanged(int)),this,SLOT(onModifyStorePyCache(int)));
40 }
41
42 FormContainer::~FormContainer()
43 {
44 }
45
46 void FormContainer::FillPanel(YACS::ENGINE::Container *container)
47 {
48   DEBTRACE("FormContainer::FillPanel");
49   FormContainerBase::FillPanel(container);
50   if(container)
51   {
52     ch_aoc->setCheckState(container->isAttachedOnCloning()?Qt::Checked:Qt::Unchecked);
53     ch_pycache->setCheckState(container->storeContext()?Qt::Checked:Qt::Unchecked);
54   }
55   cb_type->clear();
56   cb_type->addItem("mono");
57   cb_type->addItem("multi");
58   if(_properties.count("type") && _properties["type"]=="multi")
59     cb_type->setCurrentIndex(1);
60 }
61
62 QString FormContainer::getTypeStr() const
63 {
64   return QString("Container");
65 }
66
67 void FormContainer::onModifyType(const QString &text)
68 {
69   DEBTRACE("onModifyType " << text.toStdString());
70   if (!_container)
71     return;
72   std::string prop=_container->getProperty("type");
73   _properties["type"] = text.toStdString();
74   if (_properties["type"] == "mono")
75     _advancedParams->setModeText("mono");
76   else
77     _advancedParams->setModeText("multi");
78   if (prop != text.toStdString())
79     onModified();
80 }
81
82 void FormContainer::onModifyAOC(int val)
83 {
84   if (!_container)
85     return;
86   bool val2(false);
87   if(val==Qt::Unchecked)
88     val2=false;
89   if(val==Qt::Checked)
90     val2=true;
91   bool prop(_container->isAttachedOnCloning());
92   int prop2((int)val2);
93   std::ostringstream oss; oss << prop2;
94   _properties[YACS::ENGINE::Container::AOC_ENTRY]=oss.str();
95   _container->setAttachOnCloningStatus(val2);
96   if(prop!=val2)
97     onModified();
98 }
99
100 void FormContainer::onModifyStorePyCache(int val)
101 {
102   if (!_container)
103     return;
104   bool val2(false);
105   if(val==Qt::Unchecked)
106     val2=false;
107   if(val==Qt::Checked)
108     val2=true;
109   bool prop = _container->storeContext();
110   int prop2((int)val2);
111   std::ostringstream oss; oss << prop2;
112   //_properties[YACS::ENGINE::Container::AOC_ENTRY]=oss.str();
113   _container->setStoreContext(val2);
114   if(prop!=val2)
115     onModified();
116 }