annotate MainWindowController.py @ 21:c8bb3cee7935

pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 29 Apr 2010 05:03:38 +0200
parents 6f7003fc6e6d
children dcc8abff0694
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
2 from DisplayModel import DisplayModel
15
b1aeb98824c1 Add a list view displaying all feeds
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 14
diff changeset
3 from Feed import Feed
18
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
4 from FeedEntry import FeedEntry
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
5 from PyQt4 import QtCore, QtGui
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
6 from PyQt4.QtCore import QUrl
14
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 from Ui_MainWindow import Ui_MainWindow
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 class MainWindowController(QtGui.QMainWindow):
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 def __init__(self, session=None):
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 QtGui.QWidget.__init__(self, None)
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 self.session = session
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 self.ui = Ui_MainWindow()
42a225be7e56 first version of the GUI
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 self.ui.setupUi(self)
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
15 self.setupWidgets()
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
16
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
17 def setupWidgets(self):
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
18 self.setupAddFeedMenuEntry()
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
19 self.setupFeedList()
18
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
20 self.setupFeedEntryList()
15
b1aeb98824c1 Add a list view displaying all feeds
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 14
diff changeset
21
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
22 def setupAddFeedMenuEntry(self):
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
23 self.connect(self.ui.actionAdd, QtCore.SIGNAL("activated(int)"), self.addFeed)
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
24
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
25 def setupFeedList(self):
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
26 self.allFeeds = Feed.all(self.session)
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
27 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString)
15
b1aeb98824c1 Add a list view displaying all feeds
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 14
diff changeset
28 self.ui.feedList.setModel(feedModel)
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
29 self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected)
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
30
18
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
31 def setupFeedEntryList(self):
19
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
32 self.connect(self.ui.feedEntryList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedEntrySelected)
18
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
33
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
34 def feedSelected(self, index):
19
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
35 self.selectedFeed = self.allFeeds[index.row()]
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
36 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString)
18
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
37 self.ui.feedEntryList.setModel(model)
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
38 self.ui.feedEntryList.update()
19
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
39
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
40 def feedEntrySelected(self, index):
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
41 row = index.row()
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
42 entry = self.selectedFeed.entries[row]
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
43 baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one
6f7003fc6e6d display the summary of the selected feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
44 self.ui.webView.setHtml(entry.summary, baseUrl)
15
b1aeb98824c1 Add a list view displaying all feeds
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 14
diff changeset
45
21
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
46 def addFeed(self):
c8bb3cee7935 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
47 pass