forked from openlp/openlp
Local aware song order
bzr-revno: 1139 Fixes: https://launchpad.net/bugs/687638
This commit is contained in:
commit
bdc0c28809
@ -25,6 +25,8 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import locale
|
||||||
|
import re
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -61,6 +63,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
# which Song is required.
|
# which Song is required.
|
||||||
self.remoteSong = -1
|
self.remoteSong = -1
|
||||||
self.editItem = None
|
self.editItem = None
|
||||||
|
self.whitespace = re.compile(r'\W+', re.UNICODE)
|
||||||
|
|
||||||
def requiredIcons(self):
|
def requiredIcons(self):
|
||||||
MediaManagerItem.requiredIcons(self)
|
MediaManagerItem.requiredIcons(self)
|
||||||
@ -173,8 +176,8 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
if search_type == 0:
|
if search_type == 0:
|
||||||
log.debug(u'Titles Search')
|
log.debug(u'Titles Search')
|
||||||
search_results = self.parent.manager.get_all_objects(Song,
|
search_results = self.parent.manager.get_all_objects(Song,
|
||||||
Song.search_title.like(u'%' + search_keywords.lower() + u'%'),
|
Song.search_title.like(u'%' + self.whitespace.sub(u' ',
|
||||||
Song.search_title.asc())
|
search_keywords.lower()) + u'%'), Song.search_title.asc())
|
||||||
self.displayResultsSong(search_results)
|
self.displayResultsSong(search_results)
|
||||||
elif search_type == 1:
|
elif search_type == 1:
|
||||||
log.debug(u'Lyrics Search')
|
log.debug(u'Lyrics Search')
|
||||||
@ -213,6 +216,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
def displayResultsSong(self, searchresults):
|
def displayResultsSong(self, searchresults):
|
||||||
log.debug(u'display results Song')
|
log.debug(u'display results Song')
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
|
searchresults.sort(cmp=self.collateSongTitles)
|
||||||
for song in searchresults:
|
for song in searchresults:
|
||||||
author_list = u''
|
author_list = u''
|
||||||
for author in song.authors:
|
for author in song.authors:
|
||||||
@ -437,3 +441,9 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
if editId != 0:
|
if editId != 0:
|
||||||
Receiver.send_message(u'service_item_update',
|
Receiver.send_message(u'service_item_update',
|
||||||
u'%s:%s' %(editId, uuid))
|
u'%s:%s' %(editId, uuid))
|
||||||
|
|
||||||
|
def collateSongTitles(self, song_1, song_2):
|
||||||
|
"""
|
||||||
|
Locale aware collation of song titles
|
||||||
|
"""
|
||||||
|
return locale.strcoll(unicode(song_1.title), unicode(song_2.title))
|
||||||
|
@ -56,7 +56,7 @@ class SongsPlugin(Plugin):
|
|||||||
self.manager = Manager(u'songs', init_schema)
|
self.manager = Manager(u'songs', init_schema)
|
||||||
self.icon_path = u':/plugins/plugin_songs.png'
|
self.icon_path = u':/plugins/plugin_songs.png'
|
||||||
self.icon = build_icon(self.icon_path)
|
self.icon = build_icon(self.icon_path)
|
||||||
self.whitespace = re.compile(r'\W+')
|
self.whitespace = re.compile(r'\W+', re.UNICODE)
|
||||||
|
|
||||||
def getSettingsTab(self):
|
def getSettingsTab(self):
|
||||||
visible_name = self.getString(StringContent.VisibleName)
|
visible_name = self.getString(StringContent.VisibleName)
|
||||||
|
Loading…
Reference in New Issue
Block a user