Merge lp:~dmascialino/encuentro/save_downloads_list into lp:encuentro

Proposed by Diego Mascialino
Status: Merged
Merged at revision: 180
Proposed branch: lp:~dmascialino/encuentro/save_downloads_list
Merge into: lp:encuentro
Diff against target: 53 lines (+18/-0)
2 files modified
encuentro/ui/central_panel.py (+16/-0)
encuentro/ui/main.py (+2/-0)
To merge this branch: bzr merge lp:~dmascialino/encuentro/save_downloads_list
Reviewer Review Type Date Requested Status
Facundo Batista Pending
Review via email: mp+170991@code.launchpad.net

Description of the change

Now we persist the pending episodes to download.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'encuentro/ui/central_panel.py'
2--- encuentro/ui/central_panel.py 2013-05-15 22:26:46 +0000
3+++ encuentro/ui/central_panel.py 2013-06-23 20:45:31 +0000
4@@ -44,6 +44,7 @@
5 from PyQt4.QtCore import Qt, QSize
6
7 from encuentro import data, image
8+from encuentro.config import config, signal
9 from encuentro.data import Status
10 from encuentro.ui import remembering
11 from encuentro.ui.throbber import Throbber
12@@ -57,6 +58,7 @@
13 def __init__(self, episodes_widget):
14 self.episodes_widget = episodes_widget
15 super(DownloadsWidget, self).__init__('downloads')
16+ signal.register(self.save_state)
17
18 _headers = (u"Descargando...", u"Estado")
19 self.setColumnCount(len(_headers))
20@@ -135,6 +137,20 @@
21 q += 1
22 return q
23
24+ def save_state(self):
25+ p = self.pending()
26+ if p > 0:
27+ config[config.SYSTEM]['pending_ids'] = \
28+ [e.episode_id for e, _ in self.queue[-p:]]
29+
30+ def load_pending(self):
31+ loaded_pending_ids = config[config.SYSTEM].get('pending_ids', [])
32+
33+ for episode_id in loaded_pending_ids:
34+ main_window = self.episodes_widget.main_window
35+ episode = main_window.programs_data[episode_id]
36+ main_window.queue_download(episode)
37+
38
39 class HTMLDelegate(QStyledItemDelegate):
40 """Custom delegate so the QTreeWidget can do HTML.
41
42=== modified file 'encuentro/ui/main.py'
43--- encuentro/ui/main.py 2013-05-14 12:57:43 +0000
44+++ encuentro/ui/main.py 2013-06-23 20:45:31 +0000
45@@ -119,6 +119,8 @@
46 ue = update.UpdateEpisodes(self)
47 ue.background()
48 self.show()
49+
50+ self.episodes_download.load_pending()
51 logger.debug("Main UI started ok")
52
53 def _sanitize_config(self):

Subscribers

People subscribed via source and target branches