Implement #2325 ('Fetch All News Now' Option)

This commit is contained in:
Kovid Goyal 2009-04-23 21:31:18 -07:00
parent 075f59b8d1
commit 94c66a4eb9
2 changed files with 137 additions and 116 deletions

View File

@ -131,6 +131,10 @@ class RecipeModel(QAbstractItemModel, SearchQueryParser):
self.categories = sorted(self.category_map.keys(), cmp=self.sort_categories) self.categories = sorted(self.category_map.keys(), cmp=self.sort_categories)
self._map = dict(self.category_map) self._map = dict(self.category_map)
def scheduled_recipes(self):
for recipe in self.category_map[_('Scheduled')]:
yield recipe
def sort_categories(self, x, y): def sort_categories(self, x, y):
def decorate(x): def decorate(x):
@ -305,6 +309,8 @@ class SchedulerDialog(QDialog, Ui_Dialog):
self.connect(button, SIGNAL('toggled(bool)'), self.do_schedule) self.connect(button, SIGNAL('toggled(bool)'), self.do_schedule)
self.connect(self.search, SIGNAL('search(PyQt_PyObject)'), self._model.search) self.connect(self.search, SIGNAL('search(PyQt_PyObject)'), self._model.search)
self.connect(self._model, SIGNAL('modelReset()'), lambda : self.detail_box.setVisible(False)) self.connect(self._model, SIGNAL('modelReset()'), lambda : self.detail_box.setVisible(False))
self.connect(self.download_all_button, SIGNAL('clicked()'),
self.download_all)
self.connect(self.download, SIGNAL('clicked()'), self.download_now) self.connect(self.download, SIGNAL('clicked()'), self.download_now)
self.search.setFocus(Qt.OtherFocusReason) self.search.setFocus(Qt.OtherFocusReason)
self.old_news.setValue(gconf['oldest_news']) self.old_news.setValue(gconf['oldest_news'])
@ -317,6 +323,10 @@ class SchedulerDialog(QDialog, Ui_Dialog):
if current.parent().isValid(): if current.parent().isValid():
self.show_recipe(current) self.show_recipe(current)
def download_all(self, *args):
for recipe in self._model.scheduled_recipes():
self.emit(SIGNAL('download_now(PyQt_PyObject)'), recipe)
def download_now(self): def download_now(self):
recipe = self._model.data(self.recipes.currentIndex(), Qt.UserRole) recipe = self._model.data(self.recipes.currentIndex(), Qt.UserRole)
self.emit(SIGNAL('download_now(PyQt_PyObject)'), recipe) self.emit(SIGNAL('download_now(PyQt_PyObject)'), recipe)

View File

