Skip to content

Commit

Permalink
Merge branch 'release-7.7' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Jan 10, 2021
2 parents 4999bfc + 904a7b8 commit 88e9490
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/tribler-gui/tribler_gui/dialogs/startdownloaddialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def on_received_metainfo(self, response):

self.received_metainfo.emit(metainfo)

def on_reload_torrent_info(self):
def on_reload_torrent_info(self, *args):
"""
This method is called when user clicks the QLabel text showing loading or error message. Here, we reset
the number of retries to fetch the metainfo. Note color of QLabel is also reset to white.
Expand Down
17 changes: 9 additions & 8 deletions src/tribler-gui/tribler_gui/widgets/downloadsdetailstabwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, parent):
QTabWidget.__init__(self, parent)
self.current_download = None
self.files_widgets = {} # dict of file name -> widget
self.selected_files_info = []

def initialize_details_widget(self):
connect(self.window().download_files_list.customContextMenuRequested, self.on_right_click_file_item)
Expand Down Expand Up @@ -152,15 +153,15 @@ def on_right_click_file_item(self, pos):
return

item_infos = [] # Array of (item, included, is_selected)
selected_files_info = []
self.selected_files_info = []

for i in range(self.window().download_files_list.topLevelItemCount()):
item = self.window().download_files_list.topLevelItem(i)
is_selected = item in self.window().download_files_list.selectedItems()
item_infos.append((item, item.file_info["included"], is_selected))

if is_selected:
selected_files_info.append(item.file_info)
self.selected_files_info.append(item.file_info)

item_clicked = self.window().download_files_list.itemAt(pos)
if not item_clicked or not item_clicked in self.window().download_files_list.selectedItems():
Expand All @@ -180,9 +181,9 @@ def on_right_click_file_item(self, pos):
include_action = QAction('Include file' + ('(s)' if num_selected > 1 else ''), self)
exclude_action = QAction('Exclude file' + ('(s)' if num_selected > 1 else ''), self)

connect(include_action.triggered, lambda: self.on_files_included(selected_files_info))
connect(include_action.triggered, self.on_files_included)
include_action.setEnabled(True)
connect(exclude_action.triggered, lambda: self.on_files_excluded(selected_files_info))
connect(exclude_action.triggered, self.on_files_excluded)
exclude_action.setEnabled(not (num_excludes + num_includes_selected == len(item_infos)))

menu.addAction(include_action)
Expand All @@ -193,17 +194,17 @@ def on_right_click_file_item(self, pos):
def get_included_file_list(self):
return [file_info["index"] for file_info in self.current_download["files"] if file_info["included"]]

def on_files_included(self, files_data):
def on_files_included(self, *args):
included_list = self.get_included_file_list()
for file_data in files_data:
for file_data in self.selected_files_info:
if not file_data["index"] in included_list:
included_list.append(file_data["index"])

self.set_included_files(included_list)

def on_files_excluded(self, files_data):
def on_files_excluded(self, *args):
included_list = self.get_included_file_list()
for file_data in files_data:
for file_data in self.selected_files_info:
if file_data["index"] in included_list:
included_list.remove(file_data["index"])

Expand Down
9 changes: 7 additions & 2 deletions src/tribler-gui/tribler_gui/widgets/tablecontentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from tribler_gui.defs import ACTION_BUTTONS, BITTORRENT_BIRTHDAY, COMMIT_STATUS_TODELETE, HEALTH_CHECKING
from tribler_gui.i18n import tr
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import format_size, format_votes, get_votes_rating_description, pretty_date
from tribler_gui.utilities import connect, format_size, format_votes, get_votes_rating_description, pretty_date


def get_item_uid(item):
Expand Down Expand Up @@ -44,7 +44,9 @@ def __init__(self, parent=None):
self.sort_desc = True
self.saved_header_state = None
self.saved_scroll_state = None
self.qt_object_destroyed = False

connect(self.destroyed, self.on_destroy)
# Every remote query must be attributed to its specific model to avoid updating wrong models
# on receiving a result. We achieve this by maintaining a set of in-flight remote queries.
# Note that this only applies to results that are returned through the events notification
Expand All @@ -53,6 +55,9 @@ def __init__(self, parent=None):
# last one. In a sense, the queries' UUIDs play the role of "subscription topics" for the model.
self.remote_queries = set()

def on_destroy(self, *args):
self.qt_object_destroyed = True

def reset(self):
self.beginResetModel()
self.data_items = []
Expand Down Expand Up @@ -192,7 +197,7 @@ def on_query_results(self, response, remote=False, on_top=False):
:return: True, if response, False otherwise
"""
# TODO: count remote results
if not response:
if not response or self.qt_object_destroyed:
return False

# Trigger labels update on the initial table load
Expand Down

0 comments on commit 88e9490

Please sign in to comment.