Salome HOME
956133da7a0c3ed9ac7cfcc3c46b849a067fd993
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_ManagePortsDlg.cxx
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SUPERVGUI_ManagePortsDlg.cxx
8 //  Author : Alexander SLADKOV
9 //  Module : SUPERV
10
11 using namespace std;
12
13 #include "SUPERVGUI_ManagePortsDlg.h"
14 #include "SUPERVGUI_CanvasNode.h"
15 #include "SUPERVGUI_CanvasPort.h"
16 #include "SUPERVGUI_CanvasControlNode.h"
17 #include "SUPERVGUI.h"
18
19 #include <qlayout.h>
20 #include <qlabel.h>
21 #include <qpushbutton.h>
22 #include <qhbox.h>
23 #include <qgroupbox.h>
24
25 static const char* gTypes[] = 
26   {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"};
27
28 static const char* const add_pix_data[] = { 
29 "20 20 4 1",
30 ". c None",
31 "b c #084818",
32 "a c #186929",
33 "# c #208541",
34 "....................",
35 "....................",
36 "....................",
37 "....................",
38 "........##a.........",
39 "........##b.........",
40 "........##b.........",
41 "........##b.........",
42 "........##b.........",
43 "...############a....",
44 "...############b....",
45 "...abbbb##bbbbbb....",
46 "........##b.........",
47 "........##b.........",
48 "........##b.........",
49 "........##b.........",
50 "........abb.........",
51 "....................",
52 "....................",
53 "...................."};
54
55 static const char* const del_pix_data[] = { 
56 "16 16 3 1",
57 ". c None",
58 "# c #800000",
59 "a c #ffffff",
60 "................",
61 "................",
62 ".##a........##a.",
63 ".####a.....##a..",
64 "..####a...##a...",
65 "....###a.#a.....",
66 ".....#####a.....",
67 "......###a......",
68 ".....#####a.....",
69 "....###a.##a....",
70 "...###a...##a...",
71 "..###a.....#a...",
72 "..###a......#a..",
73 "...#a........#a.",
74 "................",
75 "................"};
76
77 static const char* const up_pix_data[] = { 
78 "16 16 5 1",
79 ". c None",
80 "# c #000000",
81 "a c #838183",
82 "c c #c5c2c5",
83 "b c #ffffff",
84 "................",
85 "................",
86 "........#.......",
87 "......a#b#......",
88 ".....a#bbb#.....",
89 "....a#bccbb#....",
90 "...a#bccccbb#...",
91 "..a####ccb####..",
92 ".aaaaa#ccb#.....",
93 ".....a#ccb#.....",
94 ".....a#ccb#.....",
95 ".....a#ccb#.....",
96 ".....a#ccb#.....",
97 ".....a#ccb#.....",
98 ".....a#####.....",
99 "................"};
100
101 static const char* const down_pix_data[] = { 
102 "16 16 5 1",
103 ". c None",
104 "# c #000000",
105 "a c #838183",
106 "c c #c5c2c5",
107 "b c #ffffff",
108 "................",
109 ".....#####a.....",
110 ".....#bcc#a.....",
111 ".....#bcc#a.....",
112 ".....#bcc#a.....",
113 ".....#bcc#a.....",
114 ".....#bcc#a.....",
115 ".....#bcc#aaaaa.",
116 "..####bcc####a..",
117 "...#bbccccb#a...",
118 "....#bbccb#a....",
119 ".....#bbb#a.....",
120 "......#b#a......",
121 ".......#........",
122 "................",
123 "................"};
124
125
126 /**
127  * Constructor
128  */
129 SUPERVGUI_ManagePortsDlg::SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode )
130   : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
131 {
132   myNode = theNode;
133   myLastItem = 0;
134   init();
135 }
136
137 void SUPERVGUI_ManagePortsDlg::init()
138 {
139   setName( "SUPERVGUI_ManagePortsDlg" );
140
141   SUPERV_CNode aCNode = myNode->getEngine();
142   setCaption( tr( "TIT_MANAGE_PORTS" ) + aCNode->Name() );
143
144   QGridLayout* aBaseLayout = new QGridLayout( this );
145   aBaseLayout->setMargin( 11 ); 
146   aBaseLayout->setSpacing( 6 );
147
148   // -- name and type upper line widgets --
149   QLabel* aNameLbl = new QLabel( tr( "NAME_LBL") , this );
150   myNameEdt = new QLineEdit( this );
151   QLabel* aTypeLbl = new QLabel( tr( "TYPE_LBL" ), this );
152   myTypeCombo = new QComboBox( false, this ); // input field not editable
153
154   aBaseLayout->addWidget( aNameLbl, 0, 0 );
155   aBaseLayout->addWidget( myNameEdt, 0, 1 );
156   aBaseLayout->addWidget( aTypeLbl, 0, 2 );  
157   aBaseLayout->addWidget( myTypeCombo, 0, 3 );
158   aBaseLayout->setColStretch( 1, 1 );
159   aBaseLayout->setColStretch( 3, 1 );
160
161   // -- common Input/Output variables --
162   QPixmap adPix( (const char**) add_pix_data );
163   QPixmap rmPix( (const char**) del_pix_data );
164   QPixmap upPix( (const char**) up_pix_data );
165   QPixmap dnPix( (const char**) down_pix_data );
166
167   // -- Input ports group box --
168   QGroupBox* anInputGr = new QGroupBox( 1, Qt::Vertical, tr( "INPUT" ), this );
169   anInputGr->layout()->setSpacing( 6 ); 
170   anInputGr->layout()->setMargin( 11 );
171
172   myInList = new QListBox( anInputGr );
173   myInList->setSelectionMode( QListBox::Single );
174
175   QGroupBox* anInputBtnGr = new QGroupBox( 0, Qt::Vertical, anInputGr );
176   anInputBtnGr->setFrameStyle( QFrame::NoFrame );
177   anInputBtnGr->layout()->setSpacing( 0 ); 
178   anInputBtnGr->layout()->setMargin( 0 );  
179
180   QVBoxLayout* anInputBtnLay = new QVBoxLayout( anInputBtnGr->layout() );
181   anInputBtnLay->layout()->setSpacing( 6 ); 
182   anInputBtnLay->layout()->setMargin( 0 );
183   
184   QPushButton* anAddInputBtn = new QPushButton( anInputBtnGr );
185   anAddInputBtn->setPixmap( adPix );
186   QPushButton* aDeleteInputBtn = new QPushButton( anInputBtnGr );
187   aDeleteInputBtn->setPixmap( rmPix );
188   QPushButton* anUpInputBtn = new QPushButton( anInputBtnGr );
189   anUpInputBtn->setPixmap( upPix );
190   QPushButton* aDownInputBtn = new QPushButton( anInputBtnGr );
191   aDownInputBtn->setPixmap( dnPix );
192
193   connect( anAddInputBtn, SIGNAL( clicked() ), this, SLOT( addInput() ) );
194   connect( aDeleteInputBtn, SIGNAL( clicked() ), this, SLOT( removeInput() ) );
195   connect( anUpInputBtn, SIGNAL( clicked() ), this, SLOT( upInput() ) );
196   connect( aDownInputBtn, SIGNAL( clicked() ), this, SLOT( downInput() ) );
197
198   anInputBtnLay->addWidget( anAddInputBtn );
199   anInputBtnLay->addWidget( aDeleteInputBtn );
200   anInputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) );
201   anInputBtnLay->addWidget( anUpInputBtn );
202   anInputBtnLay->addWidget( aDownInputBtn );
203   anInputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) );
204
205   aBaseLayout->addMultiCellWidget( anInputGr, 1, 1, 0, 1 );
206
207   // -- Output ports group box --
208   QGroupBox* anOutputGr = new QGroupBox( 1, Qt::Vertical, tr( "OUTPUT" ), this );
209   anOutputGr->layout()->setSpacing( 6 ); 
210   anOutputGr->layout()->setMargin( 11 );
211
212   myOutList = new QListBox( anOutputGr );
213   myOutList->setSelectionMode( QListBox::Single );
214
215   QGroupBox* anOutputBtnGr = new QGroupBox( 0, Qt::Vertical, anOutputGr );
216   anOutputBtnGr->setFrameStyle( QFrame::NoFrame );
217   anOutputBtnGr->layout()->setSpacing( 0 ); 
218   anOutputBtnGr->layout()->setMargin( 0 );  
219
220   QVBoxLayout* anOutputBtnLay = new QVBoxLayout( anOutputBtnGr->layout() );
221   anOutputBtnLay->layout()->setSpacing( 6 ); 
222   anOutputBtnLay->layout()->setMargin( 0 );
223   
224   QPushButton* anAddOutputBtn = new QPushButton( anOutputBtnGr );
225   anAddOutputBtn->setPixmap( adPix );
226   QPushButton* aDeleteOutputBtn = new QPushButton( anOutputBtnGr );
227   aDeleteOutputBtn->setPixmap( rmPix );
228   QPushButton* anUpOutputBtn = new QPushButton( anOutputBtnGr );
229   anUpOutputBtn->setPixmap( upPix );
230   QPushButton* aDownOutputBtn = new QPushButton( anOutputBtnGr );
231   aDownOutputBtn->setPixmap( dnPix );
232
233   connect( anAddOutputBtn, SIGNAL( clicked() ), this, SLOT( addOutput() ) );
234   connect( aDeleteOutputBtn, SIGNAL( clicked() ), this, SLOT( removeOutput() ) );
235   connect( anUpOutputBtn, SIGNAL( clicked() ), this, SLOT( upOutput() ) );
236   connect( aDownOutputBtn, SIGNAL( clicked() ), this, SLOT( downOutput() ) );
237
238   anOutputBtnLay->addWidget( anAddOutputBtn );
239   anOutputBtnLay->addWidget( aDeleteOutputBtn );
240   anOutputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) );
241   anOutputBtnLay->addWidget( anUpOutputBtn );
242   anOutputBtnLay->addWidget( aDownOutputBtn );
243   anOutputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) );
244
245   aBaseLayout->addMultiCellWidget( anOutputGr, 1, 1, 2, 3 );
246
247   // -- Ok / Cancel buttons line at the bottom of dialog -- 
248   QGroupBox* aBtnBox = new QGroupBox( this );
249   aBtnBox->setColumnLayout( 0, Qt::Vertical );
250   aBtnBox->layout()->setSpacing( 0 ); 
251   aBtnBox->layout()->setMargin( 0 );
252   
253   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
254   aBtnLayout->setAlignment( Qt::AlignTop );
255   aBtnLayout->setSpacing( 6 ); 
256   aBtnLayout->setMargin( 11 );
257
258   QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
259   QPushButton* aCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), aBtnBox );
260   connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
261   connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
262
263   aBtnLayout->addWidget( aOkBtn );
264   aBtnLayout->addStretch();
265   aBtnLayout->addWidget( aCancelBtn );
266   
267   aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 3 );
268   // -----------
269
270   connect( myInList,SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
271   connect( myOutList, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
272   connect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
273   connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&)));
274
275   myNode->getMain()->lockedGraph( true );
276
277   // asv : 11.01.05 : if a node is a loop node, then only INPUT ports can be added/removed
278   if ( myNode->getNodeType() == SUPERV::LoopNode ) {
279     myOutList->setEnabled( false );
280     anAddOutputBtn->setEnabled( false );
281     aDeleteOutputBtn->setEnabled( false );
282     anUpOutputBtn->setEnabled( false );
283     aDownOutputBtn->setEnabled( false );
284   }
285     
286 }
287
288 /**
289  * Destructor
290  */
291 SUPERVGUI_ManagePortsDlg::~SUPERVGUI_ManagePortsDlg() {
292 }
293
294 /** 
295  * Set the ports as entered by user (order, name/type, etc.) and close the dialog
296  */
297 void SUPERVGUI_ManagePortsDlg::accept() {
298   myNode->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
299   // 1. set the ports to Engine's CNode
300   SUPERV_INode aINode = myNode->getInlineNode();
301   if ( !SUPERV_isNull( aINode ) ) {
302     int i; 
303     const bool isLoop = ( myNode->getNodeType() == SUPERV::LoopNode );
304
305     // 1.1 delete all ports (delete CanvasPorts, they delete SUPERV_Ports) 
306     QObjectList* oldPorts = myNode->queryList("SUPERVGUI_CanvasPort");
307     QObjectListIt it( *oldPorts ); // iterate over the old ports
308     QObject *obj;
309
310     // asv : 11.01.05 : fix for a bug: for Loop node, removal of an Input Port
311     // automatically removes the corresponding Output Port.  So for Loops the
312     // oldPorts list should be filtered to include only Input Ports.
313     // But I'll filter Gate-s as well..
314     QObjectList portsToRemove;
315     while ( (obj = it.current()) != 0 ) {
316       ++it;
317       SUPERV::Port_var aPort = ((SUPERVGUI_CanvasPort*)obj)->getEngine();
318       if ( !aPort->IsGate() && ( !isLoop || aPort->IsInput() ) )
319         portsToRemove.append( obj );
320     }
321     delete oldPorts; // delete the list, not the objects
322     
323     // portsToRemove list contains:
324     // for Loop node: all INPUT ports except Gates
325     // for other Inline: all INPUT and OUTPUT ports except Gates
326     it = QObjectListIt( portsToRemove );
327     while ( (obj = it.current()) != 0 ) {
328       ++it;
329       ((SUPERVGUI_CanvasPort*)obj)->remove();
330     }
331
332     // 1.2 create new ports in INode and CanvasPort in myNode
333     PortListItem* item;
334     SUPERV_Port aPort;
335     for ( i = 0; i < myInList->count(); i++ ) {
336       item = (PortListItem*)myInList->item( i );
337       aPort = aINode->InPort( item->PortName.latin1(), item->PortType.latin1() );
338       myNode->createPort( aPort.in() );
339       // asv : 11.01.05 : for Loop nodes do the same as in SUPERVGUI_CanvasStartNode::addInputPort()
340       if ( isLoop ) {
341         SUPERVGUI_CanvasStartNode* aStartLoopNode = (SUPERVGUI_CanvasStartNode*)myNode;
342         aStartLoopNode->merge();
343         aStartLoopNode->getCoupled()->merge();
344       }
345     }
346     // creating Out-ports, except LoopNode-s
347     for ( i = 0; i < myOutList->count() && !isLoop; i++ ) {
348       item = (PortListItem*)myOutList->item( i );
349       aPort = aINode->OutPort( item->PortName.latin1(), item->PortType.latin1() );
350       myNode->createPort( aPort.in() );
351     }  
352
353     // 2. update the node's presentation
354     myNode->getMain()->getCanvas()->update();
355   }
356   
357   // 3. close the dialog
358   myNode->getMain()->lockedGraph( false );
359   QDialog::accept();
360   close();
361 }
362
363 /** 
364  * Simply close the dialog
365  */
366 void SUPERVGUI_ManagePortsDlg::reject() {
367   myNode->getMain()->lockedGraph( false );
368   QDialog::reject();
369   close();
370 }
371
372 /**
373  * Update current values on show event
374  */
375 void SUPERVGUI_ManagePortsDlg::showEvent( QShowEvent* theEvent ) {
376   init( myNode );
377   QDialog::showEvent( theEvent );
378 }
379
380 /**
381  * Initialize In/Out tables with values from the given node
382  */
383 void SUPERVGUI_ManagePortsDlg::init( const SUPERVGUI_CanvasNode* theNode ) {
384   if ( !theNode ) {
385     MESSAGE("ERROR: SUPERVGUI_ManagePortsDlg: the CanvasNode is nil!");
386     return;
387   }
388
389   SUPERV_INode aINode = myNode->getInlineNode();
390   if ( SUPERV_isNull( aINode ) ) {
391     MESSAGE("ERROR: SUPERVGUI_ManagePortsDlg: the node of wrong type is found (not InLine node)!");
392     return;
393   }
394   
395   // 1. fill myTypeCombo with all available types
396   myTypeCombo->insertStrList( gTypes );
397
398   // 2. fill Input and Output listboxes with Ports' names/types
399   QStringList aTypes;
400   SUPERV_Ports aPorts = aINode->Ports();
401   for ( int i=0; i < aPorts->length(); i++ ) {
402     if ( aPorts[i]->IsGate() )
403       continue;
404     if ( aPorts[i]->IsInput() )
405       new PortListItem( myInList, aPorts[i]->Name(), aPorts[i]->Type() );
406     else 
407       new PortListItem( myOutList, aPorts[i]->Name(), aPorts[i]->Type() );
408   }
409 }
410
411 void SUPERVGUI_ManagePortsDlg::addPort( QListBox* theLB ) {
412   if ( !theLB )
413     return;
414   QString name = myNameEdt->text();
415   if ( !name.isNull() && name.length() ) {
416     bool found = false; // check if already exists -- and don't allow if yes
417     for ( int i = 0; i < theLB->count(); i++ ) {
418       if ( ((PortListItem*)theLB->item(i))->PortName == name ) {
419         found = true;
420         break;
421       }
422     }
423     if ( found )
424       QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") );
425     else
426       new PortListItem( theLB, name, myTypeCombo->currentText() );
427   }
428 }
429
430 /**
431  * called on 'X' button press - remove selected port item
432  */
433 void SUPERVGUI_ManagePortsDlg::removePort( QListBox* theLB ) {
434   if ( !theLB )
435     return;
436
437   const int i = theLB->currentItem();
438   if ( i >=0 )
439     delete theLB->item( i );    
440 }
441
442 /**
443  * called on up/down key press - move the selected list box item from position 'from' to position 'to'
444  */
445 void SUPERVGUI_ManagePortsDlg::moveItem( QListBox* theLB, const int from, const int to ) {
446   if ( !theLB )
447     return;
448
449   // disconnect itemChanged - it leads to crash if there was only 1 item left
450   disconnect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
451
452   if ( from >= 0 && from < theLB->count() && to >=0 && to < theLB->count() ) {
453     QListBoxItem* item = theLB->item( from );
454     theLB->takeItem( item );
455     theLB->insertItem( item, to );
456     theLB->setCurrentItem( item );
457     theLB->setSelected( item, true );
458   }
459
460   // connect back..
461   connect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*)));
462 }
463
464 /**
465  * move the selected item UP
466  */
467 void SUPERVGUI_ManagePortsDlg::moveUp( QListBox* theLB ) {
468   if ( !theLB )
469     return;
470   const int i = theLB->currentItem();
471   moveItem( theLB, i, i-1 );
472 }
473
474 /**
475  * move the selected item DOWN
476  */
477 void SUPERVGUI_ManagePortsDlg::moveDown( QListBox* theLB ) {
478   if ( !theLB )
479     return;
480   const int i = theLB->currentItem();
481   moveItem( theLB, i, i+1 );
482 }
483
484
485 /**
486  * returns true if there is a current and selected item in the given listbox and it
487  * equals to the given item.
488  */
489 bool isEditingItem( const QListBoxItem* item, const QListBox* theLB ) {
490   return item && item == theLB->item( theLB->currentItem() ) && theLB->isSelected( item );
491 }
492
493 /**
494  * called when name is changed.  Tries to change name of the item, which was
495  * the last selected by user item in myInList or myOutList (myLastItem)
496  */
497 void SUPERVGUI_ManagePortsDlg::nameChanged( const QString& name ) {
498   if ( isEditingItem( myLastItem, myInList ) || isEditingItem( myLastItem, myOutList ) ) {
499     ((PortListItem*)myLastItem)->PortName = name;
500     //myLastItem->listBox()->repaint( true );
501     // it would be much better to change the item and repaint it -- but -- repaint() 
502     // is done only after a while, which is not good..  so -- "cheating" around
503     const int i = myLastItem->listBox()->index( myLastItem );
504     moveItem( myLastItem->listBox(), i, i );
505   }
506 }
507
508 /**
509  * called when type item in myTypeCombo is changed.  Tries to change type
510  * of the last selected by user item in myInList or myOutList (myLastItem)
511  */
512 void SUPERVGUI_ManagePortsDlg::typeChanged( const QString& type ) {
513   if ( isEditingItem( myLastItem, myInList ) || isEditingItem( myLastItem, myOutList ) ) {
514     ((PortListItem*)myLastItem)->PortType = type;
515     //myLastItem->listBox()->repaint( true );
516     // it would be much better to change the item and repaint it -- but -- repaint() 
517     // is done only after a while, which is not good..  so -- "cheating" around
518     const int i = myLastItem->listBox()->index( myLastItem );
519     moveItem( myLastItem->listBox(), i, i );
520   }
521 }
522
523 /**
524  * called when new item became "currentItem" in any myInList or myOutList listboxes.
525  */
526 void SUPERVGUI_ManagePortsDlg::itemChanged( QListBoxItem * item ) {
527   if ( !item ) // after remove, etc..
528     return;
529
530   // disable nameChanged, typeChanged callbacks
531   disconnect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
532   disconnect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&)));
533   
534   myLastItem = item;
535   myNameEdt->setText( ((PortListItem*)item)->PortName );
536   for ( int i = 0; i < myTypeCombo->count(); i++ )
537     if ( myTypeCombo->text( i ) == ((PortListItem*)item)->PortType ) {
538       myTypeCombo->setCurrentItem( i );
539       break;
540     }
541
542   // connect back nameChanged, typeChanged
543   connect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&)));
544   connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&)));
545 }
546
547
548
549
550 /*!
551  * Port parameters dialog definition (taken from SUPERVGUI_Node.cxx without change)
552  */
553 SUPERVGUI_PortParamsDlg::SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames)
554   : QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu  ),
555     myPortsNames( thePortsNames )
556 {
557   setSizeGripEnabled( true );
558   setCaption("Port parameters");
559
560   QGridLayout* aBaseLayout = new QGridLayout( this );
561   aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 );
562
563   QLabel* aNameLbl = new QLabel("Port Name", this );
564   aBaseLayout->addWidget(aNameLbl, 0, 0);
565
566   myNameTxt = new QLineEdit( this );
567   aNameLbl->setBuddy( myNameTxt );
568   aBaseLayout->addWidget(myNameTxt, 0, 1);
569   
570   QLabel* aTypeLbl = new QLabel("Value Type", this );
571   aBaseLayout->addWidget(aTypeLbl, 1, 0);
572  
573   myTypeTxt = new QComboBox( this );
574   aTypeLbl->setBuddy( myTypeTxt );
575   myTypeTxt->insertStrList( gTypes );
576   aBaseLayout->addWidget(myTypeTxt, 1, 1);
577  
578   QGroupBox* aBtnBox = new QGroupBox( this );
579   aBtnBox->setColumnLayout( 0, Qt::Vertical );
580   aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 );
581   QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() );
582   aBtnLayout->setAlignment( Qt::AlignTop );
583   aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
584
585   aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 );
586
587   QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
588   connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
589   aBtnLayout->addWidget( aOKBtn );
590
591   aBtnLayout->addStretch();
592
593   QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox );
594   connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
595   aBtnLayout->addWidget( aCancelBtn );
596 }
597
598 void SUPERVGUI_PortParamsDlg::clickOnOk()
599 {
600   if (getName().isEmpty() || getType().isEmpty())
601     QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_CREATE_PORT" ) );
602   else if (myPortsNames.contains(getName()))
603     QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") );
604   else  
605     accept();
606 }