]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxListBox.h
Salome HOME
74b4887289cbe8633701caa37c386d26f374afcd
[modules/gui.git] / src / Qtx / QtxListBox.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 // File:      QtxListBox.h
23 // Author:    Sergey TELKOV
24 //
25 #ifndef QTXLISTBOX_H
26 #define QTXLISTBOX_H
27
28 #include "Qtx.h"
29
30 // This file isn't yet ported to Qt4 => there are some corrections for OCCViewer porting  -->
31 //#include <qlistbox.h>
32 #include <QListWidget>
33 #include <QListWidgetItem>
34 // <--
35
36 #ifdef WIN32
37 #pragma warning( disable:4251 )
38 #endif
39
40 class QLineEdit;
41 class QValidator;
42
43 class QTX_EXPORT QtxListBox : public QListWidget//QListBox // This file isn't yet ported to Qt4 => there are some corrections for OCCViewer porting
44 {
45     Q_OBJECT
46
47 public:
48     QtxListBox( QWidget* = 0, const char* = 0, Qt::WindowFlags = 0 );
49     virtual ~QtxListBox();
50
51     bool              isEditEnabled() const;
52     bool              defaultEditAction() const;
53     bool              isModificationEnabled() const;
54
55     QListWidgetItem*  editedItem() const;
56     int               editedIndex() const;
57
58     void              startEdition( const int );
59     void              startEdition( const QListWidgetItem* );
60     void              endEdition( const bool );
61
62     void              ensureItemVisible( const int );
63     void              ensureItemVisible( const QListWidgetItem* );
64
65     virtual bool      eventFilter( QObject*, QEvent* );
66
67     const QValidator* validator() const;
68
69     void              moveItemToTop( const int );
70     void              moveItemToBottom( const int );
71     void              moveItem( const int, const int );
72
73     void              createItem( const int = -1 );
74     void              deleteItem( const int = -1 );
75
76 signals:
77     void              itemEdited( int );
78     void              itemEdited( QListWidgetItem* );
79     void              itemMoved( int, int );
80
81 public slots:
82     virtual void      setEditEnabled( bool );
83     virtual void      setDefaultEditAction( bool );
84     virtual void      setModificationEnabled( bool );
85
86     virtual void      clearValidator();
87     virtual void      setValidator( const QValidator* );
88     virtual void      setContentsPos( int, int );
89
90 private slots:
91     void              onContentsMoving( int, int );
92
93 protected:
94     virtual void      keyPressEvent( QKeyEvent* );
95     virtual void      viewportResizeEvent( QResizeEvent* );
96     virtual void      mouseDoubleClickEvent( QMouseEvent* );
97
98 private:
99     QLineEdit*        editor() const;
100     void              createEditor();
101     void              updateEditor();
102
103 private:
104     QLineEdit*        myEditor;
105     int               myEditIndex;
106     bool              myEditState;
107     bool              myEditDefault;
108     bool              myModifEnabled;
109 };
110
111 #ifdef WIN32
112 #pragma warning( default:4251 )
113 #endif
114
115 #endif