forked from openlp/openlp
- Fixed custom slide sorting
- Improved songs sorting speed bzr-revno: 1566
This commit is contained in:
commit
721def9b10
@ -25,6 +25,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import locale
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from sqlalchemy.sql import or_, func
|
from sqlalchemy.sql import or_, func
|
||||||
@ -133,15 +134,19 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
self.onPreviewClick()
|
self.onPreviewClick()
|
||||||
self.onRemoteEditClear()
|
self.onRemoteEditClear()
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, custom_slides):
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
for customSlide in list:
|
# Sort the customs by its title considering language specific
|
||||||
custom_name = QtGui.QListWidgetItem(customSlide.title)
|
# characters. lower() is needed for windows!
|
||||||
|
custom_slides.sort(
|
||||||
|
cmp=locale.strcoll, key=lambda custom: custom.title.lower())
|
||||||
|
for custom_slide in custom_slides:
|
||||||
|
custom_name = QtGui.QListWidgetItem(custom_slide.title)
|
||||||
custom_name.setData(
|
custom_name.setData(
|
||||||
QtCore.Qt.UserRole, QtCore.QVariant(customSlide.id))
|
QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id))
|
||||||
self.listView.addItem(custom_name)
|
self.listView.addItem(custom_name)
|
||||||
# Auto-select the item if name has been set
|
# Auto-select the item if name has been set
|
||||||
if customSlide.title == self.autoSelectItem :
|
if custom_slide.title == self.autoSelectItem:
|
||||||
self.listView.setCurrentItem(custom_name)
|
self.listView.setCurrentItem(custom_name)
|
||||||
|
|
||||||
def onNewClick(self):
|
def onNewClick(self):
|
||||||
|
@ -149,20 +149,18 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
else:
|
else:
|
||||||
self.presentationWidget.hide()
|
self.presentationWidget.hide()
|
||||||
|
|
||||||
def loadList(self, list, initialLoad=False):
|
def loadList(self, files, initialLoad=False):
|
||||||
"""
|
"""
|
||||||
Add presentations into the media manager
|
Add presentations into the media manager
|
||||||
This is called both on initial load of the plugin to populate with
|
This is called both on initial load of the plugin to populate with
|
||||||
existing files, and when the user adds new files via the media manager
|
existing files, and when the user adds new files via the media manager
|
||||||
"""
|
"""
|
||||||
currlist = self.getFileList()
|
currlist = self.getFileList()
|
||||||
titles = []
|
titles = [os.path.split(file)[1] for file in currlist]
|
||||||
for file in currlist:
|
|
||||||
titles.append(os.path.split(file)[1])
|
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.parent.formparent.displayProgressBar(len(list))
|
self.parent.formparent.displayProgressBar(len(files))
|
||||||
for file in list:
|
for file in files:
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.parent.formparent.incrementProgressBar()
|
self.parent.formparent.incrementProgressBar()
|
||||||
if currlist.count(file) > 0:
|
if currlist.count(file) > 0:
|
||||||
|
@ -229,7 +229,10 @@ 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)
|
# Sort the songs by its title considering language specific characters.
|
||||||
|
# lower() is needed for windows!
|
||||||
|
searchresults.sort(
|
||||||
|
cmp=locale.strcoll, key=lambda song: song.title.lower())
|
||||||
for song in searchresults:
|
for song in searchresults:
|
||||||
author_list = [author.display_name for author in song.authors]
|
author_list = [author.display_name for author in song.authors]
|
||||||
song_title = unicode(song.title)
|
song_title = unicode(song.title)
|
||||||
@ -475,13 +478,6 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
Receiver.send_message(u'service_item_update',
|
Receiver.send_message(u'service_item_update',
|
||||||
u'%s:%s' % (editId, item._uuid))
|
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):
|
def search(self, string):
|
||||||
"""
|
"""
|
||||||
Search for some songs
|
Search for some songs
|
||||||
|
Loading…
Reference in New Issue
Block a user