@ -1,7 +1,8 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class> <class>Dialog</class>
<widget class="QDialog" name="Dialog" > <widget class="QDialog" name="Dialog">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -9,42 +10,52 @@
<height>575</height> <height>575</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Schedule news download</string> <string>Schedule news download</string>
</property> </property>
<property name="windowIcon" > <property name="windowIcon">
<iconset resource="../images.qrc" > <iconset resource="../images.qrc">
<normaloff>:/images/scheduler.svg</normaloff>:/images/scheduler.svg</iconset> <normaloff>:/images/scheduler.svg</normaloff>:/images/scheduler.svg</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout" > <layout class="QGridLayout" name="gridLayout">
<item rowspan="3" row="0" column="0" > <item row="0" column="0" rowspan="3">
<widget class="QGroupBox" name="recipe_box" > <widget class="QGroupBox" name="recipe_box">
<property name="title" > <property name="title">
<string>Recipes</string> <string>Recipes</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTreeView" name="recipes" > <widget class="QTreeView" name="recipes">
<property name="showDropIndicator" stdset="0" > <property name="showDropIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="iconSize" > <property name="iconSize">
<size> <size>
<width>16</width> <width>16</width>
<height>16</height> <height>16</height>
</size> </size>
</property> </property>
<property name="animated" > <property name="animated">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="headerHidden" > <property name="headerHidden">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="rnumber" > <widget class="QPushButton" name="download_all_button">
<property name="text" > <property name="toolTip">
<string>Download all scheduled recipes at once</string>
</property>
<property name="text">
<string>Download &amp;all scheduled</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rnumber">
<property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
@ -52,92 +63,92 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3" > <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QScrollArea" name="scrollArea" > <widget class="QScrollArea" name="scrollArea">
<property name="frameShape" > <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="widgetResizable" > <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents" > <widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>381</width>
<height>500</height> <height>500</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5" > <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin" > <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="detail_box" > <widget class="QGroupBox" name="detail_box">
<property name="title" > <property name="title">
<string>Schedule for download</string> <string>Schedule for download</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" > <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QLabel" name="blurb" > <widget class="QLabel" name="blurb">
<property name="text" > <property name="text">
<string>blurb</string> <string>blurb</string>
</property> </property>
<property name="textFormat" > <property name="textFormat">
<enum>Qt::RichText</enum> <enum>Qt::RichText</enum>
</property> </property>
<property name="wordWrap" > <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="openExternalLinks" > <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="schedule" > <widget class="QCheckBox" name="schedule">
<property name="text" > <property name="text">
<string>&amp;Schedule for download:</string> <string>&amp;Schedule for download:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" native="1" name="widget" > <widget class="QWidget" name="widget" native="true">
<property name="enabled" > <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2" > <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2" > <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QRadioButton" name="daily_button" > <widget class="QRadioButton" name="daily_button">
<property name="text" > <property name="text">
<string>Every </string> <string>Every </string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="day" /> <widget class="QComboBox" name="day"/>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4">
<property name="text" > <property name="text">
<string>at</string> <string>at</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTimeEdit" name="time" /> <widget class="QTimeEdit" name="time"/>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer" > <spacer name="horizontalSpacer">
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -148,41 +159,41 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout" > <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QRadioButton" name="interval_button" > <widget class="QRadioButton" name="interval_button">
<property name="text" > <property name="text">
<string>Every </string> <string>Every </string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="interval" > <widget class="QDoubleSpinBox" name="interval">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" > <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip" > <property name="toolTip">
<string>Interval at which to download this recipe. A value of zero means that the recipe will be downloaded every hour.</string> <string>Interval at which to download this recipe. A value of zero means that the recipe will be downloaded every hour.</string>
</property> </property>
<property name="suffix" > <property name="suffix">
<string> days</string> <string> days</string>
</property> </property>
<property name="decimals" > <property name="decimals">
<number>1</number> <number>1</number>
</property> </property>
<property name="minimum" > <property name="minimum">
<double>0.000000000000000</double> <double>0.000000000000000</double>
</property> </property>
<property name="maximum" > <property name="maximum">
<double>365.100000000000023</double> <double>365.100000000000023</double>
</property> </property>
<property name="singleStep" > <property name="singleStep">
<double>1.000000000000000</double> <double>1.000000000000000</double>
</property> </property>
<property name="value" > <property name="value">
<double>1.000000000000000</double> <double>1.000000000000000</double>
</property> </property>
</widget> </widget>
@ -193,54 +204,54 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="last_downloaded" > <widget class="QLabel" name="last_downloaded">
<property name="text" > <property name="text">
<string/> <string/>
</property> </property>
<property name="wordWrap" > <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="account" > <widget class="QGroupBox" name="account">
<property name="title" > <property name="title">
<string>&amp;Account</string> <string>&amp;Account</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2" > <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1" > <item row="0" column="1">
<widget class="QLineEdit" name="username" /> <widget class="QLineEdit" name="username"/>
</item> </item>
<item row="0" column="0" > <item row="0" column="0">
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2">
<property name="text" > <property name="text">
<string>&amp;Username:</string> <string>&amp;Username:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>username</cstring> <cstring>username</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0">
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3">
<property name="text" > <property name="text">
<string>&amp;Password:</string> <string>&amp;Password:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>password</cstring> <cstring>password</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="1">
<widget class="QLineEdit" name="password" > <widget class="QLineEdit" name="password">
<property name="echoMode" > <property name="echoMode">
<enum>QLineEdit::Password</enum> <enum>QLineEdit::Password</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="2" column="0">
<widget class="QCheckBox" name="show_password" > <widget class="QCheckBox" name="show_password">
<property name="text" > <property name="text">
<string>&amp;Show password</string> <string>&amp;Show password</string>
</property> </property>
</widget> </widget>
@ -249,18 +260,18 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label" > <widget class="QLabel" name="label">
<property name="text" > <property name="text">
<string>For the scheduling to work, you must leave calibre running.</string> <string>For the scheduling to work, you must leave calibre running.</string>
</property> </property>
<property name="wordWrap" > <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="download" > <widget class="QPushButton" name="download">
<property name="text" > <property name="text">
<string>&amp;Download now</string> <string>&amp;Download now</string>
</property> </property>
</widget> </widget>
@ -274,28 +285,28 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="1" > <item row="2" column="1">
<widget class="QDialogButtonBox" name="buttonBox" > <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="1">
<widget class="QSpinBox" name="old_news" > <widget class="QSpinBox" name="old_news">
<property name="toolTip" > <property name="toolTip">
<string>Delete downloaded news older than the specified number of days. Set to zero to disable.</string> <string>Delete downloaded news older than the specified number of days. Set to zero to disable.</string>
</property> </property>
<property name="suffix" > <property name="suffix">
<string> days</string> <string> days</string>
</property> </property>
<property name="prefix" > <property name="prefix">
<string>Delete downloaded news older than </string> <string>Delete downloaded news older than </string>
</property> </property>
<property name="maximum" > <property name="maximum">
<number>1000</number> <number>1000</number>
</property> </property>
</widget> </widget>
@ -303,7 +314,7 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../images.qrc" /> <include location="../images.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
@ -312,11 +323,11 @@
<receiver>Dialog</receiver> <receiver>Dialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>613</x> <x>613</x>
<y>824</y> <y>824</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>157</x> <x>157</x>
<y>274</y> <y>274</y>
</hint> </hint>
@ -328,11 +339,11 @@
<receiver>Dialog</receiver> <receiver>Dialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>681</x> <x>681</x>
<y>824</y> <y>824</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>286</x> <x>286</x>
<y>274</y> <y>274</y>
</hint> </hint>
@ -344,11 +355,11 @@
<receiver>widget</receiver> <receiver>widget</receiver>
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>454</x> <x>454</x>
<y>147</y> <y>147</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>461</x> <x>461</x>
<y>168</y> <y>168</y>
</hint> </hint>
@ -360,11 +371,11 @@
<receiver>widget</receiver> <receiver>widget</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>458</x> <x>458</x>
<y>137</y> <y>137</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>461</x> <x>461</x>
<y>169</y> <y>169</y>
</hint> </hint>
@ -376,11 +387,11 @@
<receiver>day</receiver> <receiver>day</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>421</x> <x>421</x>
<y>186</y> <y>186</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>500</x> <x>500</x>
<y>184</y> <y>184</y>
</hint> </hint>
@ -392,11 +403,11 @@
<receiver>time</receiver> <receiver>time</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>442</x> <x>442</x>
<y>193</y> <y>193</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>603</x> <x>603</x>
<y>183</y> <y>183</y>
</hint> </hint>
@ -408,11 +419,11 @@
<receiver>interval</receiver> <receiver>interval</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>428</x> <x>428</x>
<y>213</y> <y>213</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>495</x> <x>495</x>
<y>218</y> <y>218</y>
</hint> </hint>