Ticket #229: deluge_patch4

File deluge_patch4, 4.1 KB (added by Lajnold, 15 years ago)

Patch for adding an "Added" column to the torrent view.

Line 
1Index: deluge/core/core.py
2===================================================================
3--- deluge/core/core.py (revision 4141)
4+++ deluge/core/core.py (working copy)
5@@ -68,7 +68,7 @@ STATUS_KEYS = ['active_time', 'compact', 'distribu
6     'move_on_completed_path', 'name', 'next_announce', 'num_files', 'num_peers', 'num_pieces',
7     'num_seeds', 'paused', 'peers', 'piece_length', 'prioritize_first_last', 'private', 'progress',
8     'queue', 'ratio', 'remove_at_ratio', 'save_path', 'seed_rank', 'seeding_time', 'state', 'stop_at_ratio',
9-    'stop_ratio', 'total_done', 'total_payload_download', 'total_payload_upload', 'total_peers',
10+    'stop_ratio', 'time_added', 'total_done', 'total_payload_download', 'total_payload_upload', 'total_peers',
11     'total_seeds', 'total_size', 'total_uploaded', 'total_wanted', 'tracker', 'tracker_host',
12     'tracker_status', 'trackers', 'upload_payload_rate']
13 
14Index: deluge/core/torrentmanager.py
15===================================================================
16--- deluge/core/torrentmanager.py       (revision 4141)
17+++ deluge/core/torrentmanager.py       (working copy)
18@@ -538,7 +538,8 @@ class TorrentManager(component.Component):
19                 torrent.options["stop_ratio"],
20                 torrent.options["stop_at_ratio"],
21                 torrent.options["remove_at_ratio"],
22-                torrent.magnet
23+                torrent.magnet,
24+                torrent.time_added
25             )
26             state.torrents.append(torrent_state)
27         
28Index: deluge/core/torrent.py
29===================================================================
30--- deluge/core/torrent.py      (revision 4141)
31+++ deluge/core/torrent.py      (working copy)
32@@ -34,6 +34,7 @@
33 """Internal Torrent class"""
34 
35 import os
36+import time
37 from urlparse import urlparse
38 
39 try:
40@@ -198,6 +199,11 @@ class Torrent:
41         # The tracker status
42         self.tracker_status = ""
43 
44+        if state:
45+            self.time_added = state.time_added
46+        else:
47+            self.time_added = time.time()
48+
49         log.debug("Torrent object created.")
50 
51     ## Options methods ##
52@@ -566,7 +572,8 @@ class Torrent:
53             "stop_at_ratio": self.options["stop_at_ratio"],
54             "remove_at_ratio": self.options["remove_at_ratio"],
55             "move_on_completed": self.options["move_completed"],
56-            "move_on_completed_path": self.options["move_completed_path"]
57+            "move_on_completed_path": self.options["move_completed_path"],
58+            "time_added": self.time_added
59         }
60 
61         def ti_name():
62Index: deluge/ui/gtkui/torrentview.py
63===================================================================
64--- deluge/ui/gtkui/torrentview.py      (revision 4141)
65+++ deluge/ui/gtkui/torrentview.py      (working copy)
66@@ -180,6 +180,10 @@ class TorrentView(listview.ListView, component.Com
67                                             listview.cell_data_ratio,
68                                             [float],
69                                             status_field=["distributed_copies"])
70+        self.add_func_column(_("Added"),
71+                                            listview.cell_data_date,
72+                                            [float],
73+                                            status_field=["time_added"])
74         self.add_text_column(_("Tracker"), status_field=["tracker_host"])
75 
76         # Set filter to None for now
77Index: deluge/ui/gtkui/listview.py
78===================================================================
79--- deluge/ui/gtkui/listview.py (revision 4141)
80+++ deluge/ui/gtkui/listview.py (working copy)
81@@ -34,6 +34,7 @@
82 
83 import cPickle
84 import os.path
85+import time
86 
87 import pygtk
88 pygtk.require('2.0')
89@@ -88,6 +89,12 @@ def cell_data_ratio(column, cell, model, row, data
90 
91     cell.set_property('text', ratio_str)
92 
93+def cell_data_date(column, cell, model, row, data):
94+    """Display value as date, eg 2008/05/05"""
95+    time_val = model.get_value(row, data)
96+    time_str = time.strftime("%Y/%m/%d", time.localtime(time_val))
97+    cell.set_property('text', time_str)
98+
99 class ListViewColumnState:
100     """Used for saving/loading column state"""
101     def __init__(self, name, position, width, visible, sort, sort_order):