fixed short lines

This commit is contained in:
Andreas Preikschat 2013-04-18 11:17:00 +02:00
parent 1901d66da9
commit 5547035550

View File

@ -76,8 +76,7 @@ class SongMediaItem(MediaManagerItem):
self.openLyrics = OpenLyrics(self.plugin.manager) self.openLyrics = OpenLyrics(self.plugin.manager)
self.single_service_item = False self.single_service_item = False
self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self) self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self)
# Holds information about whether the edit is remotely triggered and # Holds information about whether the edit is remotely triggered and which Song is required.
# which Song is required.
self.remoteSong = -1 self.remoteSong = -1
self.editItem = None self.editItem = None
self.quick_preview_allowed = True self.quick_preview_allowed = True
@ -89,10 +88,8 @@ class SongMediaItem(MediaManagerItem):
dest_file = os.path.join( dest_file = os.path.join(
AppLocation.get_section_data_path(self.plugin.name), u'audio', str(song.id), os.path.split(bga)[1]) AppLocation.get_section_data_path(self.plugin.name), u'audio', str(song.id), os.path.split(bga)[1])
check_directory_exists(os.path.split(dest_file)[0]) check_directory_exists(os.path.split(dest_file)[0])
shutil.copyfile(os.path.join(AppLocation.get_section_data_path(u'servicemanager'), bga), shutil.copyfile(os.path.join(AppLocation.get_section_data_path(u'servicemanager'), bga), dest_file)
dest_file) song.media_files.append(MediaFile.populate(weight=i, file_name=dest_file))
song.media_files.append(MediaFile.populate(
weight=i, file_name=dest_file))
self.plugin.manager.save_object(song, True) self.plugin.manager.save_object(song, True)
def add_end_header_bar(self): def add_end_header_bar(self):
@ -120,7 +117,7 @@ class SongMediaItem(MediaManagerItem):
def config_update(self): def config_update(self):
""" """
IS triggered when the songs config is updated Is triggered when the songs config is updated
""" """
log.debug(u'config_updated') log.debug(u'config_updated')
self.searchAsYouType = Settings().value(self.settings_section + u'/search as type') self.searchAsYouType = Settings().value(self.settings_section + u'/search as type')
@ -211,10 +208,9 @@ class SongMediaItem(MediaManagerItem):
of songs of songs
""" """
log.debug(u'on_song_list_load - start') log.debug(u'on_song_list_load - start')
# Called to redisplay the song list screen edit from a search # Called to redisplay the song list screen edit from a search or from the exit of the Song edit dialog. If
# or from the exit of the Song edit dialog. If remote editing is active # remote editing is active Trigger it and clean up so it will not update again. Push edits to the service
# Trigger it and clean up so it will not update again. # manager to update items
# Push edits to the service manager to update items
if self.editItem and self.updateServiceOnEdit and not self.remote_triggered: if self.editItem and self.updateServiceOnEdit and not self.remote_triggered:
item = self.build_service_item(self.editItem) item = self.build_service_item(self.editItem)
self.service_manager.replace_service_item(item) self.service_manager.replace_service_item(item)
@ -280,9 +276,8 @@ class SongMediaItem(MediaManagerItem):
def on_search_text_edit_changed(self, text): def on_search_text_edit_changed(self, text):
""" """
If search as type enabled invoke the search on each key press. If search as type enabled invoke the search on each key press. If the Lyrics are being searched do not start
If the Lyrics are being searched do not start till 7 characters till 7 characters have been entered.
have been entered.
""" """
if self.searchAsYouType: if self.searchAsYouType:
search_length = 1 search_length = 1
@ -320,9 +315,8 @@ class SongMediaItem(MediaManagerItem):
def onRemoteEdit(self, song_id, preview=False): def onRemoteEdit(self, song_id, preview=False):
""" """
Called by ServiceManager or SlideController by event passing Called by ServiceManager or SlideController by event passing the Song Id in the payload along with an indicator
the Song Id in the payload along with an indicator to say which to say which type of display is required.
type of display is required.
""" """
log.debug(u'onRemoteEdit for song %s' % song_id) log.debug(u'onRemoteEdit for song %s' % song_id)
song_id = int(song_id) song_id = int(song_id)
@ -362,11 +356,11 @@ class SongMediaItem(MediaManagerItem):
if check_item_selected(self.list_view, UiStrings().SelectDelete): if check_item_selected(self.list_view, UiStrings().SelectDelete):
items = self.list_view.selectedIndexes() items = self.list_view.selectedIndexes()
if QtGui.QMessageBox.question(self, if QtGui.QMessageBox.question(self,
UiStrings().ConfirmDelete, UiStrings().ConfirmDelete,
translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '', translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)), QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return return
self.application.set_busy_cursor() self.application.set_busy_cursor()
self.main_window.display_progress_bar(len(items)) self.main_window.display_progress_bar(len(items))
@ -430,8 +424,8 @@ class SongMediaItem(MediaManagerItem):
verse_tags_translated = True verse_tags_translated = True
if not song.verse_order.strip(): if not song.verse_order.strip():
for verse in verse_list: for verse in verse_list:
# We cannot use from_loose_input() here, because database # We cannot use from_loose_input() here, because database is supposed to contain English lowercase
# is supposed to contain English lowercase singlechar tags. # singlechar tags.
verse_tag = verse[0][u'type'] verse_tag = verse[0][u'type']
verse_index = None verse_index = None
if len(verse_tag) > 1: if len(verse_tag) > 1:
@ -470,9 +464,7 @@ class SongMediaItem(MediaManagerItem):
if Settings().value(u'general/ccli number'): if Settings().value(u'general/ccli number'):
service_item.raw_footer.append(translate('SongsPlugin.MediaItem', 'CCLI License: ') + service_item.raw_footer.append(translate('SongsPlugin.MediaItem', 'CCLI License: ') +
Settings().value(u'general/ccli number')) Settings().value(u'general/ccli number'))
service_item.audit = [ service_item.audit = [song.title, author_list, song.copyright, unicode(song.ccli_number)]
song.title, author_list, song.copyright, unicode(song.ccli_number)
]
service_item.data_string = {u'title': song.search_title, u'authors': u', '.join(author_list)} service_item.data_string = {u'title': song.search_title, u'authors': u', '.join(author_list)}
service_item.xml_version = self.openLyrics.song_to_xml(song) service_item.xml_version = self.openLyrics.song_to_xml(song)
# Add the audio file to the service item. # Add the audio file to the service item.
@ -489,9 +481,8 @@ class SongMediaItem(MediaManagerItem):
if self.plugin.status != PluginStatus.Active or not item.data_string: if self.plugin.status != PluginStatus.Active or not item.data_string:
return return
if item.data_string[u'title'].find(u'@') == -1: if item.data_string[u'title'].find(u'@') == -1:
# This file seems to be an old one (prior to 1.9.5), which means, # FIXME: This file seems to be an old one (prior to 1.9.5), which means, that the search title
# that the search title (data_string[u'title']) is probably wrong. # (data_string[u'title']) is probably wrong. We add "@" to search title and hope that we do not add any
# We add "@" to search title and hope that we do not add any
# duplicate. This should work for songs without alternate title. # duplicate. This should work for songs without alternate title.
search_results = self.plugin.manager.get_all_objects(Song, search_results = self.plugin.manager.get_all_objects(Song,
Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(u' ', Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(u' ',