Version: 8.3.0
FormContainerDecorator.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 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 
21 #include "FormContainer.hxx"
22 #include "FormHPContainer.hxx"
23 
25 #include "Exception.hxx"
26 
27 //#define _DEVDEBUG_
28 #include "YacsTrace.hxx"
29 
30 using namespace YACS::ENGINE;
31 
33 
35 {
36  setupUi(this);
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 &)));
41  if(!cont)
42  return ;
43  HomogeneousPoolContainer *hpc(dynamic_cast<HomogeneousPoolContainer *>(cont));
44  if(!hpc)
45  _typ=new FormContainer(this);
46  else
47  _typ=new FormHPContainer(this);
49  _typ->FillPanel(cont);
50  gridLayout_1->addWidget(_typ);
51  connectForTyp();
52  tb_container->setChecked(CHECKED);
54 }
55 
57 {
58  delete _typ;
59 }
60 
62 {
64  _typ->FillPanel(container);
65 }
66 
68 {
69  return _typ;
70 }
71 
73 {
74  if(!checkOK())
75  return false;
76  return _typ->onApply();
77 }
78 
80 {
81  if(!checkOK())
82  return ;
83  _typ->onCancel();
84 }
85 
87 {
88  QWidget::show();
89  if(!checkOK())
90  return ;
91  _typ->show();
92  tb_container->setChecked(CHECKED);
94 }
95 
97 {
98  QWidget::hide();
99  if(!checkOK())
100  return ;
101  _typ->hide();
102 }
103 
105 {
106  DEBTRACE("FormContainer::on_tb_container_toggled " << checked);
107  CHECKED = checked;
108  if (CHECKED)
109  {
110  getWidget()->show();
111  }
112  else
113  {
114  getWidget()->hide();
115  }
116 }
117 
119 {
120  tb_container->setChecked(CHECKED);
121 }
122 
123 std::string FormContainerDecorator::getHostName(int index) const
124 {
125  if(!checkOK())
126  return std::string();
127  return _typ->cb_resource->itemText(index).toStdString();
128 }
129 
130 void FormContainerDecorator::setName(const std::string& name)
131 {
132  if(!checkOK())
133  return ;
134  _typ->le_name->setText(name.c_str());
135 }
136 
138 {
139  emit(resourceMousePressed());
140 }
141 
143 {
144  emit(resourceActivated(v));
145 }
146 
148 {
149  emit(containerToggled(v));
150 }
151 
153 {
154  return _typ;
155 }
156 
158 {
159  if(!container)
160  return ;
161  YACS::ENGINE::HomogeneousPoolContainer *cont1(dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container));
162  if(_typ)
163  {
164  bool isTyp1(dynamic_cast<FormHPContainer *>(_typ)!=0);
165  if((!cont1 && !isTyp1) || (cont1 && isTyp1))
166  return ;
167  delete _typ; _typ=0;
168  }
169  if(!cont1)
170  _typ=new FormContainer(this);
171  else
172  _typ=new FormHPContainer(this);
173  gridLayout_1->addWidget(_typ);
175  connectForTyp();
176  _typ->FillPanel(container);
177 }
178 
180 {
181  connect(_typ->cb_resource,SIGNAL(mousePressed()),this,SLOT(onResMousePressed()));
182  connect(_typ->cb_resource,SIGNAL(activated(int)),this,SLOT(onResActivated));
183  connect(tb_container,SIGNAL(toggled(bool)),this,SLOT(onContToggled()));
184 }