Skip to content

Commit

Permalink
Undostack: Add documentation for existing methods
Browse files Browse the repository at this point in the history
Added documentation for existing methods in UndoStack class.
  • Loading branch information
tetektoza committed Nov 30, 2023
1 parent 94a7055 commit 98ead68
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions source/undostack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ void UndoStack::push(std::unique_ptr<Command> cmd)
m_undoPos = m_cmds.size() - 1;
}

/**
* @brief Undos command that is currently the first one on the stack
*
* This function undos the command that is currently on the stack, setting
* redo option to be available at the same time. It also pops any commands that
* have the isObsolete flag set.
*/
void UndoStack::undo()
{
// Erase any command that was previously set as obsolete
Expand All @@ -38,6 +45,13 @@ void UndoStack::undo()
m_undoPos--;
}

/**
* @brief Redos command that is currently the first one on the stack
*
* This function redos the command that is currently on the stack, setting
* undo option to be available at the same time. It also pops any commands that
* have the isObsolete flag set.
*/
void UndoStack::redo()
{
// erase any command that was previously set as obsolete
Expand All @@ -52,16 +66,29 @@ void UndoStack::redo()
m_canRedo = false;
}

/**
* @brief Returns if stack can currently redo
*/
bool UndoStack::canRedo() const
{
return m_canRedo;
}

/**
* @brief Returns if stack can currently undo
*/
bool UndoStack::canUndo() const
{
return m_canUndo;
}

/**
* @brief Sets undo stack to a starting position
*
* This function clears undo stack to a starting position. To be
* exact it sets it's position to 0, clears any commands and disables
* flags that inform if stack can currently undo or redo.
*/
void UndoStack::clear()
{
m_undoPos = 0;
Expand Down

0 comments on commit 98ead68

Please sign in to comment.