Fix entering Songbooks with keyboard

Also clear songbook entry field when editing another song

lp:~sam92/openlp/bug-1537212 (revision 2611)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1273/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1197/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1136/
[FAILURE] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/972/
Stopping after failure

bzr-revno: 2612
Fixes: https://launchpad.net/bugs/1537212
This commit is contained in:
s.mehrbrodt@gmail.com 2016-01-30 20:41:22 +00:00 committed by Tim Bentley
commit 8fbd431bed
2 changed files with 28 additions and 1 deletions

View File

@ -324,7 +324,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
if self.topics_combo_box.hasFocus() and self.topics_combo_box.currentText():
self.on_topic_add_button_clicked()
return
if self.songbooks_combo_box.hasFocus() and self.songbooks_combo_box.currentText():
if self.songbooks_combo_box.hasFocus() or self.songbook_entry_edit.hasFocus():
self.on_songbook_add_button_clicked()
return
QtWidgets.QDialog.keyPressEvent(self, event)
@ -514,6 +514,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
topic_name.setData(QtCore.Qt.UserRole, topic.id)
self.topics_list_view.addItem(topic_name)
self.songbooks_list_view.clear()
self.songbook_entry_edit.clear()
for songbook_entry in self.song.songbook_entries:
self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name,
songbook_entry.entry)

View File

@ -74,6 +74,13 @@ author_xml = '<properties>\
</authors>\
</properties>'
songbook_xml = '<properties>\
<songbooks>\
<songbook name="Collection 1" entry="48"/>\
<songbook name="Collection 2" entry="445 A"/>\
</songbooks>\
</properties>'
class TestOpenLyricsImport(TestCase, TestMixin):
"""
@ -166,3 +173,22 @@ class TestOpenLyricsImport(TestCase, TestMixin):
# THEN: add_author should have been called twice
self.assertEquals(mocked_song.method_calls[0][1][1], 'words+music')
self.assertEquals(mocked_song.method_calls[1][1][1], 'words')
def process_songbooks_test(self):
"""
Test that _process_songbooks works
"""
# GIVEN: A OpenLyric XML with songbooks and a mocked out manager
with patch('openlp.plugins.songs.lib.openlyricsxml.Book'):
mocked_manager = MagicMock()
mocked_manager.get_object_filtered.return_value = None
ol = OpenLyrics(mocked_manager)
properties_xml = objectify.fromstring(songbook_xml)
mocked_song = MagicMock()
# WHEN: processing the songbook xml
ol._process_songbooks(properties_xml, mocked_song)
# THEN: add_songbook_entry should have been called twice
self.assertEquals(mocked_song.method_calls[0][1][1], '48')
self.assertEquals(mocked_song.method_calls[1][1][1], '445 A')