Salome HOME
7851fc83a555e66b3c0f198cf71f1d730cc8da7a
[modules/gui.git] / src / Qtx / QtxDirListEditor.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef QTX_DIRLISTEDITOR_H
20 #define QTX_DIRLISTEDITOR_H
21
22 #include "Qtx.h"
23
24 #include <qwidget.h>
25 #include <qtoolbutton.h>
26 #include <qlineedit.h>
27 #include <qlistbox.h>
28 #include <qcombobox.h>
29
30 #ifdef WIN32
31 #pragma warning( disable:4251 )
32 #endif
33
34 /*!
35  * \brief The GUI implementation of the directory list
36  */
37 class QTX_EXPORT QtxDirListEditor : public QWidget {
38
39   Q_OBJECT
40
41 public:
42
43   /*!
44    * \brief Constructor
45    * \param parent - the parent of the widget
46    */
47   QtxDirListEditor(QWidget* parent);
48
49   /*!
50    * \brief Destructor
51    */
52   ~QtxDirListEditor();
53
54   /*!
55    * \brief Gets list of paths
56    * \param list - the returned reference to the list of paths
57    */
58   void          getPathList(QStringList& list);
59
60   /*!
61    * \brief Sets list of paths
62    * \param list - the list of paths to set
63    */
64   void          setPathList(const QStringList& list);
65
66   /*!
67    * \brief Event filter, redefined from QObject class
68    */
69   bool          eventFilter(QObject* object, QEvent* event);
70
71 protected:
72
73   /*!
74    * \brief Validates entered path
75    * \retval bool - returns status (true if OK)
76    */
77   bool          validate( const bool quietMode = false );
78
79   /*!
80    * \brief Appends/changes path
81    * \param item - the item in QListBox
82    * \param dir - the path
83    */
84   void          appendDir(QListBoxItem* item, const QString& dir);
85
86   /*!
87    * \brief Removes directory from list
88    * \param item - the item in QListBox
89    */
90   void          removeDir(QListBoxItem* item);
91
92   /*!
93    * \brief Resize event handler, reimplemented from QWidget
94    * \param event - the resize event
95    */
96   void          resizeEvent(QResizeEvent* event);
97
98 protected slots:
99
100   /*!
101    * \brief Called when user clicks inside directories list box
102    */
103   void          onMouseButtonClicked(int, QListBoxItem*, const QPoint&);
104
105   /*!
106    * \brief Called when user double-clicks on any item
107    */
108   void          onDblClicked(QListBoxItem*);
109
110   /*!
111    * \brief <...> (Browse dir) button slot
112    */
113   void          onBtnClicked();
114
115   /*!
116    * \brief Ccalled when user finises editing of path by pressing <Enter>
117    */
118   void          onEditFinished();
119
120   /*!
121    * \brief <Insert> button slot
122    */
123   void          onInsert();
124
125   /*!
126    * \brief  <Delete> button slot
127    */
128   void          onDelete();
129
130   /*!
131    * \brief  <Move up> button slot
132    */
133   void          onUp();
134
135   /*!
136    * \brief  <Move down> button slot
137    */
138   void          onDown();
139
140 private:
141   QListBox*     myDirList;          //!< directory list
142   QLineEdit*    myEdit;             //!< path edit box
143   QToolButton*  myBtn;              //!<  browse pah button
144   bool          myEdited;           //!<  edit mode flag
145   QListBoxItem* myLastSelected;     //!< last selected row
146
147 };
148
149 #endif