File indexing completed on 2024-05-12 13:51:27
0001 /* 0002 * SPDX-FileCopyrightText: 2006-2010 Peter Penz <peter.penz19@gmail.com> 0003 * SPDX-FileCopyrightText: 2006 Gregor Kališnik <gregor@podnapisi.net> 0004 * SPDX-FileCopyrightText: 2012 Stuart Citrin <ctrn3e8@gmail.com> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef FILTERBAR_H 0010 #define FILTERBAR_H 0011 0012 #include <QWidget> 0013 0014 class QLineEdit; 0015 class QToolButton; 0016 0017 /** 0018 * @brief Provides an input field for filtering the currently shown items. 0019 * 0020 * @author Gregor Kališnik <gregor@podnapisi.net> 0021 */ 0022 class FilterBar : public QWidget 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit FilterBar(QWidget *parent = nullptr); 0028 ~FilterBar() override; 0029 0030 /** Called by view container to hide this **/ 0031 void closeFilterBar(); 0032 0033 /** 0034 * Selects the whole text of the filter bar. 0035 */ 0036 void selectAll(); 0037 0038 public Q_SLOTS: 0039 /** Clears the input field. */ 0040 void clear(); 0041 /** Clears the input field if the "lock button" is disabled. */ 0042 void clearIfUnlocked(); 0043 /** The input field is cleared also if the "lock button" is released. */ 0044 void slotToggleLockButton(bool checked); 0045 0046 Q_SIGNALS: 0047 /** 0048 * Signal that reports the name filter has been 0049 * changed to \a nameFilter. 0050 */ 0051 void filterChanged(const QString &nameFilter); 0052 0053 /** 0054 * Emitted as soon as the filterbar should get closed. 0055 */ 0056 void closeRequest(); 0057 0058 /* 0059 * Emitted as soon as the focus should be returned back to the view. 0060 */ 0061 void focusViewRequest(); 0062 0063 protected: 0064 void showEvent(QShowEvent *event) override; 0065 void keyPressEvent(QKeyEvent *event) override; 0066 0067 private: 0068 QLineEdit *m_filterInput; 0069 QToolButton *m_lockButton; 0070 }; 0071 0072 #endif