changeset 72:e8c2730eb444

control the display of unread feeds/all feeds via Preferences
author Dirk Olmes <dirk@xanthippe.ping.de>
date Wed, 11 Aug 2010 03:23:02 +0200
parents 228da10cc98b
children 5585f3d23541
files FeedList.py Preferences.py PreferencesDialog.py Ui_Preferences.ui
diffstat 4 files changed, 57 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/FeedList.py	Wed Aug 11 03:10:32 2010 +0200
+++ b/FeedList.py	Wed Aug 11 03:23:02 2010 +0200
@@ -1,11 +1,15 @@
 
 from Feed import Feed
 from FeedEntry import FeedEntry
+from Preferences import Preferences
 from sqlalchemy.orm import joinedload
 
 def getFeeds(session):
-#    return AllFeeds(session).getFeeds()
-    return UnreadFeeds(session).getFeeds()
+    preferences = Preferences(session)
+    if preferences.showOnlyUnreadFeeds():
+        return UnreadFeeds(session).getFeeds()
+    else:
+        return AllFeeds(session).getFeeds()
 
 class AllFeeds(object):
     '''A simple feed list that returns all feeds stored in the database'''
--- a/Preferences.py	Wed Aug 11 03:10:32 2010 +0200
+++ b/Preferences.py	Wed Aug 11 03:23:02 2010 +0200
@@ -4,6 +4,7 @@
 
 START_MAXIMIZED = "START_MAXIMIZED"
 HIDE_READ_ENTRIES = "HIDE_READ_FEED_ENTRIES"
+SHOW_ONLY_UNREAD_FEEDS = "SHOW_ONLY_UNREAD_FEEDS"
 
 class Preferences(object):
     def __init__(self, session):
@@ -36,3 +37,11 @@
     def setHideReadFeedEntries(self, flag):
         pref = self._cachedPreference(HIDE_READ_ENTRIES)
         pref.value = util.bool2str(flag)
+        
+    def showOnlyUnreadFeeds(self):
+        pref = self._cachedPreference(SHOW_ONLY_UNREAD_FEEDS, False)
+        return util.str2bool(pref.value)
+    
+    def setShowOnlyUnreadFeeds(self, flag):
+        pref = self._cachedPreference(SHOW_ONLY_UNREAD_FEEDS)
+        pref.value = util.bool2str(flag)
--- a/PreferencesDialog.py	Wed Aug 11 03:10:32 2010 +0200
+++ b/PreferencesDialog.py	Wed Aug 11 03:23:02 2010 +0200
@@ -18,6 +18,9 @@
         
         hideRead = self.preferences.hideReadFeedEntries()
         self.ui.hideReadFeedEntries.setChecked(hideRead)
+        
+        showOnlyUnreadFeeds = self.preferences.showOnlyUnreadFeeds()
+        self.ui.showOnlyUnreadFeeds.setChecked(showOnlyUnreadFeeds)
 
     def startMaximizedChanged(self, change):
         if change:
@@ -31,6 +34,12 @@
         else:
             self.preferences.setHideReadFeedEntries(False)
 
+    def showOnlyFeedsWithUnreadEntries(self, change):
+        if change:
+            self.preferences.setShowOnlyUnreadFeeds(True)
+        else:
+            self.preferences.setShowOnlyUnreadFeeds(False)
+
     def accept(self):
         self.session.commit()
         QtGui.QDialog.accept(self)
--- a/Ui_Preferences.ui	Wed Aug 11 03:10:32 2010 +0200
+++ b/Ui_Preferences.ui	Wed Aug 11 03:23:02 2010 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>400</width>
-    <height>300</height>
+    <height>152</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -21,7 +21,7 @@
    <property name="geometry">
     <rect>
      <x>30</x>
-     <y>240</y>
+     <y>110</y>
      <width>341</width>
      <height>32</height>
     </rect>
@@ -50,7 +50,7 @@
    <property name="geometry">
     <rect>
      <x>10</x>
-     <y>40</y>
+     <y>70</y>
      <width>171</width>
      <height>22</height>
     </rect>
@@ -59,6 +59,19 @@
     <string>Hide read feed entries</string>
    </property>
   </widget>
+  <widget class="QCheckBox" name="showOnlyUnreadFeeds">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>40</y>
+     <width>301</width>
+     <height>22</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Show only feeds that have unread entries</string>
+   </property>
+  </widget>
  </widget>
  <resources>
   <include location="Feedworm.qrc"/>
@@ -128,9 +141,26 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>showOnlyUnreadFeeds</sender>
+   <signal>stateChanged(int)</signal>
+   <receiver>Preferences</receiver>
+   <slot>showOnlyFeedsWithUnreadEntries()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>160</x>
+     <y>50</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>199</x>
+     <y>75</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>startMaximizedChanged()</slot>
   <slot>hideReadFeedEntriesChanged()</slot>
+  <slot>showOnlyFeedsWithUnreadEntries()</slot>
  </slots>
 </ui>