Salome HOME
Update copyrights
[modules/yacs.git] / src / genericgui / FormComponent.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 "FormComponent.hxx"
21
22 //#define _DEVDEBUG_
23 #include "YacsTrace.hxx"
24
25 #include <QList>
26
27 using namespace std;
28
29 bool FormComponent::_checked = false;
30
31 ComboBox::ComboBox(QWidget *parent)
32   : QComboBox(parent)
33 {
34 }
35
36 ComboBox::~ComboBox()
37 {
38 }
39     
40 void ComboBox::mousePressEvent(QMouseEvent *event)
41 {
42   emit mousePressed();
43   QComboBox::mousePressEvent(event);
44 }
45
46
47 FormComponent::FormComponent(QWidget *parent)
48 {
49   setupUi(this);
50
51   le_name->setReadOnly(true);
52
53   gridLayout3->removeWidget(cb_instance);
54   delete cb_instance;
55   cb_instance = new ComboBox(fr_component);
56   gridLayout3->addWidget(cb_instance, 1, 1, 1, 1);
57
58   gridLayout3->removeWidget(cb_container);
59   delete cb_container;
60   cb_container = new ComboBox(fr_component);
61   gridLayout3->addWidget(cb_container, 2, 1, 1, 1);
62
63   QIcon icon;
64   icon.addFile("icons:icon_down.png");
65   icon.addFile("icons:icon_up.png",
66                 QSize(), QIcon::Normal, QIcon::On);
67   tb_component->setIcon(icon);
68   on_tb_component_toggled(FormComponent::_checked);
69 }
70
71 FormComponent::~FormComponent()
72 {
73 }
74
75 void FormComponent::on_tb_component_toggled(bool checked)
76 {
77   DEBTRACE("FormComponent::on_tb_component_toggled " << checked);
78   _checked = checked;
79   if (_checked) fr_component->show();
80   else fr_component->hide();
81 }