Mercurial > hg > Feedworm
comparison MainWindow.py @ 31:5bb57caa8f66
display a feed's entries sorted by their update date
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 30 Apr 2010 06:01:54 +0200 |
parents | bdd1296a4b8c |
children | f371d02fa09d |
comparison
equal
deleted
inserted
replaced
30:ee1432a91141 | 31:5bb57caa8f66 |
---|---|
1 | 1 |
2 from AddFeed import AddFeed | 2 from AddFeed import AddFeed |
3 from DisplayModel import DisplayModel | 3 from DisplayModel import DisplayModel |
4 from Feed import Feed | 4 from Feed import Feed |
5 from FeedEntry import FeedEntry | 5 from FeedEntry import FeedEntry |
6 import FeedUpdater | |
7 from PyQt4 import QtGui | 6 from PyQt4 import QtGui |
8 from PyQt4.QtCore import QUrl | 7 from PyQt4.QtCore import QUrl |
8 from PyQt4.QtGui import QFont | |
9 from Ui_MainWindow import Ui_MainWindow | 9 from Ui_MainWindow import Ui_MainWindow |
10 import FeedUpdater | |
10 | 11 |
11 class MainWindow(QtGui.QMainWindow): | 12 class MainWindow(QtGui.QMainWindow): |
12 def __init__(self, session=None): | 13 def __init__(self, session=None): |
13 QtGui.QWidget.__init__(self, None) | 14 QtGui.QWidget.__init__(self, None) |
14 self.session = session | 15 self.session = session |
15 self.ui = Ui_MainWindow() | 16 self.ui = Ui_MainWindow() |
16 self.ui.setupUi(self) | 17 self.ui.setupUi(self) |
17 self.updateFeedList() | 18 self.updateFeedList() |
19 self.initFeedEntryList() | |
18 | 20 |
19 def updateFeedList(self): | 21 def updateFeedList(self): |
20 self.allFeeds = Feed.all(self.session) | 22 self.allFeeds = Feed.all(self.session) |
21 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) | 23 feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) |
22 self.ui.feedList.setModel(feedModel) | 24 self.ui.feedList.setModel(feedModel) |
23 self.ui.feedList.update() | 25 self.ui.feedList.update() |
24 | 26 |
27 def initFeedEntryList(self): | |
28 pass | |
29 # self.ui.feedEntryList.setItemDelegate() | |
30 # self.ui.feedList.setItemDelegate(CustomItemDelegate(self)) | |
31 | |
25 def feedSelected(self, index): | 32 def feedSelected(self, index): |
26 self.selectedFeed = self.allFeeds[index.row()] | 33 self.selectedFeed = self.allFeeds[index.row()] |
27 model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) | 34 sortedEntries = self.selectedFeed.entriesSortedByUpdateDate() |
35 model = DisplayModel(self, sortedEntries, FeedEntry.userPresentableString) | |
28 self.ui.feedEntryList.setModel(model) | 36 self.ui.feedEntryList.setModel(model) |
29 self.ui.feedEntryList.update() | 37 self.ui.feedEntryList.update() |
30 | 38 |
31 def feedEntrySelected(self, index): | 39 def feedEntrySelected(self, index): |
32 row = index.row() | 40 row = index.row() |
40 if success: | 48 if success: |
41 url = addFeed.getUrl() | 49 url = addFeed.getUrl() |
42 FeedUpdater.createNewFeed(url, self.session) | 50 FeedUpdater.createNewFeed(url, self.session) |
43 # TODO get status from feedUpdater and display in status area of the main window | 51 # TODO get status from feedUpdater and display in status area of the main window |
44 self.updateFeedList() | 52 self.updateFeedList() |
53 | |
54 class CustomItemDelegate(QtGui.QStyledItemDelegate): | |
55 def __init__(self, parent): | |
56 print("init") | |
57 QtGui.QStyledItemDelegate.__init__(self, parent) | |
58 | |
59 def paint(self, painter, style, index): | |
60 style.font.setWeight(QFont.Bold) | |
61 QtGui.QStyledItemDelegate.paint(self, painter, style, index) |