Another PyQt 5.6 compatibility fix

This commit is contained in:
Kovid Goyal 2016-06-19 10:24:21 +05:30
parent 8470b1794d
commit e7dbd513a9
2 changed files with 34 additions and 36 deletions

View File

@ -13,7 +13,8 @@ from collections import OrderedDict
from PyQt5.Qt import (QDialog, Qt, QTime, QObject, QMenu, QHBoxLayout,
QAction, QIcon, QMutex, QTimer, pyqtSignal, QWidget, QGridLayout,
QCheckBox, QTimeEdit, QLabel, QLineEdit, QDoubleSpinBox, QSize)
QCheckBox, QTimeEdit, QLabel, QLineEdit, QDoubleSpinBox, QSize,
QTreeView, QSizePolicy)
from calibre.gui2.dialogs.scheduler_ui import Ui_Dialog
from calibre.gui2 import config as gconf, error_dialog, gprefs
@ -30,6 +31,19 @@ def convert_day_time_schedule(val):
return (tuple(xrange(7)), hour, minute)
return ((day_of_week,), hour, minute)
class RecipesView(QTreeView):
def __init__(self, parent):
QTreeView.__init__(self, parent)
self.setAnimated(True)
self.setHeaderHidden(True)
self.setObjectName('recipes')
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
def currentChanged(self, current, previous):
QTreeView.currentChanged(self, current, previous)
self.parent().current_changed(current, previous)
class Base(QWidget):
def __init__(self, parent=None):
@ -210,6 +224,8 @@ class SchedulerDialog(QDialog, Ui_Dialog):
self.recipe_model.searched.connect(self.search.search_done,
type=Qt.QueuedConnection)
self.recipe_model.searched.connect(self.search_done)
self.recipes = RecipesView(self)
self.gridLayout.addWidget(self.recipes, 1, 0, 1, 1)
self.recipes.setFocus(Qt.OtherFocusReason)
self.commit_on_change = True
self.previous_urn = None
@ -220,7 +236,6 @@ class SchedulerDialog(QDialog, Ui_Dialog):
self.buttonBox.ActionRole)
self.download_button.setIcon(QIcon(I('arrow-down.png')))
self.download_button.setVisible(False)
self.recipes.currentChanged = self.current_changed
for b, c in self.SCHEDULE_TYPES.iteritems():
b = getattr(self, b)
b.toggled.connect(self.schedule_type_selected)

View File

@ -53,12 +53,21 @@
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>498</height>
<width>581</width>
<height>444</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -118,29 +127,28 @@
<item>
<widget class="QRadioButton" name="days_of_week">
<property name="text">
<string>Days of week</string>
<string>&amp;Days of week</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="days_of_month">
<property name="text">
<string>Days of month</string>
<string>Da&amp;ys of month</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="every_x_days">
<property name="text">
<string>Every x days</string>
<string>Every &amp;x days</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="schedule_stack">
</widget>
<widget class="QStackedWidget" name="schedule_stack"/>
</item>
<item>
<widget class="QLabel" name="last_downloaded">
@ -316,31 +324,6 @@
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QTreeView" name="recipes">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="count_label">
<property name="text">
@ -356,7 +339,7 @@
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Delete downloaded news &amp;older than:</string>
<string>Delete downloaded &amp;news older than:</string>
</property>
<property name="buddy">
<cstring>old_news</cstring>