From 9ed39c3d6a772420896994576431cb8105c7620b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 22 Apr 2014 17:17:58 +0530 Subject: [PATCH] Add note about multiple inheritance issues in PyQt5 --- setup/qt5-migrate.py | 11 ++++++++++- src/calibre/gui2/keyboard.py | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/setup/qt5-migrate.py b/setup/qt5-migrate.py index 7233306c1c..4bd6717ae6 100644 --- a/setup/qt5-migrate.py +++ b/setup/qt5-migrate.py @@ -22,10 +22,19 @@ __copyright__ = '2014, Kovid Goyal ' # QT5XX: Test touchscreen support on windows 8 in the viewer -# Look for obsolete classes and functions from the list here: +# QT5XX: Look for obsolete classes and functions from the list here: # http://qt-project.org/doc/qt-5/obsoleteclasses.html as these will not be # present in PyQt5 +# QT5XX: For classes that inherit both a QObject based class and +# SearchQueryParser, PyQt5 class the SearchQueryParser __init__ method when +# calling the QObject based classes __init__ method. The simplest fix is to +# make SearchQueryParser the first base class instead of the second. An +# alternative fix is to create a derived class from SearchQueryParser whose +# __init__ method accepts any args and does nothing and inherit from that. Do +# this porting and test the results when possible. Porting already done and +# tested for keyboard.py + # QT5XX: Delete this file after migration is completed import os, re diff --git a/src/calibre/gui2/keyboard.py b/src/calibre/gui2/keyboard.py index 7af4089d4c..1b0ac7d177 100644 --- a/src/calibre/gui2/keyboard.py +++ b/src/calibre/gui2/keyboard.py @@ -163,7 +163,7 @@ class Node(object): for child in self.children: yield child -class ConfigModel(QAbstractItemModel, SearchQueryParser): +class ConfigModel(SearchQueryParser, QAbstractItemModel): def __init__(self, keyboard, parent=None): QAbstractItemModel.__init__(self, parent) @@ -556,7 +556,7 @@ class Delegate(QStyledItemDelegate): # {{{ def setModelData(self, editor, model, index): self.closeEditor.emit(editor, self.NoHint) custom_keys = editor.custom_keys - sc = index.data(Qt.UserRole).toPyObject().data + sc = index.data(Qt.UserRole).data if custom_keys is None: candidates = [] for ckey in sc['default_keys']: