diff --git a/include/ResourceAction.h b/include/ResourceAction.h index 0a627ceef..81ba85a0e 100644 --- a/include/ResourceAction.h +++ b/include/ResourceAction.h @@ -30,36 +30,59 @@ class trackContainer; class ResourceItem; +/*! \brief The ResourceAction class provides centralized functionality for all actions + * related to a ResourceItem. + * + * These actions are for example loading projects, samples, presets, + * plugin-specific presets etc. Using this class we can avoid duplicated + * functionality in ResourcePreviewer, ResourceBrowser, TrackContainerView, + * InstrumentTrack & Co. + */ + class ResourceAction { public: + /*! Lists all supported actions. */ enum Actions { - EditProperties, - LoadProject, - LoadInNewTrackSongEditor, - LoadInNewTrackBBEditor, - LoadInActiveInstrumentTrack, - DownloadIntoCollection, - UploadToWWW, - DeleteLocalResource, - ImportFile, + EditProperties, /*!< Open a dialog to edit properties of the ResourceItem */ + LoadProject, /*!< Load the project represented by the ResourceItem */ + LoadInNewTrackSongEditor, /*!< Load preset, sample etc. in a new track in Song Editor */ + LoadInNewTrackBBEditor, /*!< Load preset, sample etc. in a new track in BB Editor */ + LoadInActiveInstrumentTrack,/*!< Load preset, sample etc. in active instrument track */ + DownloadIntoCollection, /*!< Download the resource into local collection */ + UploadToWWW, /*!< Upload the resource to Web */ + DeleteLocalResource, /*!< Delete local resource (=file) */ + ImportFile, /*!< Try to import the resource via import filter plugins */ NumActions } ; typedef Actions Action; - ResourceAction( const ResourceItem * _item, - Action _action = NumActions ) : - m_action( _action ), - m_item( _item ) + /*! \brief Constructs a ResourceAction object. + * \param item The ResourceItem the action is about + * \param action An optional action from the Action enumeration used for the defaultTrigger() method + */ + ResourceAction( const ResourceItem * item, + Action action = NumActions ) : + m_action( action ), + m_item( item ) { } bool loadProject(); - bool loadByPlugin( InstrumentTrack * _target ); - bool loadPreset( InstrumentTrack * _target ); - bool importProject( trackContainer * _target ); - // most actions can be triggered without any further information + bool loadByPlugin( InstrumentTrack * target ); + bool loadPreset( InstrumentTrack * target ); + bool importProject( trackContainer * target ); + + /*! \brief Triggers the action passed to the constructor without any further options. + * + * Most actions can be triggered without any further information. + * This allows simple but powerful code constructs: + * \code + * ResourceAction( myItem, ResourceAction::LoadProject ).defaultTrigger(); + * \endcode + * \return true if the operation succeeded, otherwise false. + */ bool defaultTrigger();