File indexing completed on 2022-11-22 14:17:19

0001 /*
0002     Copyright (C) 2006-2010 by Peter Penz <peter.penz19@gmail.com>
0003     Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>
0004 
0005     This library is free software; you can redistribute it and/or
0006     modify it under the terms of the GNU Lesser General Public
0007     License as published by the Free Software Foundation; either
0008     version 2.1 of the License, or (at your option) any later version.
0009 
0010     This library is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013     Lesser General Public License for more details.
0014 
0015     You should have received a copy of the GNU Lesser General Public
0016     License along with this library; if not, write to the Free Software
0017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018 */
0019 
0020 #ifndef FILTERBAR_H
0021 #define FILTERBAR_H
0022 
0023 #include <QWidget>
0024 
0025 class KLineEdit;
0026 
0027 /**
0028  * @brief Provides an input field for filtering the currently shown items.
0029  *
0030  * @author Gregor Kališnik <gregor@podnapisi.net>
0031  */
0032 class FilterBar : public QWidget
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037     explicit FilterBar(QWidget* parent = 0);
0038     virtual ~FilterBar();
0039 
0040     /**
0041      * Selects the whole text of the filter bar.
0042      */
0043     void selectAll();
0044 
0045 public slots:
0046     /** Clears the input field. */
0047     void clear();
0048 
0049     /** Hides and clears the input field */
0050     void hide();
0051 
0052 signals:
0053     /**
0054      * Signal that reports the name filter has been
0055      * changed to \a nameFilter.
0056      */
0057     void filterChanged(const QString& nameFilter);
0058 
0059     /**
0060      * Emitted as soon as the filterbar should get closed.
0061      */
0062     void closeRequest();
0063 
0064 protected:
0065     virtual void showEvent(QShowEvent* event);
0066     virtual void keyReleaseEvent(QKeyEvent* event);
0067 
0068 private:
0069     KLineEdit *m_filterInput;
0070 };
0071 
0072 #endif