Add Song Theme Handling

This commit is contained in:
Tim Bentley 2009-06-14 08:02:58 +01:00
parent fbc16a0270
commit dc40e79ee7
3 changed files with 25 additions and 6 deletions

View File

@ -70,6 +70,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onVerseListViewPressed)
QtCore.QObject.connect(self.SongbookCombo,
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
QtCore.QObject.connect(self.ThemeSelectionComboItem,
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
# Create other objects and forms
self.songmanager = songmanager
self.authors_form = AuthorsForm(self.songmanager)
@ -110,6 +112,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for book in books:
self.SongbookCombo.addItem(book.name)
def loadThemes(self, theme_list):
self.ThemeSelectionComboItem.clear()
self.ThemeSelectionComboItem.addItem(u' ')
for theme in theme_list:
self.ThemeSelectionComboItem.addItem(theme)
def newSong(self):
log.debug(u'New Song')
self.song = Song()
@ -132,6 +140,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
# Not Found
id = 0
book_name.setCurrentIndex(id)
if self.song.theme_name is not None and len(self.song.theme_name) > 0:
id = self.SongbookCombo.findText(unicode(self.song.theme_name), QtCore.Qt.MatchExactly)
if id == -1:
# Not Found
id = 0
self.song.theme_name = None
self.SongbookCombo.setCurrentIndex(id)
if len(title) > 1:
self.AlternativeEdit.setText(title[1])
self.CopyrightEditItem.setText(self.song.copyright)
@ -233,6 +248,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
book = self.songmanager.get_book_by_name(book_name)
self.song.song_book_id = book.id
def onThemeComboChanged(self, item):
if item == 0:
#None means no Theme
self.song.song_theme = None
else:
them_name = unicode(self.ThemeSelectionComboItem.itemText(item))
self.song.theme_name = them_name
def onVerseListViewPressed(self):
self.EditButton.setEnabled(True)
self.DeleteButton.setEnabled(True)

View File

@ -238,10 +238,7 @@ class SongMediaItem(MediaManagerItem):
for index in indexes:
id = self.SongListData.getId(index)
song = self.parent.songmanager.get_song(id)
if song.theme_name == None or len(song.theme_name) == 0:
service_item.theme = None
else:
service_item.theme = song.theme_name
service_item.theme = song.theme_name
if song.lyrics.startswith(u'<?xml version='):
songXML=SongXMLParser(song.lyrics)
verseList = songXML.get_verses()

View File

@ -79,7 +79,6 @@ class SongsPlugin(Plugin):
QtCore.QObject.connect(self.ImportOpenlp2Item, QtCore.SIGNAL(u'triggered()'), self.onImportOpenlp1ItemClick)
QtCore.QObject.connect(self.ImportOpenSongItem, QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick)
def add_export_menu_item(self, export_menu):
self.ExportSongMenu = QtGui.QMenu(export_menu)
self.ExportSongMenu.setObjectName(u'ExportSongMenu')
@ -125,7 +124,7 @@ class SongsPlugin(Plugin):
log.debug(u'Handle event called with event %s' % event.event_type)
if event.event_type == EventType.ThemeListChanged:
log.debug(u'New Theme request received')
#self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
self.media_item.edit_song_form.loadThemes(self.theme_manager.getThemes())
if event.event_type == EventType.LoadServiceItem and event.payload == 'Song':
log.debug(u'Load Service Item received')
self.media_item.onSongAddClick()