summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2022-10-21 22:58:46 +0200
committerPeter LaFosse <peter@vector35.com>2022-11-10 16:19:13 -0500
commit78a4c923fe3fd5790e03e2c963e0a519d8c2b93b (patch)
tree3641ec3679eeb65b9ea171b1b1479b67fb3040c3
parent4fd944de0e28e2d66cb5792c4f7a80cfad387b56 (diff)
Show filtered/total count in search
-rw-r--r--ui/filter.h5
-rw-r--r--ui/stringsview.h4
-rw-r--r--ui/symbollist.h2
-rw-r--r--ui/taglist.h4
-rw-r--r--ui/typeview.h38
5 files changed, 33 insertions, 20 deletions
diff --git a/ui/filter.h b/ui/filter.h
index 006b92de..17466a84 100644
--- a/ui/filter.h
+++ b/ui/filter.h
@@ -36,12 +36,16 @@ class BINARYNINJAUIAPI FilterEdit : public QLineEdit
Q_OBJECT
FilterTarget* m_target;
+ QString m_rightText;
public:
FilterEdit(FilterTarget* target);
+ const QString& rightText() const { return m_rightText; }
+ void setRightText(const QString& text);
protected:
virtual void keyPressEvent(QKeyEvent* event) override;
+ virtual void paintEvent(QPaintEvent* event) override;
};
/*!
@@ -62,6 +66,7 @@ class BINARYNINJAUIAPI FilteredView : public QWidget
void updateFonts();
void clearFilter();
void showFilter(const QString& initialText);
+ void showRightText(const QString& text);
static bool match(const std::string& name, const std::string& filter);
diff --git a/ui/stringsview.h b/ui/stringsview.h
index 100a496f..35a7b73a 100644
--- a/ui/stringsview.h
+++ b/ui/stringsview.h
@@ -77,6 +77,7 @@ class BINARYNINJAUIAPI StringsListModel : public QAbstractItemModel, public Bina
size_t getFilteredStringCount() const { return m_filteredByOptions; }
size_t getStringCount() const { return m_strings.size(); }
+ size_t getUnfilteredStringCount() const { return m_allStrings.size(); }
void toggleIncludeStringsOverlappingCode() { m_includeStringsOverlappingCode = !m_includeStringsOverlappingCode; };
void toggleIncludeOnlyReferenced() { m_includeOnlyReferenced = !m_includeOnlyReferenced; };
@@ -89,6 +90,9 @@ class BINARYNINJAUIAPI StringsListModel : public QAbstractItemModel, public Bina
bool getIncludeStringsOverlappingCode() const { return m_includeStringsOverlappingCode; };
bool getIncludeOnlyReferenced() const { return m_includeOnlyReferenced; };
bool getIncludeOnlyFromCurrentFunction() const { return m_includeOnlyFromCurrentFunction; };
+
+Q_SIGNALS:
+ void updateCount();
};
/*!
diff --git a/ui/symbollist.h b/ui/symbollist.h
index 5a7b1c1d..8fad740e 100644
--- a/ui/symbollist.h
+++ b/ui/symbollist.h
@@ -261,6 +261,7 @@ class BINARYNINJAUIAPI SymbolListModel : public QAbstractItemModel, public Binar
void updateFunctions();
void backgroundUpdate();
bool hasSymbols() const;
+ size_t getUnfilteredCount() const;
void setFilter(const std::string& filter);
void showExportedDataVars(bool show) { m_showExportedDataVars = show; }
@@ -294,6 +295,7 @@ class BINARYNINJAUIAPI SymbolListModel : public QAbstractItemModel, public Binar
Q_SIGNALS:
void afterListReset();
void beforeListReset();
+ void updateCount();
};
/*!
diff --git a/ui/taglist.h b/ui/taglist.h
index 9b3198d4..76a4d396 100644
--- a/ui/taglist.h
+++ b/ui/taglist.h
@@ -73,6 +73,8 @@ class BINARYNINJAUIAPI TagListModel : public QAbstractItemModel
bool setModelData(const std::vector<std::pair<TagTypeRef, std::vector<BinaryNinja::TagReference>>>& refs,
QItemSelectionModel* selectionModel, int sortColumn, Qt::SortOrder sortOrder, bool& selectionUpdated);
+Q_SIGNALS:
+ void updateCount();
};
/*!
@@ -118,6 +120,8 @@ class BINARYNINJAUIAPI TagList : public QTreeView, public BinaryNinja::BinaryDat
FilteredView* m_filterView;
Menu* m_menu;
std::unordered_map<std::string, bool> m_expandedItems;
+ size_t m_allRefsCount;
+ size_t m_filteredRefsCount;
public:
typedef std::function<bool(const BinaryNinja::TagReference&)> FilterFn;
diff --git a/ui/typeview.h b/ui/typeview.h
index 1aa89cc8..8744ffa7 100644
--- a/ui/typeview.h
+++ b/ui/typeview.h
@@ -18,6 +18,7 @@
#include "menus.h"
#include "xreflist.h"
#include "clickablelabel.h"
+#include "filter.h"
#define TYPE_VIEW_UPDATE_CHECK_INTERVAL 200
@@ -221,6 +222,9 @@ class BINARYNINJAUIAPI TypeView : public QAbstractScrollArea, public View, publi
virtual void setNavigationMode(std::string mode) override;
virtual std::vector<std::string> getNavigationModes() override;
+ size_t getUnfilteredTypeCount() const { return m_allTypeLines.size(); }
+ size_t getFilteredTypeCount() const { return m_typeLines.size(); }
+
uint64_t findMatchingLine(const BinaryNinja::QualifiedName& name, uint64_t offset, size_t& cursorOffset);
bool navigateToType(const std::string& name, uint64_t offset = 0);
@@ -287,6 +291,9 @@ class BINARYNINJAUIAPI TypeView : public QAbstractScrollArea, public View, publi
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
virtual void scrollContentsBy(int dx, int dy) override;
+ Q_SIGNALS:
+ void updateCount();
+
private Q_SLOTS:
void copySelection();
void selectAll();
@@ -355,31 +362,13 @@ class TypeViewType : public ViewType
\ingroup typeview
*/
-class BINARYNINJAUIAPI TypeFilterEdit : public QLineEdit
-{
- Q_OBJECT
-
- public:
- TypeFilterEdit(QWidget* parent);
-
- protected:
- virtual void keyPressEvent(QKeyEvent* event) override;
-
- Q_SIGNALS:
- void focusView();
-};
-
-/*!
-
- \ingroup typeview
-*/
-class BINARYNINJAUIAPI TypeFilter : public QWidget
+class BINARYNINJAUIAPI TypeFilter : public QWidget, public FilterTarget
{
Q_OBJECT
TypesContainer* m_container;
ClickableIcon* m_showSystemTypes;
- TypeFilterEdit* m_textFilter;
+ FilterEdit* m_textFilter;
bool MatchesAutoFilter(BinaryViewRef data, const BinaryNinja::QualifiedName& name);
bool MatchesTextFilter(const std::vector<BinaryNinja::TypeDefinitionLine>& lines);
@@ -400,6 +389,15 @@ class BINARYNINJAUIAPI TypeFilter : public QWidget
bool areAutoTypesVisible();
void setShowAutoTypes(bool showAutoTypes);
void clearTextFilter();
+ void setRightText(const QString& text);
+
+ protected:
+ void setFilter(const std::string& filter) override;
+ void scrollToFirstItem() override;
+ void scrollToCurrentItem() override;
+ void selectFirstItem() override;
+ void activateFirstItem() override;
+ void closeFilter() override;
};
/*!