This commit is contained in:
Tim Bentley 2012-06-21 21:10:14 +01:00
commit b99a8a2595
16 changed files with 74 additions and 54 deletions

View File

@ -349,8 +349,9 @@ class MediaManagerItem(QtGui.QWidget):
can run it.
``files``
The list of files to be loaded
The list of files to be loaded
"""
#FIXME: change local variables to words_separated_by_underscores.
newFiles = []
errorShown = False
for file in files:
@ -366,7 +367,7 @@ class MediaManagerItem(QtGui.QWidget):
errorShown = True
else:
newFiles.append(file)
if file:
if files:
self.validateAndLoad(newFiles)
def validateAndLoad(self, files):
@ -377,6 +378,7 @@ class MediaManagerItem(QtGui.QWidget):
``files``
The files to be loaded.
"""
#FIXME: change local variables to words_separated_by_underscores.
names = []
fullList = []
for count in range(self.listView.count()):

View File

@ -234,10 +234,10 @@ class Renderer(object):
serviceItem = ServiceItem()
if self.force_page:
# make big page for theme edit dialog to get line count
serviceItem.add_from_text(u'', VERSE_FOR_LINE_COUNT)
serviceItem.add_from_text(VERSE_FOR_LINE_COUNT)
else:
self.image_manager.deleteImage(theme_data.theme_name)
serviceItem.add_from_text(u'', VERSE)
serviceItem.add_from_text(VERSE)
serviceItem.renderer = self
serviceItem.raw_footer = FOOTER
# if No file do not update cache

View File

@ -220,20 +220,17 @@ class ServiceItem(object):
self.image_border)
self._new_item()
def add_from_text(self, title, raw_slide, verse_tag=None):
def add_from_text(self, raw_slide, verse_tag=None):
"""
Add a text slide to the service item.
``frame_title``
The title of the slide in the service item.
``raw_slide``
The raw text of the slide.
"""
if verse_tag:
verse_tag = verse_tag.upper()
self.service_item_type = ServiceItemType.Text
title = title.split(u'\n')[0]
title = raw_slide[:30].split(u'\n')[0]
self._raw_frames.append(
{u'title': title, u'raw_slide': raw_slide, u'verseTag': verse_tag})
self._new_item()

View File

@ -1216,6 +1216,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if self.liveController.display:
self.liveController.display.close()
self.liveController.display = None
# Allow the main process to exit
self.application = None
def serviceChanged(self, reset=False, serviceName=None):
"""

View File

@ -44,7 +44,7 @@ VLC_AVAILABLE = False
try:
import vlc
VLC_AVAILABLE = bool(vlc.get_default_instance())
except (ImportError, NameError):
except (ImportError, NameError, NotImplementedError):
pass
except OSError, e:
if sys.platform.startswith('win'):

View File

@ -63,8 +63,7 @@ class BiblePlugin(Plugin):
# unicode(UiStrings().Export))
# Set to invisible until we can export bibles
self.exportBibleItem.setVisible(False)
if self.manager.old_bible_databases:
self.toolsUpgradeItem.setVisible(True)
self.toolsUpgradeItem.setVisible(bool(self.manager.old_bible_databases))
def finalise(self):
"""

View File

@ -63,6 +63,7 @@ class Verse(BaseModel):
"""
pass
def init_schema(url):
"""
Setup a bible database connection and initialise the database schema.

View File

@ -418,7 +418,7 @@ class BibleMediaItem(MediaManagerItem):
``bible``
The bible to initialise (unicode).
``last_book_id``
The "book reference id" of the book which is choosen at the moment.
(int)
@ -976,7 +976,7 @@ class BibleMediaItem(MediaManagerItem):
else:
service_item.theme = self.settings.bible_theme
for slide in raw_slides:
service_item.add_from_text(slide[:30], slide)
service_item.add_from_text(slide)
return True
def formatTitle(self, start_bitem, old_bitem):

View File

