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

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 AMAROKURLHANDLER_H
0018 #define AMAROKURLHANDLER_H
0019 
0020 #include "amarok_export.h"
0021 #include "AmarokUrlGenerator.h"
0022 #include "AmarokUrlRunnerBase.h"
0023 #include "core/meta/forward_declarations.h"
0024 #include "playlist/PlaylistViewUrlRunner.h"
0025 
0026 #include <QIcon>
0027 
0028 #include <QMap>
0029 
0030 
0031 class TimecodeObserver;
0032 class AmarokUrlHandler;
0033 class NavigationUrlRunner;
0034 class PlayUrlRunner;
0035 
0036 namespace The
0037 {
0038     AMAROK_EXPORT AmarokUrlHandler* amarokUrlHandler();
0039 }
0040 
0041 /**
0042 A singleton class for handling and delegating all amarok:// urls
0043 
0044  @author Nikolaj Hald Nielsen <nhn@kde.org>
0045 */
0046 class AMAROK_EXPORT AmarokUrlHandler : public QObject
0047 {
0048     Q_OBJECT
0049     friend AmarokUrlHandler* The::amarokUrlHandler();
0050 
0051 public:
0052 
0053     void registerRunner( AmarokUrlRunnerBase * runner, const QString & command );
0054     void unRegisterRunner( AmarokUrlRunnerBase * runner );
0055 
0056     void registerGenerator( AmarokUrlGenerator * generator );
0057     void unRegisterGenerator( AmarokUrlGenerator * generator );
0058 
0059     bool run( const AmarokUrl &url );
0060 
0061     BookmarkList urlsByCommand( const QString &command );
0062     QIcon iconForCommand( const QString &command );
0063 
0064     void updateTimecodes( const QString * BookmarkName = nullptr );
0065     void paintNewTimecode( const QString &name, int pos );
0066 
0067     QList<AmarokUrlGenerator *> generators() { return m_registeredGenerators; }
0068 
0069     AmarokUrl createBrowserViewBookmark();
0070     AmarokUrl createPlaylistViewBookmark();
0071     AmarokUrl createContextViewBookmark();
0072 
0073     QString prettyCommand( const QString &command ); 
0074 
0075 
0076 public Q_SLOTS:
0077     void bookmarkAlbum( const Meta::AlbumPtr &album );
0078     void bookmarkArtist( const Meta::ArtistPtr &artist );
0079 
0080     void bookmarkCurrentBrowserView();
0081     void bookmarkCurrentPlaylistView();
0082     void bookmarkCurrentContextView();
0083 
0084 Q_SIGNALS:
0085     void timecodesUpdated( const QString * BookmarkName );
0086     void timecodeAdded( const QString &name, int pos );
0087 
0088 private:
0089 
0090     AmarokUrlHandler();
0091     ~AmarokUrlHandler() override;
0092 
0093     QMap<QString, AmarokUrlRunnerBase *> m_registeredRunners;
0094     QList<AmarokUrlGenerator *> m_registeredGenerators;
0095 
0096     NavigationUrlRunner * m_navigationRunner;
0097     Playlist::ViewUrlRunner * m_playlistViewRunner;
0098     PlayUrlRunner * m_playRunner;
0099     TimecodeObserver * m_timecodeObserver;
0100 
0101 };
0102 
0103 #endif