Implement the "Search in" feature (#873)

This commit is contained in:
Itay Cohen 2018-10-24 00:08:02 +03:00 committed by xarkes
parent 08107fdc67
commit 02ce3cb731
3 changed files with 47 additions and 2 deletions

View File

@ -6,6 +6,19 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "common/Helpers.h" #include "common/Helpers.h"
static const QMap<QString, QString> 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<SearchDescription> *search, QObject *parent) SearchModel::SearchModel(QList<SearchDescription> *search, QObject *parent)
: QAbstractListModel(parent), : QAbstractListModel(parent),
search(search) search(search)
@ -116,6 +129,12 @@ SearchWidget::SearchWidget(MainWindow *main, QAction *action) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->searchInCombo->blockSignals(true);
QMap<QString, QString>::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_model = new SearchModel(&search, this);
search_proxy_model = new SearchSortFilterProxyModel(search_model, this); search_proxy_model = new SearchSortFilterProxyModel(search_model, this);
ui->searchTreeView->setModel(search_proxy_model); ui->searchTreeView->setModel(search_proxy_model);
@ -138,6 +157,8 @@ SearchWidget::SearchWidget(MainWindow *main, QAction *action) :
connect(ui->searchspaceCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->searchspaceCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
[ = ](int index) { updatePlaceholderText(index);}); [ = ](int index) { updatePlaceholderText(index);});
QString currentSearchBoundary = Core()->getConfig("search.in");
ui->searchInCombo->setCurrentIndex(ui->searchInCombo->findData(currentSearchBoundary));
} }
SearchWidget::~SearchWidget() {} SearchWidget::~SearchWidget() {}
@ -213,3 +234,10 @@ void SearchWidget::updatePlaceholderText(int index)
ui->filterLineEdit->setPlaceholderText("jmp rax"); ui->filterLineEdit->setPlaceholderText("jmp rax");
} }
} }
void SearchWidget::on_searchInCombo_currentIndexChanged(int index)
{
Config()->setConfig("search.in",
ui->searchInCombo->itemData(index).toString());
}

View File

@ -66,7 +66,7 @@ public:
private slots: private slots:
void on_searchTreeView_doubleClicked(const QModelIndex &index); void on_searchTreeView_doubleClicked(const QModelIndex &index);
void on_searchInCombo_currentIndexChanged(int index);
void searchChanged(); void searchChanged();
void refreshSearchspaces(); void refreshSearchspaces();

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>463</width> <width>548</width>
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
@ -94,6 +94,23 @@
<item> <item>
<widget class="QComboBox" name="searchspaceCombo"/> <widget class="QComboBox" name="searchspaceCombo"/>
</item> </item>
<item>
<widget class="QLabel" name="searchInLabel">
<property name="text">
<string>Search in:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="searchInCombo">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>300</height>
</size>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>