Convert CommandManagerCallback uint32 -> size_t

Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
Chris Burel
2021-05-24 12:03:52 -07:00
parent a86e2ddf24
commit f4442425ed
5 changed files with 27 additions and 37 deletions
@@ -146,9 +146,9 @@ namespace EMStudio
void OnPostExecuteCommand(MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine, bool wasSuccess, const AZStd::string& outResult) override;
void OnPreExecuteCommandGroup(MCore::CommandGroup* group, bool undo) override { MCORE_UNUSED(group); MCORE_UNUSED(undo); }
void OnPostExecuteCommandGroup(MCore::CommandGroup* group, bool wasSuccess) override { MCORE_UNUSED(group); MCORE_UNUSED(wasSuccess); }
void OnAddCommandToHistory(uint32 historyIndex, MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine) override { MCORE_UNUSED(historyIndex); MCORE_UNUSED(group); MCORE_UNUSED(command); MCORE_UNUSED(commandLine); }
void OnRemoveCommand(uint32 historyIndex) override { MCORE_UNUSED(historyIndex); }
void OnSetCurrentCommand(uint32 index) override { MCORE_UNUSED(index); }
void OnAddCommandToHistory(size_t historyIndex, MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine) override { MCORE_UNUSED(historyIndex); MCORE_UNUSED(group); MCORE_UNUSED(command); MCORE_UNUSED(commandLine); }
void OnRemoveCommand(size_t historyIndex) override { MCORE_UNUSED(historyIndex); }
void OnSetCurrentCommand(size_t index) override { MCORE_UNUSED(index); }
};
EventProcessingCallback* mEventProcessingCallback;
};
@@ -296,9 +296,9 @@ namespace EMStudio
void OnPreUndoCommand(MCore::Command* command, const MCore::CommandLine& commandLine);
void OnPreExecuteCommandGroup(MCore::CommandGroup* /*group*/, bool /*undo*/) override { }
void OnPostExecuteCommandGroup(MCore::CommandGroup* /*group*/, bool /*wasSuccess*/) override { }
void OnAddCommandToHistory(uint32 /*historyIndex*/, MCore::CommandGroup* /*group*/, MCore::Command* /*command*/, const MCore::CommandLine& /*commandLine*/) override { }
void OnRemoveCommand(uint32 /*historyIndex*/) override { }
void OnSetCurrentCommand(uint32 /*index*/) override { }
void OnAddCommandToHistory(size_t /*historyIndex*/, MCore::CommandGroup* /*group*/, MCore::Command* /*command*/, const MCore::CommandLine& /*commandLine*/) override { }
void OnRemoveCommand(size_t /*historyIndex*/) override { }
void OnSetCurrentCommand(size_t /*index*/) override { }
void OnShowErrorReport(const AZStd::vector<AZStd::string>& errors) override;
private:
AZStd::vector<AZStd::string> m_skipClearRecorderCommands;
@@ -125,7 +125,7 @@ namespace EMStudio
}
// Add a new item to the history.
void ActionHistoryCallback::OnAddCommandToHistory(uint32 historyIndex, MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine)
void ActionHistoryCallback::OnAddCommandToHistory(size_t historyIndex, MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine)
{
MCORE_UNUSED(commandLine);
mTempString = MCore::CommandManager::CommandHistoryEntry::ToString(group, command, mIndex++).c_str();
@@ -135,28 +135,28 @@ namespace EMStudio
}
// Remove an item from the history.
void ActionHistoryCallback::OnRemoveCommand(uint32 historyIndex)
void ActionHistoryCallback::OnRemoveCommand(size_t historyIndex)
{
// Remove the item.
mIsRemoving = true;
delete mList->takeItem(historyIndex);
delete mList->takeItem(aznumeric_caster(historyIndex));
mIsRemoving = false;
}
// Set the current command.
void ActionHistoryCallback::OnSetCurrentCommand(uint32 index)
void ActionHistoryCallback::OnSetCurrentCommand(size_t index)
{
if (mIsRemoving)
{
return;
}
if (index == MCORE_INVALIDINDEX32)
if (index == InvalidIndex)
{
mList->setCurrentRow(-1);
// Darken all history items.
const int numCommands = static_cast<int>(GetCommandManager()->GetNumHistoryItems());
const int numCommands = mList->count();
for (int i = 0; i < numCommands; ++i)
{
mList->item(i)->setForeground(m_darkenedBrush);
@@ -165,19 +165,19 @@ namespace EMStudio
}
// get the list of selected items
mList->setCurrentRow(index);
mList->setCurrentRow(aznumeric_caster(index));
// Get the current history index.
const uint32 historyIndex = GetCommandManager()->GetHistoryIndex();
if (historyIndex == MCORE_INVALIDINDEX32)
if (historyIndex == InvalidIndex)
{
AZStd::string outResult;
const uint32 numRedos = index + 1;
for (uint32 i = 0; i < numRedos; ++i)
const size_t numRedos = index + 1;
for (size_t i = 0; i < numRedos; ++i)
{
outResult.clear();
const bool result = GetCommandManager()->Redo(outResult);
if (outResult.size() > 0)
if (!outResult.empty())
{
if (!result)
{
@@ -195,7 +195,7 @@ namespace EMStudio
// try to undo
outResult.clear();
const bool result = GetCommandManager()->Undo(outResult);
if (outResult.size() > 0)
if (!outResult.empty())
{
if (!result)
{
@@ -212,7 +212,7 @@ namespace EMStudio
{
outResult.clear();
const bool result = GetCommandManager()->Redo(outResult);
if (outResult.size() > 0)
if (!outResult.empty())
{
if (!result)
{
@@ -222,13 +222,6 @@ namespace EMStudio
}
}
// Darken disabled commands.
const uint32 orgIndex = index;
if (index == MCORE_INVALIDINDEX32)
{
index = 0;
}
const int numCommands = static_cast<int>(GetCommandManager()->GetNumHistoryItems());
for (int i = index; i < numCommands; ++i)
{
@@ -236,12 +229,9 @@ namespace EMStudio
}
// Color enabled ones.
if (orgIndex != MCORE_INVALIDINDEX32)
for (int i = 0; i <= static_cast<int>(index); ++i)
{
for (int i = 0; i <= static_cast<int>(index); ++i)
{
mList->item(index)->setForeground(m_brush);
}
mList->item(i)->setForeground(m_brush);
}
}
} // namespace EMStudio
@@ -37,11 +37,11 @@ namespace EMStudio
void OnPreExecuteCommand(MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine) override;
void OnPostExecuteCommand(MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine, bool wasSuccess, const AZStd::string& outResult) override;
void OnAddCommandToHistory(uint32 historyIndex, MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine) override;
void OnAddCommandToHistory(size_t historyIndex, MCore::CommandGroup* group, MCore::Command* command, const MCore::CommandLine& commandLine) override;
void OnPreExecuteCommandGroup(MCore::CommandGroup* group, bool undo) override;
void OnPostExecuteCommandGroup(MCore::CommandGroup* group, bool wasSuccess) override;
void OnRemoveCommand(uint32 historyIndex) override;
void OnSetCurrentCommand(uint32 index) override;
void OnRemoveCommand(size_t historyIndex) override;
void OnSetCurrentCommand(size_t index) override;
private:
QListWidget* mList;
@@ -83,19 +83,19 @@ namespace MCore
* @param command The command that is linked with this history item.
* @param commandLine The command line that is linked to this history item.
*/
virtual void OnAddCommandToHistory(uint32 historyIndex, CommandGroup* group, Command* command, const CommandLine& commandLine) = 0;
virtual void OnAddCommandToHistory(size_t historyIndex, CommandGroup* group, Command* command, const CommandLine& commandLine) = 0;
/**
* This callback is executed when a command is being removed from the command history.
* @param historyIndex The history index of the command that is being removed.
*/
virtual void OnRemoveCommand(uint32 historyIndex) = 0;
virtual void OnRemoveCommand(size_t historyIndex) = 0;
/**
* This callback is executed when we step back or forth in the command history.
* @param index The new history index which will be the current state the system will be in.
*/
virtual void OnSetCurrentCommand(uint32 index) = 0;
virtual void OnSetCurrentCommand(size_t index) = 0;
/**
* This callback is executed before the error array is getting cleared and the interfaces shall show some error reporting window or something similar.