# HG changeset patch # User Dirk Olmes # Date 1272416261 -7200 # Node ID b1aeb98824c13496c52cfb47dd5a4a61633aa788 # Parent 42a225be7e56153a76f000bf28dbc9d767b1104b Add a list view displaying all feeds diff -r 42a225be7e56 -r b1aeb98824c1 MainWindowController.py --- a/MainWindowController.py Wed Apr 28 02:36:00 2010 +0200 +++ b/MainWindowController.py Wed Apr 28 02:57:41 2010 +0200 @@ -1,6 +1,11 @@ +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 -from PyQt4 import QtGui class MainWindowController(QtGui.QMainWindow): def __init__(self, session=None): @@ -8,3 +13,28 @@ 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.fetchAllFeeds() + + def fetchAllFeeds(self): + self.allFeeds = self.session.query(Feed).all() + + 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() \ No newline at end of file diff -r 42a225be7e56 -r b1aeb98824c1 Ui_MainWindow.ui --- a/Ui_MainWindow.ui Wed Apr 28 02:36:00 2010 +0200 +++ b/Ui_MainWindow.ui Wed Apr 28 02:57:41 2010 +0200 @@ -13,7 +13,18 @@ Feedworm - + + + + + 0 + 0 + 221 + 551 + + + + @@ -27,6 +38,8 @@ Feed + + @@ -40,6 +53,11 @@ Ctrl+Q + + + Add ... + +