1 /* 2 This file is part of KAddressBook. 3 4 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org> 5 6 SPDX-License-Identifier: LGPL-2.0-or-later 7 */ 8 9 #pragma once 10 11 #include <QWidget> 12 13 class QLineEdit; 14 15 /** 16 * @short The quick search widget from the toolbar 17 * 18 * This widget allows the user to filter for contacts 19 * that match a given string criteria. 20 * The filter string the user enters here is emitted to 21 * the ContactsFilterModel, which does the real filtering. 22 * 23 * @author Tobias Koenig <tokoe@kde.org> 24 */ 25 class QuickSearchWidget : public QWidget 26 { 27 Q_OBJECT 28 29 public: 30 /** 31 * Creates the quick search widget. 32 * 33 * @param parent The parent widget. 34 */ 35 explicit QuickSearchWidget(QWidget *parent = nullptr); 36 37 /** 38 * Destroys the quick search widget. 39 */ 40 ~QuickSearchWidget() override; 41 42 /** 43 * Returns the size hint of the quick search widget. 44 */ 45 QSize sizeHint() const override; 46 47 void updateQuickSearchText(const QString &text); 48 49 public Q_SLOTS: 50 void slotFocusQuickSearch(); 51 52 Q_SIGNALS: 53 /** 54 * This signal is emitted whenever the user has changed 55 * the filter string in the line edit. 56 * 57 * @param filterString The new filter string. 58 */ 59 void filterStringChanged(const QString &filterString); 60 61 /** 62 * This signal is emitted whenever the user pressed the 63 * arrow down key. In this case we set the focus on the 64 * item view that shows the contacts, so the user can 65 * navigate much faster. 66 */ 67 void arrowDownKeyPressed(); 68 69 protected: 70 void keyPressEvent(QKeyEvent *) override; 71 72 private: 73 void resetTimer(); 74 void delayedTextChanged(); 75 QLineEdit *mEdit = nullptr; 76 QTimer *mTimer = nullptr; 77 }; 78 79