From 2b13576eb3cd02ee4785baf7f0dbde1ceb533a58 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 31 Mar 2022 19:10:39 +0200 Subject: [PATCH] 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. --- electrum/gui/qt/history_list.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py index 7b5343c8d..807c67c9d 100644 --- a/electrum/gui/qt/history_list.py +++ b/electrum/gui/qt/history_list.py @@ -421,8 +421,8 @@ class HistoryModel(CustomModel, Logger): HistoryColumns.TXID: 'TXID', }[section] - def flags(self, idx): - extra_flags = Qt.NoItemFlags # type: Qt.ItemFlag + def flags(self, idx: QModelIndex) -> int: + extra_flags = Qt.NoItemFlags # type: Qt.ItemFlag if idx.column() in self.view.editable_columns: extra_flags |= Qt.ItemIsEditable return super().flags(idx) | int(extra_flags) @@ -658,11 +658,13 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): assert False 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(): + # can happen e.g. before list is populated for the first time return - tx_item = self.tx_item_from_proxy_row(idx.row()) - if self.hm.flags(self.model().mapToSource(idx)) & Qt.ItemIsEditable: + tx_item = idx.internalPointer().get_data() + if self.hm.flags(idx) & Qt.ItemIsEditable: super().mouseDoubleClickEvent(event) else: if tx_item.get('lightning'):