mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
qt channels list: make selection more in line with other tabs
(allow selecting none, and allow multi-select)
This commit is contained in:
parent
7488cc91cd
commit
95979ba58d
1 changed files with 13 additions and 3 deletions
|
@ -4,7 +4,8 @@ from enum import IntEnum
|
|||
|
||||
from PyQt5 import QtCore, QtGui
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QMenu, QHBoxLayout, QLabel, QVBoxLayout, QGridLayout, QLineEdit, QPushButton
|
||||
from PyQt5.QtWidgets import (QMenu, QHBoxLayout, QLabel, QVBoxLayout, QGridLayout, QLineEdit,
|
||||
QPushButton, QAbstractItemView)
|
||||
from PyQt5.QtGui import QFont
|
||||
|
||||
from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates
|
||||
|
@ -46,6 +47,7 @@ class ChannelsList(MyTreeView):
|
|||
super().__init__(parent, self.create_menu, stretch_column=self.Columns.NODE_ID,
|
||||
editable_columns=[])
|
||||
self.setModel(QtGui.QStandardItemModel(self))
|
||||
self.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||
self.main_window = parent
|
||||
self.update_rows.connect(self.do_update_rows)
|
||||
self.update_single_row.connect(self.do_update_single_row)
|
||||
|
@ -121,7 +123,15 @@ class ChannelsList(MyTreeView):
|
|||
def create_menu(self, position):
|
||||
menu = QMenu()
|
||||
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together
|
||||
idx = self.selectionModel().currentIndex()
|
||||
selected = self.selected_in_column(self.Columns.NODE_ID)
|
||||
if not selected:
|
||||
return
|
||||
multi_select = len(selected) > 1
|
||||
if multi_select:
|
||||
return
|
||||
idx = self.indexAt(position)
|
||||
if not idx.isValid():
|
||||
return
|
||||
item = self.model().itemFromIndex(idx)
|
||||
if not item:
|
||||
return
|
||||
|
@ -153,7 +163,7 @@ class ChannelsList(MyTreeView):
|
|||
menu.exec_(self.viewport().mapToGlobal(position))
|
||||
|
||||
@QtCore.pyqtSlot(Channel)
|
||||
def do_update_single_row(self, chan):
|
||||
def do_update_single_row(self, chan: Channel):
|
||||
lnworker = self.parent.wallet.lnworker
|
||||
if not lnworker:
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue