File indexing completed on 2024-05-19 04:50:24

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org>                                *
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) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef OPMLDIRECTORYSERVICE_H
0018 #define OPMLDIRECTORYSERVICE_H
0019 
0020 
0021 #include "amarokurls/AmarokUrlRunnerBase.h"
0022 #include "../ServiceBase.h"
0023 #include "OpmlDirectoryDatabaseHandler.h"
0024 #include "ServiceSqlCollection.h"
0025 
0026 #include "core/support/Amarok.h"
0027 #include <KIO/Job>
0028 
0029 
0030 class OpmlDirectoryServiceFactory: public ServiceFactory
0031 {
0032     Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_service_opmldirectory.json")
0033     Q_INTERFACES(Plugins::PluginFactory)
0034     Q_OBJECT
0035 
0036     public:
0037         OpmlDirectoryServiceFactory();
0038         ~OpmlDirectoryServiceFactory() override;
0039 
0040         void init() override;
0041         QString name() override;
0042         KConfigGroup config() override;
0043 };
0044 
0045 /**
0046 A service for displaying, previewing and downloading music from OpmlDirectory.com
0047 
0048     @author 
0049 */
0050 class OpmlDirectoryService : public ServiceBase, public AmarokUrlRunnerBase
0051 {
0052     Q_OBJECT
0053     public:
0054         OpmlDirectoryService( OpmlDirectoryServiceFactory* parent, const QString &name,
0055                               const QString &prettyName );
0056 
0057         ~OpmlDirectoryService() override;
0058 
0059         void polish() override;
0060 
0061         Collections::Collection * collection() override { return nullptr; }
0062 
0063         /* UrlRunnerBase methods */
0064         QString command() const override;
0065         QString prettyCommand() const override;
0066         bool run( const AmarokUrl &url ) override;
0067         QIcon icon() const override { return QIcon::fromTheme( QStringLiteral("view-services-opml-amarok") ); }
0068 
0069     private Q_SLOTS:
0070         void subscribe();
0071         void slotSelectionChanged( const QItemSelection &, const QItemSelection & );
0072 
0073     private:
0074 
0075         QPushButton *m_addOpmlButton;
0076         QPushButton *m_subscribeButton;
0077 
0078         int m_currentCategoryId;
0079 
0080         int m_numberOfFeeds;
0081         int m_numberOfCategories;
0082 };
0083 
0084 #endif