CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkSearchBox.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkSearchBox_h
22 #define __ctkSearchBox_h
23 
24 // QT includes
25 #include <QIcon>
26 #include <QLineEdit>
27 
28 // CTK includes
29 #include "ctkWidgetsExport.h"
30 
31 class ctkSearchBoxPrivate;
32 
47 class CTK_WIDGETS_EXPORT ctkSearchBox : public QLineEdit
48 {
49  Q_OBJECT
50 #if QT_VERSION < 0x040700
53  Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
54 #endif
57  Q_PROPERTY(bool showSearchIcon READ showSearchIcon WRITE setShowSearchIcon)
58 
59 
61  Q_PROPERTY(QIcon searchIcon READ searchIcon WRITE setSearchIcon)
64  Q_PROPERTY(QIcon clearIcon READ clearIcon WRITE setClearIcon)
65 
66 public:
68  typedef QLineEdit Superclass;
69 
70  ctkSearchBox(QWidget *parent = 0);
71  virtual ~ctkSearchBox();
72 
73 #if QT_VERSION < 0x040700
74  QString placeholderText()const;
75  void setPlaceholderText(const QString& defaultText);
76 #endif
78  void setShowSearchIcon(bool show);
79  bool showSearchIcon()const;
80 
82  void setAlwaysShowClearIcon(bool show);
83  bool alwaysShowClearIcon()const;
84 
86  void setSearchIcon(const QIcon& icon);
88  QIcon searchIcon()const;
89 
91  void setClearIcon(const QIcon& icon);
93  QIcon clearIcon()const;
94 
95 protected Q_SLOTS:
98 
99 protected:
100  virtual void paintEvent(QPaintEvent*);
101  virtual void mousePressEvent(QMouseEvent* event);
102  virtual void mouseMoveEvent(QMouseEvent *event);
103  virtual void resizeEvent(QResizeEvent * event);
104 
105  QScopedPointer<ctkSearchBoxPrivate> d_ptr;
106 
107 private:
108  Q_DECLARE_PRIVATE(ctkSearchBox);
109  Q_DISABLE_COPY(ctkSearchBox);
110 };
111 #endif // __ctkSearchBox_h
112 
QIcon clearIcon() const
Get the current clear icon.
void setShowSearchIcon(bool show)
False by default.
void setClearIcon(const QIcon &icon)
Set the clear icon.
virtual void paintEvent(QPaintEvent *)
QScopedPointer< ctkSearchBoxPrivate > d_ptr
Definition: ctkSearchBox.h:105
virtual void mouseMoveEvent(QMouseEvent *event)
ctkSearchBox(QWidget *parent=0)
QIcon searchIcon() const
Get the current search icon.
virtual ~ctkSearchBox()
void setSearchIcon(const QIcon &icon)
Set the search icon.
void setAlwaysShowClearIcon(bool show)
False by default.
QLineEdit Superclass
Superclass typedef.
Definition: ctkSearchBox.h:68
void updateClearButtonState()
Change the clear icon's state to enabled or disabled.
virtual void mousePressEvent(QMouseEvent *event)
bool showSearchIcon() const
virtual void resizeEvent(QResizeEvent *event)
QString placeholderText() const
void setPlaceholderText(const QString &defaultText)
bool alwaysShowClearIcon() const