summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorDentomologist <dentomologist@gmail.com>2025-06-08 14:09:16 -0700
committerDentomologist <dentomologist@gmail.com>2025-10-04 14:27:14 -0700
commitd364a244d760d0fb3b981b7acf407fd5b787b495 (patch)
tree92a669e2ff22be04dd6c66352e895256620b82bd /Source/Core
parent9c97498f4b2982221faf17e0cf97af43a6fa0984 (diff)
CheatSearchWidget: Add GetTableRowCount function
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/CheatSearchWidget.cpp18
-rw-r--r--Source/Core/DolphinQt/CheatSearchWidget.h1
2 files changed, 11 insertions, 8 deletions
diff --git a/Source/Core/DolphinQt/CheatSearchWidget.cpp b/Source/Core/DolphinQt/CheatSearchWidget.cpp
index c18e8cb6a6..cd58628735 100644
--- a/Source/Core/DolphinQt/CheatSearchWidget.cpp
+++ b/Source/Core/DolphinQt/CheatSearchWidget.cpp
@@ -352,9 +352,8 @@ void CheatSearchWidget::OnNextScanClicked()
m_address_table_current_values.clear();
const bool show_in_hex = m_display_values_in_hex_checkbox->isChecked();
- const bool too_many_results = new_count > TABLE_MAX_ROWS;
- const size_t result_count_to_display = too_many_results ? TABLE_MAX_ROWS : new_count;
- for (size_t i = 0; i < result_count_to_display; ++i)
+ const size_t row_count = GetTableRowCount();
+ for (size_t i = 0; i < row_count; ++i)
{
m_address_table_current_values[m_session->GetResultAddress(i)] =
m_session->GetResultValueAsString(i, show_in_hex);
@@ -585,6 +584,11 @@ void CheatSearchWidget::GenerateARCodes()
}
}
+size_t CheatSearchWidget::GetTableRowCount() const
+{
+ return std::min(TABLE_MAX_ROWS, m_session->GetResultCount());
+}
+
void CheatSearchWidget::RefreshCurrentValueTableItem(
QTableWidgetItem* const current_value_table_item)
{
@@ -615,12 +619,10 @@ void CheatSearchWidget::RecreateGUITable()
m_address_table->setHorizontalHeaderLabels(
{tr("Description"), tr("Address"), tr("Last Value"), tr("Current Value")});
- const size_t result_count = m_session->GetResultCount();
- const bool too_many_results = result_count > TABLE_MAX_ROWS;
- const int result_count_to_display = int(too_many_results ? TABLE_MAX_ROWS : result_count);
- m_address_table->setRowCount(result_count_to_display);
+ const int row_count = static_cast<int>(GetTableRowCount());
+ m_address_table->setRowCount(row_count);
- for (int i = 0; i < result_count_to_display; ++i)
+ for (int i = 0; i < row_count; ++i)
{
const u32 address = m_session->GetResultAddress(i);
const auto user_data_it = m_address_table_user_data.find(address);
diff --git a/Source/Core/DolphinQt/CheatSearchWidget.h b/Source/Core/DolphinQt/CheatSearchWidget.h
index f7427ca6a6..f83f1add24 100644
--- a/Source/Core/DolphinQt/CheatSearchWidget.h
+++ b/Source/Core/DolphinQt/CheatSearchWidget.h
@@ -73,6 +73,7 @@ private:
void GenerateARCodes();
int GetVisibleRowsBeginIndex() const;
int GetVisibleRowsEndIndex() const;
+ size_t GetTableRowCount() const;
Core::System& m_system;