1 // Copyright (C) 2006-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FormContainerDecorator.hxx"
21 #include "FormContainer.hxx"
22 #include "FormHPContainer.hxx"
24 #include "HomogeneousPoolContainer.hxx"
25 #include "Exception.hxx"
28 #include "YacsTrace.hxx"
30 using namespace YACS::ENGINE;
32 bool FormContainerDecorator::CHECKED = false;
34 FormContainerDecorator::FormContainerDecorator(YACS::ENGINE::Container *cont, QWidget *parent):QWidget(parent),_typ(0)
37 _icon.addFile("icons:icon_down.png");
38 _icon.addFile("icons:icon_up.png",QSize(), QIcon::Normal, QIcon::On);
39 tb_container->setIcon(_icon);
40 connect(this,SIGNAL(typeOfContainerIsKnown(const QString&)),label,SLOT(setText(const QString &)));
43 HomogeneousPoolContainer *hpc(dynamic_cast<HomogeneousPoolContainer *>(cont));
45 _typ=new FormContainer(this);
47 _typ=new FormHPContainer(this);
48 emit typeOfContainerIsKnown(_typ->getTypeStr());
49 _typ->FillPanel(cont);
50 gridLayout_1->addWidget(_typ);
52 tb_container->setChecked(CHECKED);
53 on_tb_container_toggled(CHECKED);
56 FormContainerDecorator::~FormContainerDecorator()
61 void FormContainerDecorator::FillPanel(YACS::ENGINE::Container *container)
63 checkAndRepareTypeIfNecessary(container);
64 _typ->FillPanel(container);
67 QWidget *FormContainerDecorator::getWidget()
72 bool FormContainerDecorator::onApply()
76 return _typ->onApply();
79 void FormContainerDecorator::onCancel()
86 void FormContainerDecorator::show()
92 tb_container->setChecked(CHECKED);
93 on_tb_container_toggled(CHECKED);
96 void FormContainerDecorator::hide()
104 void FormContainerDecorator::on_tb_container_toggled(bool checked)
106 DEBTRACE("FormContainer::on_tb_container_toggled " << checked);
118 void FormContainerDecorator::synchronizeCheckContainer()
120 tb_container->setChecked(CHECKED);
123 std::string FormContainerDecorator::getHostName(int index) const
126 return std::string();
127 return _typ->cb_resource->itemText(index).toStdString();
130 void FormContainerDecorator::setName(const std::string& name)
134 _typ->le_name->setText(name.c_str());
137 void FormContainerDecorator::onResMousePressed()
139 emit(resourceMousePressed());
142 void FormContainerDecorator::onResActivated(int v)
144 emit(resourceActivated(v));
147 void FormContainerDecorator::onContToggled(bool v)
149 emit(containerToggled(v));
152 bool FormContainerDecorator::checkOK() const
157 void FormContainerDecorator::checkAndRepareTypeIfNecessary(YACS::ENGINE::Container *container)
161 YACS::ENGINE::HomogeneousPoolContainer *cont1(dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container));
164 bool isTyp1(dynamic_cast<FormHPContainer *>(_typ)!=0);
165 if((!cont1 && !isTyp1) || (cont1 && isTyp1))
170 _typ=new FormContainer(this);
172 _typ=new FormHPContainer(this);
173 gridLayout_1->addWidget(_typ);
174 emit typeOfContainerIsKnown(_typ->getTypeStr());
176 _typ->FillPanel(container);
179 void FormContainerDecorator::connectForTyp()
181 connect(_typ->cb_resource,SIGNAL(mousePressed()),this,SLOT(onResMousePressed()));
182 connect(_typ->cb_resource,SIGNAL(activated(int)),this,SLOT(onResActivated(int)));
183 connect(tb_container,SIGNAL(toggled(bool)),this,SLOT(onContToggled(bool)));