Cleanups and fixes

This commit is contained in:
Tim Bentley 2010-11-29 07:32:08 +00:00
parent 6ecc121bdf
commit 5decd5c466
3 changed files with 11 additions and 10 deletions

View File

@ -46,7 +46,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
Constructor Constructor
""" """
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
#self.parent = parent
self.setupUi(self) self.setupUi(self)
# Connecting signals and slots # Connecting signals and slots
self.previewButton = QtGui.QPushButton() self.previewButton = QtGui.QPushButton()
@ -124,8 +123,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.slideListView.addItem(slide[1]) self.slideListView.addItem(slide[1])
theme = self.customSlide.theme_name theme = self.customSlide.theme_name
id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly) id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly)
# No theme match
if id == -1: if id == -1:
id = 0 # Not Found id = 0
self.themeComboBox.setCurrentIndex(id) self.themeComboBox.setCurrentIndex(id)
else: else:
self.themeComboBox.setCurrentIndex(0) self.themeComboBox.setCurrentIndex(0)
@ -264,7 +264,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.titleEdit.setFocus() self.titleEdit.setFocus()
return False, translate('CustomPlugin.EditCustomForm', return False, translate('CustomPlugin.EditCustomForm',
'You need to type in a title.') 'You need to type in a title.')
# We must have one slide. # We must have at least one slide.
if self.slideListView.count() == 0: if self.slideListView.count() == 0:
return False, translate('CustomPlugin.EditCustomForm', return False, translate('CustomPlugin.EditCustomForm',
'You need to add at least one slide') 'You need to add at least one slide')

View File

@ -50,7 +50,7 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
def setText(self, text): def setText(self, text):
""" """
Set the text for slideTextEdit. Set the text for slideTextEdit.
``text`` ``text``
The text (unicode). The text (unicode).
""" """
@ -67,7 +67,7 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
def onSplitButtonPressed(self): def onSplitButtonPressed(self):
""" """
Splits a slide in two slides. Adds a slide split at the cursor.
""" """
if self.slideTextEdit.textCursor().columnNumber() != 0: if self.slideTextEdit.textCursor().columnNumber() != 0:
self.slideTextEdit.insertPlainText(u'\n') self.slideTextEdit.insertPlainText(u'\n')

View File

@ -43,6 +43,7 @@ import logging
from xml.dom.minidom import Document from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump from xml.etree.ElementTree import ElementTree, XML, dump
from lxml import etree, objectify
from xml.parsers.expat import ExpatError from xml.parsers.expat import ExpatError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -129,10 +130,11 @@ class CustomXMLParser(object):
The XML of the song to be parsed. The XML of the song to be parsed.
""" """
self.custom_xml = None self.custom_xml = None
if xml[:5] == u'<?xml':
xml = xml[38:]
try: try:
self.custom_xml = ElementTree( self.custom_xml = objectify.fromstring(xml)
element=XML(unicode(xml).encode('unicode-escape'))) except etree.XMLSyntaxError:
except ExpatError:
log.exception(u'Invalid xml %s', xml) log.exception(u'Invalid xml %s', xml)
def get_verses(self): def get_verses(self):
@ -146,8 +148,7 @@ class CustomXMLParser(object):
if element.tag == u'verse': if element.tag == u'verse':
if element.text is None: if element.text is None:
element.text = u'' element.text = u''
verse_list.append([element.attrib, verse_list.append([element.attrib, unicode(element.text)])
unicode(element.text).decode('unicode-escape')])
return verse_list return verse_list
def dump_xml(self): def dump_xml(self):