Skip to content

Commit

Permalink
QStringModel: Add Length column (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson authored Nov 21, 2023
1 parent ca5158a commit 59c6e9c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions angrmanagement/ui/widgets/qstring_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@


class QStringModel(QAbstractTableModel):
HEADER = ["Address", "Size (Bytes)", "String"]
HEADER = ["Address", "Size (Bytes)", "Length", "String"]

ADDRESS_COL = 0
SIZE_COL = 1
STRING_COL = 2
LENGTH_COL = 2
STRING_COL = 3

def __init__(self, cfg, func=None):
super().__init__()
Expand Down Expand Up @@ -147,6 +148,7 @@ def _get_column_data(self, v: "MemoryData", col: int) -> Any:
mapping = {
self.ADDRESS_COL: lambda x: x.addr,
self.SIZE_COL: lambda x: x.size,
self.LENGTH_COL: lambda x: len(self._get_decoded_string_content(x)) if x.content is not None else "<ERROR>",
self.STRING_COL: lambda x: filter_string_for_display(self._get_decoded_string_content(x))
if x.content is not None
else "<ERROR>",
Expand Down Expand Up @@ -182,7 +184,7 @@ def __init__(self, instance, parent, selection_callback=None):

# let the last column (string) fill table width
self.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
self.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(QStringModel.STRING_COL, QHeaderView.Stretch)

self.doubleClicked.connect(self._on_string_selected)

Expand Down

0 comments on commit 59c6e9c

Please sign in to comment.