forked from openlp/openlp
Fixes
This commit is contained in:
parent
c240068a6e
commit
2fe31991e2
@ -77,14 +77,14 @@ class FormattingTagController(object):
|
||||
|
||||
"""
|
||||
for linenumber, html1 in enumerate(self.protected_tags):
|
||||
if self._strip(html1[u'start tag']) == tag:
|
||||
if self._strip(html1['start tag']) == tag:
|
||||
return translate('OpenLP.FormattingTagForm', 'Tag %s already defined.') % tag
|
||||
if self._strip(html1[u'desc']) == desc:
|
||||
if self._strip(html1['desc']) == desc:
|
||||
return translate('OpenLP.FormattingTagForm', 'Description %s already defined.') % tag
|
||||
for linenumber, html1 in enumerate(self.custom_tags):
|
||||
if self._strip(html1[u'start tag']) == tag:
|
||||
if self._strip(html1['start tag']) == tag:
|
||||
return translate('OpenLP.FormattingTagForm', 'Tag %s already defined.') % tag
|
||||
if self._strip(html1[u'desc']) == desc:
|
||||
if self._strip(html1['desc']) == desc:
|
||||
return translate('OpenLP.FormattingTagForm', 'Description %s already defined.') % tag
|
||||
tag = {
|
||||
'desc': desc,
|
||||
@ -136,7 +136,7 @@ class FormattingTagController(object):
|
||||
elif not match.group('empty'):
|
||||
end_tags.append(tag)
|
||||
match = self.html_tag_regex.search(start_html, match.end())
|
||||
return u''.join(map(lambda tag: '</%s>' % tag, reversed(end_tags)))
|
||||
return ''.join(map(lambda tag: '</%s>' % tag, reversed(end_tags)))
|
||||
|
||||
def start_tag_changed(self, start_html, end_html):
|
||||
"""
|
||||
|
@ -141,24 +141,24 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont
|
||||
self.new_button.setEnabled(True)
|
||||
self.delete_button.setEnabled(False)
|
||||
for linenumber, html in enumerate(FormattingTags.get_html_tags()):
|
||||
if html[u'protected']:
|
||||
if html['protected']:
|
||||
line = self.tag_table_widget_read.rowCount()
|
||||
self.tag_table_widget_read.setRowCount(line + 1)
|
||||
self.tag_table_widget_read.setItem(line, 0, QtGui.QTableWidgetItem(html[u'desc']))
|
||||
self.tag_table_widget_read.setItem(line, 1, QtGui.QTableWidgetItem(self._strip(html[u'start tag'])))
|
||||
self.tag_table_widget_read.setItem(line, 2, QtGui.QTableWidgetItem(html[u'start html']))
|
||||
self.tag_table_widget_read.setItem(line, 3, QtGui.QTableWidgetItem(html[u'end html']))
|
||||
self.tag_table_widget_read.setItem(line, 0, QtGui.QTableWidgetItem(html['desc']))
|
||||
self.tag_table_widget_read.setItem(line, 1, QtGui.QTableWidgetItem(self._strip(html['start tag'])))
|
||||
self.tag_table_widget_read.setItem(line, 2, QtGui.QTableWidgetItem(html['start html']))
|
||||
self.tag_table_widget_read.setItem(line, 3, QtGui.QTableWidgetItem(html['end html']))
|
||||
self.tag_table_widget_read.resizeRowsToContents()
|
||||
else:
|
||||
line = self.tag_table_widget.rowCount()
|
||||
self.tag_table_widget.setRowCount(line + 1)
|
||||
self.tag_table_widget.setItem(line, 0, QtGui.QTableWidgetItem(html[u'desc']))
|
||||
self.tag_table_widget.setItem(line, 1, QtGui.QTableWidgetItem(self._strip(html[u'start tag'])))
|
||||
self.tag_table_widget.setItem(line, 2, QtGui.QTableWidgetItem(html[u'start html']))
|
||||
self.tag_table_widget.setItem(line, 3, QtGui.QTableWidgetItem(html[u'end html']))
|
||||
self.tag_table_widget.setItem(line, 0, QtGui.QTableWidgetItem(html['desc']))
|
||||
self.tag_table_widget.setItem(line, 1, QtGui.QTableWidgetItem(self._strip(html['start tag'])))
|
||||
self.tag_table_widget.setItem(line, 2, QtGui.QTableWidgetItem(html['start html']))
|
||||
self.tag_table_widget.setItem(line, 3, QtGui.QTableWidgetItem(html['end html']))
|
||||
self.tag_table_widget.resizeRowsToContents()
|
||||
# Permanent (persistent) tags do not have this key
|
||||
html[u'temporary'] = False
|
||||
html['temporary'] = False
|
||||
self.reloading = False
|
||||
|
||||
def on_current_cell_changed(self, cur_row, cur_col, pre_row, pre_col):
|
||||
|
@ -16,13 +16,13 @@ class TestFormattingTagController(TestCase):
|
||||
Test that the _strip strips the correct chars
|
||||
"""
|
||||
# GIVEN: An instance of the Formatting Tag Form and a string containing a tag
|
||||
tag = u'{tag}'
|
||||
tag = '{tag}'
|
||||
|
||||
# WHEN: Calling _strip
|
||||
result = self.services._strip(tag)
|
||||
|
||||
# THEN: The tag should be returned with the wrappers removed.
|
||||
self.assertEqual(result, u'tag', u'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'')
|
||||
self.assertEqual(result, 'tag', 'FormattingTagForm._strip should return u\'tag\' when called with u\'{tag}\'')
|
||||
|
||||
def test_end_tag_changed_processes_correctly(self):
|
||||
"""
|
||||
|
@ -19,9 +19,9 @@ from openlp.core.ui.formattingtagform import FormattingTagForm
|
||||
class TestFormattingTagForm(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.init_patcher = patch(u'openlp.core.ui.formattingtagform.FormattingTagForm.__init__')
|
||||
self.qdialog_patcher = patch(u'openlp.core.ui.formattingtagform.QtGui.QDialog')
|
||||
self.ui_formatting_tag_dialog_patcher = patch(u'openlp.core.ui.formattingtagform.Ui_FormattingTagDialog')
|
||||
self.init_patcher = patch('openlp.core.ui.formattingtagform.FormattingTagForm.__init__')
|
||||
self.qdialog_patcher = patch('openlp.core.ui.formattingtagform.QtGui.QDialog')
|
||||
self.ui_formatting_tag_dialog_patcher = patch('openlp.core.ui.formattingtagform.Ui_FormattingTagDialog')
|
||||
self.mocked_init = self.init_patcher.start()
|
||||
self.mocked_qdialog = self.qdialog_patcher.start()
|
||||
self.mocked_ui_formatting_tag_dialog = self.ui_formatting_tag_dialog_patcher.start()
|
||||
|
Loading…
Reference in New Issue
Block a user