diff --git a/src/calibre/gui2/actions/copy_to_library.py b/src/calibre/gui2/actions/copy_to_library.py index 5a626dac42..87990e43ae 100644 --- a/src/calibre/gui2/actions/copy_to_library.py +++ b/src/calibre/gui2/actions/copy_to_library.py @@ -15,7 +15,7 @@ from collections import defaultdict from PyQt5.Qt import ( QToolButton, QDialog, QGridLayout, QIcon, QLabel, QDialogButtonBox, QApplication, QLineEdit, QHBoxLayout, QFormLayout, QCheckBox, QWidget, - QScrollArea, QVBoxLayout, Qt, QListWidgetItem, QListWidget, QSize) + QScrollArea, QVBoxLayout, Qt, QListWidgetItem, QListWidget, QSize, QAbstractItemView) from calibre import as_unicode from calibre.constants import ismacos @@ -207,7 +207,7 @@ class ChooseLibrary(Dialog): # {{{ def setup_ui(self): self.l = l = QGridLayout(self) self.items = i = QListWidget(self) - i.setSelectionMode(i.SingleSelection) + i.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) i.currentItemChanged.connect(self.current_changed) l.addWidget(i) self.v = v = QVBoxLayout() diff --git a/src/calibre/gui2/complete2.py b/src/calibre/gui2/complete2.py index 864457c219..b4f61a1b7e 100644 --- a/src/calibre/gui2/complete2.py +++ b/src/calibre/gui2/complete2.py @@ -7,7 +7,7 @@ __copyright__ = '2012, Kovid Goyal ' __docformat__ = 'restructuredtext en' from PyQt5.Qt import ( - QLineEdit, QAbstractListModel, Qt, pyqtSignal, QObject, QKeySequence, + QLineEdit, QAbstractListModel, Qt, pyqtSignal, QObject, QKeySequence, QAbstractItemView, QApplication, QListView, QPoint, QModelIndex, QStyleOptionComboBox, QStyle, QComboBox, QTimer) try: @@ -93,7 +93,7 @@ class Completer(QListView): # {{{ self.setEditTriggers(self.NoEditTriggers) self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.setSelectionBehavior(self.SelectRows) - self.setSelectionMode(self.SingleSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) self.setUniformItemSizes(True) self.setAlternatingRowColors(True) self.setModel(CompleteModel(self, sort_func=sort_func, strip_completion_entries=strip_completion_entries)) diff --git a/src/calibre/gui2/dialogs/authors_edit.py b/src/calibre/gui2/dialogs/authors_edit.py index b5dcc4844f..c554986a7f 100644 --- a/src/calibre/gui2/dialogs/authors_edit.py +++ b/src/calibre/gui2/dialogs/authors_edit.py @@ -9,7 +9,7 @@ from collections import OrderedDict from PyQt5.Qt import ( QDialog, QGridLayout, QDialogButtonBox, QListWidget, QApplication, Qt, - pyqtSignal, QSize, QPushButton, QIcon, QStyledItemDelegate, QLabel) + pyqtSignal, QSize, QPushButton, QIcon, QStyledItemDelegate, QLabel, QAbstractItemView) from calibre.utils.config_base import tweaks from calibre.gui2 import gprefs @@ -51,7 +51,7 @@ class List(QListWidget): def __init__(self, all_authors, parent): QListWidget.__init__(self, parent) self.setDragEnabled(True) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.setDropIndicatorShown(True) self.setDragDropMode(self.InternalMove) self.setAlternatingRowColors(True) diff --git a/src/calibre/gui2/dialogs/exim.py b/src/calibre/gui2/dialogs/exim.py index 8e86336d65..ad1f85dee6 100644 --- a/src/calibre/gui2/dialogs/exim.py +++ b/src/calibre/gui2/dialogs/exim.py @@ -10,7 +10,7 @@ import os, stat from PyQt5.Qt import ( QSize, QStackedLayout, QWidget, QVBoxLayout, QLabel, QPushButton, QListWidget, QListWidgetItem, QIcon, Qt, pyqtSignal, QGridLayout, - QProgressBar, QDialog, QDialogButtonBox, QScrollArea, QLineEdit, QFrame + QProgressBar, QDialog, QDialogButtonBox, QScrollArea, QLineEdit, QFrame, QAbstractItemView ) from calibre import human_readable, as_unicode @@ -200,7 +200,7 @@ class EximDialog(Dialog): la.setWordWrap(True), l.addWidget(la) self.lib_list = ll = QListWidget(self) l.addWidget(ll) - ll.setSelectionMode(ll.ExtendedSelection) + ll.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) ll.setStyleSheet('QListView::item { padding: 5px }') ll.setAlternatingRowColors(True) lpaths = all_known_libraries() diff --git a/src/calibre/gui2/dialogs/select_formats.py b/src/calibre/gui2/dialogs/select_formats.py index d11ec3f6b1..8c5571903d 100644 --- a/src/calibre/gui2/dialogs/select_formats.py +++ b/src/calibre/gui2/dialogs/select_formats.py @@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en' from PyQt5.Qt import QVBoxLayout, QDialog, QLabel, QDialogButtonBox, Qt, \ - QAbstractListModel, QListView, QSize, QApplication + QAbstractListModel, QListView, QSize, QApplication, QAbstractItemView from calibre.gui2 import file_icon_provider @@ -70,8 +70,8 @@ class SelectFormats(QDialog): self.fview.setStyleSheet('QListView { %s }' % sheet) self._l.addWidget(self.fview) self.fview.setModel(self.formats) - self.fview.setSelectionMode(self.fview.SingleSelection if single else - self.fview.MultiSelection) + self.fview.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection if single else + QAbstractItemView.SelectionMode.MultiSelection) self.bbox = \ QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel, Qt.Orientation.Horizontal, self) diff --git a/src/calibre/gui2/font_family_chooser.py b/src/calibre/gui2/font_family_chooser.py index 3a8f677546..b60b95b9be 100644 --- a/src/calibre/gui2/font_family_chooser.py +++ b/src/calibre/gui2/font_family_chooser.py @@ -12,7 +12,7 @@ from PyQt5.Qt import (QFontInfo, QFontMetrics, Qt, QFont, QFontDatabase, QPen, QStyledItemDelegate, QSize, QStyle, QStringListModel, pyqtSignal, QDialog, QVBoxLayout, QApplication, QFontComboBox, QPushButton, QToolButton, QGridLayout, QListView, QWidget, QDialogButtonBox, QIcon, - QHBoxLayout, QLabel, QLineEdit, QSizePolicy) + QHBoxLayout, QLabel, QLineEdit, QSizePolicy, QAbstractItemView) from calibre.constants import config_dir from calibre.gui2 import choose_files, error_dialog, info_dialog, empty_index @@ -186,7 +186,7 @@ class FontsView(QListView): def __init__(self, parent): QListView.__init__(self, parent) - self.setSelectionMode(self.SingleSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) self.setAlternatingRowColors(True) self.d = FontFamilyDelegate(self) self.setItemDelegate(self.d) diff --git a/src/calibre/gui2/icon_theme.py b/src/calibre/gui2/icon_theme.py index c5ff372a9e..b510c7527f 100644 --- a/src/calibre/gui2/icon_theme.py +++ b/src/calibre/gui2/icon_theme.py @@ -16,7 +16,7 @@ from PyQt5.Qt import ( QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage, pyqtSignal, QStackedLayout, QWidget, QLabel, Qt, QComboBox, QPixmap, QGridLayout, QStyledItemDelegate, QApplication, QStaticText, - QStyle, QPen, QProgressDialog + QStyle, QPen, QProgressDialog, QAbstractItemView ) try: from PyQt5 import sip @@ -217,7 +217,7 @@ class ThemeCreateDialog(Dialog): l.setFieldGrowthPolicy(l.ExpandingFieldsGrow) self.missing_icons_group = mg = QGroupBox(self) self.mising_icons = mi = QListWidget(mg) - mi.setSelectionMode(mi.NoSelection) + mi.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection) mg.l = QVBoxLayout(mg) mg.l.addWidget(mi) self.splitter.addWidget(mg) diff --git a/src/calibre/gui2/library/alternate_views.py b/src/calibre/gui2/library/alternate_views.py index 39b33deae1..4b7ebbd0e9 100644 --- a/src/calibre/gui2/library/alternate_views.py +++ b/src/calibre/gui2/library/alternate_views.py @@ -704,7 +704,7 @@ class GridView(QListView): # restore_vpos() # self.setLayoutMode(self.Batched) self.setResizeMode(self.Adjust) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.setVerticalScrollMode(self.ScrollPerPixel) self.delegate = CoverDelegate(self) self.delegate.animation.valueChanged.connect(self.animation_value_changed) diff --git a/src/calibre/gui2/library/annotations.py b/src/calibre/gui2/library/annotations.py index 6bfa04255b..48b2a150e5 100644 --- a/src/calibre/gui2/library/annotations.py +++ b/src/calibre/gui2/library/annotations.py @@ -10,7 +10,7 @@ from PyQt5.Qt import ( QApplication, QCheckBox, QComboBox, QCursor, QDateTime, QFont, QFormLayout, QHBoxLayout, QIcon, QKeySequence, QLabel, QMenu, QPalette, QPlainTextEdit, QSize, QSplitter, Qt, QTextBrowser, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, - QVBoxLayout, QWidget, pyqtSignal + QVBoxLayout, QWidget, pyqtSignal, QAbstractItemView ) from calibre import prepare_string_for_xml @@ -204,7 +204,7 @@ class ResultsList(QTreeWidget): def __init__(self, parent): QTreeWidget.__init__(self, parent) self.setHeaderHidden(True) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect(self.show_context_menu) self.delegate = AnnotsResultsDelegate(self) diff --git a/src/calibre/gui2/metadata/pdf_covers.py b/src/calibre/gui2/metadata/pdf_covers.py index 8716e610ec..cf87882494 100644 --- a/src/calibre/gui2/metadata/pdf_covers.py +++ b/src/calibre/gui2/metadata/pdf_covers.py @@ -11,7 +11,7 @@ from threading import Thread from glob import glob from PyQt5.Qt import ( - QDialog, QApplication, QLabel, QVBoxLayout, QDialogButtonBox, Qt, + QDialog, QApplication, QLabel, QVBoxLayout, QDialogButtonBox, Qt, QAbstractItemView, pyqtSignal, QListWidget, QListWidgetItem, QSize, QPixmap, QStyledItemDelegate ) try: @@ -59,7 +59,7 @@ class PDFCovers(QDialog): self.item_delegate = CoverDelegate(self) c.setItemDelegate(self.item_delegate) c.setIconSize(QSize(120, 160)) - c.setSelectionMode(c.SingleSelection) + c.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) c.setViewMode(c.IconMode) c.setUniformItemSizes(True) c.setResizeMode(c.Adjust) diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index c80eeb24e1..df6126f984 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -20,7 +20,7 @@ from PyQt5.Qt import ( QWidget, QTableView, QGridLayout, QPalette, QTimer, pyqtSignal, QAbstractTableModel, QSize, QListView, QPixmap, QModelIndex, QAbstractListModel, QRect, QTextBrowser, QStringListModel, QMenu, - QCursor, QHBoxLayout, QPushButton, QSizePolicy, QSplitter) + QCursor, QHBoxLayout, QPushButton, QSizePolicy, QSplitter, QAbstractItemView) from calibre.customize.ui import metadata_plugins from calibre.ebooks.metadata import authors_to_string, rating_to_stars @@ -214,7 +214,7 @@ class ResultsView(QTableView): # {{{ def __init__(self, parent=None): QTableView.__init__(self, parent) self.rt_delegate = RichTextDelegate(self) - self.setSelectionMode(self.SingleSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) self.setAlternatingRowColors(True) self.setSelectionBehavior(self.SelectRows) self.setIconSize(QSize(24, 24)) @@ -774,7 +774,7 @@ class CoversView(QListView): # {{{ self.setResizeMode(self.Adjust) self.setGridSize(QSize(190, 260)) self.setIconSize(QSize(*CoverDelegate.ICON_SIZE)) - self.setSelectionMode(self.SingleSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) self.setViewMode(self.IconMode) self.delegate = CoverDelegate(self) diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index cc0003e18f..4ba2cba1c6 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -12,7 +12,7 @@ from PyQt5.Qt import (QWidget, QDialog, QLabel, QGridLayout, QComboBox, QSize, QLineEdit, QIntValidator, QDoubleValidator, QFrame, Qt, QIcon, QHBoxLayout, QScrollArea, QPushButton, QVBoxLayout, QDialogButtonBox, QToolButton, QListView, QAbstractListModel, pyqtSignal, QSizePolicy, QSpacerItem, - QApplication, QStandardItem, QStandardItemModel, QCheckBox, QMenu) + QApplication, QStandardItem, QStandardItemModel, QCheckBox, QMenu, QAbstractItemView) from calibre import prepare_string_for_xml, sanitize_file_name, as_unicode from calibre.constants import config_dir @@ -911,7 +911,7 @@ class EditRules(QWidget): # {{{ self.g = g = QGridLayout() self.rules_view = QListView(self) self.rules_view.doubleClicked.connect(self.edit_rule) - self.rules_view.setSelectionMode(self.rules_view.ExtendedSelection) + self.rules_view.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.rules_view.setAlternatingRowColors(True) self.rtfd = RichTextDelegate(parent=self.rules_view, max_width=400) self.rules_view.setItemDelegate(self.rtfd) diff --git a/src/calibre/gui2/preferences/texture_chooser.py b/src/calibre/gui2/preferences/texture_chooser.py index 402a9f1234..aea5da7f47 100644 --- a/src/calibre/gui2/preferences/texture_chooser.py +++ b/src/calibre/gui2/preferences/texture_chooser.py @@ -9,7 +9,7 @@ import glob, os, shutil from functools import partial from PyQt5.Qt import ( QDialog, QVBoxLayout, QListWidget, QListWidgetItem, Qt, QIcon, - QApplication, QSize, QDialogButtonBox, QTimer, QLabel) + QApplication, QSize, QDialogButtonBox, QTimer, QLabel, QAbstractItemView) from calibre.constants import config_dir from calibre.gui2 import choose_files, error_dialog @@ -49,7 +49,7 @@ class TextureChooser(QDialog): il.setViewMode(il.IconMode) il.setFlow(il.LeftToRight) il.setSpacing(20) - il.setSelectionMode(il.SingleSelection) + il.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) il.itemSelectionChanged.connect(self.update_remove_state) l.addWidget(il) diff --git a/src/calibre/gui2/search_restriction_mixin.py b/src/calibre/gui2/search_restriction_mixin.py index 8ae7234eba..2b144cccc8 100644 --- a/src/calibre/gui2/search_restriction_mixin.py +++ b/src/calibre/gui2/search_restriction_mixin.py @@ -9,7 +9,7 @@ from functools import partial from PyQt5.Qt import ( Qt, QMenu, QIcon, QDialog, QGridLayout, QLabel, QLineEdit, QComboBox, - QDialogButtonBox, QSize, QVBoxLayout, QListWidget, QRadioButton, QAction, QTextBrowser) + QDialogButtonBox, QSize, QVBoxLayout, QListWidget, QRadioButton, QAction, QTextBrowser, QAbstractItemView) from calibre.gui2 import error_dialog, question_dialog, gprefs from calibre.gui2.dialogs.confirm_delete import confirm @@ -32,7 +32,7 @@ class SelectNames(QDialog): # {{{ self._names = QListWidget(self) self._names.addItems(sorted(names, key=sort_key)) - self._names.setSelectionMode(self._names.MultiSelection) + self._names.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection) l.addWidget(self._names) self._or = QRadioButton(_('Match any of the selected %s')%txt) diff --git a/src/calibre/gui2/tag_mapper.py b/src/calibre/gui2/tag_mapper.py index 254c04e8d9..fcf6dc6c84 100644 --- a/src/calibre/gui2/tag_mapper.py +++ b/src/calibre/gui2/tag_mapper.py @@ -8,7 +8,7 @@ import textwrap from PyQt5.Qt import ( QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QListWidget, QIcon, - QSize, QComboBox, QLineEdit, QListWidgetItem, QStyledItemDelegate, + QSize, QComboBox, QLineEdit, QListWidgetItem, QStyledItemDelegate, QAbstractItemView, QStaticText, Qt, QStyle, QToolButton, QInputDialog, QMenu, pyqtSignal ) @@ -295,7 +295,7 @@ class Rules(QWidget): l.addLayout(h) self.rule_list = r = QListWidget(self) self.delegate = Delegate(self) - r.setSelectionMode(r.ExtendedSelection) + r.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) r.setItemDelegate(self.delegate) r.doubleClicked.connect(self.edit_rule) h.addWidget(r) diff --git a/src/calibre/gui2/toc/main.py b/src/calibre/gui2/toc/main.py index 668b4b5ab3..1b04c8775b 100644 --- a/src/calibre/gui2/toc/main.py +++ b/src/calibre/gui2/toc/main.py @@ -10,7 +10,7 @@ from functools import partial from PyQt5.Qt import ( QApplication, QCheckBox, QCursor, QDialog, QDialogButtonBox, QFrame, QGridLayout, QIcon, QInputDialog, QItemSelectionModel, QKeySequence, QLabel, QMenu, - QPushButton, QScrollArea, QSize, QSizePolicy, QStackedWidget, Qt, + QPushButton, QScrollArea, QSize, QSizePolicy, QStackedWidget, Qt, QAbstractItemView, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal ) from threading import Thread @@ -386,7 +386,7 @@ class TreeWidget(QTreeWidget): # {{{ self.setHeaderLabel(_('Table of Contents')) self.setIconSize(QSize(ICON_SIZE, ICON_SIZE)) self.setDragEnabled(True) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.viewport().setAcceptDrops(True) self.setDropIndicatorShown(True) self.setDragDropMode(self.InternalMove) diff --git a/src/calibre/gui2/tweak_book/char_select.py b/src/calibre/gui2/tweak_book/char_select.py index e2ec301d76..d0f8bb12b5 100644 --- a/src/calibre/gui2/tweak_book/char_select.py +++ b/src/calibre/gui2/tweak_book/char_select.py @@ -13,7 +13,7 @@ from PyQt5.Qt import ( QAbstractItemModel, QAbstractListModel, QApplication, QCheckBox, QGridLayout, QHBoxLayout, QIcon, QInputMethodEvent, QLabel, QListView, QMenu, QMimeData, QModelIndex, QPen, QPushButton, QSize, QSizePolicy, QSplitter, - QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal + QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal, QAbstractItemView ) from calibre.gui2.tweak_book import tprefs @@ -618,7 +618,7 @@ class CharView(QListView): self.setDropIndicatorShown(True) self._model.allow_dnd = False else: - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.viewport().setAcceptDrops(True) self.setDragEnabled(True) self.setAcceptDrops(True) diff --git a/src/calibre/gui2/tweak_book/check.py b/src/calibre/gui2/tweak_book/check.py index f08dc45358..666ef8438b 100644 --- a/src/calibre/gui2/tweak_book/check.py +++ b/src/calibre/gui2/tweak_book/check.py @@ -9,7 +9,8 @@ import sys from PyQt5.Qt import ( QIcon, Qt, QSplitter, QListWidget, QTextBrowser, QPalette, QMenu, - QListWidgetItem, pyqtSignal, QApplication, QStyledItemDelegate) + QListWidgetItem, pyqtSignal, QApplication, QStyledItemDelegate, + QAbstractItemView) from calibre.ebooks.oeb.polish.check.base import WARN, INFO, DEBUG, ERROR, CRITICAL from calibre.ebooks.oeb.polish.check.main import run_checks, fix_errors @@ -70,7 +71,7 @@ class Check(QSplitter): self.items.setSpacing(3) self.items.itemDoubleClicked.connect(self.current_item_activated) self.items.currentItemChanged.connect(self.current_item_changed) - self.items.setSelectionMode(self.items.NoSelection) + self.items.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection) self.delegate = Delegate(self.items) self.items.setItemDelegate(self.delegate) self.addWidget(i) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 5bfd630ee3..a2064d9724 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -11,7 +11,7 @@ from collections import Counter, OrderedDict, defaultdict from functools import partial from PyQt5.Qt import ( QApplication, QCheckBox, QDialog, QDialogButtonBox, QFont, QFormLayout, - QGridLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListWidget, + QGridLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListWidget, QAbstractItemView, QListWidgetItem, QMenu, QPainter, QPixmap, QRadioButton, QScrollArea, QSize, QSpinBox, QStyle, QStyledItemDelegate, Qt, QTimer, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal @@ -252,7 +252,7 @@ class FileList(QTreeWidget, OpenWithHandler): self.header().close() self.setDragEnabled(True) self.setEditTriggers(self.EditKeyPressed) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.viewport().setAcceptDrops(True) self.setDropIndicatorShown(True) self.setDragDropMode(self.InternalMove) diff --git a/src/calibre/gui2/tweak_book/manage_fonts.py b/src/calibre/gui2/tweak_book/manage_fonts.py index fe5f28b2df..e18732a4ae 100644 --- a/src/calibre/gui2/tweak_book/manage_fonts.py +++ b/src/calibre/gui2/tweak_book/manage_fonts.py @@ -11,7 +11,7 @@ from io import BytesIO from PyQt5.Qt import ( QSplitter, QVBoxLayout, QTableView, QWidget, QLabel, QAbstractTableModel, Qt, QTimer, QPushButton, pyqtSignal, QFormLayout, QLineEdit, QIcon, QSize, - QHBoxLayout, QTextEdit, QApplication, QMessageBox) + QHBoxLayout, QTextEdit, QApplication, QMessageBox, QAbstractItemView) from calibre.ebooks.oeb.polish.container import get_container from calibre.ebooks.oeb.polish.fonts import font_family_data, change_font @@ -253,7 +253,7 @@ class ManageFonts(Dialog): fv.setSortingEnabled(True) fv.setShowGrid(False) fv.setAlternatingRowColors(True) - fv.setSelectionMode(fv.ExtendedSelection) + fv.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) fv.setSelectionBehavior(fv.SelectRows) fv.horizontalHeader().setSortIndicator(1, Qt.SortOrder.AscendingOrder) self.container = c = QWidget() diff --git a/src/calibre/gui2/tweak_book/polish.py b/src/calibre/gui2/tweak_book/polish.py index 8eee5df25b..71c00ce656 100644 --- a/src/calibre/gui2/tweak_book/polish.py +++ b/src/calibre/gui2/tweak_book/polish.py @@ -12,7 +12,7 @@ from PyQt5.Qt import ( QTextBrowser, QVBoxLayout, QDialog, QDialogButtonBox, QIcon, QLabel, QCheckBox, Qt, QListWidgetItem, QHBoxLayout, QListWidget, QPixmap, QSpinBox, QStyledItemDelegate, QSize, QStyle, QPen, - QProgressBar, pyqtSignal, QApplication + QProgressBar, pyqtSignal, QApplication, QAbstractItemView ) from calibre import human_readable, fit_image, force_unicode @@ -185,7 +185,7 @@ class CompressImages(Dialog): for name in sorted(get_compressible_images(c), key=numeric_sort_key): x = QListWidgetItem(name, i) x.setData(Qt.ItemDataRole.UserRole, c.filesize(name)) - i.setSelectionMode(i.ExtendedSelection) + i.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) i.setMinimumHeight(350), i.setMinimumWidth(350) i.selectAll(), i.setSpacing(5) self.delegate = ImageItemDelegate(self) diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py index 07cba73ed2..3dc79417e2 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -18,7 +18,7 @@ from PyQt5.Qt import ( QDialog, QGridLayout, QStackedWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QIcon, QWidget, QSize, QFormLayout, Qt, QSpinBox, QCheckBox, pyqtSignal, QDoubleSpinBox, QComboBox, QLabel, QFont, QApplication, - QFontComboBox, QPushButton, QSizePolicy, QHBoxLayout, QGroupBox, + QFontComboBox, QPushButton, QSizePolicy, QHBoxLayout, QGroupBox, QAbstractItemView, QToolButton, QVBoxLayout, QSpacerItem, QTimer, QRadioButton) from calibre import prepare_string_for_xml @@ -434,7 +434,7 @@ class ToolbarList(QListWidget): def __init__(self, parent=None): QListWidget.__init__(self, parent) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) class ToolbarSettings(QWidget): diff --git a/src/calibre/gui2/tweak_book/reports.py b/src/calibre/gui2/tweak_book/reports.py index 39b8ccb079..7ef8c3bfba 100644 --- a/src/calibre/gui2/tweak_book/reports.py +++ b/src/calibre/gui2/tweak_book/reports.py @@ -20,7 +20,7 @@ from PyQt5.Qt import ( QListWidgetItem, QLineEdit, QStackedWidget, QSplitter, QByteArray, QPixmap, QStyledItemDelegate, QModelIndex, QRect, QStyle, QPalette, QTimer, QMenu, QAbstractItemModel, QTreeView, QFont, QRadioButton, QHBoxLayout, - QFontDatabase, QComboBox, QUrl) + QFontDatabase, QComboBox, QUrl, QAbstractItemView) from calibre import human_readable, fit_image from calibre.constants import DEBUG @@ -130,7 +130,8 @@ class FilesView(QTableView): def __init__(self, model, parent=None): QTableView.__init__(self, parent) - self.setSelectionBehavior(self.SelectRows), self.setSelectionMode(self.ExtendedSelection) + self.setSelectionBehavior(self.SelectRows) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.setAlternatingRowColors(True) self.setSortingEnabled(True) self.proxy = p = ProxyModel(self) diff --git a/src/calibre/gui2/tweak_book/search.py b/src/calibre/gui2/tweak_book/search.py index 34195357d7..9fe34592bd 100644 --- a/src/calibre/gui2/tweak_book/search.py +++ b/src/calibre/gui2/tweak_book/search.py @@ -14,7 +14,7 @@ from PyQt5.Qt import ( QGridLayout, QHBoxLayout, QIcon, QItemSelection, QKeySequence, QLabel, QLineEdit, QListView, QMenu, QMimeData, QModelIndex, QPushButton, QScrollArea, QSize, QSizePolicy, QStackedLayout, QStyledItemDelegate, Qt, QTimer, QToolBar, - QToolButton, QVBoxLayout, QWidget, pyqtSignal + QToolButton, QVBoxLayout, QWidget, pyqtSignal, QAbstractItemView ) from calibre import prepare_string_for_xml @@ -912,7 +912,7 @@ class SavedSearches(QWidget): self.model.dataChanged.connect(self.show_details) searches.setModel(self.model) searches.selectionModel().currentChanged.connect(self.show_details) - searches.setSelectionMode(searches.ExtendedSelection) + searches.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.delegate = SearchDelegate(searches) searches.setItemDelegate(self.delegate) searches.setAlternatingRowColors(True) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index 2e680856d2..65da759548 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -16,7 +16,7 @@ from PyQt5.Qt import ( QInputDialog, QKeySequence, QLabel, QLineEdit, QListWidget, QListWidgetItem, QMenu, QModelIndex, QPlainTextEdit, QPushButton, QSize, QStackedLayout, Qt, QTableView, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, - QWidget, pyqtSignal + QWidget, pyqtSignal, QAbstractItemView ) from threading import Thread @@ -216,7 +216,7 @@ class ManageUserDictionaries(Dialog): self.la = la = QLabel(_('Words in this dictionary:')) l.addWidget(la) self.words = w = UserWordList(self) - w.setSelectionMode(w.ExtendedSelection) + w.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) l.addWidget(w) self.add_word_button = b = QPushButton(_('&Add word'), self) b.clicked.connect(self.add_word) diff --git a/src/calibre/gui2/viewer/highlights.py b/src/calibre/gui2/viewer/highlights.py index 0cf65f9feb..4a6454a186 100644 --- a/src/calibre/gui2/viewer/highlights.py +++ b/src/calibre/gui2/viewer/highlights.py @@ -10,7 +10,8 @@ from itertools import chain from PyQt5.Qt import ( QColor, QFont, QHBoxLayout, QIcon, QImage, QItemSelectionModel, QKeySequence, QLabel, QMenu, QPainter, QPainterPath, QPixmap, QPushButton, QRect, QSizePolicy, - Qt, QTextEdit, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal + Qt, QTextEdit, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal, + QAbstractItemView ) from calibre.constants import ( @@ -156,7 +157,7 @@ class Highlights(QTreeWidget): self.default_decoration = QIcon(I('blank.png')) self.setHeaderHidden(True) self.num_of_items = 0 - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) set_no_activate_on_click(self) self.itemActivated.connect(self.item_activated) self.currentItemChanged.connect(self.current_item_changed) diff --git a/src/calibre/gui2/viewer/toolbars.py b/src/calibre/gui2/viewer/toolbars.py index 27ef167af6..c5588914c1 100644 --- a/src/calibre/gui2/viewer/toolbars.py +++ b/src/calibre/gui2/viewer/toolbars.py @@ -8,7 +8,8 @@ from functools import partial from PyQt5.Qt import ( QAction, QGroupBox, QHBoxLayout, QIcon, QKeySequence, QLabel, QListWidget, - QListWidgetItem, QMenu, Qt, QToolBar, QToolButton, QVBoxLayout, pyqtSignal + QListWidgetItem, QMenu, Qt, QToolBar, QToolButton, QVBoxLayout, pyqtSignal, + QAbstractItemView ) from PyQt5.QtWebEngineWidgets import QWebEnginePage @@ -305,7 +306,7 @@ class ActionsList(QListWidget): def __init__(self, actions, parent=None, is_source=True): QListWidget.__init__(self, parent) - self.setSelectionMode(self.ExtendedSelection) + self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.setDragEnabled(True) self.viewport().setAcceptDrops(True) self.setDropIndicatorShown(True)