@ -46,6 +46,22 @@ class OpenSongBible(BibleDB):
BibleDB.__init__(self, parent, **kwargs)
self.filename = kwargs['filename']
def get_text(self, element):
"""
Recursively get all text in an objectify element and its child elements.
``element``
An objectify element to get the text from
"""
verse_text = u''
if element.text:
verse_text = element.text
for sub_element in element.iterchildren():
verse_text += self.get_text(sub_element)
if element.tail:
verse_text += element.tail
return verse_text
def do_import(self, bible_name=None):
"""
Loads a Bible from file.
@ -89,7 +105,7 @@ class OpenSongBible(BibleDB):
db_book.id,
int(chapter.attrib[u'n'].split()[-1]),
int(verse.attrib[u'n']),
unicode(verse.text))
unicode(self.get_text(verse)))
self.wizard.incrementProgressBar(unicode(translate(
'BiblesPlugin.Opensong', 'Importing %s %s...',
'Importing <book name> <chapter>...')) %

View File

@ -210,12 +210,12 @@ class CustomMediaItem(MediaManagerItem):
theme = customSlide.theme_name
if theme:
service_item.theme = theme
customXML = CustomXMLParser(customSlide.text)
verseList = customXML.get_verses()
raw_slides = [verse[1] for verse in verseList]
custom_xml = CustomXMLParser(customSlide.text)
verse_list = custom_xml.get_verses()
raw_slides = [verse[1] for verse in verse_list]
service_item.title = title
for slide in raw_slides:
service_item.add_from_text(slide[:30], slide)
service_item.add_from_text(slide)
if Settings().value(self.settingsSection + u'/display footer',
QtCore.QVariant(True)).toBool() or credit:
service_item.raw_footer.append(u' '.join([title, credit]))

View File

@ -245,6 +245,9 @@ window.OpenLP = {
}
else {
$.each(data.results.items, function (idx, value) {
if (typeof value[0] !== "number"){
value[0] = OpenLP.escapeString(value[0])
}
ul.append($("<li>").append($("<a>").attr("href", "#options")
.attr("data-rel", "dialog").attr("value", value[0])
.click(OpenLP.showOptions).text(value[1])));

View File

@ -57,19 +57,17 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self.firstNameEdit.setFocus()
return QtGui.QDialog.exec_(self)
def onFirstNameEditTextEdited(self, text):
def onFirstNameEditTextEdited(self, display_name):
if not self._autoDisplayName:
return
display_name = text
if self.lastNameEdit.text() != u'':
if not self.lastNameEdit.text():
display_name = display_name + u' ' + self.lastNameEdit.text()
self.displayEdit.setText(display_name)
def onLastNameEditTextEdited(self, text):
def onLastNameEditTextEdited(self, display_name):
if not self._autoDisplayName:
return
display_name = text
if self.firstNameEdit.text() != u'':
if not self.firstNameEdit.text():
display_name = self.firstNameEdit.text() + u' ' + display_name
self.displayEdit.setText(display_name)

View File

@ -256,8 +256,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
verse_tags_translated = False
if self.song.lyrics.startswith(u'<?xml version='):
songXML = SongXML()
verseList = songXML.get_verses(self.song.lyrics)
for count, verse in enumerate(verseList):
verse_list = songXML.get_verses(self.song.lyrics)
for count, verse in enumerate(verse_list):
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
# This silently migrates from localized verse type markup.
@ -479,27 +479,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onVerseEditButtonClicked(self):
item = self.verseListWidget.currentItem()
if item:
tempText = item.text()
verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
self.verseForm.setVerse(tempText, True, verseId)
temp_text = item.text()
verse_id = unicode(item.data(QtCore.Qt.UserRole).toString())
self.verseForm.setVerse(temp_text, True, verse_id)
if self.verseForm.exec_():
after_text, verse_tag, verse_num = self.verseForm.getVerse()
verse_def = u'%s%s' % (verse_tag, verse_num)
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def))
item.setText(after_text)
# number of lines has changed, repaint the list moving the data
if len(tempText.split(u'\n')) != len(after_text.split(u'\n')):
tempList = {}
tempId = {}
if len(temp_text.split(u'\n')) != len(after_text.split(u'\n')):
temp_list = []
temp_ids = []
for row in range(self.verseListWidget.rowCount()):
tempList[row] = self.verseListWidget.item(row, 0)\
.text()
tempId[row] = self.verseListWidget.item(row, 0)\
.data(QtCore.Qt.UserRole)
item = self.verseListWidget.item(row, 0)
temp_list.append(item.text())
temp_ids.append(item.data(QtCore.Qt.UserRole))
self.verseListWidget.clear()
for row in range (0, len(tempList)):
item = QtGui.QTableWidgetItem(tempList[row], 0)
item.setData(QtCore.Qt.UserRole, tempId[row])
for row, entry in enumerate(temp_list):
item = QtGui.QTableWidgetItem(entry, 0)
item.setData(QtCore.Qt.UserRole, temp_ids[row])
self.verseListWidget.setItem(row, 0, item)
self.tagRows()
# Check if all verse tags are used.
@ -923,9 +922,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
multiple = []
for i in range(self.verseListWidget.rowCount()):
item = self.verseListWidget.item(i, 0)
verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
verse_tag = verseId[0]
verse_num = verseId[1:]
verse_id = unicode(item.data(QtCore.Qt.UserRole).toString())
verse_tag = verse_id[0]
verse_num = verse_id[1:]
sxml.add_verse_to_lyrics(verse_tag, verse_num,
unicode(item.text()))
if verse_num > u'1' and verse_tag not in multiple:

View File

@ -193,6 +193,7 @@ class VerseType(object):
return default
return verse_index
def retrieve_windows_encoding(recommendation=None):
"""
Determines which encoding to use on an information source. The process uses
@ -252,12 +253,14 @@ def retrieve_windows_encoding(recommendation=None):
return None
return filter(lambda item: item[1] == choice[0], encodings)[0][0]
def clean_string(string):
"""
Strips punctuation from the passed string to assist searching
"""
return WHITESPACE.sub(u' ', APOSTROPHE.sub(u'', string)).lower()
def clean_title(title):
"""
Cleans the song title by removing Unicode control chars groups C0 & C1,
@ -265,6 +268,7 @@ def clean_title(title):
"""
return CONTROL_CHARS.sub(u'', title).rstrip()
def clean_song(manager, song):
"""
Cleans the search title, rebuilds the search lyrics, adds a default author

View File

@ -465,14 +465,14 @@ class SongMediaItem(MediaManagerItem):
service_item.theme = song.theme_name
service_item.edit_id = item_id
if song.lyrics.startswith(u'<?xml version='):
verseList = SongXML().get_verses(song.lyrics)
verse_list = SongXML().get_verses(song.lyrics)
# no verse list or only 1 space (in error)
verse_tags_translated = False
if VerseType.from_translated_string(unicode(
verseList[0][0][u'type'])) is not None:
verse_list[0][0][u'type'])) is not None:
verse_tags_translated = True
if not song.verse_order.strip():
for verse in verseList:
for verse in verse_list:
# We cannot use from_loose_input() here, because database
# is supposed to contain English lowercase singlechar tags.
verse_tag = verse[0][u'type']
@ -486,14 +486,13 @@ class SongMediaItem(MediaManagerItem):
verse_index = VerseType.from_tag(verse_tag)
verse_tag = VerseType.TranslatedTags[verse_index].upper()
verse_def = u'%s%s' % (verse_tag, verse[0][u'label'])
service_item.add_from_text(
verse[1][:30], unicode(verse[1]), verse_def)
service_item.add_from_text(unicode(verse[1]), verse_def)
else:
# Loop through the verse list and expand the song accordingly.
for order in song.verse_order.lower().split():
if not order:
break
for verse in verseList:
for verse in verse_list:
if verse[0][u'type'][0].lower() == order[0] and \
(verse[0][u'label'].lower() == order[1:] or \
not order[1:]):
@ -506,12 +505,11 @@ class SongMediaItem(MediaManagerItem):
verse_tag = VerseType.TranslatedTags[verse_index]
verse_def = u'%s%s' % (verse_tag,
verse[0][u'label'])
service_item.add_from_text(
verse[1][:30], verse[1], verse_def)
service_item.add_from_text(verse[1], verse_def)
else:
verses = song.lyrics.split(u'\n\n')
for slide in verses:
service_item.add_from_text(slide[:30], unicode(slide))
service_item.add_from_text(unicode(slide))
service_item.title = song.title
author_list = [unicode(author.display_name) for author in song.authors]
service_item.raw_footer.append(song.title)

View File

@ -187,8 +187,9 @@ class OpenSongImport(SongImport):
content = this_line[1:right_bracket].lower()
# have we got any digits?
# If so, verse number is everything from the digits
# to the end (even if there are some alpha chars on the end)
match = re.match(u'(\D*)(\d+.*)', content)
# to the end (openlp does not have concept of part verses, so
# just ignore any non integers on the end (including floats))
match = re.match(u'(\D*)(\d+)', content)
if match is not None:
verse_tag = match.group(1)
verse_num = match.group(2)