# HG changeset patch # User Dirk Olmes # Date 1272510218 -7200 # Node ID c8bb3cee7935cdd6e1bde4650f59cd75eb8ba712 # Parent 0b8398ca6cd07086323046e1f0ba59f25d091861 pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry diff -r 0b8398ca6cd0 -r c8bb3cee7935 DisplayModel.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DisplayModel.py Thu Apr 29 05:03:38 2010 +0200 @@ -0,0 +1,20 @@ + +from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt + +class DisplayModel(QAbstractListModel): + def __init__(self, parent=None, list=None, displayFunction=None, **args): + QAbstractListModel.__init__(self, parent, *args) + self.list = list + self.displayFunction = displayFunction + + def rowCount(self, parent=QModelIndex()): + return len(self.list) + + def data(self, index, role): + if index.isValid() and role == Qt.DisplayRole: + row = index.row() + object = self.list[row] + displayString = self.displayFunction(object) + return QVariant(displayString) + else: + return QVariant() diff -r 0b8398ca6cd0 -r c8bb3cee7935 MainWindowController.py --- a/MainWindowController.py Wed Apr 28 04:00:56 2010 +0200 +++ b/MainWindowController.py Thu Apr 29 05:03:38 2010 +0200 @@ -1,8 +1,9 @@ +from DisplayModel import DisplayModel from Feed import Feed from FeedEntry import FeedEntry from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt, QUrl +from PyQt4.QtCore import QUrl from Ui_MainWindow import Ui_MainWindow class MainWindowController(QtGui.QMainWindow): @@ -14,9 +15,13 @@ self.setupWidgets() def setupWidgets(self): + self.setupAddFeedMenuEntry() self.setupFeedList() self.setupFeedEntryList() + def setupAddFeedMenuEntry(self): + self.connect(self.ui.actionAdd, QtCore.SIGNAL("activated(int)"), self.addFeed) + def setupFeedList(self): self.allFeeds = Feed.all(self.session) feedModel = DisplayModel(self, self.allFeeds, Feed.userPresentableString) @@ -37,21 +42,6 @@ entry = self.selectedFeed.entries[row] baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one self.ui.webView.setHtml(entry.summary, baseUrl) - -class DisplayModel(QAbstractListModel): - def __init__(self, parent=None, list=None, displayFunction=None, **args): - QAbstractListModel.__init__(self, parent, *args) - self.list = list - self.displayFunction = displayFunction - - def rowCount(self, parent=QModelIndex()): - return len(self.list) - def data(self, index, role): - if index.isValid() and role == Qt.DisplayRole: - row = index.row() - object = self.list[row] - displayString = self.displayFunction(object) - return QVariant(displayString) - else: - return QVariant() + def addFeed(self): + pass \ No newline at end of file