Salome HOME
Minor changes in various source files to remove compilation warnings (unused variable...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_ManagePortsDlg.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SUPERVGUI_ManagePortsDlg.h
8 //  Author : Alexander SLADKOV
9 //  Module : SUPERV
10
11 #ifndef SUPERVGUI_ManagePortsDlg_H
12 #define SUPERVGUI_ManagePortsDlg_H
13
14 #include <qdialog.h>
15 #include <qlistbox.h>
16 #include <qstringlist.h>
17 #include <qlineedit.h>
18 #include <qcombobox.h>
19
20 class SUPERVGUI_CanvasNode;
21
22 /** 
23  * Simple redefinition of ListBoxItem for storing ports name and type without having to parce it
24  */
25 class PortListItem : QListBoxText {
26 public:
27   PortListItem ( QListBox* lb, const QString& name, const QString& type )
28   : QListBoxText( lb/*, QString( "%1 (%2)" ).arg( name ).arg( type )*/ ),
29     PortName( name ),
30     PortType( type ) {}
31   QString PortName;
32   QString PortType;
33   virtual QString text() const { return QString( "%1 (%2)" ).arg( PortName ).arg( PortType ); }
34 };
35
36 /**
37  * The dialog class
38  */
39 class SUPERVGUI_ManagePortsDlg: public QDialog {
40   
41   Q_OBJECT
42
43 public:
44   SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode );
45   virtual ~SUPERVGUI_ManagePortsDlg();
46
47 protected slots:
48   void accept();
49   void reject();
50
51   void addInput()     { addPort( myInList ); }    
52   void addOutput()    { addPort( myOutList );}
53   void removeInput()  { removePort( myInList ); }
54   void removeOutput() { removePort( myOutList );}
55   void upInput()      { moveUp( myInList ); }
56   void upOutput()     { moveUp( myOutList );}
57   void downInput()    { moveDown( myInList ); }
58   void downOutput()   { moveDown( myOutList );}
59
60   void nameChanged( const QString& name );
61   void typeChanged( const QString& type );
62   void itemChanged( QListBoxItem * item );
63
64 protected:
65   virtual void showEvent( QShowEvent* theEvent );
66   void addPort( QListBox* );
67   void removePort( QListBox* );
68   void moveUp( QListBox* );
69   void moveDown( QListBox* );
70   void moveItem( QListBox* theLB, const int from, const int to );
71   
72 private:
73   void init();
74   void init( const SUPERVGUI_CanvasNode* theNode );
75
76   SUPERVGUI_CanvasNode*         myNode;
77
78   QLineEdit*                    myNameEdt;
79   QComboBox*                    myTypeCombo;
80   QListBox*                     myInList;
81   QListBox*                     myOutList;
82   QListBoxItem*                 myLastItem;
83 };
84
85 /*!
86  * Port parameters dialog definition (taken from SUPERVGUI_Node.h without change)
87  */
88 class SUPERVGUI_PortParamsDlg: public QDialog {
89   Q_OBJECT
90     
91  public:
92   SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames);
93   ~SUPERVGUI_PortParamsDlg() {};
94
95   QString getName() { return myNameTxt->text(); }
96   QString getType() { return myTypeTxt->currentText(); }
97
98  public slots:
99   void clickOnOk();
100     
101    
102  private:
103   QLineEdit* myNameTxt;
104   QComboBox* myTypeTxt;
105   QStringList myPortsNames;
106 };
107
108
109 #endif