forked from openlp/openlp
Implement natural sort for authors, topics, songbooks, themes in Edit Song comboboxen, Song Maintenance form
This commit is contained in:
parent
abc25744a2
commit
74497b9229
@ -34,6 +34,7 @@ from PyQt5 import QtCore, QtWidgets
|
||||
from openlp.core.common import Registry, RegistryProperties, AppLocation, UiStrings, check_directory_exists, translate
|
||||
from openlp.core.lib import FileDialog, PluginStatus, MediaType, create_separated_list
|
||||
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box
|
||||
from openlp.core.utils import get_natural_key
|
||||
from openlp.plugins.songs.lib import VerseType, clean_song
|
||||
from openlp.plugins.songs.lib.db import Book, Song, Author, AuthorType, Topic, MediaFile, SongBookEntry
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
@ -110,7 +111,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
"""
|
||||
Generically load a set of objects into a cache and a combobox.
|
||||
"""
|
||||
objects = self.manager.get_all_objects(cls, order_by_ref=cls.name)
|
||||
objects = self.manager.get_all_objects(cls)
|
||||
objects.sort(key=lambda object: get_natural_key(object.name))
|
||||
combo.clear()
|
||||
combo.addItem('')
|
||||
for obj in objects:
|
||||
@ -343,7 +345,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
"""
|
||||
Load the authors from the database into the combobox.
|
||||
"""
|
||||
authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name)
|
||||
authors = self.manager.get_all_objects(Author)
|
||||
authors.sort(key=lambda author: get_natural_key(author.display_name))
|
||||
self.authors_combo_box.clear()
|
||||
self.authors_combo_box.addItem('')
|
||||
self.authors = []
|
||||
@ -381,6 +384,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
self.theme_combo_box.clear()
|
||||
self.theme_combo_box.addItem('')
|
||||
self.themes = theme_list
|
||||
self.themes.sort(key=lambda theme: get_natural_key(theme))
|
||||
self.theme_combo_box.addItems(theme_list)
|
||||
set_case_insensitive_completer(self.themes, self.theme_combo_box)
|
||||
|
||||
|
@ -27,6 +27,7 @@ from sqlalchemy.sql import and_
|
||||
|
||||
from openlp.core.common import Registry, RegistryProperties, UiStrings, translate
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.utils import get_natural_key
|
||||
from openlp.plugins.songs.forms.authorsform import AuthorsForm
|
||||
from openlp.plugins.songs.forms.topicsform import TopicsForm
|
||||
from openlp.plugins.songs.forms.songbookform import SongBookForm
|
||||
@ -121,7 +122,8 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
|
||||
Reloads the Authors list.
|
||||
"""
|
||||
self.authors_list_widget.clear()
|
||||
authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name)
|
||||
authors = self.manager.get_all_objects(Author)
|
||||
authors.sort(key=lambda author: get_natural_key(author.display_name))
|
||||
for author in authors:
|
||||
if author.display_name:
|
||||
author_name = QtWidgets.QListWidgetItem(author.display_name)
|
||||
@ -135,7 +137,8 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
|
||||
Reloads the Topics list.
|
||||
"""
|
||||
self.topics_list_widget.clear()
|
||||
topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
|
||||
topics = self.manager.get_all_objects(Topic)
|
||||
topics.sort(key=lambda topic: get_natural_key(topic.name))
|
||||
for topic in topics:
|
||||
topic_name = QtWidgets.QListWidgetItem(topic.name)
|
||||
topic_name.setData(QtCore.Qt.UserRole, topic.id)
|
||||
@ -146,7 +149,8 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
|
||||
Reloads the Books list.
|
||||
"""
|
||||
self.song_books_list_widget.clear()
|
||||
books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
|
||||
books = self.manager.get_all_objects(Book)
|
||||
books.sort(key=lambda book: get_natural_key(book.name))
|
||||
for book in books:
|
||||
book_name = QtWidgets.QListWidgetItem('%s (%s)' % (book.name, book.publisher))
|
||||
book_name.setData(QtCore.Qt.UserRole, book.id)
|
||||
|
Loading…
Reference in New Issue
Block a user