]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h
Salome HOME
6403ec3aa3d35419dafd3d51389f36421ee46301
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_ManagePortsDlg.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SUPERV SUPERVGUI : GUI for Supervisor component
23 //  File   : SUPERVGUI_ManagePortsDlg.h
24 //  Author : Alexander SLADKOV
25 //  Module : SUPERV
26 //
27 #ifndef SUPERVGUI_ManagePortsDlg_H
28 #define SUPERVGUI_ManagePortsDlg_H
29
30 #include "SUPERVGUI.h"
31
32 #include <qdialog.h>
33 #include <qlistbox.h>
34 #include <qstringlist.h>
35 #include <qlineedit.h>
36 #include <qcombobox.h>
37 #include <qpair.h>
38
39 class SUPERVGUI_CanvasNode;
40
41 /** 
42  * Simple redefinition of ListBoxItem for storing ports name and type without having to parce it
43  */
44 class PortListItem : QListBoxText {
45 public:
46   PortListItem ( QListBox* lb, const QString& name, const QString& type )
47   : QListBoxText( lb/*, QString( "%1 (%2)" ).arg( name ).arg( type )*/ ),
48     PortName( name ),
49     PortType( type ) {}
50   QString PortName;
51   QString PortType;
52   virtual QString text() const { return QString( "%1 (%2)" ).arg( PortName ).arg( PortType ); }
53 };
54
55 /**
56  * The dialog class
57  */
58 class SUPERVGUI_ManagePortsDlg: public QDialog {
59   
60   Q_OBJECT
61
62 public:
63   SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode );
64   virtual ~SUPERVGUI_ManagePortsDlg();
65
66 protected slots:
67   void accept();
68   void reject();
69
70   void addInput()     { addPort( myInList ); }    
71   void addOutput()    { addPort( myOutList );}
72   void removeInput()  { removePort( myInList ); }
73   void removeOutput() { removePort( myOutList );}
74   void upInput()      { moveUp( myInList ); }
75   void upOutput()     { moveUp( myOutList );}
76   void downInput()    { moveDown( myInList ); }
77   void downOutput()   { moveDown( myOutList );}
78
79   void nameChanged( const QString& name );
80   void typeChanged( const QString& type );
81   void itemChanged( QListBoxItem * item );
82   void itemDeselect(QListBoxItem* item, const QPoint& point); // mkr: PAL12448
83
84 protected:
85   void addPort( QListBox* );
86   void removePort( QListBox* );
87   void moveUp( QListBox* );
88   void moveDown( QListBox* );
89   void moveItem( QListBox* theLB, const int from, const int to );
90   // mkr : PAL8060
91   void createLinkEngine( SUPERV::Port_ptr thePort, 
92                          QValueList< QPair< QString,QString > >& theOwnList, 
93                          QValueList< QPair< QString,QString > >& theCorrespList );
94   
95 private:
96   void init();
97   void init( const SUPERVGUI_CanvasNode* theNode );
98
99   SUPERVGUI_CanvasNode*         myNode;
100
101   QLineEdit*                    myNameEdt;
102   QComboBox*                    myTypeCombo;
103   QListBox*                     myInList;
104   QListBox*                     myOutList;
105   QListBoxItem*                 myLastItem;
106 };
107
108 /*!
109  * Port parameters dialog definition (taken from SUPERVGUI_Node.h without change)
110  */
111 class SUPERVGUI_PortParamsDlg: public QDialog {
112   Q_OBJECT
113     
114  public:
115   SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames);
116   ~SUPERVGUI_PortParamsDlg() {};
117
118   QString getName() { return myNameTxt->text(); }
119   QString getType() { return myTypeTxt->currentText(); }
120
121  public slots:
122   void clickOnOk();
123     
124    
125  private:
126   QLineEdit* myNameTxt;
127   QComboBox* myTypeTxt;
128   QStringList myPortsNames;
129 };
130
131
132 #endif