changeset 105:d372b3ee7bd8

add marking the entire current selection as read
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 07 Mar 2011 07:08:12 +0100
parents 4f87be5399ff
children 2ab09e7a3691
files MainWindow.py Ui_MainWindow.ui
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MainWindow.py	Sat Mar 05 03:40:35 2011 +0100
+++ b/MainWindow.py	Mon Mar 07 07:08:12 2011 +0100
@@ -127,6 +127,21 @@
         self.session.commit()
         self.ui.feedEntryList.doItemsLayout()
 
+    def markSelectedEntriesRead(self):
+        selectedIndexes = self.ui.feedEntryList.selectedIndexes()
+        for index in selectedIndexes:
+            # selectedIndexes returns one QModelIndex instance per row/column combo.
+            # We are only interested in the rows here so just operate on the first
+            # column
+            if index.column() == 0:
+                row = index.row()
+                # use selectedEntry here to ensure it has a valid state after all
+                # selected entries are marked read
+                self.selectedEntry = self.feedEntries[row]
+                self.selectedEntry.toggleRead()
+        self.session.commit()
+        self.ui.feedEntryList.doItemsLayout()
+
     def addFeed(self):
         addFeed = AddFeed(self.session)
         success = addFeed.exec_()
--- a/Ui_MainWindow.ui	Sat Mar 05 03:40:35 2011 +0100
+++ b/Ui_MainWindow.ui	Mon Mar 07 07:08:12 2011 +0100
@@ -79,6 +79,7 @@
      <string>Feed</string>
     </property>
     <addaction name="actionAddFeed"/>
+    <addaction name="actionMarkSelectedEntriesRead"/>
     <addaction name="actionMarkFeedRead"/>
     <addaction name="actionUpdate"/>
     <addaction name="actionDeleteFeed"/>
@@ -220,6 +221,14 @@
     <string>Delete</string>
    </property>
   </action>
+  <action name="actionMarkSelectedEntriesRead">
+   <property name="enabled">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Mark selected read</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>
@@ -424,6 +433,22 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>actionMarkSelectedEntriesRead</sender>
+   <signal>activated()</signal>
+   <receiver>MainWindow</receiver>
+   <slot>markSelectedEntriesRead()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>495</x>
+     <y>374</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>addFeed()</slot>
@@ -437,5 +462,6 @@
   <slot>markSelectedFeedRead()</slot>
   <slot>deleteFeed()</slot>
   <slot>feedEntryDoubleClicked()</slot>
+  <slot>markSelectedEntriesRead()</slot>
  </slots>
 </ui>