|
|
|
@ -70,12 +70,16 @@ class UTXOList(MyTreeView): |
|
|
|
self._spend_set = set() |
|
|
|
self._spend_set = set() |
|
|
|
self._utxo_dict = {} |
|
|
|
self._utxo_dict = {} |
|
|
|
self.wallet = self.parent.wallet |
|
|
|
self.wallet = self.parent.wallet |
|
|
|
|
|
|
|
|
|
|
|
self.std_model = QStandardItemModel(self) |
|
|
|
self.std_model = QStandardItemModel(self) |
|
|
|
self.setModel(self.std_model) |
|
|
|
self.setModel(self.std_model) |
|
|
|
self.setSelectionMode(QAbstractItemView.ExtendedSelection) |
|
|
|
self.setSelectionMode(QAbstractItemView.ExtendedSelection) |
|
|
|
self.setSortingEnabled(True) |
|
|
|
self.setSortingEnabled(True) |
|
|
|
self.update() |
|
|
|
|
|
|
|
|
|
|
|
def create_toolbar(self, config): |
|
|
|
|
|
|
|
toolbar, menu = self.create_toolbar_with_menu('') |
|
|
|
|
|
|
|
self.num_coins_label = toolbar.itemAt(0).widget() |
|
|
|
|
|
|
|
menu.addAction(_('Coin control'), lambda: self.add_selection_to_coincontrol()) |
|
|
|
|
|
|
|
return toolbar |
|
|
|
|
|
|
|
|
|
|
|
def update(self): |
|
|
|
def update(self): |
|
|
|
# not calling maybe_defer_update() as it interferes with coincontrol status bar |
|
|
|
# not calling maybe_defer_update() as it interferes with coincontrol status bar |
|
|
|
@ -103,6 +107,7 @@ class UTXOList(MyTreeView): |
|
|
|
self.refresh_row(name, idx) |
|
|
|
self.refresh_row(name, idx) |
|
|
|
self.filter() |
|
|
|
self.filter() |
|
|
|
self.update_coincontrol_bar() |
|
|
|
self.update_coincontrol_bar() |
|
|
|
|
|
|
|
self.num_coins_label.setText(_('{} unspent transaction outputs').format(len(utxos))) |
|
|
|
|
|
|
|
|
|
|
|
def update_coincontrol_bar(self): |
|
|
|
def update_coincontrol_bar(self): |
|
|
|
# update coincontrol status bar |
|
|
|
# update coincontrol status bar |
|
|
|
@ -142,9 +147,9 @@ class UTXOList(MyTreeView): |
|
|
|
utxo_item[self.Columns.OUTPOINT].setBackground(ColorScheme.BLUE.as_color(True)) |
|
|
|
utxo_item[self.Columns.OUTPOINT].setBackground(ColorScheme.BLUE.as_color(True)) |
|
|
|
utxo_item[self.Columns.OUTPOINT].setToolTip(f"{key}\n{_('Coin is frozen')}") |
|
|
|
utxo_item[self.Columns.OUTPOINT].setToolTip(f"{key}\n{_('Coin is frozen')}") |
|
|
|
|
|
|
|
|
|
|
|
def get_selected_outpoints(self) -> Optional[List[str]]: |
|
|
|
def get_selected_outpoints(self) -> List[str]: |
|
|
|
if not self.model(): |
|
|
|
if not self.model(): |
|
|
|
return None |
|
|
|
return [] |
|
|
|
items = self.selected_in_column(self.Columns.OUTPOINT) |
|
|
|
items = self.selected_in_column(self.Columns.OUTPOINT) |
|
|
|
return [x.data(self.ROLE_PREVOUT_STR) for x in items] |
|
|
|
return [x.data(self.ROLE_PREVOUT_STR) for x in items] |
|
|
|
|
|
|
|
|
|
|
|
@ -172,6 +177,17 @@ class UTXOList(MyTreeView): |
|
|
|
self._spend_set.clear() |
|
|
|
self._spend_set.clear() |
|
|
|
self._refresh_coincontrol() |
|
|
|
self._refresh_coincontrol() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_selection_to_coincontrol(self): |
|
|
|
|
|
|
|
if bool(self._spend_set): |
|
|
|
|
|
|
|
self.clear_coincontrol() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
selected = self.get_selected_outpoints() |
|
|
|
|
|
|
|
coins = [self._utxo_dict[name] for name in selected] |
|
|
|
|
|
|
|
if not coins: |
|
|
|
|
|
|
|
self.parent.show_error(_('You need to select coins from the list first.\nUse ctrl+left mouse button to select multiple items')) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
self.add_to_coincontrol(coins) |
|
|
|
|
|
|
|
|
|
|
|
def _refresh_coincontrol(self): |
|
|
|
def _refresh_coincontrol(self): |
|
|
|
self.refresh_all() |
|
|
|
self.refresh_all() |
|
|
|
self.update_coincontrol_bar() |
|
|
|
self.update_coincontrol_bar() |
|
|
|
@ -244,8 +260,6 @@ class UTXOList(MyTreeView): |
|
|
|
|
|
|
|
|
|
|
|
def create_menu(self, position): |
|
|
|
def create_menu(self, position): |
|
|
|
selected = self.get_selected_outpoints() |
|
|
|
selected = self.get_selected_outpoints() |
|
|
|
if selected is None: |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
menu = QMenu() |
|
|
|
menu = QMenu() |
|
|
|
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together |
|
|
|
menu.setSeparatorsCollapsible(True) # consecutive separators are merged together |
|
|
|
coins = [self._utxo_dict[name] for name in selected] |
|
|
|
coins = [self._utxo_dict[name] for name in selected] |
|
|
|
|