openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #24008
[Merge] lp:~sam92/openlp/authortype-editing into lp:openlp
Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/authortype-editing into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #1336933 in OpenLP: "Allow editing of author types"
https://bugs.launchpad.net/openlp/+bug/1336933
Bug #1338316 in OpenLP: "Can't move up in servicemanager"
https://bugs.launchpad.net/openlp/+bug/1338316
For more details, see:
https://code.launchpad.net/~sam92/openlp/authortype-editing/+merge/226115
Allow editing of author types and fix bug in servicemanager
lp:~sam92/openlp/authortype-editing (revision 2391)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/518/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/476/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/421/
[FAILURE] http://ci.openlp.org/job/Branch-04-Windows_Tests/380/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/246/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/120/
--
https://code.launchpad.net/~sam92/openlp/authortype-editing/+merge/226115
Your team OpenLP Core is requested to review the proposed merge of lp:~sam92/openlp/authortype-editing into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2014-06-05 16:25:37 +0000
+++ openlp/core/ui/servicemanager.py 2014-07-09 12:51:18 +0000
@@ -1103,7 +1103,7 @@
Moves the cursor selection up the window. Called by the up arrow.
"""
item = self.service_manager_list.currentItem()
- item_before = self.service_manager_list.item_above(item)
+ item_before = self.service_manager_list.itemAbove(item)
if item_before is None:
return
self.service_manager_list.setCurrentItem(item_before)
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2014-05-03 15:01:43 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2014-07-09 12:51:18 +0000
@@ -138,6 +138,9 @@
self.author_remove_layout = QtGui.QHBoxLayout()
self.author_remove_layout.setObjectName('author_remove_layout')
self.author_remove_layout.addStretch()
+ self.author_edit_button = QtGui.QPushButton(self.authors_group_box)
+ self.author_edit_button.setObjectName('author_edit_button')
+ self.author_remove_layout.addWidget(self.author_edit_button)
self.author_remove_button = QtGui.QPushButton(self.authors_group_box)
self.author_remove_button.setObjectName('author_remove_button')
self.author_remove_layout.addWidget(self.author_remove_button)
@@ -305,6 +308,7 @@
translate('SongsPlugin.EditSongForm', 'Title && Lyrics'))
self.authors_group_box.setTitle(SongStrings.Authors)
self.author_add_button.setText(translate('SongsPlugin.EditSongForm', '&Add to Song'))
+ self.author_edit_button.setText(translate('SongsPlugin.EditSongForm', '&Edit Author Type'))
self.author_remove_button.setText(translate('SongsPlugin.EditSongForm', '&Remove'))
self.maintenance_button.setText(translate('SongsPlugin.EditSongForm', '&Manage Authors, Topics, Song Books'))
self.topics_group_box.setTitle(SongStrings.Topic)
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2014-07-03 16:54:51 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2014-07-09 12:51:18 +0000
@@ -70,6 +70,7 @@
self.setupUi(self)
# Connecting signals and slots
self.author_add_button.clicked.connect(self.on_author_add_button_clicked)
+ self.author_edit_button.clicked.connect(self.on_author_edit_button_clicked)
self.author_remove_button.clicked.connect(self.on_author_remove_button_clicked)
self.authors_list_view.itemClicked.connect(self.on_authors_list_view_clicked)
self.topic_add_button.clicked.connect(self.on_topic_add_button_clicked)
@@ -334,6 +335,7 @@
"""
self.verse_edit_button.setEnabled(False)
self.verse_delete_button.setEnabled(False)
+ self.author_edit_button.setEnabled(False)
self.author_remove_button.setEnabled(False)
self.topic_remove_button.setEnabled(False)
@@ -354,12 +356,9 @@
# Types
self.author_types_combo_box.clear()
- self.author_types_combo_box.addItem('')
# Don't iterate over the dictionary to give them this specific order
- self.author_types_combo_box.addItem(AuthorType.Types[AuthorType.Words], AuthorType.Words)
- self.author_types_combo_box.addItem(AuthorType.Types[AuthorType.Music], AuthorType.Music)
- self.author_types_combo_box.addItem(AuthorType.Types[AuthorType.WordsAndMusic], AuthorType.WordsAndMusic)
- self.author_types_combo_box.addItem(AuthorType.Types[AuthorType.Translation], AuthorType.Translation)
+ for author_type in AuthorType.SortedTypes:
+ self.author_types_combo_box.addItem(AuthorType.Types[author_type], author_type)
def load_topics(self):
"""
@@ -596,9 +595,32 @@
"""
Run a set of actions when an author in the list is selected (mainly enable the delete button).
"""
- if self.authors_list_view.count() > 1:
+ count = self.authors_list_view.count()
+ if count > 0:
+ self.author_edit_button.setEnabled(True)
+ if count > 1:
+ # There must be at least one author
self.author_remove_button.setEnabled(True)
+ def on_author_edit_button_clicked(self):
+ """
+ Show a dialog to change the type of an author when the edit button is clicked
+ """
+ self.author_edit_button.setEnabled(False)
+ item = self.authors_list_view.currentItem()
+ author_id, author_type = item.data(QtCore.Qt.UserRole)
+ choice, ok = QtGui.QInputDialog.getItem(self, translate('SongsPlugin.EditSongForm', 'Edit Author Type'),
+ translate('SongsPlugin.EditSongForm', 'Choose type for this author'),
+ AuthorType.TranslatedTypes,
+ current=AuthorType.SortedTypes.index(author_type),
+ editable=False)
+ if not ok:
+ return
+ author = self.manager.get_object(Author, author_id)
+ author_type = AuthorType.from_translated_text(choice)
+ item.setData(QtCore.Qt.UserRole, (author_id, author_type))
+ item.setText(author.get_display_name(author_type))
+
def on_author_remove_button_clicked(self):
"""
Remove the author from the list when the delete button is clicked.
=== modified file 'openlp/plugins/songs/lib/db.py'
--- openlp/plugins/songs/lib/db.py 2014-06-03 19:23:21 +0000
+++ openlp/plugins/songs/lib/db.py 2014-07-09 12:51:18 +0000
@@ -69,17 +69,42 @@
The 'words+music' type is not an official type, but is provided for convenience.
"""
+ NoType = ''
Words = 'words'
Music = 'music'
WordsAndMusic = 'words+music'
Translation = 'translation'
Types = {
+ NoType: '',
Words: translate('SongsPlugin.AuthorType', 'Words', 'Author who wrote the lyrics of a song'),
Music: translate('SongsPlugin.AuthorType', 'Music', 'Author who wrote the music of a song'),
WordsAndMusic: translate('SongsPlugin.AuthorType', 'Words and Music',
'Author who wrote both lyrics and music of a song'),
Translation: translate('SongsPlugin.AuthorType', 'Translation', 'Author who translated the song')
}
+ SortedTypes = [
+ NoType,
+ Words,
+ Music,
+ WordsAndMusic
+ ]
+ TranslatedTypes = [
+ Types[NoType],
+ Types[Words],
+ Types[Music],
+ Types[WordsAndMusic]
+ ]
+
+ @staticmethod
+ def from_translated_text(translated_type):
+ """
+ Get the AuthorType from a translated string.
+ :param translated_type: Translated Author type.
+ """
+ for key, value in AuthorType.Types.items():
+ if value == translated_type:
+ return key
+ return AuthorType.NoType
class Book(BaseModel):
=== modified file 'tests/functional/openlp_plugins/songs/test_db.py'
--- tests/functional/openlp_plugins/songs/test_db.py 2014-05-13 09:12:07 +0000
+++ tests/functional/openlp_plugins/songs/test_db.py 2014-07-09 12:51:18 +0000
@@ -112,3 +112,16 @@
# THEN: It should have been removed and the other author should still be there
self.assertEqual(1, len(song.authors_songs))
self.assertEqual(None, song.authors_songs[0].author_type)
+
+ def test_get_author_type_from_translated_text(self):
+ """
+ Test getting an author type from translated text
+ """
+ # GIVEN: A string with an author type
+ author_type_name = AuthorType.Types[AuthorType.Words]
+
+ # WHEN: We call the method
+ author_type = AuthorType.from_translated_text(author_type_name)
+
+ # THEN: The type should be correct
+ self.assertEqual(author_type, AuthorType.Words)
Follow ups