File indexing completed on 2021-12-21 13:28:00

0001 /**
0002  * Copyright (C) 2003 Richard Lärkäng <nouseforaname@home.se>
0003  * Copyright (C) 2003-2004 Scott Wheeler <wheeler@kde.org>
0004  *
0005  * This program is free software; you can redistribute it and/or modify it under
0006  * the terms of the GNU General Public License as published by the Free Software
0007  * Foundation; either version 2 of the License, or (at your option) any later
0008  * version.
0009  *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License along with
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef JUK_SEARCHWIDGET_H
0019 #define JUK_SEARCHWIDGET_H
0020 
0021 #include <QWidget>
0022 #include <QList>
0023 #include <QLineEdit>
0024 
0025 #include "playlistsearch.h"
0026 
0027 class QEvent;
0028 class QComboBox;
0029 
0030 class SearchWidget;
0031 
0032 class SearchLine : public QWidget
0033 {
0034     Q_OBJECT
0035 
0036     friend class SearchWidget;
0037 
0038 public:
0039     enum Mode { Default = 0, CaseSensitive = 1, Pattern = 2 };
0040 
0041     explicit SearchLine(QWidget *parent, bool simple = false);
0042 
0043     PlaylistSearch::Component searchComponent() const;
0044     void setSearchComponent(const PlaylistSearch::Component &component);
0045 
0046     void updateColumns();
0047 
0048 public slots:
0049     void clear();
0050 
0051 protected:
0052     virtual bool eventFilter(QObject *watched, QEvent *e) override;
0053 
0054 signals:
0055     void signalQueryChanged();
0056     void signalDownPressed();
0057     void returnPressed();
0058 
0059 private slots:
0060     void slotActivate();
0061 
0062 private:
0063     bool m_simple;
0064     QLineEdit *m_lineEdit;
0065     QComboBox *m_searchFieldsBox;
0066     QComboBox *m_caseSensitive;
0067     QList<int> m_columnList;
0068 };
0069 
0070 class SearchWidget : public SearchLine
0071 {
0072     Q_OBJECT
0073 
0074 public:
0075     explicit SearchWidget(QWidget *parent);
0076 
0077     PlaylistSearch* search(const PlaylistList& playlists) const;
0078     PlaylistSearch* search(Playlist *playlist) const;
0079     void setSearch(const PlaylistSearch* search);
0080 
0081     virtual QString searchText() const;
0082     virtual void setSearchText(const QString &text);
0083 
0084 public slots:
0085     void setEnabled(bool enable);
0086 
0087 signals:
0088     // This signal is only emitted when the Show/Hide action is triggered.
0089     // Minimizing/closing the JuK window will not trigger this signal.
0090 
0091     void signalShown(bool shown);
0092 };
0093 
0094 #endif
0095 
0096 // vim: set et sw=4 tw=0 sta: