]> SALOME platform Git repositories - modules/yacs.git/blob - src/genericgui/EditionContainer.cxx
Salome HOME
Fix make check with Python 2.7
[modules/yacs.git] / src / genericgui / EditionContainer.cxx
1 // Copyright (C) 2006-2012  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.
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 "EditionContainer.hxx"
21
22 //#define _DEVDEBUG_
23 #include "YacsTrace.hxx"
24
25 #include "FormContainer.hxx"
26 #include "QtGuiContext.hxx"
27 #include "guiObservers.hxx"
28 #include "Proc.hxx"
29 #include "Message.hxx"
30
31 #include <cassert>
32
33 using namespace std;
34
35 using namespace YACS;
36 using namespace YACS::HMI;
37 using namespace YACS::ENGINE;
38
39 EditionContainer::EditionContainer(Subject* subject,
40                                    QWidget* parent,
41                                    const char* name)
42   : ItemEdition(subject, parent, name)
43 {
44   _wContainer = new FormContainer(this);
45   _wid->gridLayout1->addWidget(_wContainer);
46   connect(_wContainer->cb_resource, SIGNAL(mousePressed()),
47           this, SLOT(fillContainerPanel()));
48   connect(_wContainer->tb_container, SIGNAL(toggled(bool)),
49           this, SLOT(fillContainerPanel())); // --- to update display of current selection
50   _wContainer->tb_container->toggle();
51 }
52
53 EditionContainer::~EditionContainer()
54 {
55 }
56
57 void EditionContainer::update(GuiEvent event, int type, Subject* son)
58 {
59   DEBTRACE("EditionContainer::update");
60   ItemEdition::update(event, type, son);
61   switch (event)
62     {
63     case RENAME:
64       _wContainer->le_name->setText((son->getName()).c_str());
65       fillContainerPanel();
66       break;
67     default:
68       ;
69     }
70 }
71
72 void EditionContainer::fillContainerPanel()
73 {
74   DEBTRACE("EditionContainer::fillContainerPanel");
75   SubjectContainer *scont = dynamic_cast<SubjectContainer*>(_subject);
76   YASSERT(scont);
77   _wContainer->FillPanel(scont->getContainer());
78 }
79
80 void EditionContainer::onApply()
81 {
82   DEBTRACE("EditionContainer::onApply");
83   bool edited = true;
84   if (!_wContainer->onApply())
85     {
86       _isEdited = true;
87       Message mess(GuiContext::getCurrent()->_lastErrorMessage);
88       return;
89     }
90   edited = false;
91   _isEdited = _isEdited || edited;
92   ItemEdition::onApply();
93 }
94
95 void EditionContainer::onCancel()
96 {
97   DEBTRACE("EditionContainer::onCancel");
98   SubjectContainer *scont = dynamic_cast<SubjectContainer*>(_subject);
99   YASSERT(scont);
100   _wContainer->FillPanel(scont->getContainer());
101   ItemEdition::onCancel();
102 }