File indexing completed on 2024-05-19 04:49:51

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  * Copyright (c) 2009 Téo Mrnjavac <teo@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 AMAROK_PLAYLISTSEARCHPROXY_H
0019 #define AMAROK_PLAYLISTSEARCHPROXY_H
0020 
0021 #include "ProxyBase.h"
0022 
0023 namespace Playlist
0024 {
0025 
0026 /**
0027  * A ProxyModel that implements Playlist searching.
0028  * It should sit anywhere above the FilterProxy and SortProxy.
0029  * @author Téo Mrnjavac <teo@kde.org>
0030  */
0031 class SearchProxy : public ProxyBase
0032 {
0033     Q_OBJECT
0034 public:
0035     /**
0036      * Constructor.
0037      */
0038     explicit SearchProxy( AbstractModel *belowModel, QObject *parent = nullptr );
0039 
0040     /**
0041      * Destructor.
0042      */
0043     ~SearchProxy() override;
0044 
0045     /**
0046      * Implementation of Playlist::AbstractModel: search/filter-related functions.
0047      */
0048     void clearSearchTerm() override;
0049     int currentSearchFields() override { return m_currentSearchFields; }
0050     QString currentSearchTerm() override { return m_currentSearchTerm; }
0051     int find( const QString & searchTerm, int searchFields = MatchTrack ) override;
0052     int findNext( const QString & searchTerm, int selectedRow, int searchFields = MatchTrack   ) override;
0053     int findPrevious( const QString & searchTerm, int selectedRow, int searchFields = MatchTrack  ) override;
0054 
0055 private:
0056     QString m_currentSearchTerm;
0057     int m_currentSearchFields;
0058 };
0059 
0060 }   //namespace Playlist
0061 
0062 #endif  //AMAROK_PLAYLISTSEARCHPROXY_H