itom 2.2.1
K:/git-itom/sources/itom/itomWidgets/searchBox.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 SEARCHBOX_H
00032 #define SEARCHBOX_H
00033 
00034 // QT includes
00035 #include <QIcon>
00036 #include <QLineEdit>
00037 
00038 // CTK includes
00039 #include "commonWidgets.h"
00040 
00041 class SearchBoxPrivate;
00042 
00057 class ITOMWIDGETS_EXPORT SearchBox : public QLineEdit
00058 {
00059   Q_OBJECT
00060 #if QT_VERSION < 0x040700
00061 
00062 
00063   Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
00064 #endif
00065 
00066 
00067   Q_PROPERTY(bool showSearchIcon READ showSearchIcon WRITE setShowSearchIcon)
00068 
00069   
00070 
00071   Q_PROPERTY(QIcon searchIcon READ searchIcon WRITE setSearchIcon)
00074   Q_PROPERTY(QIcon clearIcon READ clearIcon WRITE setClearIcon)
00075 
00076 public:
00078   typedef QLineEdit Superclass;
00079 
00080   SearchBox(QWidget *parent = 0);
00081   virtual ~SearchBox();
00082 
00083 #if QT_VERSION < 0x040700
00084   QString placeholderText()const;
00085   void setPlaceholderText(const QString& defaultText);
00086 #endif
00087 
00088   void setShowSearchIcon(bool show);
00089   bool showSearchIcon()const;
00090 
00092   void setAlwaysShowClearIcon(bool show);
00093   bool alwaysShowClearIcon()const;
00094 
00096   void setSearchIcon(const QIcon& icon);
00098   QIcon searchIcon()const;
00099 
00101   void setClearIcon(const QIcon& icon);
00103   QIcon clearIcon()const;
00104 
00105 protected Q_SLOTS:
00107   void updateClearButtonState();
00108 
00109 protected:
00110   virtual void paintEvent(QPaintEvent*);
00111   virtual void mousePressEvent(QMouseEvent* event);
00112   virtual void mouseMoveEvent(QMouseEvent *event);
00113   virtual void resizeEvent(QResizeEvent * event);
00114 
00115   QScopedPointer<SearchBoxPrivate> d_ptr;
00116 
00117 private:
00118   Q_DECLARE_PRIVATE(SearchBox);
00119   Q_DISABLE_COPY(SearchBox);
00120 };
00121 #endif // __SearchBox_h
00122 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends