Mercurial > hg > Feedworm
comparison MainWindowController.py @ 23:dcc8abff0694
All the wiring of slots is done through QtDesigner now, look how much code has just disappeared :-)
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 29 Apr 2010 05:41:52 +0200 |
parents | c8bb3cee7935 |
children |
comparison
equal
deleted
inserted
replaced
22:cb9d8da0f307 | 23:dcc8abff0694 |
---|---|
1 | 1 |
2 from DisplayModel import DisplayModel | 2 from DisplayModel import DisplayModel |
3 from Feed import Feed | 3 from Feed import Feed |
4 from FeedEntry import FeedEntry | 4 from FeedEntry import FeedEntry |
5 from PyQt4 import QtCore, QtGui | 5 from PyQt4 import QtGui |
6 from PyQt4.QtCore import QUrl | 6 from PyQt4.QtCore import QUrl |
7 from Ui_MainWindow import Ui_MainWindow | 7 from Ui_MainWindow import Ui_MainWindow |
8 | 8 |
9 class MainWindowController(QtGui.QMainWindow): | 9 class MainWindowController(QtGui.QMainWindow): |
10 def __init__(self, session=None): | 10 def __init__(self, session=None): |
11 QtGui.QWidget.__init__(self, None) | 11 QtGui.QWidget.__init__(self, None) |
12 self.session = session | 12 self.session = session |
13 self.ui = Ui_MainWindow() | 13 self.ui = Ui_MainWindow() |
14 self.ui.setupUi(self) | 14 self.ui.setupUi(self) |
15 self.setupWidgets() | 15 self.setupFeedList() |
16 | 16 |
17 def setupWidgets(self): | |
18 self.setupAddFeedMenuEntry() | |
19 self.setupFeedList() | |
20 self.setupFeedEntryList() | |
21 | |
22 def setupAddFeedMenuEntry(self): | |
23 self.connect(self.ui.actionAdd, QtCore.SIGNAL("activated(int)"), self.addFeed) | |
24 | |
25 def setupFeedList(self): | 17 def setupFeedList(self): |
26 self.allFeeds = Feed.all(self.session) | 18 self.allFeeds = Feed.all(self.session) |
27 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) | 19 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) |
28 self.ui.feedList.setModel(feedModel) | 20 self.ui.feedList.setModel(feedModel) |
29 self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected) | |
30 | |
31 def setupFeedEntryList(self): | |
32 self.connect(self.ui.feedEntryList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedEntrySelected) | |
33 | 21 |
34 def feedSelected(self, index): | 22 def feedSelected(self, index): |
35 self.selectedFeed = self.allFeeds[index.row()] | 23 self.selectedFeed = self.allFeeds[index.row()] |
36 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) | 24 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) |
37 self.ui.feedEntryList.setModel(model) | 25 self.ui.feedEntryList.setModel(model) |
42 entry = self.selectedFeed.entries[row] | 30 entry = self.selectedFeed.entries[row] |
43 baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one | 31 baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one |
44 self.ui.webView.setHtml(entry.summary, baseUrl) | 32 self.ui.webView.setHtml(entry.summary, baseUrl) |
45 | 33 |
46 def addFeed(self): | 34 def addFeed(self): |
47 pass | 35 print("Add Feed!") |
36 |