Fix #229 add 'date added' column, with patch from Lajnold

This commit is contained in:
Andrew Resch 2008-11-02 04:41:55 +00:00
parent a2a3bd2148
commit e5cbca13dc
7 changed files with 721 additions and 667 deletions

View File

@ -68,7 +68,7 @@ STATUS_KEYS = ['active_time', 'compact', 'distributed_copies', 'download_payload
'move_on_completed_path', 'name', 'next_announce', 'num_files', 'num_peers', 'num_pieces',
'num_seeds', 'paused', 'peers', 'piece_length', 'prioritize_first_last', 'private', 'progress',
'queue', 'ratio', 'remove_at_ratio', 'save_path', 'seed_rank', 'seeding_time', 'state', 'stop_at_ratio',
'stop_ratio', 'total_done', 'total_payload_download', 'total_payload_upload', 'total_peers',
'stop_ratio', 'time_added', 'total_done', 'total_payload_download', 'total_payload_upload', 'total_peers',
'total_seeds', 'total_size', 'total_uploaded', 'total_wanted', 'tracker', 'tracker_host',
'tracker_status', 'trackers', 'upload_payload_rate']

View File

@ -34,6 +34,7 @@
"""Internal Torrent class"""
import os
import time
from urlparse import urlparse
try:
@ -198,6 +199,11 @@ class Torrent:
# The tracker status
self.tracker_status = ""
if state:
self.time_added = state.time_added
else:
self.time_added = time.time()
log.debug("Torrent object created.")
## Options methods ##
@ -566,7 +572,8 @@ class Torrent:
"stop_at_ratio": self.options["stop_at_ratio"],
"remove_at_ratio": self.options["remove_at_ratio"],
"move_on_completed": self.options["move_completed"],
"move_on_completed_path": self.options["move_completed_path"]
"move_on_completed_path": self.options["move_completed_path"],
"time_added": self.time_added
}
def ti_name():

View File

@ -75,7 +75,8 @@ class TorrentState:
stop_ratio=2.00,
stop_at_ratio=False,
remove_at_ratio=False,
magnet=None
magnet=None,
time_added=-1
):
self.torrent_id = torrent_id
self.filename = filename
@ -84,6 +85,7 @@ class TorrentState:
self.queue = queue
self.is_finished = is_finished
self.magnet = magnet
self.time_added = time_added
# Options
self.compact = compact
@ -538,7 +540,8 @@ class TorrentManager(component.Component):
torrent.options["stop_ratio"],
torrent.options["stop_at_ratio"],
torrent.options["remove_at_ratio"],
torrent.magnet
torrent.magnet,
torrent.time_added
)
state.torrents.append(torrent_state)
@ -778,4 +781,3 @@ class TorrentManager(component.Component):
log.debug("on_alert_metadata_received")
torrent = self.torrents[str(alert.handle.info_hash())]
torrent.write_torrentfile()

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,7 @@
import cPickle
import os.path
import time
import pygtk
pygtk.require('2.0')
@ -88,6 +89,14 @@ def cell_data_ratio(column, cell, model, row, data):
cell.set_property('text', ratio_str)
def cell_data_date(column, cell, model, row, data):
"""Display value as date, eg 2008/05/05"""
time_val = model.get_value(row, data)
time_str = ""
if time_val > -1:
time_str = time.strftime("%d/%m/%y", time.localtime(time_val))
cell.set_property('text', time_str)
class ListViewColumnState:
"""Used for saving/loading column state"""
def __init__(self, name, position, width, visible, sort, sort_order):

View File

@ -33,6 +33,7 @@
# statement from all source files in the program, then also delete it here.
import gtk, gtk.glade
import time
from deluge.ui.client import aclient as client
import deluge.component as component
@ -60,6 +61,11 @@ def fspeed(value, max_value=-1):
else:
return deluge.common.fspeed(value)
def fdate(value):
if value < 0:
return ""
return time.strftime("%d/%m/%y", time.localtime(value))
class StatisticsTab(Tab):
def __init__(self):
Tab.__init__(self)
@ -88,7 +94,8 @@ class StatisticsTab(Tab):
(glade.get_widget("summary_seed_time"), deluge.common.ftime, ("seeding_time",)),
(glade.get_widget("summary_seed_rank"), str, ("seed_rank",)),
(glade.get_widget("summary_auto_managed"), str, ("is_auto_managed",)),
(glade.get_widget("progressbar"), fpcnt, ("progress",))
(glade.get_widget("progressbar"), fpcnt, ("progress",)),
(glade.get_widget("summary_date_added"), fdate, ("time_added",))
]
def update(self):
@ -110,7 +117,7 @@ class StatisticsTab(Tab):
"total_seeds", "eta", "ratio", "next_announce",
"tracker_status", "max_connections", "max_upload_slots",
"max_upload_speed", "max_download_speed", "active_time",
"seeding_time", "seed_rank", "is_auto_managed"]
"seeding_time", "seed_rank", "is_auto_managed", "time_added"]
client.get_torrent_status(
self._on_get_torrent_status, selected, status_keys)

View File

@ -180,6 +180,10 @@ class TorrentView(listview.ListView, component.Component):
listview.cell_data_ratio,
[float],
status_field=["distributed_copies"])
self.add_func_column(_("Added"),
listview.cell_data_date,
[float],
status_field=["time_added"])
self.add_text_column(_("Tracker"), status_field=["tracker_host"])
# Set filter to None for now