changeset 18:35225588b895

add a list view for displaying feed entries from the selected feed
author Dirk Olmes <dirk@xanthippe.ping.de>
date Wed, 28 Apr 2010 03:46:47 +0200
parents 5fda8bd94fa8
children 6f7003fc6e6d
files FeedEntry.py MainWindowController.py Ui_MainWindow.ui
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/FeedEntry.py	Wed Apr 28 03:37:01 2010 +0200
+++ b/FeedEntry.py	Wed Apr 28 03:46:47 2010 +0200
@@ -12,3 +12,6 @@
 
     def __repr__(self):
         return "<FeedEntry (%d) %s>" % (self.pk, self.link)
+
+    def userPresentableString(self):
+        return self.title
\ No newline at end of file
--- a/MainWindowController.py	Wed Apr 28 03:37:01 2010 +0200
+++ b/MainWindowController.py	Wed Apr 28 03:46:47 2010 +0200
@@ -1,5 +1,6 @@
 
 from Feed import Feed
+from FeedEntry import FeedEntry
 from PyQt4 import QtCore, QtGui
 from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt
 from Ui_MainWindow import Ui_MainWindow
@@ -14,6 +15,7 @@
         
     def setupWidgets(self):
         self.setupFeedList()
+        self.setupFeedEntryList()
         
     def setupFeedList(self):
         self.allFeeds = Feed.all(self.session)
@@ -21,9 +23,14 @@
         self.ui.feedList.setModel(feedModel)
         self.connect(self.ui.feedList, QtCore.SIGNAL("clicked(QModelIndex)"), self.feedSelected)
         
+    def setupFeedEntryList(self):
+        pass
+        
     def feedSelected(self, index):
         feed = self.allFeeds[index.row()]
-        print("feed selected: " + str(feed))
+        model = DisplayModel(self, feed.entries, FeedEntry.userPresentableString)
+        self.ui.feedEntryList.setModel(model)
+        self.ui.feedEntryList.update()
 
 class DisplayModel(QAbstractListModel):
     def __init__(self, parent=None, list=None, displayFunction=None, **args):
--- a/Ui_MainWindow.ui	Wed Apr 28 03:37:01 2010 +0200
+++ b/Ui_MainWindow.ui	Wed Apr 28 03:46:47 2010 +0200
@@ -23,6 +23,22 @@
       <height>551</height>
      </rect>
     </property>
+    <property name="alternatingRowColors">
+     <bool>true</bool>
+    </property>
+    <property name="resizeMode">
+     <enum>QListView::Fixed</enum>
+    </property>
+   </widget>
+   <widget class="QListView" name="feedEntryList">
+    <property name="geometry">
+     <rect>
+      <x>230</x>
+      <y>0</y>
+      <width>571</width>
+      <height>111</height>
+     </rect>
+    </property>
    </widget>
   </widget>
   <widget class="QMenuBar" name="menubar">