trequest_list: select new items - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit ef88bb1c286db6c7ca29754a750c499cb90dbb82 DIR parent d9e7807fff34ec4f32480a70b8cd5f69766845d6 HTML Author: Janus <ysangkok@gmail.com> Date: Thu, 17 Jan 2019 15:29:21 +0100 request_list: select new items Diffstat: M electrum/gui/qt/main_window.py | 2 ++ M electrum/gui/qt/request_list.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) --- DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -1070,6 +1070,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.address_list.update() self.clear_receive_tab() self.request_list.update() + self.request_list.select_key(key) def create_bitcoin_request(self, amount, message, expiration): addr = self.wallet.get_unused_address() t@@ -1094,6 +1095,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): else: self.sign_payment_request(addr) #self.save_request_button.setEnabled(False) + return addr def view_and_paste(self, title, msg, data): dialog = WindowModalDialog(self, title) DIR diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py t@@ -27,7 +27,7 @@ from enum import IntEnum from PyQt5.QtGui import QStandardItemModel, QStandardItem from PyQt5.QtWidgets import QMenu, QHeaderView -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QItemSelectionModel from electrum.i18n import _ from electrum.util import format_time, age t@@ -76,6 +76,16 @@ class RequestList(MyTreeView): self.selectionModel().currentRowChanged.connect(self.item_changed) self.setColumnWidth(self.Columns.ADDRESS, 250) + def select_key(self, key): + for i in range(self.model().rowCount()): + item = self.model().index(i, 0) + row_key = item.data(ROLE_RHASH_OR_ADDR) + if item.data(ROLE_REQUEST_TYPE) == REQUEST_TYPE_LN: + row_key = self.wallet.lnworker.invoices[row_key][1] + if key == row_key: + self.selectionModel().setCurrentIndex(item, QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows) + break + def item_changed(self, idx): # TODO use siblingAtColumn when min Qt version is >=5.11 addr = self.model().itemFromIndex(idx.sibling(idx.row(), self.Columns.ADDRESS)).text()