BranchWatchDialog: Const Correctness

m_index_list_temp should not be imagined as a member of `BranchWatchDialog`, so it is now mutable to allow for more const member functions.
This commit is contained in:
mitaclaw 2024-08-31 12:36:24 -07:00
parent 7ce703a4a8
commit 0c889c715d
2 changed files with 43 additions and 43 deletions

View File

@ -104,7 +104,7 @@ public:
} }
bool IsBranchTypeAllowed(UGeckoInstruction inst) const; bool IsBranchTypeAllowed(UGeckoInstruction inst) const;
void SetInspected(const QModelIndex& index); void SetInspected(const QModelIndex& index) const;
private: private:
const Core::BranchWatch& m_branch_watch; const Core::BranchWatch& m_branch_watch;
@ -190,7 +190,7 @@ bool BranchWatchProxyModel::IsBranchTypeAllowed(UGeckoInstruction inst) const
return false; return false;
} }
void BranchWatchProxyModel::SetInspected(const QModelIndex& index) void BranchWatchProxyModel::SetInspected(const QModelIndex& index) const
{ {
sourceModel()->SetInspected(mapToSource(index)); sourceModel()->SetInspected(mapToSource(index));
} }
@ -535,7 +535,7 @@ void BranchWatchDialog::showEvent(QShowEvent* event)
QDialog::showEvent(event); QDialog::showEvent(event);
} }
void BranchWatchDialog::OnStartPause(bool checked) void BranchWatchDialog::OnStartPause(bool checked) const
{ {
if (checked) if (checked)
{ {
@ -672,22 +672,22 @@ void BranchWatchDialog::OnBranchNotOverwritten()
UpdateStatus(); UpdateStatus();
} }
void BranchWatchDialog::OnWipeRecentHits() void BranchWatchDialog::OnWipeRecentHits() const
{ {
m_table_model->OnWipeRecentHits(); m_table_model->OnWipeRecentHits();
} }
void BranchWatchDialog::OnWipeInspection() void BranchWatchDialog::OnWipeInspection() const
{ {
m_table_model->OnWipeInspection(); m_table_model->OnWipeInspection();
} }
void BranchWatchDialog::OnTimeout() void BranchWatchDialog::OnTimeout() const
{ {
Update(); Update();
} }
void BranchWatchDialog::OnEmulationStateChanged(Core::State new_state) void BranchWatchDialog::OnEmulationStateChanged(Core::State new_state) const
{ {
if (TimerCondition(m_branch_watch, new_state)) if (TimerCondition(m_branch_watch, new_state))
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS); m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
@ -781,7 +781,7 @@ void BranchWatchDialog::OnToggleAutoSave(bool checked)
m_autosave_filepath = filepath.toStdString(); m_autosave_filepath = filepath.toStdString();
} }
void BranchWatchDialog::OnHideShowControls(bool checked) void BranchWatchDialog::OnHideShowControls(bool checked) const
{ {
if (checked) if (checked)
m_control_toolbar->hide(); m_control_toolbar->hide();
@ -789,12 +789,12 @@ void BranchWatchDialog::OnHideShowControls(bool checked)
m_control_toolbar->show(); m_control_toolbar->show();
} }
void BranchWatchDialog::OnToggleIgnoreApploader(bool checked) void BranchWatchDialog::OnToggleIgnoreApploader(bool checked) const
{ {
m_system.SetIsBranchWatchIgnoreApploader(checked); m_system.SetIsBranchWatchIgnoreApploader(checked);
} }
void BranchWatchDialog::OnTableClicked(const QModelIndex& index) void BranchWatchDialog::OnTableClicked(const QModelIndex& index) const
{ {
const QVariant v = m_table_proxy->data(index, UserRole::ClickRole); const QVariant v = m_table_proxy->data(index, UserRole::ClickRole);
switch (index.column()) switch (index.column())
@ -811,7 +811,7 @@ void BranchWatchDialog::OnTableClicked(const QModelIndex& index)
} }
} }
void BranchWatchDialog::OnTableContextMenu(const QPoint& pos) void BranchWatchDialog::OnTableContextMenu(const QPoint& pos) const
{ {
if (m_table_view->horizontalHeader()->hiddenSectionCount() == Column::NumberOfColumns) if (m_table_view->horizontalHeader()->hiddenSectionCount() == Column::NumberOfColumns)
{ {
@ -827,12 +827,12 @@ void BranchWatchDialog::OnTableContextMenu(const QPoint& pos)
m_index_list_temp.shrink_to_fit(); m_index_list_temp.shrink_to_fit();
} }
void BranchWatchDialog::OnTableHeaderContextMenu(const QPoint& pos) void BranchWatchDialog::OnTableHeaderContextMenu(const QPoint& pos) const
{ {
m_mnu_column_visibility->exec(m_table_view->horizontalHeader()->mapToGlobal(pos)); m_mnu_column_visibility->exec(m_table_view->horizontalHeader()->mapToGlobal(pos));
} }
void BranchWatchDialog::OnTableDelete() void BranchWatchDialog::OnTableDelete() const
{ {
std::ranges::transform( std::ranges::transform(
m_index_list_temp, m_index_list_temp.begin(), m_index_list_temp, m_index_list_temp.begin(),
@ -847,7 +847,7 @@ void BranchWatchDialog::OnTableDelete()
UpdateStatus(); UpdateStatus();
} }
void BranchWatchDialog::OnTableDeleteKeypress() void BranchWatchDialog::OnTableDeleteKeypress() const
{ {
m_index_list_temp = m_table_view->selectionModel()->selectedRows(); m_index_list_temp = m_table_view->selectionModel()->selectedRows();
OnTableDelete(); OnTableDelete();
@ -855,17 +855,17 @@ void BranchWatchDialog::OnTableDeleteKeypress()
m_index_list_temp.shrink_to_fit(); m_index_list_temp.shrink_to_fit();
} }
void BranchWatchDialog::OnTableSetBLR() void BranchWatchDialog::OnTableSetBLR() const
{ {
SetStubPatches(0x4e800020); SetStubPatches(0x4e800020);
} }
void BranchWatchDialog::OnTableSetNOP() void BranchWatchDialog::OnTableSetNOP() const
{ {
SetStubPatches(0x60000000); SetStubPatches(0x60000000);
} }
void BranchWatchDialog::OnTableCopyAddress() void BranchWatchDialog::OnTableCopyAddress() const
{ {
auto iter = m_index_list_temp.begin(); auto iter = m_index_list_temp.begin();
if (iter == m_index_list_temp.end()) if (iter == m_index_list_temp.end())
@ -883,17 +883,17 @@ void BranchWatchDialog::OnTableCopyAddress()
QApplication::clipboard()->setText(text); QApplication::clipboard()->setText(text);
} }
void BranchWatchDialog::OnTableSetBreakpointBreak() void BranchWatchDialog::OnTableSetBreakpointBreak() const
{ {
SetBreakpoints(true, false); SetBreakpoints(true, false);
} }
void BranchWatchDialog::OnTableSetBreakpointLog() void BranchWatchDialog::OnTableSetBreakpointLog() const
{ {
SetBreakpoints(false, true); SetBreakpoints(false, true);
} }
void BranchWatchDialog::OnTableSetBreakpointBoth() void BranchWatchDialog::OnTableSetBreakpointBoth() const
{ {
SetBreakpoints(true, true); SetBreakpoints(true, true);
} }
@ -955,14 +955,14 @@ void BranchWatchDialog::SaveQSettings() const
m_table_view->horizontalHeader()->saveState()); m_table_view->horizontalHeader()->saveState());
} }
void BranchWatchDialog::Update() void BranchWatchDialog::Update() const
{ {
if (m_branch_watch.GetRecordingPhase() == Core::BranchWatch::Phase::Blacklist) if (m_branch_watch.GetRecordingPhase() == Core::BranchWatch::Phase::Blacklist)
UpdateStatus(); UpdateStatus();
m_table_model->UpdateHits(); m_table_model->UpdateHits();
} }
void BranchWatchDialog::UpdateStatus() void BranchWatchDialog::UpdateStatus() const
{ {
switch (m_branch_watch.GetRecordingPhase()) switch (m_branch_watch.GetRecordingPhase())
{ {

View File

@ -66,7 +66,7 @@ protected:
void showEvent(QShowEvent* event) override; void showEvent(QShowEvent* event) override;
private: private:
void OnStartPause(bool checked); void OnStartPause(bool checked) const;
void OnClearBranchWatch(); void OnClearBranchWatch();
void OnSave(); void OnSave();
void OnSaveAs(); void OnSaveAs();
@ -76,27 +76,27 @@ private:
void OnCodePathNotTaken(); void OnCodePathNotTaken();
void OnBranchWasOverwritten(); void OnBranchWasOverwritten();
void OnBranchNotOverwritten(); void OnBranchNotOverwritten();
void OnWipeRecentHits(); void OnWipeRecentHits() const;
void OnWipeInspection(); void OnWipeInspection() const;
void OnTimeout(); void OnTimeout() const;
void OnEmulationStateChanged(Core::State new_state); void OnEmulationStateChanged(Core::State new_state) const;
void OnThemeChanged(); void OnThemeChanged();
void OnHelp(); void OnHelp();
void OnToggleAutoSave(bool checked); void OnToggleAutoSave(bool checked);
void OnHideShowControls(bool checked); void OnHideShowControls(bool checked) const;
void OnToggleIgnoreApploader(bool checked); void OnToggleIgnoreApploader(bool checked) const;
void OnTableClicked(const QModelIndex& index); void OnTableClicked(const QModelIndex& index) const;
void OnTableContextMenu(const QPoint& pos); void OnTableContextMenu(const QPoint& pos) const;
void OnTableHeaderContextMenu(const QPoint& pos); void OnTableHeaderContextMenu(const QPoint& pos) const;
void OnTableDelete(); void OnTableDelete() const;
void OnTableDeleteKeypress(); void OnTableDeleteKeypress() const;
void OnTableSetBLR(); void OnTableSetBLR() const;
void OnTableSetNOP(); void OnTableSetNOP() const;
void OnTableCopyAddress(); void OnTableCopyAddress() const;
void OnTableSetBreakpointBreak(); void OnTableSetBreakpointBreak() const;
void OnTableSetBreakpointLog(); void OnTableSetBreakpointLog() const;
void OnTableSetBreakpointBoth(); void OnTableSetBreakpointBoth() const;
void ConnectSlots(); void ConnectSlots();
void DisconnectSlots(); void DisconnectSlots();
@ -107,10 +107,10 @@ private:
public: public:
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually. // TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
void Update(); void Update() const;
private: private:
void UpdateStatus(); void UpdateStatus() const;
void UpdateIcons(); void UpdateIcons();
void Save(const Core::CPUThreadGuard& guard, const std::string& filepath); void Save(const Core::CPUThreadGuard& guard, const std::string& filepath);
void Load(const Core::CPUThreadGuard& guard, const std::string& filepath); void Load(const Core::CPUThreadGuard& guard, const std::string& filepath);
@ -151,6 +151,6 @@ private:
QIcon m_icn_full, m_icn_partial; QIcon m_icn_full, m_icn_partial;
QModelIndexList m_index_list_temp; mutable QModelIndexList m_index_list_temp;
std::optional<std::string> m_autosave_filepath; std::optional<std::string> m_autosave_filepath;
}; };