Improved register searching
This commit is contained in:
@@ -122,12 +122,10 @@ void RegisterGroupWidget::setAllRegistersVisible(bool visible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterGroupWidget::filterRegisters(const std::string& keyword) {
|
void RegisterGroupWidget::filterRegisters(const QString& keyword) {
|
||||||
int matchingWidgetCount = 0;
|
int matchingWidgetCount = 0;
|
||||||
for (const auto& registerWidget : this->registerWidgets) {
|
for (const auto& registerWidget : this->registerWidgets) {
|
||||||
if (keyword.empty()
|
if (keyword.isEmpty() || (registerWidget->searchKeywords.contains(keyword, Qt::CaseInsensitive))) {
|
||||||
|| (registerWidget->descriptor.name.value().find(keyword) != std::string::npos)
|
|
||||||
) {
|
|
||||||
matchingWidgetCount++;
|
matchingWidgetCount++;
|
||||||
registerWidget->setVisible(true);
|
registerWidget->setVisible(true);
|
||||||
|
|
||||||
@@ -142,7 +140,7 @@ void RegisterGroupWidget::filterRegisters(const std::string& keyword) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
this->setVisible(true);
|
this->setVisible(true);
|
||||||
if (!keyword.empty()) {
|
if (!keyword.isEmpty()) {
|
||||||
this->expand();
|
this->expand();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "TargetRegistersPaneWidget.hpp"
|
#include "TargetRegistersPaneWidget.hpp"
|
||||||
#include "ItemWidget.hpp"
|
#include "ItemWidget.hpp"
|
||||||
@@ -40,7 +39,7 @@ namespace Bloom::Widgets
|
|||||||
void expand();
|
void expand();
|
||||||
void setAllRegistersVisible(bool visible);
|
void setAllRegistersVisible(bool visible);
|
||||||
|
|
||||||
void filterRegisters(const std::string& keyword);
|
void filterRegisters(const QString& keyword);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
|||||||
@@ -18,7 +18,14 @@ RegisterWidget::RegisterWidget(
|
|||||||
TargetRegisterDescriptor descriptor,
|
TargetRegisterDescriptor descriptor,
|
||||||
InsightWorker& insightWorker,
|
InsightWorker& insightWorker,
|
||||||
QWidget *parent
|
QWidget *parent
|
||||||
): ItemWidget(parent), descriptor(std::move(descriptor)), insightWorker(insightWorker) {
|
)
|
||||||
|
: ItemWidget(parent)
|
||||||
|
, descriptor(std::move(descriptor))
|
||||||
|
, searchKeywords(QString::fromStdString(
|
||||||
|
this->descriptor.name.value_or("") + this->descriptor.description.value_or("")
|
||||||
|
).toLower())
|
||||||
|
, insightWorker(insightWorker)
|
||||||
|
{
|
||||||
this->setObjectName("register-item");
|
this->setObjectName("register-item");
|
||||||
this->setFixedHeight(25);
|
this->setFixedHeight(25);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "ItemWidget.hpp"
|
#include "ItemWidget.hpp"
|
||||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||||
@@ -23,6 +24,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Targets::TargetRegisterDescriptor descriptor;
|
Targets::TargetRegisterDescriptor descriptor;
|
||||||
|
QString searchKeywords;
|
||||||
std::optional<Targets::TargetRegister> currentRegister;
|
std::optional<Targets::TargetRegister> currentRegister;
|
||||||
|
|
||||||
RegisterWidget(
|
RegisterWidget(
|
||||||
|
|||||||
@@ -124,8 +124,6 @@ TargetRegistersPaneWidget::TargetRegistersPaneWidget(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetRegistersPaneWidget::filterRegisters(const QString& keyword) {
|
void TargetRegistersPaneWidget::filterRegisters(const QString& keyword) {
|
||||||
auto stdKeyword = keyword.toLower().toStdString();
|
|
||||||
|
|
||||||
for (const auto& registerGroupWidget : this->registerGroupWidgets) {
|
for (const auto& registerGroupWidget : this->registerGroupWidgets) {
|
||||||
// If the group name matches the keyword, then don't bother iterating through all the register widgets
|
// If the group name matches the keyword, then don't bother iterating through all the register widgets
|
||||||
if (keyword.isEmpty() || registerGroupWidget->name.contains(keyword, Qt::CaseInsensitive)) {
|
if (keyword.isEmpty() || registerGroupWidget->name.contains(keyword, Qt::CaseInsensitive)) {
|
||||||
@@ -140,7 +138,7 @@ void TargetRegistersPaneWidget::filterRegisters(const QString& keyword) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
registerGroupWidget->filterRegisters(stdKeyword);
|
registerGroupWidget->filterRegisters(keyword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user