Back to index

salome-gui  6.5.0
QtxPathListEdit.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File:      QtxPathListEdit.h
00021 // Author:    Sergey TELKOV
00022 //
00023 #ifndef QTXPATHLISTEDIT_H
00024 #define QTXPATHLISTEDIT_H
00025 
00026 #include "Qtx.h"
00027 
00028 #include <QFrame>
00029 #include <QPointer>
00030 
00031 class QLineEdit;
00032 class QListView;
00033 class QCompleter;
00034 class QModelIndex;
00035 class QToolButton;
00036 class QStringListModel;
00037 
00038 #ifdef WIN32
00039 #pragma warning( disable:4251 )
00040 #endif
00041 
00042 class QTX_EXPORT QtxPathListEdit : public QFrame
00043 {
00044   Q_OBJECT
00045 
00046   class Editor;
00047   class Delegate;
00048 
00049 public:
00050   QtxPathListEdit( const Qtx::PathType, QWidget* = 0 );
00051   QtxPathListEdit( QWidget* = 0 );
00052   virtual ~QtxPathListEdit();
00053 
00054   Qtx::PathType     pathType() const;
00055   void              setPathType( const Qtx::PathType );
00056 
00057   QStringList       pathList() const;
00058   void              setPathList( const QStringList& );
00059 
00060   bool              isDuplicateEnabled() const;
00061   void              setDuplicateEnabled( const bool );
00062 
00063   int               count() const;
00064   bool              contains( const QString& ) const;
00065 
00066   void              clear();
00067   void              remove( const int );
00068   void              remove( const QString& );
00069   void              insert( const QString&, const int = -1 );
00070 
00071   bool              eventFilter( QObject*, QEvent* );
00072 
00073 protected slots:
00074   void              onUp( bool = false );
00075   void              onDown( bool = false );
00076   void              onInsert( bool = false );
00077   void              onDelete( bool = false );
00078 
00079 private:
00080   void              initialize();
00081   QWidget*          createEditor( QWidget* );
00082   void              setModelData( QWidget*, const QModelIndex& );
00083   void              setEditorData( QWidget*, const QModelIndex& );
00084 
00085   bool              checkExistance( const QString&, const bool = true );
00086   bool              checkDuplicate( const QString&, const int, const bool = true );
00087 
00088 private:
00089   QListView*        myList;
00090   Qtx::PathType     myType;
00091   QStringListModel* myModel;
00092   QCompleter*       myCompleter;
00093   bool              myDuplicate;
00094 
00095   friend class QtxPathListEdit::Delegate;
00096 };
00097 
00098 #endif