Lomse library. API documentation  0.30.0
CmdDeleteStaffObj Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdDeleteStaffObj:
CmdDelete DocCmdSimple DocCommand

Detailed Description

A command for deleting the staff object (e.g. note, rest, clef, barline, etc.) pointed by the cursor.

See constructor for details.

Public Member Functions

 CmdDeleteStaffObj (const std::string &name="")
 
int get_cursor_update_policy () override
 
int get_undo_policy () override
 
int get_selection_update_policy () override
 
- Public Member Functions inherited from DocCmdSimple
virtual ~DocCmdSimple ()
 
bool is_composite () override
 
- Public Member Functions inherited from DocCommand
virtual ~DocCommand ()
 
std::string get_name ()
 
bool is_reversible ()
 
bool is_recordable ()
 
std::string get_error ()
 

Additional Inherited Members

- Public Types inherited from DocCommand
enum  ECmdCursorPolicy
 
enum  ECmdUndoPolicy
 
enum  ECmdSelectionPolicy
 

Constructor & Destructor Documentation

◆ CmdDeleteStaffObj()

CmdDeleteStaffObj::CmdDeleteStaffObj ( const std::string &  name = "")

This command deletes the staff object (e.g. note, rest, clef, barline, etc.) pointed by the cursor.

Parameters
nameThe displayable name for the command. If not specified or empty will default to string "Delete " followed by the name of the object to delete.

Remarks

  • If object pointed by cursor is not valid (e.g. nullptr or is not an staff object), the command will not be executed and will return a failure code.
  • After executing the command:
    • the selection will be empty.
    • the cursor will point to next valid position after the deleted object.
void CommandHandler::delete_staffobj()
{
//delete the StaffObj pointed by the cursor
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
//get object pointed by the cursor
ImoStaffObj* pSO = dynamic_cast<ImoStaffObj*>( m_cursor->get_pointee() );
//if no object, ignore command. e.g., user clicked 'Del' key on no object
if (pSO)
{
string name = gettext("Delete " + pSO->get_name() );
SpInteractor->exec_command( new CmdDeleteStaffObj(name)
}
}
}

Member Function Documentation

◆ get_cursor_update_policy()

int CmdDeleteStaffObj::get_cursor_update_policy ( )
inlineoverridevirtual

Returns a value from ECmdCursorPolicy that indicates the update policy followed by this command.

Implements DocCommand.

◆ get_selection_update_policy()

int CmdDeleteStaffObj::get_selection_update_policy ( )
inlineoverridevirtual

Returns a value from ECmdSelectionPolicy that indicates the undo policy followed by this command.

Implements DocCommand.

◆ get_undo_policy()

int CmdDeleteStaffObj::get_undo_policy ( )
inlineoverridevirtual

Returns a value from ECmdUndoPolicy that indicates the undo policy followed by this command.

Implements DocCommand.