MetadataChoiceDialog aims to provide a fairly extensible dialog for displaying selection info, without requiring reimplementation or extra UI code whenever complex behavior is required. More...
MetadataChoiceDialog aims to provide a fairly extensible dialog for displaying selection info, without requiring reimplementation or extra UI code whenever complex behavior is required.
It can optionally display metadata to the right, a 2nd column with extra information about entries, and can have a checkbox-toggleable second filter (the first one being a regular text filter bar).
These are all described in the class documentation below.
Classes | |
struct | EntryItem |
class | ManagedTableDelegate |
class | EntryItemMetadataView |
class | MetadataChoiceDialog |
MetadataChoiceDialog is a dynamic UI View and Controller that allows the user to make a selection given a list of entries, and metadata about those entries. More... | |
struct | MetadataChoiceDialog::ExtraFilterState |
struct | MetadataChoiceDialog::MetadataState |
struct | MetadataChoiceDialog::InfoColumn |
class ManagedTableDelegate |
Public Member Functions | |
virtual | ~ManagedTableDelegate () |
virtual size_t | ManagedTableColumnCount ()=0 |
virtual size_t | ManagedTableRowCount ()=0 |
virtual QString | ManagedTableColumnName (size_t)=0 |
virtual QString | ManagedTableDisplayText (size_t row, size_t col)=0 |
virtual std::vector< std::pair< QString, std::function< void(EntryItem item)> > > | GetTableContextMenuItems ()=0 |
virtual void | ExecuteContextMenuItem (size_t menuItemIndex, size_t idx)=0 |
virtual std::vector< EntryItem > | GetAllItems () const =0 |
virtual bool | EntryItemPassesExtraFilters (EntryItem &item)=0 |
|
virtual |
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
|
pure virtual |
Implemented in MetadataChoiceDialog.
class EntryItemMetadataView |
Public Member Functions | |
EntryItemMetadataView (QWidget *parent) | |
void | SetDelegate (EntryItemMetadataViewDelegate *delegate) |
virtual void | DisplayPlainText (EntryItem &item) |
virtual void | DisplayTextLines (EntryItem &item) |
Protected Attributes | |
bool | m_currentItemIsTruncated |
|
explicit |
|
inline |
|
virtual |
|
virtual |
|
protected |
class MetadataChoiceDialog |
MetadataChoiceDialog is a dynamic UI View and Controller that allows the user to make a selection given a list of entries, and metadata about those entries.
The Model's data is left up to the developer using the dialog to manage. A developer can implement a second checkbox-toggled filter, custom metadata shown in a box to the right of the table, and/or a custom second column with additional info about entries.
Content from all of these callbacks is cached, however these caches can be evicted if data has changed or been added.
This dialog can to scale to very large amounts of arbitrary info by lazily loading it from provided callbacks, without requiring bespoke dialogs being built for those applications.
Example:
AddContextButton and AddContextMenuItem can also be used for more complex UI behavior if required, and examples are provided for using those in their respective documentation. There are also several methods for adding or editing entries, evicting caches, and so on, if you need to modify the dialog's contents on the fly via a button or context menu item.
Public Slots | |
virtual void | selectionChanged (std::optional< size_t > idx) |
void | accept () override |
void | reject () override |
Public Member Functions | |
void | AddWidthRequiredByItem (void *item, size_t widthRequired) |
void | RemoveWidthRequiredByItem (QWidget *item) |
void | AddHeightRequiredByItem (void *item, size_t widthRequired) |
void | RemoveHeightRequiredByItem (QWidget *item) |
MetadataChoiceDialog (QWidget *parent, const QString &title, const QString &prompt, const QStringList &entries, std::unordered_map< size_t, QString > metadata) | |
Create a choice selection dialog with a Title, list of entries, and pre-built set of metadata for those entries. | |
MetadataChoiceDialog (QWidget *parent, const QString &title, const QString &prompt, const QStringList &entries, std::unordered_map< size_t, std::vector< BinaryNinja::DisassemblyTextLine > > metadata) | |
Create a choice selection dialog with a Title, list of entries, and pre-built set of metadata for those entries. | |
MetadataChoiceDialog (QWidget *parent, const QString &title, const QString &prompt, const QStringList &entries) | |
Create a choice selection dialog with a Title and list of entries. | |
MetadataChoiceDialog (QWidget *parent, const QString &title, const QString &prompt="Select") | |
void | SetMetadataCallback (const std::function< QString(EntryItem item)> &callback) |
Set the callback the dialog will execute to retrieve metadata for a given item. | |
void | SetMetadataCallback (const std::function< std::vector< BinaryNinja::DisassemblyTextLine >(EntryItem item)> &callback) |
Set the callback the dialog will execute to retrieve metadata for a given item. | |
void | AddColumn (QString columnTitle, const std::function< QString(EntryItem item)> &callback) |
Set the callback the dialog will execute to retrieve second column text for a given item. | |
void | SetExtraFilter (QString filterTitle, const std::function< bool(EntryItem item)> callback) |
Set a callback for any optional extra conditions that entries must pass to be displayed. | |
void | SetShouldCacheMetadata (bool s) |
Set whether metadata should be cached after calling the metadata callback once. | |
void | SetShouldCacheExtraFilterResults (bool s) |
Set whether the entries that pass the extra filter should be cached. | |
std::optional< EntryItem > | GetChosenEntry () const |
Get the chosen entry. | |
void | AddEntries (QStringList &entries) |
Add entries to the initial set. | |
void | InvalidateAllCaches () |
Clear all caches. | |
void | AddContextButton (QWidget *button) |
Add a button (or other widget) to the right side of the search bar. | |
void | AddContextMenuItem (QString title, const std::function< void(EntryItem item)>action) |
void | SelectFirstValidEntry () |
Public Member Functions inherited from ManagedTableDelegate | |
virtual | ~ManagedTableDelegate () |
Public Member Functions inherited from EntryItemMetadataViewDelegate | |
virtual | ~EntryItemMetadataViewDelegate () |
Protected Member Functions | |
virtual size_t | ManagedTableColumnCount () override |
virtual size_t | ManagedTableRowCount () override |
virtual QString | ManagedTableColumnName (size_t) override |
virtual QString | ManagedTableDisplayText (size_t row, size_t col) override |
virtual std::vector< std::pair< QString, std::function< void(EntryItem item)> > > | GetTableContextMenuItems () override |
virtual void | ExecuteContextMenuItem (size_t menuItemIndex, size_t idx) override |
virtual bool | EntryItemPassesExtraFilters (EntryItem &item) override |
virtual std::vector< EntryItem > | GetAllItems () const override |
virtual MetadataMode | GetCurrentMode () override |
virtual std::vector< BinaryNinja::DisassemblyTextLine > | LinesForEntryItem (EntryItem &item) override |
virtual QString | PlaintextForEntryItem (EntryItem &item) override |
bool | ExtraFilterEnabled () |
void | UpdateMinimumSpace () |
Protected Attributes | |
std::vector< EntryItem > | m_entries |
QHBoxLayout * | m_midRowLayout |
bool | m_secondColumnCacheEnabled = true |
std::vector< InfoColumn > | m_infoColumns |
std::vector< std::pair< QString, std::function< void(EntryItem item)> > > | m_contextMenuItems |
ManagedTableView * | m_entryListView |
EntryItemMetadataView * | m_metadataView |
FilteredView * | m_filterView |
FilterEdit * | m_edit |
MetadataState | m_metadata |
QCheckBox * | m_extraFilterCheckbox |
ExtraFilterState | m_extraFilter |
QLabel * | m_selectedText |
QPushButton * | m_cancel |
QPushButton * | m_choose |
std::optional< EntryItem > | m_chosenEntry |
std::optional< EntryItem > | m_selectedEntry |
MetadataChoiceDialog::MetadataChoiceDialog | ( | QWidget * | parent, |
const QString & | title, | ||
const QString & | prompt, | ||
const QStringList & | entries, | ||
std::unordered_map< size_t, QString > | metadata ) |
Create a choice selection dialog with a Title, list of entries, and pre-built set of metadata for those entries.
parent | Parent Widget |
title | Title of the dialog |
prompt | Text of the button to select a choice |
entries | List of entries |
metadata | Map of indices to the metadata for those entries. |
MetadataChoiceDialog::MetadataChoiceDialog | ( | QWidget * | parent, |
const QString & | title, | ||
const QString & | prompt, | ||
const QStringList & | entries, | ||
std::unordered_map< size_t, std::vector< BinaryNinja::DisassemblyTextLine > > | metadata ) |
Create a choice selection dialog with a Title, list of entries, and pre-built set of metadata for those entries.
parent | Parent Widget |
title | Title of the dialog |
prompt | Text of the button to select a choice |
entries | List of entries |
metadata | Map of indices to the metadata (as InstructionTextTokens) for those entries. |
MetadataChoiceDialog::MetadataChoiceDialog | ( | QWidget * | parent, |
const QString & | title, | ||
const QString & | prompt, | ||
const QStringList & | entries ) |
Create a choice selection dialog with a Title and list of entries.
parent | Parent Widget |
title | Title of the dialog |
prompt | Text of the button to select a choice |
entries | List of entries |
|
inline |
|
overrideprotectedvirtual |
Implements ManagedTableDelegate.
|
overrideprotectedvirtual |
Implements ManagedTableDelegate.
|
overrideprotectedvirtual |
Implements ManagedTableDelegate.
|
overrideprotectedvirtual |
Implements ManagedTableDelegate.
|
inlineoverrideprotectedvirtual |
Implements ManagedTableDelegate.
|
overrideprotectedvirtual |
Implements ManagedTableDelegate.
|
overrideprotectedvirtual |
Implements ManagedTableDelegate.
|
inlineoverrideprotectedvirtual |
Implements ManagedTableDelegate.
|
inlineoverrideprotectedvirtual |
Implements EntryItemMetadataViewDelegate.
|
overrideprotectedvirtual |
Implements EntryItemMetadataViewDelegate.
|
overrideprotectedvirtual |
Implements EntryItemMetadataViewDelegate.
|
inlineprotected |
void MetadataChoiceDialog::AddWidthRequiredByItem | ( | void * | item, |
size_t | widthRequired ) |
void MetadataChoiceDialog::RemoveWidthRequiredByItem | ( | QWidget * | item | ) |
void MetadataChoiceDialog::AddHeightRequiredByItem | ( | void * | item, |
size_t | widthRequired ) |
void MetadataChoiceDialog::RemoveHeightRequiredByItem | ( | QWidget * | item | ) |
|
protected |
void MetadataChoiceDialog::SetMetadataCallback | ( | const std::function< QString(EntryItem item)> & | callback | ) |
Set the callback the dialog will execute to retrieve metadata for a given item.
callback | Non nullable function (can be a lambda) that returns a QString containing metadata about the given EntryItem |
void MetadataChoiceDialog::SetMetadataCallback | ( | const std::function< std::vector< BinaryNinja::DisassemblyTextLine >(EntryItem item)> & | callback | ) |
Set the callback the dialog will execute to retrieve metadata for a given item.
callback | Non nullable function (can be a lambda) that returns a vector of DisassemblyTextLines. |
void MetadataChoiceDialog::AddColumn | ( | QString | columnTitle, |
const std::function< QString(EntryItem item)> & | callback ) |
Set the callback the dialog will execute to retrieve second column text for a given item.
secondColumnTitle | Title for the 2nd column |
callback | Non nullable function (can be a lambda) that returns a QString containing optional second column text for the given index |
void MetadataChoiceDialog::SetExtraFilter | ( | QString | filterTitle, |
const std::function< bool(EntryItem item)> | callback ) |
Set a callback for any optional extra conditions that entries must pass to be displayed.
The user will be able to toggle this filter via a checkbox.
filterTitle | Title for the checkbox to toggle this filter condition. |
callback | Callback function that checks whether a given entry index passes the extra filter. |
|
inline |
Set whether metadata should be cached after calling the metadata callback once.
By default this is enabled.
s | Whether to cache metadata. |
|
inline |
Set whether the entries that pass the extra filter should be cached.
By default this is enabled.
If the qualifications of the extra filter cannot change while this dialog is visible, this should be kept enabled.
s | Whether to cache extra filter results. |
|
inline |
Get the chosen entry.
Should be called after ->exec() has finished.
void MetadataChoiceDialog::AddEntries | ( | QStringList & | entries | ) |
Add entries to the initial set.
entries | List of entries to add. |
void MetadataChoiceDialog::InvalidateAllCaches | ( | ) |
Clear all caches.
void MetadataChoiceDialog::AddContextButton | ( | QWidget * | button | ) |
Add a button (or other widget) to the right side of the search bar.
You are responsible for the behavior of this widget.
Example:
button | Widget to add. |
void MetadataChoiceDialog::AddContextMenuItem | ( | QString | title, |
const std::function< void(EntryItem item)> | action ) |
void MetadataChoiceDialog::SelectFirstValidEntry | ( | ) |
|
virtualslot |
|
overrideslot |
|
overrideslot |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
struct MetadataChoiceDialog::ExtraFilterState |
Class Members | ||
---|---|---|
bool | exists = false | |
bool | enabled = false | |
bool | cacheEnabled = true | |
QString | title | |
unordered_map< size_t, bool > | cache | |
function< bool(EntryItem item)> | callback |
struct MetadataChoiceDialog::MetadataState |
Class Members | ||
---|---|---|
bool | exists = false | |
bool | cacheEnabled = true | |
MetadataMode | mode | |
unordered_map< size_t, QString > | preloadedPlaintext | |
unordered_map< size_t, vector< DisassemblyTextLine > > | preloadedTextLines | |
unordered_map< size_t, QString > | plaintextCache | |
unordered_map< size_t, vector< DisassemblyTextLine > > | disassemblyTextLineCache | |
function< QString(EntryItem item)> | plaintextCallback | |
function< vector< DisassemblyTextLine >(EntryItem item)> | disassemblyTextLineCallback |
struct MetadataChoiceDialog::InfoColumn |
Class Members | ||
---|---|---|
QString | name | |
unordered_map< size_t, QString > | textCache | |
function< QString(EntryItem &item)> | textCallback |