forked from openlp/openlp
Song editor fixes
bzr-revno: 562
This commit is contained in:
commit
47d0dfe089
@ -45,6 +45,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
|
self.parent = parent
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Connecting signals and slots
|
# Connecting signals and slots
|
||||||
QtCore.QObject.connect(self.AuthorAddButton,
|
QtCore.QObject.connect(self.AuthorAddButton,
|
||||||
@ -52,13 +53,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,11 +73,15 @@ 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,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
|
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
|
||||||
|
QtCore.QObject.connect(self.ThemeAddButton,
|
||||||
|
QtCore.SIGNAL(u'clicked()'),
|
||||||
|
self.parent.parent.render_manager.theme_manager.onAddTheme)
|
||||||
QtCore.QObject.connect(self.MaintenanceButton,
|
QtCore.QObject.connect(self.MaintenanceButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
|
||||||
QtCore.QObject.connect(self.TitleEditItem,
|
QtCore.QObject.connect(self.TitleEditItem,
|
||||||
@ -89,7 +96,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus)
|
QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus)
|
||||||
# Create other objects and forms
|
# Create other objects and forms
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.parent = parent
|
|
||||||
self.verse_form = EditVerseForm()
|
self.verse_form = EditVerseForm()
|
||||||
self.initialise()
|
self.initialise()
|
||||||
self.AuthorsListView.setSortingEnabled(False)
|
self.AuthorsListView.setSortingEnabled(False)
|
||||||
@ -110,7 +116,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 +172,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 +281,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 +347,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 +356,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 +423,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()
|
||||||
|
@ -32,7 +32,7 @@ from openlp.plugins.songs.lib.classes import *
|
|||||||
def init_models(url):
|
def init_models(url):
|
||||||
engine = create_engine(url)
|
engine = create_engine(url)
|
||||||
metadata.bind = engine
|
metadata.bind = engine
|
||||||
session = scoped_session(sessionmaker(autoflush=True,
|
session = scoped_session(sessionmaker(autoflush=False,
|
||||||
autocommit=False, bind=engine))
|
autocommit=False, bind=engine))
|
||||||
mapper(Author, authors_table)
|
mapper(Author, authors_table)
|
||||||
mapper(Book, song_books_table)
|
mapper(Book, song_books_table)
|
||||||
|
Loading…
Reference in New Issue
Block a user