Salome HOME
Copyright update 2022
[modules/gui.git] / src / Qtx / QtxPathListEdit.h
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
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, or (at your option) any later version.
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/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:      QtxPathListEdit.h
21 // Author:    Sergey TELKOV
22 //
23 #ifndef QTXPATHLISTEDIT_H
24 #define QTXPATHLISTEDIT_H
25
26 #include "Qtx.h"
27
28 #include <QFrame>
29 #include <QPointer>
30
31 class QLineEdit;
32 class QListView;
33 class QCompleter;
34 class QModelIndex;
35 class QToolButton;
36 class QStringListModel;
37
38 #ifdef WIN32
39 #pragma warning( disable:4251 )
40 #endif
41
42 class QTX_EXPORT QtxPathListEdit : public QFrame
43 {
44   Q_OBJECT
45
46   class Editor;
47   class Delegate;
48
49 public:
50   QtxPathListEdit( const Qtx::PathType, QWidget* = 0 );
51   QtxPathListEdit( QWidget* = 0 );
52   virtual ~QtxPathListEdit();
53
54   Qtx::PathType     pathType() const;
55   void              setPathType( const Qtx::PathType );
56
57   QStringList       pathList() const;
58   void              setPathList( const QStringList& );
59
60   bool              isDuplicateEnabled() const;
61   void              setDuplicateEnabled( const bool );
62
63   int               count() const;
64   bool              contains( const QString& ) const;
65
66   void              clear();
67   void              remove( const int );
68   void              remove( const QString& );
69   void              insert( const QString&, const int = -1 );
70
71   bool              eventFilter( QObject*, QEvent* );
72
73 protected slots:
74   void              onUp( bool = false );
75   void              onDown( bool = false );
76   void              onInsert( bool = false );
77   void              onDelete( bool = false );
78
79 private:
80   void              initialize();
81   QWidget*          createEditor( QWidget* );
82   void              setModelData( QWidget*, const QModelIndex& );
83   void              setEditorData( QWidget*, const QModelIndex& );
84
85   bool              checkExistance( const QString&, const bool = true );
86   bool              checkDuplicate( const QString&, const int, const bool = true );
87
88 private:
89   QListView*        myList;
90   Qtx::PathType     myType;
91   QStringListModel* myModel;
92   QCompleter*       myCompleter;
93   bool              myDuplicate;
94
95   friend class QtxPathListEdit::Delegate;
96 };
97
98 #endif