Mercurial > hg > Feedworm
diff 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 |
line wrap: on
line diff
--- a/MainWindow.py Thu Apr 29 16:49:45 2010 +0200 +++ b/MainWindow.py Fri Apr 30 06:01:54 2010 +0200 @@ -3,10 +3,11 @@ from DisplayModel import DisplayModel from Feed import Feed from FeedEntry import FeedEntry -import FeedUpdater from PyQt4 import QtGui from PyQt4.QtCore import QUrl +from PyQt4.QtGui import QFont from Ui_MainWindow import Ui_MainWindow +import FeedUpdater class MainWindow(QtGui.QMainWindow): def __init__(self, session=None): @@ -15,16 +16,23 @@ self.ui = Ui_MainWindow() self.ui.setupUi(self) self.updateFeedList() + self.initFeedEntryList() - def updateFeedList(self): + def updateFeedList(self): self.allFeeds = Feed.all(self.session) feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) self.ui.feedList.setModel(feedModel) self.ui.feedList.update() + def initFeedEntryList(self): + pass +# self.ui.feedEntryList.setItemDelegate() + # self.ui.feedList.setItemDelegate(CustomItemDelegate(self)) + def feedSelected(self, index): self.selectedFeed = self.allFeeds[index.row()] - model = DisplayModel(self, self.selectedFeed.entries, FeedEntry.userPresentableString) + sortedEntries = self.selectedFeed.entriesSortedByUpdateDate() + model = DisplayModel(self, sortedEntries, FeedEntry.userPresentableString) self.ui.feedEntryList.setModel(model) self.ui.feedEntryList.update() @@ -42,3 +50,12 @@ FeedUpdater.createNewFeed(url, self.session) # TODO get status from feedUpdater and display in status area of the main window self.updateFeedList() + +class CustomItemDelegate(QtGui.QStyledItemDelegate): + def __init__(self, parent): + print("init") + QtGui.QStyledItemDelegate.__init__(self, parent) + + def paint(self, painter, style, index): + style.font.setWeight(QFont.Bold) + QtGui.QStyledItemDelegate.paint(self, painter, style, index)