Mercurial > hg > Feedworm
comparison MainWindowController.py @ 19:6f7003fc6e6d
display the summary of the selected feed entry
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 28 Apr 2010 04:00:30 +0200 |
parents | 35225588b895 |
children | c8bb3cee7935 |
comparison
equal
deleted
inserted
replaced
18:35225588b895 | 19:6f7003fc6e6d |
---|---|
1 | 1 |
2 from Feed import Feed | 2 from Feed import Feed |
3 from FeedEntry import FeedEntry | 3 from FeedEntry import FeedEntry |
4 from PyQt4 import QtCore, QtGui | 4 from PyQt4 import QtCore, QtGui |
5 from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt | 5 from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt, QUrl |
6 from Ui_MainWindow import Ui_MainWindow | 6 from Ui_MainWindow import Ui_MainWindow |
7 | 7 |
8 class MainWindowController(QtGui.QMainWindow): | 8 class MainWindowController(QtGui.QMainWindow): |
9 def __init__(self, session=None): | 9 def __init__(self, session=None): |
10 QtGui.QWidget.__init__(self, None) | 10 QtGui.QWidget.__init__(self, None) |
22 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) | 22 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) |
23 self.ui.feedList.setModel(feedModel) | 23 self.ui.feedList.setModel(feedModel) |
24 self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected) | 24 self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected) |
25 | 25 |
26 def setupFeedEntryList(self): | 26 def setupFeedEntryList(self): |
27 pass | 27 self.connect(self.ui.feedEntryList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedEntrySelected) |
28 | 28 |
29 def feedSelected(self, index): | 29 def feedSelected(self, index): |
30 feed = self.allFeeds[index.row()] | 30 self.selectedFeed = self.allFeeds[index.row()] |
31 model = DisplayModel(self, feed.entries, FeedEntry.userPresentableString) | 31 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) |
32 self.ui.feedEntryList.setModel(model) | 32 self.ui.feedEntryList.setModel(model) |
33 self.ui.feedEntryList.update() | 33 self.ui.feedEntryList.update() |
34 | |
35 def feedEntrySelected(self, index): | |
36 row = index.row() | |
37 entry = self.selectedFeed.entries[row] | |
38 baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one | |
39 self.ui.webView.setHtml(entry.summary, baseUrl) | |
34 | 40 |
35 class DisplayModel(QAbstractListModel): | 41 class DisplayModel(QAbstractListModel): |
36 def __init__(self, parent=None, list=None, displayFunction=None, **args): | 42 def __init__(self, parent=None, list=None, displayFunction=None, **args): |
37 QAbstractListModel.__init__(self, parent, *args) | 43 QAbstractListModel.__init__(self, parent, *args) |
38 self.list = list | 44 self.list = list |