1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SUPERVGUI_Information.cxx
25 // Author : Francis KLOSS
29 #include "SUPERVGUI_Information.h"
30 #include "QAD_Application.h"
31 #include "QAD_Desktop.h"
32 #include "QAD_MessageBox.h"
33 #include <qapplication.h>
35 #include <qgroupbox.h>
42 SUPERVGUI_Information::SUPERVGUI_Information(SUPERV_CNode node, bool isReadOnly)
43 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
45 Trace("SUPERVGUI_Information::SUPERVGUI_Information");
46 setCaption( tr( "TLT_INFORMATIONS" ) );
47 setSizeGripEnabled( true );
50 QGridLayout* TopLayout = new QGridLayout( this );
51 TopLayout->setSpacing( 6 );
52 TopLayout->setMargin( 11 );
54 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
55 TopGroup->setColumnLayout(0, Qt::Vertical );
56 TopGroup->layout()->setSpacing( 0 );
57 TopGroup->layout()->setMargin( 0 );
58 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
59 TopGroupLayout->setAlignment( Qt::AlignTop );
60 TopGroupLayout->setSpacing( 6 );
61 TopGroupLayout->setMargin( 11 );
63 QLabel* nameL = new QLabel( tr( "NAME_LBL" ), TopGroup );
64 nameV = new QLineEdit( TopGroup );
65 nameV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
66 nameV->setMinimumSize( 200, 0 );
67 nameV->setReadOnly( isReadOnly );
68 nameV->setText( node->Name() );
70 QLabel* authL = new QLabel( tr( "AUTHOR_LBL" ), TopGroup);
71 authV = new QLineEdit( TopGroup );
72 authV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
73 authV->setMinimumSize( 200, 0 );
74 authV->setReadOnly( isReadOnly );
75 authV->setText( node->Author() );
78 if (node->IsFactory()) {
79 contL = new QLabel( tr( "CONTAINER_LBL" ), TopGroup );
80 contV = new QLineEdit( TopGroup );
81 contV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
82 contV->setMinimumSize( 200, 0 );
83 contV->setReadOnly( false/*isReadOnly*/ );
84 contV->setText( SUPERV::FNode::_narrow(node)->GetContainer() );
86 compnameL = new QLabel( tr( "COMPONENT_NAME_LBL" ), TopGroup );
87 compnameV = new QLineEdit( TopGroup );
88 compnameV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
89 compnameV->setMinimumSize( 200, 0 );
90 compnameV->setReadOnly( true/*isReadOnly*/ );
91 compnameV->setText( SUPERV::FNode::_narrow(node)->GetComponentName() );
93 intnameL = new QLabel( tr( "INTERFACE_NAME_LBL" ), TopGroup );
94 intnameV = new QLineEdit( TopGroup );
95 intnameV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
96 intnameV->setMinimumSize( 200, 0 );
97 intnameV->setReadOnly( true/*isReadOnly*/ );
98 intnameV->setText( SUPERV::FNode::_narrow(node)->GetInterfaceName() );
101 QLabel* cdatL = new QLabel( tr( "DATE_CREATION_LBL" ), TopGroup );
102 cdatV = new QLabel( TopGroup );
103 cdatV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
104 cdatV->setMinimumSize( 200, 0 );
105 cdatV->setText( date( node->CreationDate() ) );
107 QLabel* udatL = new QLabel( tr( "DATE_MODIFICATION_LBL" ), TopGroup );
108 udatV = new QLabel( TopGroup );
109 udatV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
110 udatV->setMinimumSize( 200, 0 );
111 udatV->setText( date( node->LastUpdateDate() ) );
113 QLabel* commL = new QLabel( tr( "COMMENT_LBL" ), TopGroup);
114 commV = new QMultiLineEdit( TopGroup );
115 commV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
116 commV->setMinimumSize( 200, 100 );
117 commV->setReadOnly( isReadOnly );
118 commV->setText( node->Comment() );
120 TopGroupLayout->addWidget( nameL, 0, 0 );
121 TopGroupLayout->addWidget( nameV, 0, 1 );
122 TopGroupLayout->addWidget( authL, 1, 0 );
123 TopGroupLayout->addWidget( authV, 1, 1 );
124 if (node->IsFactory()) {
125 TopGroupLayout->addWidget( contL, 2, 0 );
126 TopGroupLayout->addWidget( contV, 2, 1 );
127 TopGroupLayout->addWidget( compnameL, 3, 0 );
128 TopGroupLayout->addWidget( compnameV, 3, 1 );
129 TopGroupLayout->addWidget( intnameL, 4, 0 );
130 TopGroupLayout->addWidget( intnameV, 4, 1 );
132 TopGroupLayout->addWidget( cdatL, 5, 0 );
133 TopGroupLayout->addWidget( cdatV, 5, 1 );
134 TopGroupLayout->addWidget( udatL, 6, 0 );
135 TopGroupLayout->addWidget( udatV, 6, 1 );
136 TopGroupLayout->addWidget( commL, 7, 0 );
137 TopGroupLayout->addMultiCellWidget( commV, 7, 8, 1, 1 );
138 TopGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ), 8, 0 );
139 TopGroupLayout->setColStretch( 1, 5 );
141 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
142 GroupButtons->setColumnLayout(0, Qt::Vertical );
143 GroupButtons->layout()->setSpacing( 0 );
144 GroupButtons->layout()->setMargin( 0 );
145 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
146 GroupButtonsLayout->setAlignment( Qt::AlignTop );
147 GroupButtonsLayout->setSpacing( 6 );
148 GroupButtonsLayout->setMargin( 11 );
150 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
151 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
153 GroupButtonsLayout->addWidget( okB, 0, 0 );
154 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
155 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
157 TopLayout->addWidget( TopGroup, 0, 0 );
158 TopLayout->addWidget( GroupButtons, 1, 0 );
160 connect( okB, SIGNAL( clicked() ), this, SLOT( okButton() ) );
161 connect( cancelB, SIGNAL( clicked() ), this, SLOT( koButton() ) );
167 SUPERVGUI_Information::~SUPERVGUI_Information() {
168 Trace("SUPERVGUI_Information::~SUPERVGUI_Information");
175 bool SUPERVGUI_Information::run( SUPERV_CNode node, bool isReadOnly ) {
176 Trace("SUPERVGUI_Information::run");
177 nameV->setReadOnly( isReadOnly );
178 authV->setReadOnly( isReadOnly );
179 commV->setReadOnly( isReadOnly );
181 nameV->setText( node->Name() );
182 authV->setText( node->Author() );
183 commV->setText( node->Comment() );
184 if (node->IsFactory()) {
185 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(node);
186 contV->setText( aFNode->GetContainer());
194 qApp->processEvents();
197 //commV->setText( node->Comment() );
198 cdatV->setText( date( node->CreationDate() ) );
199 udatV->setText( date( node->LastUpdateDate() ) );
206 if ( exec() == Accepted ) {
208 //b3 = node->SetContainer( contV->text().latin1() );
211 if ( strcmp( node->Name(), nameV->text().latin1() ) != 0 ) {
212 b1 = node->SetName( nameV->text().latin1() );
214 b2 = node->SetAuthor ( authV->text().latin1() );
215 if (node->IsFactory()) {
216 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(node);
217 b3 = aFNode->SetContainer( contV->text().latin1() );
219 b4 = node->SetComment ( commV->text().latin1() );
221 result = b1 && b2 && b3 && b4;
223 QAD_MessageBox::warn1( this, tr( "ERROR" ), tr( "MSG_CANT_CHANGE_INFO" ), tr( "BUT_OK" ) );
230 Returns string representation of date
232 QString SUPERVGUI_Information::date( SUPERV_Date d ) {
233 Trace("SUPERVGUI_Information::date");
237 dt += ( char )( d.Day / 10 + 48 );
238 dt += ( char )( d.Day % 10 + 48 );
240 dt += ( char )( d.Month / 10 + 48 );
241 dt += ( char )( d.Month % 10 + 48 );
243 dt += ( char )( ( d.Year / 1000 ) %10 + 48 );
244 dt += ( char )( ( d.Year / 100 ) % 10 + 48 );
245 dt += ( char )( ( d.Year / 10 ) % 10 + 48 );
246 dt += ( char )( d.Year %10 + 48 );
248 dt += ( char )( d.Hour / 10 + 48 );
249 dt += ( char )( d.Hour % 10 + 48 );
251 dt += ( char )( d.Minute / 10 + 48 );
252 dt += ( char )( d.Minute % 10 + 48 );
254 dt += ( char )( d.Second / 10 + 48 );
255 dt += ( char )( d.Second % 10 + 48 );
263 void SUPERVGUI_Information::okButton() {
264 Trace("SUPERVGUI_Information::okButton");
265 myNode->SetName( nameV->text().latin1());
266 myNode->SetAuthor( authV->text().latin1() );
267 if (myNode->IsFactory()) {
268 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(myNode);
269 aFNode->SetContainer( contV->text().latin1() );
271 myNode->SetComment( commV->text().latin1() );
278 void SUPERVGUI_Information::koButton() {
279 Trace("SUPERVGUI_Information::koButton");