Mercurial > hg > Feedworm
view MainWindowController.py @ 16:3ffecc709da9
move fetch logic into Feed
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 28 Apr 2010 03:00:11 +0200 |
parents | b1aeb98824c1 |
children | 5fda8bd94fa8 |
line wrap: on
line source
from Feed import Feed from PyQt4 import QtGui from PyQt4.QtCore import QAbstractListModel from PyQt4.QtCore import QModelIndex from PyQt4.QtCore import Qt from PyQt4.QtCore import QVariant from Ui_MainWindow import Ui_MainWindow class MainWindowController(QtGui.QMainWindow): def __init__(self, session=None): QtGui.QWidget.__init__(self, None) self.session = session self.ui = Ui_MainWindow() self.ui.setupUi(self) self.connectWidgets() def connectWidgets(self): feedModel = FeedModel(self) self.ui.feedList.setModel(feedModel) class FeedModel(QAbstractListModel): def __init__(self, parent=None, **args): QAbstractListModel.__init__(self, parent, *args) self.session = parent.session self.allFeeds = Feed.all(parent.session) def rowCount(self, parent=QModelIndex()): return len(self.allFeeds) def data(self, index, role): if index.isValid() and role == Qt.DisplayRole: row = index.row() feed = self.allFeeds[row] return QVariant(feed.title) else: return QVariant()