Skip to content

Commit

Permalink
Merge pull request #4540 from xoriole/show-torrent-updated
Browse files Browse the repository at this point in the history
Added torrent updated field in channel torrents
  • Loading branch information
ichorid authored Jun 7, 2019
2 parents bef8bfb + 724bd65 commit a49319d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def to_simple_dict(self, include_trackers=False):
"""
Return a basic dictionary with information about the channel.
"""
epoch = datetime.utcfromtimestamp(0)
simple_dict = {
"id": self.rowid,
"name": self.title,
Expand All @@ -231,6 +232,7 @@ def to_simple_dict(self, include_trackers=False):
"num_seeders": self.health.seeders,
"num_leechers": self.health.leechers,
"last_tracker_check": self.health.last_check,
"updated": int((self.torrent_date - epoch).total_seconds()),
"status": self.status
}

Expand Down
2 changes: 2 additions & 0 deletions TriblerGUI/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@
% (COLOR_GREEN, COLOR_RED, COLOR_NEUTRAL, COLOR_SELECTED)

CONTEXT_MENU_WIDTH = 200

BITTORRENT_BIRTHDAY = 994032000
8 changes: 6 additions & 2 deletions TriblerGUI/widgets/lazytableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def resizeEvent(self, _):
self.setColumnWidth(0, 20)
self.setColumnWidth(1, 100)
self.setColumnWidth(2, 100)
self.setColumnWidth(3, self.width() - 500) # Few pixels offset so the horizontal scrollbar does not appear
self.setColumnWidth(3, self.width() - 600) # Few pixels offset so the horizontal scrollbar does not appear
self.setColumnWidth(4, 100)
self.setColumnWidth(5, 100)
self.setColumnWidth(6, 100)
Expand Down Expand Up @@ -240,13 +240,17 @@ def resizeEvent(self, _):
if not self.isColumnHidden(4):
self.setColumnWidth(4, 100)
fixed_column_widths += 100
if not self.isColumnHidden(5):
self.setColumnWidth(5, 100)
fixed_column_widths += 100
self.setColumnWidth(1, self.width() - fixed_column_widths)
else:
self.setColumnWidth(0, 100)
self.setColumnWidth(2, 100)
self.setColumnWidth(3, 100)
self.setColumnWidth(4, 100)
self.setColumnWidth(1, self.width() - 404) # Few pixels offset so the horizontal scrollbar does not appear
self.setColumnWidth(5, 100)
self.setColumnWidth(1, self.width() - 504) # Few pixels offset so the horizontal scrollbar does not appear


class ChannelsTableView(ItemClickedMixin, SubscribeButtonMixin,
Expand Down
12 changes: 6 additions & 6 deletions TriblerGUI/widgets/searchresultspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def initialize_search_results_page(self, gui_settings):
self.window().search_details_container.details_tab_widget.initialize_details_widget()
self.window().core_manager.events_manager.node_info_updated.connect(self.model.update_node_info)

self.set_columns_visibility([u'health'], True)
self.set_columns_visibility([u'torrents', u'updated'], False)
self.set_columns_visibility([u'health', u'updated'], True)
self.set_columns_visibility([u'torrents'], False)

def perform_search(self, query):
self.query = query
Expand All @@ -56,15 +56,15 @@ def clicked_tab_button(self, _):
if self.window().search_results_tab.get_selected_index() == 0:
self.model.type_filter = ''
self.set_columns_visibility([u'votes', u'category', u'health'], True)
self.set_columns_visibility([u'torrents', u'updated'], False)
self.set_columns_visibility([u'torrents'], False)
elif self.window().search_results_tab.get_selected_index() == 1:
self.model.type_filter = 'channel'
self.set_columns_visibility([u'votes', u'torrents', u'updated'], True)
self.set_columns_visibility([u'votes', u'torrents'], True)
self.set_columns_visibility([u'size', u'category', u'health'], False)
elif self.window().search_results_tab.get_selected_index() == 2:
self.model.type_filter = 'torrent'
self.set_columns_visibility([u'votes', u'torrents', u'updated'], False)
self.set_columns_visibility([u'size', u'category', u'health'], True)
self.set_columns_visibility([u'votes', u'torrents'], False)
self.set_columns_visibility([u'size', u'category', u'health', u'updated'], True)

self.perform_search(self.query)

Expand Down
15 changes: 9 additions & 6 deletions TriblerGUI/widgets/tablecontentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt, pyqtSignal

from TriblerGUI.defs import ACTION_BUTTONS
from TriblerGUI.defs import ACTION_BUTTONS, BITTORRENT_BIRTHDAY
from TriblerGUI.utilities import format_size, format_votes, pretty_date


Expand Down Expand Up @@ -190,7 +190,7 @@ class SearchResultsContentModel(StateTooltipMixin, VotesAlignmentMixin, TriblerC
column_display_filters = {
u'size': lambda data: (format_size(float(data)) if data != '' else ''),
u'votes': format_votes,
u'updated': pretty_date,
u'updated': lambda timestamp: pretty_date(timestamp) if timestamp > BITTORRENT_BIRTHDAY else 'N/A'
}

def __init__(self, **kwargs):
Expand Down Expand Up @@ -226,18 +226,20 @@ def __init__(self, subscribed=False, **kwargs):


class TorrentsContentModel(TriblerContentModel):
columns = [u'category', u'name', u'size', u'health', ACTION_BUTTONS]
column_headers = [u'Category', u'Name', u'Size', u'Health', u'']
columns = [u'category', u'name', u'size', u'health', u'updated', ACTION_BUTTONS]
column_headers = [u'Category', u'Name', u'Size', u'Health', u'Updated', u'']
column_flags = {
u'category': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
u'name': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
u'size': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
u'health': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
u'updated': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
ACTION_BUTTONS: Qt.ItemIsEnabled | Qt.ItemIsSelectable
}

column_display_filters = {
u'size': lambda data: format_size(float(data)),
u'updated': lambda timestamp: pretty_date(timestamp) if timestamp > BITTORRENT_BIRTHDAY else 'N/A'
}

def __init__(self, channel_pk=None, channel_id=None, **kwargs):
Expand All @@ -247,13 +249,14 @@ def __init__(self, channel_pk=None, channel_id=None, **kwargs):


class MyTorrentsContentModel(TorrentsContentModel):
columns = [u'category', u'name', u'size', u'status', ACTION_BUTTONS]
column_headers = [u'Category', u'Name', u'Size', u'', u'']
columns = [u'category', u'name', u'size', u'status', u'updated', ACTION_BUTTONS]
column_headers = [u'Category', u'Name', u'Size', u'', u'Updated', u'']
column_flags = {
u'category': Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable,
u'name': Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable,
u'size': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
u'status': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
u'updated': Qt.ItemIsEnabled | Qt.ItemIsSelectable,
ACTION_BUTTONS: Qt.ItemIsEnabled | Qt.ItemIsSelectable
}

Expand Down

0 comments on commit a49319d

Please sign in to comment.