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
51  Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
54 #endif
55  Q_PROPERTY(bool showSearchIcon READ showSearchIcon WRITE setShowSearchIcon)
58 
59 
60  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
77  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 
ctkSearchBox::paintEvent
virtual void paintEvent(QPaintEvent *)
ctkSearchBox::searchIcon
QIcon searchIcon() const
Get the current search icon.
ctkSearchBox::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
ctkSearchBox::d_ptr
QScopedPointer< ctkSearchBoxPrivate > d_ptr
Definition: ctkSearchBox.h:105
ctkSearchBox::setSearchIcon
void setSearchIcon(const QIcon &icon)
Set the search icon.
ctkSearchBox
Definition: ctkSearchBox.h:48
ctkSearchBox::setPlaceholderText
void setPlaceholderText(const QString &defaultText)
ctkSearchBox::showSearchIcon
bool showSearchIcon() const
ctkSearchBox::updateClearButtonState
void updateClearButtonState()
Change the clear icon's state to enabled or disabled.
ctkSearchBox::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event)
ctkSearchBox::Superclass
QLineEdit Superclass
Superclass typedef.
Definition: ctkSearchBox.h:68
ctkSearchBox::placeholderText
QString placeholderText() const
ctkSearchBox::clearIcon
QIcon clearIcon() const
Get the current clear icon.
ctkSearchBox::ctkSearchBox
ctkSearchBox(QWidget *parent=0)
ctkSearchBox::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event)
ctkSearchBox::~ctkSearchBox
virtual ~ctkSearchBox()
ctkSearchBox::alwaysShowClearIcon
bool alwaysShowClearIcon() const
ctkSearchBox::setClearIcon
void setClearIcon(const QIcon &icon)
Set the clear icon.
ctkSearchBox::setAlwaysShowClearIcon
void setAlwaysShowClearIcon(bool show)
False by default.