forked from openlp/openlp
Add Topic handling
This commit is contained in:
parent
fb815b8ca6
commit
6640d79eb8
@ -234,9 +234,9 @@ class Ui_EditSongDialog(object):
|
||||
self.TopicRemoveLayout.setObjectName(u'TopicRemoveLayout')
|
||||
spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.TopicRemoveLayout.addItem(spacerItem2)
|
||||
self.pushButton = QtGui.QPushButton(self.TopicRemoveWidget)
|
||||
self.pushButton.setObjectName(u'pushButton')
|
||||
self.TopicRemoveLayout.addWidget(self.pushButton)
|
||||
self.TopicRemoveItem = QtGui.QPushButton(self.TopicRemoveWidget)
|
||||
self.TopicRemoveItem.setObjectName(u'TopicRemoveItem')
|
||||
self.TopicRemoveLayout.addWidget(self.TopicRemoveItem)
|
||||
self.AddTopicButton = QtGui.QPushButton(self.TopicRemoveWidget)
|
||||
self.AddTopicButton.setObjectName(u'AddTopicButton')
|
||||
self.TopicRemoveLayout.addWidget(self.AddTopicButton)
|
||||
@ -298,8 +298,8 @@ class Ui_EditSongDialog(object):
|
||||
EditSongDialog.setTabOrder(self.SongbookCombo, self.AddSongBookButton)
|
||||
EditSongDialog.setTabOrder(self.AddSongBookButton, self.SongTopicCombo)
|
||||
EditSongDialog.setTabOrder(self.SongTopicCombo, self.TopicsListView)
|
||||
EditSongDialog.setTabOrder(self.TopicsListView, self.pushButton)
|
||||
EditSongDialog.setTabOrder(self.pushButton, self.CopyrightEditItem)
|
||||
EditSongDialog.setTabOrder(self.TopicsListView, self.TopicRemoveItem)
|
||||
EditSongDialog.setTabOrder(self.TopicRemoveItem, self.CopyrightEditItem)
|
||||
EditSongDialog.setTabOrder(self.CopyrightEditItem, self.CopyrightInsertItem)
|
||||
EditSongDialog.setTabOrder(self.CopyrightInsertItem, self.CCLNumberEdit)
|
||||
EditSongDialog.setTabOrder(self.CCLNumberEdit, self.ButtonBox)
|
||||
@ -323,7 +323,7 @@ class Ui_EditSongDialog(object):
|
||||
self.AddSongBookButton.setText(translate(u'EditSongDialog', u'Manage Song Books'))
|
||||
self.TopicGroupBox.setTitle(translate(u'EditSongDialog', u'Topic'))
|
||||
self.AddTopicsToSongButton.setText(translate(u'EditSongDialog', u'Add to Song'))
|
||||
self.pushButton.setText(translate(u'EditSongDialog', u'Remove'))
|
||||
self.TopicRemoveItem.setText(translate(u'EditSongDialog', u'Remove'))
|
||||
self.AddTopicButton.setText(translate(u'EditSongDialog', u'Manage Topics'))
|
||||
self.CopyrightgroupBox.setTitle(translate(u'EditSongDialog', u'Copyright Infomaton'))
|
||||
self.CopyrightInsertItem.setText(translate(u'EditSongDialog', u'(c)'))
|
||||
|
@ -48,9 +48,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemovefromSongItemClicked)
|
||||
QtCore.QObject.connect(self.AuthorsListView,
|
||||
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onAuthorsListViewPressed)
|
||||
|
||||
QtCore.QObject.connect(self.AddTopicButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked)
|
||||
QtCore.QObject.connect(self.AddTopicsToSongButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicAddtoSongItemClicked)
|
||||
QtCore.QObject.connect(self.TopicRemoveItem,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onTopicRemovefromSongItemClicked)
|
||||
QtCore.QObject.connect(self.TopicsListView,
|
||||
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onTopicListViewPressed)
|
||||
|
||||
|
||||
QtCore.QObject.connect(self.AddSongBookButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked)
|
||||
QtCore.QObject.connect(self.CopyrightInsertItem,
|
||||
@ -82,6 +89,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.EditButton.setEnabled(False)
|
||||
self.DeleteButton.setEnabled(False)
|
||||
self.AuthorRemoveItem.setEnabled(False)
|
||||
self.TopicRemoveItem.setEnabled(False)
|
||||
|
||||
def loadAuthors(self):
|
||||
authors = self.songmanager.get_authors()
|
||||
@ -142,22 +150,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.AuthorsListView.addItem(author_name)
|
||||
# clear the results
|
||||
self.TopicsListView.clear()
|
||||
for topics in self.song.topics:
|
||||
author_name = QtGui.QListWidgetItem(unicode(author.display_name))
|
||||
author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
||||
self.AuthorsListView.addItem(author_name)
|
||||
for topic in self.song.topics:
|
||||
topic_name = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
||||
self.TopicsListView.addItem(topic_name)
|
||||
self._validate_song()
|
||||
|
||||
def onAuthorAddtoSongItemClicked(self):
|
||||
author_name = unicode(self.AuthorsSelectionComboItem.currentText())
|
||||
author = self.songmanager.get_author_by_name(author_name)
|
||||
self.song.authors.append(author)
|
||||
author_name = QtGui.QListWidgetItem(unicode(author.display_name))
|
||||
author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
||||
self.AuthorsListView.addItem(author_name)
|
||||
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
||||
self.AuthorsListView.addItem(author_item)
|
||||
|
||||
def onAuthorsListViewPressed(self):
|
||||
self.AuthorRemoveItem.setEnabled(True)
|
||||
if self.AuthorsListView.count() >1:
|
||||
self.AuthorRemoveItem.setEnabled(True)
|
||||
|
||||
def onAuthorRemovefromSongItemClicked(self):
|
||||
self.AuthorRemoveItem.setEnabled(False)
|
||||
@ -167,7 +176,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.song.authors.remove(author)
|
||||
row = self.AuthorsListView.row(item)
|
||||
self.AuthorsListView.takeItem(row)
|
||||
self.AuthorRemoveItem.setEnabled(False)
|
||||
|
||||
def onTopicAddtoSongItemClicked(self):
|
||||
topic_name = unicode(self.SongTopicCombo.currentText())
|
||||
topic = self.songmanager.get_topic_by_name(topic_name)
|
||||
self.song.topics.append(topic)
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
||||
self.TopicsListView.addItem(topic_item)
|
||||
|
||||
def onTopicListViewPressed(self):
|
||||
self.TopicRemoveItem.setEnabled(True)
|
||||
|
||||
def onTopicRemovefromSongItemClicked(self):
|
||||
self.TopicRemoveItem.setEnabled(False)
|
||||
item = self.TopicsListView.currentItem()
|
||||
topic_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
topic = self.songmanager.get_topic(topic_id)
|
||||
self.song.topics.remove(topic)
|
||||
row = self.TopicsListView.row(item)
|
||||
self.TopicsListView.takeItem(row)
|
||||
|
||||
def onAddAuthorsButtonClicked(self):
|
||||
"""
|
||||
|
@ -132,6 +132,7 @@ class SongManager():
|
||||
Details of the Author
|
||||
"""
|
||||
return self.session.query(Author).filter_by(display_name = name).first()
|
||||
|
||||
def save_author(self, author):
|
||||
"""
|
||||
Save the Author and refresh the cache
|
||||
@ -171,6 +172,12 @@ class SongManager():
|
||||
"""
|
||||
return self.session.query(Topic).get(id)
|
||||
|
||||
def get_topic_by_name(self, name):
|
||||
"""
|
||||
Details of the Topic
|
||||
"""
|
||||
return self.session.query(Topic).filter_by(name = name).first()
|
||||
|
||||
def save_topic(self, topic):
|
||||
"""
|
||||
Save the Topic
|
||||
|
Loading…
Reference in New Issue
Block a user