Mercurial > hg > Feedworm
comparison MainWindowController.py @ 18:35225588b895
add a list view for displaying feed entries from the selected feed
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 28 Apr 2010 03:46:47 +0200 |
parents | 5fda8bd94fa8 |
children | 6f7003fc6e6d |
comparison
equal
deleted
inserted
replaced
17:5fda8bd94fa8 | 18:35225588b895 |
---|---|
1 | 1 |
2 from Feed import Feed | 2 from Feed import Feed |
3 from FeedEntry import FeedEntry | |
3 from PyQt4 import QtCore, QtGui | 4 from PyQt4 import QtCore, QtGui |
4 from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt | 5 from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt |
5 from Ui_MainWindow import Ui_MainWindow | 6 from Ui_MainWindow import Ui_MainWindow |
6 | 7 |
7 class MainWindowController(QtGui.QMainWindow): | 8 class MainWindowController(QtGui.QMainWindow): |
12 self.ui.setupUi(self) | 13 self.ui.setupUi(self) |
13 self.setupWidgets() | 14 self.setupWidgets() |
14 | 15 |
15 def setupWidgets(self): | 16 def setupWidgets(self): |
16 self.setupFeedList() | 17 self.setupFeedList() |
18 self.setupFeedEntryList() | |
17 | 19 |
18 def setupFeedList(self): | 20 def setupFeedList(self): |
19 self.allFeeds = Feed.all(self.session) | 21 self.allFeeds = Feed.all(self.session) |
20 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) | 22 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) |
21 self.ui.feedList.setModel(feedModel) | 23 self.ui.feedList.setModel(feedModel) |
22 self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected) | 24 self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected) |
23 | 25 |
26 def setupFeedEntryList(self): | |
27 pass | |
28 | |
24 def feedSelected(self, index): | 29 def feedSelected(self, index): |
25 feed = self.allFeeds[index.row()] | 30 feed = self.allFeeds[index.row()] |
26 print("feed selected: " + str(feed)) | 31 model = DisplayModel(self, feed.entries, FeedEntry.userPresentableString) |
32 self.ui.feedEntryList.setModel(model) | |
33 self.ui.feedEntryList.update() | |
27 | 34 |
28 class DisplayModel(QAbstractListModel): | 35 class DisplayModel(QAbstractListModel): |
29 def __init__(self, parent=None, list=None, displayFunction=None, **args): | 36 def __init__(self, parent=None, list=None, displayFunction=None, **args): |
30 QAbstractListModel.__init__(self, parent, *args) | 37 QAbstractListModel.__init__(self, parent, *args) |
31 self.list = list | 38 self.list = list |