itom 2.2.1
K:/git-itom/sources/itom/itomWidgets/helper/completer.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom and its software development toolkit (SDK).
00008 
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013    
00014     In addition, as a special exception, the Institut fuer Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 
00027     This file is a port and modified version of the 
00028     Common framework (http://www.commontk.org)
00029 *********************************************************************** */
00030 
00031 #ifndef COMPLETER_H
00032 #define COMPLETER_H
00033 
00034 // Qt includes
00035 #include <QCompleter>
00036 #include <QMetaType>
00037 
00038 #include "commonWidgets.h"
00039 
00040 // CTK includes
00041 class CompleterPrivate;
00042 
00063 class ITOMWIDGETS_EXPORT Completer: public QCompleter
00064 {
00065   Q_OBJECT
00066   Q_ENUMS(ModelFiltering)
00074   Q_PROPERTY(ModelFiltering modelFiltering READ modelFiltering WRITE setModelFiltering)
00075 
00076 public:
00077   Completer(QObject* parent = 0);
00078   Completer(QAbstractItemModel* model, QObject* parent = 0);
00079   Completer(const QStringList& list, QObject* parent = 0 );
00080   virtual ~Completer();
00081 
00082   enum ModelFiltering
00083     {
00084     FilterStartsWith=0,
00085     FilterContains,
00086     FilterWordStartsWith
00087     };
00088 
00089   ModelFiltering modelFiltering()const;
00090   void setModelFiltering(ModelFiltering filter);
00091 
00092   virtual QStringList splitPath(const QString& s)const;
00093 
00098   QAbstractItemModel* sourceModel()const;
00099   void setSourceModel(QAbstractItemModel* model);
00100 
00101 protected:
00102   QScopedPointer<CompleterPrivate> d_ptr;
00103 
00104 private:
00105   Q_DECLARE_PRIVATE(Completer);
00106   Q_DISABLE_COPY(Completer);  
00107 };
00108 
00109 Q_DECLARE_METATYPE(Completer::ModelFiltering)
00110 
00111 #endif // __Completer_h
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends