1 /**************************************************************************************** 2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef AMAROK_ACTIONSCAPABILITY_H 18 #define AMAROK_ACTIONSCAPABILITY_H 19 20 #include "core/amarokcore_export.h" 21 #include "core/capabilities/Capability.h" 22 23 #include <QAction> 24 #include <QList> 25 26 namespace Capabilities 27 { 28 /** 29 * This capability allows different meta types to display custom actions in the right click menu in the tree view 30 * or anywhere else where the actions are shown. This is useful for purchasing from stores, downloading from services 31 * banning a genre or whatever we can think of in the future. 32 * 33 * If you want to provide this capability for an album, consider using 34 * @see AlbumActionsCapability that provides you with common album actions such as 35 * show cover etc. for free. 36 * 37 * @author Nikolaj Hald Nielsen <nhn@kde.org> 38 */ 39 class AMAROKCORE_EXPORT ActionsCapability : public Capabilities::Capability 40 { 41 Q_OBJECT 42 public: 43 /** 44 * Constructor 45 * Note: The actions are not freed after usage 46 * @param actions A list of actions to use. 47 */ 48 explicit ActionsCapability( const QList< QAction* > &actions ); 49 50 /** 51 * Destructor 52 */ 53 ~ActionsCapability() override; 54 55 /** 56 * Get the custom actions for this capability 57 * The caller must free actions that have no parent after use. 58 * Actions with a parent are freed by the parent (obviously) 59 * @return The list of actions 60 */ 61 virtual QList<QAction *> actions() const; 62 63 /** 64 * Get the capabilityInterfaceType of this capability 65 * @return The capabilityInterfaceType ( always Capabilities::Capability::Actions; ) 66 */ capabilityInterfaceType()67 static Type capabilityInterfaceType() { return Capabilities::Capability::Actions; } 68 69 protected: 70 /** 71 * No-action constructor has sense only for subclasses. 72 */ 73 ActionsCapability(); 74 75 QList< QAction* > m_actions; 76 }; 77 } 78 79 #endif 80