Skip to content

Commit

Permalink
search list using an attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Jul 1, 2024
1 parent 1326dbe commit b39512c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/asammdf/gui/widgets/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,23 @@ def paintEvent(self, event):
)
painter.drawText(self.viewport().rect(), QtCore.Qt.AlignmentFlag.AlignCenter, elided_text)
painter.restore()

def search(self, attribute="", value=None):
index = None
count = self.count()
for row in range(count):
item = self.item(row)

if hasattr(item, attribute):
if getattr(item, attribute) == value:
index = row
break
else:
widget = self.itemWidget(item)

if hasattr(widget, attribute):
if getattr(widget, attribute) == value:
index = row
break

return index
2 changes: 1 addition & 1 deletion src/asammdf/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" asammdf version module """

__version__ = "8.0.0.dev7"
__version__ = "8.0.0.dev8"

0 comments on commit b39512c

Please sign in to comment.