Merge pull request #11185 from TryTwo/PR_MemoryWidget_Address_Input_History
MemoryWidget: Make search address a combobox that holds address history.
This commit is contained in:
commit
950e1f94dc
|
@ -97,10 +97,13 @@ void MemoryWidget::CreateWidgets()
|
|||
// Search
|
||||
auto* m_address_splitter = new QSplitter(Qt::Horizontal);
|
||||
|
||||
m_search_address = new QLineEdit;
|
||||
m_search_address = new QComboBox;
|
||||
m_search_address->setInsertPolicy(QComboBox::InsertAtTop);
|
||||
m_search_address->setDuplicatesEnabled(false);
|
||||
m_search_address->setEditable(true);
|
||||
m_search_address->setMaxVisibleItems(8);
|
||||
m_search_offset = new QLineEdit;
|
||||
|
||||
m_search_address->setMaxLength(8);
|
||||
m_search_offset->setMaxLength(9);
|
||||
m_search_address->setPlaceholderText(tr("Search Address"));
|
||||
m_search_offset->setPlaceholderText(tr("Offset"));
|
||||
|
@ -297,7 +300,7 @@ void MemoryWidget::CreateWidgets()
|
|||
|
||||
void MemoryWidget::ConnectWidgets()
|
||||
{
|
||||
connect(m_search_address, &QLineEdit::textChanged, this, &MemoryWidget::OnSearchAddress);
|
||||
connect(m_search_address, &QComboBox::currentTextChanged, this, &MemoryWidget::OnSearchAddress);
|
||||
connect(m_search_offset, &QLineEdit::textChanged, this, &MemoryWidget::OnSearchAddress);
|
||||
connect(m_data_edit, &QLineEdit::textChanged, this, &MemoryWidget::ValidateAndPreviewInputValue);
|
||||
|
||||
|
@ -479,6 +482,28 @@ void MemoryWidget::OnBPTypeChanged()
|
|||
|
||||
void MemoryWidget::SetAddress(u32 address)
|
||||
{
|
||||
// Store current and target address in combo box
|
||||
const QSignalBlocker blocker(m_search_address);
|
||||
const QString current_text = m_search_address->currentText();
|
||||
const QString target_addr = QString::number(address, 16);
|
||||
bool good;
|
||||
const u32 current_addr = current_text.toUInt(&good, 16);
|
||||
|
||||
if (good)
|
||||
{
|
||||
AddressSpace::Accessors* accessors =
|
||||
AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
|
||||
good = accessors->IsValidAddress(current_addr);
|
||||
}
|
||||
|
||||
if (m_search_address->findText(current_text) == -1 && good)
|
||||
m_search_address->insertItem(0, current_text);
|
||||
|
||||
if (m_search_address->findText(target_addr) == -1)
|
||||
m_search_address->insertItem(0, target_addr);
|
||||
|
||||
m_search_address->setCurrentText(target_addr);
|
||||
|
||||
m_memory_view->SetAddress(address);
|
||||
Settings::Instance().SetMemoryVisible(true);
|
||||
raise();
|
||||
|
@ -745,8 +770,8 @@ MemoryWidget::TargetAddress MemoryWidget::GetTargetAddress() const
|
|||
TargetAddress target;
|
||||
|
||||
// Returns 0 if conversion fails
|
||||
const u32 addr = m_search_address->text().toUInt(&target.is_good_address, 16);
|
||||
target.is_good_address |= m_search_address->text().isEmpty();
|
||||
const u32 addr = m_search_address->currentText().toUInt(&target.is_good_address, 16);
|
||||
target.is_good_address |= m_search_address->currentText().isEmpty();
|
||||
const s32 offset = m_search_offset->text().toInt(&target.is_good_offset, 16);
|
||||
const u32 neg_offset = offset != std::numeric_limits<s32>::min() ?
|
||||
-offset :
|
||||
|
@ -789,7 +814,7 @@ void MemoryWidget::FindValue(bool next)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!m_search_address->text().isEmpty())
|
||||
if (!m_search_address->currentText().isEmpty())
|
||||
{
|
||||
// skip the quoted address so we don't potentially refind the last result
|
||||
target_addr.address += next ? 1 : -1;
|
||||
|
@ -807,7 +832,7 @@ void MemoryWidget::FindValue(bool next)
|
|||
|
||||
u32 offset = *found_addr;
|
||||
|
||||
m_search_address->setText(QStringLiteral("%1").arg(offset, 8, 16, QLatin1Char('0')));
|
||||
m_search_address->setCurrentText(QStringLiteral("%1").arg(offset, 8, 16, QLatin1Char('0')));
|
||||
m_search_offset->clear();
|
||||
|
||||
m_memory_view->SetAddress(offset);
|
||||
|
|
|
@ -75,7 +75,7 @@ private:
|
|||
|
||||
MemoryViewWidget* m_memory_view;
|
||||
QSplitter* m_splitter;
|
||||
QLineEdit* m_search_address;
|
||||
QComboBox* m_search_address;
|
||||
QLineEdit* m_search_offset;
|
||||
QLineEdit* m_data_edit;
|
||||
QCheckBox* m_base_check;
|
||||
|
|
Loading…
Reference in New Issue