Browse Source

qt history tab: fix double-clicking inside collapsible items

Swaps (both reverse and forward) are displayed in the list as a tree, which can be
expanded/collapsed. When expanded, double-clicking on any of the children (regardless
of child being LN or onchain), was interacting with the incorrect item (the first few
items in the top-level list).

Consider `self.tx_item_from_proxy_row(idx.row())`.
`idx.row()` is probably a small int, e.g. `0`, and `tx_item_from_proxy_row` is just
getting that item from the top-level list.

Note that the right-click>"View ..." context menu behaves correctly, so prior to
this commit it was inconsistent with double-clicking.
patch-4
SomberNight 3 years ago
parent
commit
2b13576eb3
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/gui/qt/history_list.py

12
electrum/gui/qt/history_list.py

@ -421,8 +421,8 @@ class HistoryModel(CustomModel, Logger):
HistoryColumns.TXID: 'TXID', HistoryColumns.TXID: 'TXID',
}[section] }[section]
def flags(self, idx): def flags(self, idx: QModelIndex) -> int:
extra_flags = Qt.NoItemFlags # type: Qt.ItemFlag extra_flags = Qt.NoItemFlags # type: Qt.ItemFlag
if idx.column() in self.view.editable_columns: if idx.column() in self.view.editable_columns:
extra_flags |= Qt.ItemIsEditable extra_flags |= Qt.ItemIsEditable
return super().flags(idx) | int(extra_flags) return super().flags(idx) | int(extra_flags)
@ -658,11 +658,13 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
assert False assert False
def mouseDoubleClickEvent(self, event: QMouseEvent): def mouseDoubleClickEvent(self, event: QMouseEvent):
idx = self.indexAt(event.pos()) org_idx: QModelIndex = self.indexAt(event.pos())
idx = self.proxy.mapToSource(org_idx)
if not idx.isValid(): if not idx.isValid():
# can happen e.g. before list is populated for the first time
return return
tx_item = self.tx_item_from_proxy_row(idx.row()) tx_item = idx.internalPointer().get_data()
if self.hm.flags(self.model().mapToSource(idx)) & Qt.ItemIsEditable: if self.hm.flags(idx) & Qt.ItemIsEditable:
super().mouseDoubleClickEvent(event) super().mouseDoubleClickEvent(event)
else: else:
if tx_item.get('lightning'): if tx_item.get('lightning'):

Loading…
Cancel
Save