From 02ce3cb731f56dde36bc8240df73c1a58bda50dc Mon Sep 17 00:00:00 2001 From: Itay Cohen Date: Wed, 24 Oct 2018 00:08:02 +0300 Subject: [PATCH] Implement the "Search in" feature (#873) --- src/widgets/SearchWidget.cpp | 28 ++++++++++++++++++++++++++++ src/widgets/SearchWidget.h | 2 +- src/widgets/SearchWidget.ui | 19 ++++++++++++++++++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/widgets/SearchWidget.cpp b/src/widgets/SearchWidget.cpp index 1fcd7ac3..9cb57370 100644 --- a/src/widgets/SearchWidget.cpp +++ b/src/widgets/SearchWidget.cpp @@ -6,6 +6,19 @@ #include "MainWindow.h" #include "common/Helpers.h" +static const QMap kSearchBoundariesValues { + {"io.maps", "All maps"}, + {"io.map", "Current map"}, + {"raw", "Raw"}, + {"dbg.maps", "All memory maps"}, + {"dbg.map", "Memory map"}, + {"block", "Current block"}, + {"bin.section", "Current mapped section"}, + {"bin.sections", "All mapped sections"}, + {"dbg.stack", "Stack"}, + {"dbg.heap", "Heap"} + }; + SearchModel::SearchModel(QList *search, QObject *parent) : QAbstractListModel(parent), search(search) @@ -116,6 +129,12 @@ SearchWidget::SearchWidget(MainWindow *main, QAction *action) : { ui->setupUi(this); + ui->searchInCombo->blockSignals(true); + QMap::const_iterator mapIter; + for (mapIter = kSearchBoundariesValues.begin(); mapIter != kSearchBoundariesValues.end(); ++mapIter) + ui->searchInCombo->addItem(mapIter.value(), mapIter.key()); + ui->searchInCombo->blockSignals(false); + search_model = new SearchModel(&search, this); search_proxy_model = new SearchSortFilterProxyModel(search_model, this); ui->searchTreeView->setModel(search_proxy_model); @@ -138,6 +157,8 @@ SearchWidget::SearchWidget(MainWindow *main, QAction *action) : connect(ui->searchspaceCombo, QOverload::of(&QComboBox::currentIndexChanged), [ = ](int index) { updatePlaceholderText(index);}); + QString currentSearchBoundary = Core()->getConfig("search.in"); + ui->searchInCombo->setCurrentIndex(ui->searchInCombo->findData(currentSearchBoundary)); } SearchWidget::~SearchWidget() {} @@ -213,3 +234,10 @@ void SearchWidget::updatePlaceholderText(int index) ui->filterLineEdit->setPlaceholderText("jmp rax"); } } + + +void SearchWidget::on_searchInCombo_currentIndexChanged(int index) +{ + Config()->setConfig("search.in", + ui->searchInCombo->itemData(index).toString()); +} diff --git a/src/widgets/SearchWidget.h b/src/widgets/SearchWidget.h index c6180f79..322d91eb 100644 --- a/src/widgets/SearchWidget.h +++ b/src/widgets/SearchWidget.h @@ -66,7 +66,7 @@ public: private slots: void on_searchTreeView_doubleClicked(const QModelIndex &index); - + void on_searchInCombo_currentIndexChanged(int index); void searchChanged(); void refreshSearchspaces(); diff --git a/src/widgets/SearchWidget.ui b/src/widgets/SearchWidget.ui index e184b5b4..cae1e17a 100644 --- a/src/widgets/SearchWidget.ui +++ b/src/widgets/SearchWidget.ui @@ -6,7 +6,7 @@ 0 0 - 463 + 548 300 @@ -94,6 +94,23 @@ + + + + Search in: + + + + + + + + 16777215 + 300 + + + +