Displayed listed items are shown more natural type (Jack, René and Maria)

bzr-revno: 1881
This commit is contained in:
Meinert Jordan 2012-02-19 22:53:41 +02:00 committed by Raoul Snyman
commit 5b4b48a61c
5 changed files with 41 additions and 10 deletions

View File

@ -32,7 +32,7 @@ import logging
import os.path
import types
from PyQt4 import QtCore, QtGui
from PyQt4 import QtCore, QtGui, Qt
log = logging.getLogger(__name__)
@ -318,6 +318,34 @@ def check_directory_exists(dir):
except IOError:
pass
def create_separated_list(stringlist):
"""
Returns a string that represents a join of a list of strings with a
localized separator. This function corresponts to
QLocale::createSeparatedList which was introduced in Qt 4.8 and implements
the algorithm from http://www.unicode.org/reports/tr35/#ListPatterns
``stringlist``
List of unicode strings
"""
if Qt.qVersion() >= u'4.8':
return unicode(QtCore.QLocale.createSeparatedList(stringlist))
if not stringlist:
return u''
elif len(stringlist) == 1:
return stringlist[0]
elif len(stringlist) == 2:
return unicode(translate('OpenLP.core.lib', '%1 and %2',
'Locale list separator: 2 items').arg(stringlist[0], stringlist[1]))
else:
merged = unicode(translate('OpenLP.core.lib', '%1, and %2',
u'Locale list separator: end').arg(stringlist[-2], stringlist[-1]))
for index in reversed(range(1, len(stringlist) - 2)):
merged = unicode(translate('OpenLP.core.lib', '%1, %2',
u'Locale list separator: middle').arg(stringlist[index], merged))
return unicode(translate('OpenLP.core.lib', '%1, %2',
u'Locale list separator: start').arg(stringlist[0], merged))
from eventreceiver import Receiver
from listwidgetwithdnd import ListWidgetWithDnD
from formattingtags import FormattingTags

View File

@ -31,7 +31,7 @@ import locale
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate
translate, create_separated_list
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
media_item_combo_box, critical_error_message_box, \
@ -868,7 +868,7 @@ class BibleMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.CanLoop)
service_item.add_capability(ItemCapabilities.CanWordSplit)
# Service Item: Title
service_item.title = u', '.join(raw_title)
service_item.title = create_separated_list(raw_title)
# Service Item: Theme
if len(self.settings.bible_theme) == 0:
service_item.theme = None

View File

@ -32,7 +32,8 @@ import shutil
from PyQt4 import QtCore, QtGui
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate
from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \
create_separated_list
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
critical_error_message_box, find_and_set_in_combo_box
from openlp.core.utils import AppLocation
@ -633,7 +634,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
VerseType.translated_tag(verse[0]), verse[1:]))
for count, item in enumerate(order):
if item not in verses:
valid = u', '.join(verse_names)
valid = create_separated_list(verse_names)
critical_error_message_box(
message=unicode(translate('SongsPlugin.EditSongForm',
'The verse order is invalid. There is no verse '

View File

@ -33,7 +33,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, Receiver, SettingsManager, translate
from openlp.core.lib import build_icon, Receiver, SettingsManager, translate, \
create_separated_list
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib.db import Song
@ -255,7 +256,7 @@ class SongExportForm(OpenLPWizard):
# No need to export temporary songs.
if song.temporary:
continue
authors = u', '.join([author.display_name
authors = create_separated_list([author.display_name
for author in song.authors])
title = u'%s (%s)' % (unicode(song.title), authors)
item = QtGui.QListWidgetItem(title)

View File

@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, check_item_selected, PluginStatus
translate, check_item_selected, PluginStatus, create_separated_list
from openlp.core.lib.ui import UiStrings, context_menu_action, \
context_menu_separator
from openlp.core.utils import AppLocation
@ -247,7 +247,8 @@ class SongMediaItem(MediaManagerItem):
continue
author_list = [author.display_name for author in song.authors]
song_title = unicode(song.title)
song_detail = u'%s (%s)' % (song_title, u', '.join(author_list))
song_detail = u'%s (%s)' % (song_title,
create_separated_list(author_list))
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.listView.addItem(song_name)
@ -469,7 +470,7 @@ class SongMediaItem(MediaManagerItem):
service_item.title = song.title
author_list = [unicode(author.display_name) for author in song.authors]
service_item.raw_footer.append(song.title)
service_item.raw_footer.append(u', '.join(author_list))
service_item.raw_footer.append(create_separated_list(author_list))
service_item.raw_footer.append(song.copyright)
if QtCore.QSettings().value(u'general/ccli number',
QtCore.QVariant(u'')).toString():