File indexing completed on 2024-05-19 04:49:41
0001 /**************************************************************************************** 0002 * Copyright (c) 2010, 2011 Ralf Engels <ralf-engels@gmx.de> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) version 3 or * 0007 * any later version accepted by the membership of KDE e.V. (or its successor approved * 0008 * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of * 0009 * version 3 of the license. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ****************************************************************************************/ 0018 0019 #ifndef AMAROK_SEARCHQUERYBIAS_H 0020 #define AMAROK_SEARCHQUERYBIAS_H 0021 0022 #include "amarok_export.h" 0023 #include "dynamic/Bias.h" 0024 #include "dynamic/BiasFactory.h" 0025 #include "dynamic/biases/TagMatchBias.h" 0026 0027 namespace Dynamic 0028 { 0029 0030 /** A bias that accepts a query string from the search bar. 0031 */ 0032 class SearchQueryBias : public SimpleMatchBias 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit SearchQueryBias( const QString &filter = QStringLiteral("genre:Rock") ); 0038 0039 void fromXml( QXmlStreamReader *reader ) override; 0040 void toXml( QXmlStreamWriter *writer ) const override; 0041 0042 static QString sName(); 0043 QString name() const override; 0044 QString toString() const override; 0045 0046 QWidget* widget( QWidget* parent = nullptr ) override; 0047 0048 QString filter() const; 0049 0050 public Q_SLOTS: 0051 void setFilter( const QString &filter ); 0052 0053 protected Q_SLOTS: 0054 void newQuery() override; 0055 0056 private: 0057 QString m_filter; 0058 0059 // tracks before the position at the last "matchingTracks" call 0060 mutable QStringList m_existingTracks; 0061 0062 Q_DISABLE_COPY(SearchQueryBias) 0063 }; 0064 0065 0066 class AMAROK_EXPORT SearchQueryBiasFactory : public Dynamic::AbstractBiasFactory 0067 { 0068 public: 0069 QString i18nName() const override; 0070 QString name() const override; 0071 QString i18nDescription() const override; 0072 BiasPtr createBias() override; 0073 }; 0074 0075 } 0076 0077 #endif 0078