File indexing completed on 2024-05-05 04:47:26

0001 /****************************************************************************************
0002  * Copyright (c) 2007 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 AMAROKSERVICEBROWSER_H
0018 #define AMAROKSERVICEBROWSER_H
0019 
0020 
0021 
0022 #include "browsers/BrowserCategoryList.h"
0023 #include "services/scriptable/ScriptableServiceManager.h"
0024 #include "services/ServiceBase.h"
0025 
0026 #include <QVBoxLayout>
0027 
0028 #include <QTimer>
0029 #include <QTreeView>
0030 #include <QMap>
0031 
0032 
0033 /**
0034  *  A browser for selecting and displaying a service in the style of the first
0035  *  embedded Magnatune store from a list of available services. Allows
0036  *  many services to be shown as a single category.
0037  *  Implemented as a singleton.
0038  *
0039  *  @author Nikolaj Hald Nielsen <nhn@kde.org>
0040  */
0041 class ServiceBrowser : public BrowserCategoryList
0042 {
0043     Q_OBJECT
0044 
0045     public:
0046         /**
0047          * Get the ServiceBrowser instance. Create it if it does not exist yet. ( Singleton pattern ).
0048          * @return The ServiceBrowser instance.
0049          */
0050         static ServiceBrowser *instance();
0051 
0052         /**
0053          * Destructor.
0054          */
0055         ~ServiceBrowser() override;
0056 
0057         /**
0058          * Reset a service and make it reload configuration. Not fully implemented..
0059          * @param name The name of the service to reset.
0060          */
0061         void resetService( const QString &name );
0062 
0063     public Q_SLOTS:
0064 
0065         /**
0066          * Set a scriptable service manager to handle scripted services.
0067          * @param scriptableServiceManager The scriptable service manager to set.
0068          */
0069         void setScriptableServiceManager( ScriptableServiceManager *scriptableServiceManager );
0070 
0071         void addService ( ServiceBase * );
0072 
0073     private:
0074         /**
0075          * Private constructor ( Singleton pattern )
0076          * @param parent The parent widget.
0077          * @param name The name of this widget.
0078          */
0079         ServiceBrowser( const QString& name, QWidget *parent = nullptr );
0080 
0081         static ServiceBrowser    *s_instance;
0082 
0083         ScriptableServiceManager *m_scriptableServiceManager;
0084 
0085         QTimer m_filterTimer;
0086 
0087         QString m_currentFilter;
0088 
0089 };
0090 
0091 
0092 #endif