2018-02-27 18:06:05 +01:00
|
|
|
#ifndef QSEARCHFIELD_H
|
|
|
|
#define QSEARCHFIELD_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QPointer>
|
2018-07-01 22:26:46 +02:00
|
|
|
#include <QMenu>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class QSearchFieldPrivate;
|
2018-09-04 22:55:38 +02:00
|
|
|
class QSearchField : public QWidget {
|
|
|
|
Q_OBJECT
|
2018-07-01 22:26:46 +02:00
|
|
|
|
2018-09-04 22:55:38 +02:00
|
|
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true);
|
|
|
|
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText);
|
2018-07-01 22:26:46 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
public:
|
2018-09-04 22:55:38 +02:00
|
|
|
explicit QSearchField(QWidget *parent);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-09-04 22:55:38 +02:00
|
|
|
QString text() const;
|
|
|
|
QString placeholderText() const;
|
|
|
|
void setFocus(Qt::FocusReason);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
public slots:
|
2018-09-04 22:55:38 +02:00
|
|
|
void setText(const QString &text);
|
|
|
|
void setPlaceholderText(const QString &text);
|
|
|
|
void clear();
|
|
|
|
void selectAll();
|
|
|
|
void setFocus();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
signals:
|
2018-09-04 22:55:38 +02:00
|
|
|
void textChanged(const QString &text);
|
|
|
|
void editingFinished();
|
|
|
|
void returnPressed();
|
2018-07-01 22:26:46 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
protected:
|
2018-09-04 22:55:38 +02:00
|
|
|
void resizeEvent(QResizeEvent*);
|
|
|
|
bool eventFilter(QObject*, QEvent*);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private:
|
2018-09-04 22:55:38 +02:00
|
|
|
friend class QSearchFieldPrivate;
|
|
|
|
QPointer <QSearchFieldPrivate> pimpl;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QSEARCHFIELD_H
|