Salome HOME
A new dialog class for edition of Ports of an InLine nodes is introduced. This funct...
[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
17 class SUPERVGUI_CanvasNode;
18 class QLineEdit;
19 class QComboBox;
20
21 /** 
22  * Simple redefinition of ListBoxItem for storing ports name and type without having to parce it
23  */
24 class PortListItem : QListBoxText {
25 public:
26   PortListItem ( QListBox* lb, const QString& name, const QString& type )
27   : QListBoxText( lb/*, QString( "%1 (%2)" ).arg( name ).arg( type )*/ ),
28     PortName( name ),
29     PortType( type ) {}
30   QString PortName;
31   QString PortType;
32   virtual QString text() const { return QString( "%1 (%2)" ).arg( PortName ).arg( PortType ); }
33 };
34
35 /**
36  * The dialog class
37  */
38 class SUPERVGUI_ManagePortsDlg: public QDialog {
39   
40   Q_OBJECT
41
42 public:
43   SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode );
44   virtual ~SUPERVGUI_ManagePortsDlg();
45
46 protected slots:
47   void accept();
48   void reject();
49
50   void addInput()     { addPort( myInList ); }    
51   void addOutput()    { addPort( myOutList );}
52   void removeInput()  { removePort( myInList ); }
53   void removeOutput() { removePort( myOutList );}
54   void upInput()      { moveUp( myInList ); }
55   void upOutput()     { moveUp( myOutList );}
56   void downInput()    { moveDown( myInList ); }
57   void downOutput()   { moveDown( myOutList );}
58
59   void nameChanged( const QString& name );
60   void typeChanged( const QString& type );
61   void itemChanged( QListBoxItem * item );
62
63 protected:
64   virtual void showEvent( QShowEvent* theEvent );
65   void addPort( QListBox* );
66   void removePort( QListBox* );
67   void moveUp( QListBox* );
68   void moveDown( QListBox* );
69   
70 private:
71   void init();
72   void init( const SUPERVGUI_CanvasNode* theNode );
73
74   SUPERVGUI_CanvasNode*         myNode;
75
76   QLineEdit*                    myNameEdt;
77   QComboBox*                    myTypeCombo;
78   QListBox*                     myInList;
79   QListBox*                     myOutList;
80   QListBoxItem*                 myLastItem;
81   bool                          myFromItemChanged;
82 };
83
84
85 #endif