PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 7ms RepoModel.GetById 33ms app.codeStats 0ms

/src/libtomahawk/ContextMenu.h

http://github.com/tomahawk-player/tomahawk
C Header | 111 lines | 69 code | 23 blank | 19 comment | 0 complexity | f9f869cecfa69eb544be98b24ca326bc MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  5 *   Copyright 2013,      Teo Mrnjavac <teo@kde.org>
  6 *
  7 *   Tomahawk is free software: you can redistribute it and/or modify
  8 *   it under the terms of the GNU General Public License as published by
  9 *   the Free Software Foundation, either version 3 of the License, or
 10 *   (at your option) any later version.
 11 *
 12 *   Tomahawk is distributed in the hope that it will be useful,
 13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15 *   GNU General Public License for more details.
 16 *
 17 *   You should have received a copy of the GNU General Public License
 18 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 19 */
 20
 21#ifndef CONTEXTMENU_H
 22#define CONTEXTMENU_H
 23
 24#include <QSignalMapper>
 25#include <QMenu>
 26
 27#include "Typedefs.h"
 28#include "DllMacro.h"
 29
 30namespace Tomahawk
 31{
 32
 33class DLLEXPORT ContextMenu : public QMenu
 34{
 35Q_OBJECT
 36
 37public:
 38    enum MenuActions
 39    {
 40        ActionPlay =            1,
 41        ActionQueue =           2,
 42        ActionDelete =          4,
 43        ActionCopyLink =        8,
 44        ActionLove =            16,
 45        ActionStopAfter =       32,
 46        ActionPage =            64,
 47        ActionTrackPage =       128,
 48        ActionArtistPage =      256,
 49        ActionAlbumPage =       512,
 50        ActionEditMetadata =    1024,
 51        ActionPlaylist =        2048,
 52        ActionSend =            4096,
 53        ActionMarkListened =    8192,
 54        ActionDownload =        16384,
 55        ActionOpenFileManager = 32768
 56    };
 57
 58    explicit ContextMenu( QWidget* parent = 0 );
 59    virtual ~ContextMenu();
 60
 61    int supportedActions() const { return m_supportedActions; }
 62    void setSupportedActions( int actions ) { m_supportedActions = actions; }
 63
 64    void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& plInterface );
 65
 66    void setQuery( const Tomahawk::query_ptr& query );
 67    void setQueries( const QList<Tomahawk::query_ptr>& queries );
 68
 69    void setArtist( const Tomahawk::artist_ptr& artist );
 70    void setArtists( const QList<Tomahawk::artist_ptr>& artists );
 71
 72    void setAlbum( const Tomahawk::album_ptr& album );
 73    void setAlbums( const QList<Tomahawk::album_ptr>& albums );
 74
 75    void clear();
 76
 77    unsigned int itemCount() const;
 78
 79signals:
 80    void triggered( int action );
 81
 82private slots:
 83    void onTriggered( int action );
 84    void copyLink();
 85    void openPage( MenuActions action );
 86    void addToQueue();
 87    void addToPlaylist( int playlistIdx );
 88    void sendToSource( int sourceIdx );
 89
 90    void onSocialActionsLoaded();
 91
 92private:
 93    QSignalMapper* m_sigmap;
 94    QSignalMapper* m_playlists_sigmap;
 95    QSignalMapper* m_sources_sigmap;
 96    int m_supportedActions;
 97
 98    QAction* m_loveAction;
 99
100    QList< Tomahawk::playlist_ptr > m_playlists;
101    QList< Tomahawk::query_ptr > m_queries;
102    QList< Tomahawk::artist_ptr > m_artists;
103    QList< Tomahawk::album_ptr > m_albums;
104    QList< Tomahawk::source_ptr > m_sources;
105
106    Tomahawk::playlistinterface_ptr m_interface;
107};
108
109}; // ns
110
111#endif