mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use the correct sort order for completions on the series edit boxes
Now will sort based on the tweak and using the current UI language
This commit is contained in:
parent
fc81cfda7c
commit
98dea95759
@ -320,6 +320,9 @@ class LineEdit(QLineEdit, LineEditECM):
|
|||||||
self.no_popup = False
|
self.no_popup = False
|
||||||
|
|
||||||
# Interface {{{
|
# Interface {{{
|
||||||
|
def set_sort_func(self, sort_func):
|
||||||
|
self.mcompleter.model().sort_func = sort_func
|
||||||
|
|
||||||
def update_items_cache(self, complete_items):
|
def update_items_cache(self, complete_items):
|
||||||
self.all_items = complete_items
|
self.all_items = complete_items
|
||||||
|
|
||||||
@ -457,6 +460,10 @@ class EditWithComplete(EnComboBox):
|
|||||||
self.installEventFilter(self)
|
self.installEventFilter(self)
|
||||||
|
|
||||||
# Interface {{{
|
# Interface {{{
|
||||||
|
|
||||||
|
def set_sort_func(self, sort_func):
|
||||||
|
self.lineEdit().set_sort_func(sort_func)
|
||||||
|
|
||||||
def showPopup(self):
|
def showPopup(self):
|
||||||
orig = self.disable_popup
|
orig = self.disable_popup
|
||||||
self.disable_popup = False
|
self.disable_popup = False
|
||||||
|
@ -495,6 +495,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
def __init__(self, window, rows, model, tab, refresh_books):
|
def __init__(self, window, rows, model, tab, refresh_books):
|
||||||
QDialog.__init__(self, window)
|
QDialog.__init__(self, window)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
self.series.set_sort_func(title_sort)
|
||||||
self.model = model
|
self.model = model
|
||||||
self.db = model.db
|
self.db = model.db
|
||||||
self.refresh_book_list.setChecked(gprefs['refresh_book_list_on_bulk_edit'])
|
self.refresh_book_list.setChecked(gprefs['refresh_book_list_on_bulk_edit'])
|
||||||
|
@ -12,7 +12,7 @@ from qt.core import (Qt, QApplication, QStyle, QIcon, QDoubleSpinBox, QStyleOpt
|
|||||||
QAbstractTextDocumentLayout, QFont, QFontInfo, QDate, QDateTimeEdit, QDateTime, QEvent,
|
QAbstractTextDocumentLayout, QFont, QFontInfo, QDate, QDateTimeEdit, QDateTime, QEvent,
|
||||||
QStyleOptionComboBox, QStyleOptionSpinBox, QLocale, QSize, QLineEdit, QDialog, QPalette)
|
QStyleOptionComboBox, QStyleOptionSpinBox, QLocale, QSize, QLineEdit, QDialog, QPalette)
|
||||||
|
|
||||||
from calibre.ebooks.metadata import rating_to_stars
|
from calibre.ebooks.metadata import rating_to_stars, title_sort
|
||||||
from calibre.gui2 import UNDEFINED_QDATETIME, rating_font, gprefs
|
from calibre.gui2 import UNDEFINED_QDATETIME, rating_font, gprefs
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
from calibre.gui2.widgets import EnLineEdit
|
from calibre.gui2.widgets import EnLineEdit
|
||||||
@ -286,6 +286,8 @@ class PubDateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
|
|
||||||
class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
||||||
|
|
||||||
|
use_title_sort = False
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
'''
|
'''
|
||||||
Delegate for text data. If auto_complete_function needs to return a list
|
Delegate for text data. If auto_complete_function needs to return a list
|
||||||
@ -301,6 +303,9 @@ class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
|
|
||||||
def createEditor(self, parent, option, index):
|
def createEditor(self, parent, option, index):
|
||||||
if self.auto_complete_function:
|
if self.auto_complete_function:
|
||||||
|
if self.use_title_sort:
|
||||||
|
editor = EditWithComplete(parent, sort_func=title_sort)
|
||||||
|
else:
|
||||||
editor = EditWithComplete(parent)
|
editor = EditWithComplete(parent)
|
||||||
editor.set_separator(None)
|
editor.set_separator(None)
|
||||||
editor.set_clear_button_enabled(False)
|
editor.set_clear_button_enabled(False)
|
||||||
@ -326,6 +331,8 @@ class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
|
|
||||||
class SeriesDelegate(TextDelegate): # {{{
|
class SeriesDelegate(TextDelegate): # {{{
|
||||||
|
|
||||||
|
use_title_sort = True
|
||||||
|
|
||||||
def initStyleOption(self, option, index):
|
def initStyleOption(self, option, index):
|
||||||
TextDelegate.initStyleOption(self, option, index)
|
TextDelegate.initStyleOption(self, option, index)
|
||||||
option.textElideMode = Qt.TextElideMode.ElideMiddle
|
option.textElideMode = Qt.TextElideMode.ElideMiddle
|
||||||
|
@ -611,7 +611,7 @@ class SeriesEdit(EditWithComplete, ToMetadataMixin):
|
|||||||
data_changed = pyqtSignal()
|
data_changed = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
EditWithComplete.__init__(self, parent)
|
EditWithComplete.__init__(self, parent, sort_func=title_sort)
|
||||||
self.set_clear_button_enabled(False)
|
self.set_clear_button_enabled(False)
|
||||||
self.set_separator(None)
|
self.set_separator(None)
|
||||||
self.dialog = parent
|
self.dialog = parent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user