forked from openlp/openlp
Fix partial song creation scenario
This commit is contained in:
parent
b9fee1a573
commit
f684ffb0c3
@ -52,13 +52,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.QObject.connect(self.AuthorRemoveButton,
|
QtCore.QObject.connect(self.AuthorRemoveButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
|
||||||
QtCore.QObject.connect(self.AuthorsListView,
|
QtCore.QObject.connect(self.AuthorsListView,
|
||||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onAuthorsListViewPressed)
|
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||||
|
self.onAuthorsListViewPressed)
|
||||||
QtCore.QObject.connect(self.TopicAddButton,
|
QtCore.QObject.connect(self.TopicAddButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
||||||
QtCore.QObject.connect(self.TopicRemoveButton,
|
QtCore.QObject.connect(self.TopicRemoveButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
|
||||||
QtCore.QObject.connect(self.TopicsListView,
|
QtCore.QObject.connect(self.TopicsListView,
|
||||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onTopicListViewPressed)
|
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||||
|
self.onTopicListViewPressed)
|
||||||
QtCore.QObject.connect(self.CopyrightInsertButton,
|
QtCore.QObject.connect(self.CopyrightInsertButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertButtonTriggered)
|
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertButtonTriggered)
|
||||||
QtCore.QObject.connect(self.VerseAddButton,
|
QtCore.QObject.connect(self.VerseAddButton,
|
||||||
@ -70,7 +72,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.QObject.connect(self.VerseDeleteButton,
|
QtCore.QObject.connect(self.VerseDeleteButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
||||||
QtCore.QObject.connect(self.VerseListWidget,
|
QtCore.QObject.connect(self.VerseListWidget,
|
||||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed)
|
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||||
|
self.onVerseListViewPressed)
|
||||||
QtCore.QObject.connect(self.SongbookCombo,
|
QtCore.QObject.connect(self.SongbookCombo,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
||||||
QtCore.QObject.connect(self.ThemeSelectionComboItem,
|
QtCore.QObject.connect(self.ThemeSelectionComboItem,
|
||||||
@ -110,7 +113,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
for author in authors:
|
for author in authors:
|
||||||
row = self.AuthorsSelectionComboItem.count()
|
row = self.AuthorsSelectionComboItem.count()
|
||||||
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
||||||
self.AuthorsSelectionComboItem.setItemData(row, QtCore.QVariant(author.id))
|
self.AuthorsSelectionComboItem.setItemData(
|
||||||
|
row, QtCore.QVariant(author.id))
|
||||||
|
|
||||||
def loadTopics(self):
|
def loadTopics(self):
|
||||||
topics = self.songmanager.get_topics()
|
topics = self.songmanager.get_topics()
|
||||||
@ -165,13 +169,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
title = self.song.search_title.split(u'@')
|
title = self.song.search_title.split(u'@')
|
||||||
if self.song.song_book_id != 0:
|
if self.song.song_book_id != 0:
|
||||||
book_name = self.songmanager.get_book(self.song.song_book_id)
|
book_name = self.songmanager.get_book(self.song.song_book_id)
|
||||||
id = self.SongbookCombo.findText(unicode(book_name.name), QtCore.Qt.MatchExactly)
|
id = self.SongbookCombo.findText(
|
||||||
|
unicode(book_name.name), QtCore.Qt.MatchExactly)
|
||||||
if id == -1:
|
if id == -1:
|
||||||
# Not Found
|
# Not Found
|
||||||
id = 0
|
id = 0
|
||||||
self.SongbookCombo.setCurrentIndex(id)
|
self.SongbookCombo.setCurrentIndex(id)
|
||||||
if self.song.theme_name is not None and len(self.song.theme_name) > 0:
|
if self.song.theme_name is not None and len(self.song.theme_name) > 0:
|
||||||
id = self.ThemeSelectionComboItem.findText(unicode(self.song.theme_name), QtCore.Qt.MatchExactly)
|
id = self.ThemeSelectionComboItem.findText(
|
||||||
|
unicode(self.song.theme_name), QtCore.Qt.MatchExactly)
|
||||||
if id == -1:
|
if id == -1:
|
||||||
# Not Found
|
# Not Found
|
||||||
id = 0
|
id = 0
|
||||||
@ -272,7 +278,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.song.song_book_id = 0
|
self.song.song_book_id = 0
|
||||||
else:
|
else:
|
||||||
item = int(self.SongbookCombo.currentIndex())
|
item = int(self.SongbookCombo.currentIndex())
|
||||||
self.song.song_book_id = (self.SongbookCombo.itemData(item)).toInt()[0]
|
self.song.song_book_id = \
|
||||||
|
(self.SongbookCombo.itemData(item)).toInt()[0]
|
||||||
|
|
||||||
def onThemeComboChanged(self, item):
|
def onThemeComboChanged(self, item):
|
||||||
if item == 0:
|
if item == 0:
|
||||||
@ -337,7 +344,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
|
|
||||||
def _validate_song(self):
|
def _validate_song(self):
|
||||||
"""
|
"""
|
||||||
Check the validity of the form. Only display the 'save' if the data can be saved.
|
Check the validity of the form. Only display the 'save' if the data
|
||||||
|
can be saved.
|
||||||
"""
|
"""
|
||||||
log.debug(u'Validate Song')
|
log.debug(u'Validate Song')
|
||||||
# Lets be nice and assume the data is correct.
|
# Lets be nice and assume the data is correct.
|
||||||
@ -345,26 +353,32 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
message = u''
|
message = u''
|
||||||
if len(self.TitleEditItem.displayText()) == 0:
|
if len(self.TitleEditItem.displayText()) == 0:
|
||||||
valid = False
|
valid = False
|
||||||
##self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
|
#self.TitleEditItem.setStyleSheet(
|
||||||
|
# u'background-color: red; color: white')
|
||||||
self.SongTabWidget.setCurrentIndex(0)
|
self.SongTabWidget.setCurrentIndex(0)
|
||||||
self.TitleEditItem.setFocus()
|
self.TitleEditItem.setFocus()
|
||||||
return False, translate(u'SongFormDialog', u'You need to enter a song title.')
|
return False, translate(
|
||||||
|
u'SongFormDialog', u'You need to enter a song title.')
|
||||||
#else:
|
#else:
|
||||||
#self.TitleEditItem.setStyleSheet(u'')
|
#self.TitleEditItem.setStyleSheet(u'')
|
||||||
if self.VerseListWidget.count() == 0:
|
if self.VerseListWidget.count() == 0:
|
||||||
valid = False
|
valid = False
|
||||||
#self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
|
#self.VerseListWidget.setStyleSheet(
|
||||||
|
# u'background-color: red; color: white')
|
||||||
self.SongTabWidget.setCurrentIndex(0)
|
self.SongTabWidget.setCurrentIndex(0)
|
||||||
self.VerseListWidget.setFocus()
|
self.VerseListWidget.setFocus()
|
||||||
return False, translate(u'SongFormDialog', u'You need to enter some verses.')
|
return False, translate(
|
||||||
|
u'SongFormDialog', u'You need to enter some verses.')
|
||||||
#else:
|
#else:
|
||||||
#self.VerseListWidget.setStyleSheet(u'')
|
#self.VerseListWidget.setStyleSheet(u'')
|
||||||
if self.AuthorsListView.count() == 0:
|
if self.AuthorsListView.count() == 0:
|
||||||
valid = False
|
valid = False
|
||||||
#self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
|
#self.AuthorsListView.setStyleSheet(
|
||||||
|
# u'background-color: red; color: white')
|
||||||
self.SongTabWidget.setCurrentIndex(2)
|
self.SongTabWidget.setCurrentIndex(2)
|
||||||
self.AuthorsListView.setFocus()
|
self.AuthorsListView.setFocus()
|
||||||
return False, translate(u'SongFormDialog', u'You need to provide at least one author.')
|
return False, translate(
|
||||||
|
u'SongFormDialog', u'You need to provide at least one author.')
|
||||||
#else:
|
#else:
|
||||||
#self.AuthorsListView.setStyleSheet(u'')
|
#self.AuthorsListView.setStyleSheet(u'')
|
||||||
return valid, message
|
return valid, message
|
||||||
@ -406,7 +420,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
return
|
return
|
||||||
self.song.title = unicode(self.TitleEditItem.displayText())
|
self.song.title = unicode(self.TitleEditItem.displayText())
|
||||||
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
||||||
self.song.search_title = unicode(self.TitleEditItem.displayText()) + u'@'+ unicode(self.AlternativeEdit.displayText())
|
self.song.search_title = unicode(self.TitleEditItem.displayText()) + \
|
||||||
|
u'@'+ unicode(self.AlternativeEdit.displayText())
|
||||||
self.song.comments = unicode(self.CommentsEdit.toPlainText())
|
self.song.comments = unicode(self.CommentsEdit.toPlainText())
|
||||||
self.song.ccli_number = unicode(self.CCLNumberEdit.displayText())
|
self.song.ccli_number = unicode(self.CCLNumberEdit.displayText())
|
||||||
self.processLyrics()
|
self.processLyrics()
|
||||||
@ -416,6 +431,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
Receiver().send_message(u'load_song_list')
|
Receiver().send_message(u'load_song_list')
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
self.songmanager.session.rollback()
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def processLyrics(self):
|
def processLyrics(self):
|
||||||
log.debug(u'processLyrics')
|
log.debug(u'processLyrics')
|
||||||
sxml = SongXMLBuilder()
|
sxml = SongXMLBuilder()
|
||||||
|
Loading…
Reference in New Issue
Block a user