forked from openlp/openlp
improved media item sorting
This commit is contained in:
parent
32127d51bb
commit
3359726be2
|
@ -25,6 +25,8 @@
|
|||
###############################################################################
|
||||
|
||||
import logging
|
||||
import locale
|
||||
import operator
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from sqlalchemy.sql import or_, func
|
||||
|
@ -135,6 +137,9 @@ class CustomMediaItem(MediaManagerItem):
|
|||
|
||||
def loadList(self, list):
|
||||
self.listView.clear()
|
||||
# Sort the customs by its title considering language specific
|
||||
# characters.
|
||||
list.sort(cmp=locale.strcoll, key=operator.attrgetter('title'))
|
||||
for customSlide in list:
|
||||
custom_name = QtGui.QListWidgetItem(customSlide.title)
|
||||
custom_name.setData(
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
import logging
|
||||
import locale
|
||||
import operator
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from sqlalchemy.sql import or_
|
||||
|
@ -229,7 +230,8 @@ class SongMediaItem(MediaManagerItem):
|
|||
def displayResultsSong(self, searchresults):
|
||||
log.debug(u'display results Song')
|
||||
self.listView.clear()
|
||||
searchresults.sort(cmp=self.collateSongTitles)
|
||||
# Sort the songs by its title considering language specific characters.
|
||||
searchresults.sort(cmp=locale.strcoll, key=operator.attrgetter('title'))
|
||||
for song in searchresults:
|
||||
author_list = [author.display_name for author in song.authors]
|
||||
song_title = unicode(song.title)
|
||||
|
@ -472,13 +474,6 @@ class SongMediaItem(MediaManagerItem):
|
|||
Receiver.send_message(u'service_item_update',
|
||||
u'%s:%s' % (editId, item._uuid))
|
||||
|
||||
def collateSongTitles(self, song_1, song_2):
|
||||
"""
|
||||
Locale aware collation of song titles
|
||||
"""
|
||||
return locale.strcoll(unicode(song_1.title.lower()),
|
||||
unicode(song_2.title.lower()))
|
||||
|
||||
def search(self, string):
|
||||
"""
|
||||
Search for some songs
|
||||
|
|
Loading…
Reference in New Issue