diff MainWindowController.py @ 21:c8bb3cee7935

pull out DisplayModel into its own file, add the scaffolding for the add feed menu entry
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 29 Apr 2010 05:03:38 +0200
parents 6f7003fc6e6d
children dcc8abff0694
line wrap: on
line diff
--- 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