Mercurial > hg > Feedworm
comparison MainWindow.py @ 27:bdd1296a4b8c
implemented adding a feed
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 29 Apr 2010 06:47:47 +0200 |
parents | 6b5ceffabe49 |
children | 5bb57caa8f66 |
comparison
equal
deleted
inserted
replaced
26:f9a3223182c5 | 27:bdd1296a4b8c |
---|---|
1 | 1 |
2 from AddFeed import AddFeed | |
2 from DisplayModel import DisplayModel | 3 from DisplayModel import DisplayModel |
3 from Feed import Feed | 4 from Feed import Feed |
4 from FeedEntry import FeedEntry | 5 from FeedEntry import FeedEntry |
6 import FeedUpdater | |
5 from PyQt4 import QtGui | 7 from PyQt4 import QtGui |
6 from PyQt4.QtCore import QUrl | 8 from PyQt4.QtCore import QUrl |
7 from Ui_MainWindow import Ui_MainWindow | 9 from Ui_MainWindow import Ui_MainWindow |
8 | 10 |
9 class MainWindow(QtGui.QMainWindow): | 11 class MainWindow(QtGui.QMainWindow): |
10 def __init__(self, session=None): | 12 def __init__(self, session=None): |
11 QtGui.QWidget.__init__(self, None) | 13 QtGui.QWidget.__init__(self, None) |
12 self.session = session | 14 self.session = session |
13 self.ui = Ui_MainWindow() | 15 self.ui = Ui_MainWindow() |
14 self.ui.setupUi(self) | 16 self.ui.setupUi(self) |
15 self.setupFeedList() | 17 self.updateFeedList() |
16 | 18 |
17 def setupFeedList(self): | 19 def updateFeedList(self): |
18 self.allFeeds = Feed.all(self.session) | 20 self.allFeeds = Feed.all(self.session) |
19 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) | 21 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) |
20 self.ui.feedList.setModel(feedModel) | 22 self.ui.feedList.setModel(feedModel) |
21 | 23 self.ui.feedList.update() |
24 | |
22 def feedSelected(self, index): | 25 def feedSelected(self, index): |
23 self.selectedFeed = self.allFeeds[index.row()] | 26 self.selectedFeed = self.allFeeds[index.row()] |
24 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) | 27 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) |
25 self.ui.feedEntryList.setModel(model) | 28 self.ui.feedEntryList.setModel(model) |
26 self.ui.feedEntryList.update() | 29 self.ui.feedEntryList.update() |
30 entry = self.selectedFeed.entries[row] | 33 entry = self.selectedFeed.entries[row] |
31 baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one | 34 baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one |
32 self.ui.webView.setHtml(entry.summary, baseUrl) | 35 self.ui.webView.setHtml(entry.summary, baseUrl) |
33 | 36 |
34 def addFeed(self): | 37 def addFeed(self): |
35 print("Add Feed!") | 38 addFeed = AddFeed(self.session) |
36 | 39 success = addFeed.exec_() |
40 if success: | |
41 url = addFeed.getUrl() | |
42 FeedUpdater.createNewFeed(url, self.session) | |
43 # TODO get status from feedUpdater and display in status area of the main window | |
44 self.updateFeedList() |