Text clean ups

Move Author / Topic / Book edit form Song Edit
Add above to Toolbar
Add Icons
This commit is contained in:
Tim Bentley 2009-07-18 06:43:50 +01:00
parent 52cea4125a
commit b1fd518ff6
11 changed files with 127 additions and 94 deletions

View File

@ -243,3 +243,9 @@ class Plugin(object):
"""
pass
def shutdown(self):
"""
Called by the plugin Manager to cleanup things
"""
pass

View File

@ -174,3 +174,10 @@ class PluginManager(object):
for plugin in self.plugins:
plugin.initialise()
def cleanup_plugins(self):
"""
Loop through all the plugins and give them an opportunity to
clean themselves up
"""
for plugin in self.plugins:
plugin.cleanup()

View File

@ -139,16 +139,24 @@ class MainWindow(object):
if ret == QtGui.QMessageBox.Save:
self.ServiceManagerContents.onSaveService()
self.mainDisplay.close()
self.cleanUp()
event.accept()
elif ret == QtGui.QMessageBox.Discard:
self.mainDisplay.close()
self.cleanUp()
event.accept()
else:
event.ignore()
else:
self.mainDisplay.close()
self.cleanUp()
event.accept()
def cleanUp(self):
# Call the cleanup method to shutdown plugins.
log.info(u'cleanup plugins')
self.plugin_manager.initialise_plugins()
def OosChanged(self, reset = False, oosName = None):
"""
Hook to change the title if the OOS has been changed

View File

@ -58,7 +58,6 @@ class BibleDBImpl(BibleCommon):
def add_verse(self, bookid, chap, vse, text):
#log.debug(u'add_verse %s,%s,%s", bookid, chap, vse)
#metadata.bind.echo = False
verse = Verse()
verse.book_id = bookid
verse.chapter = chap
@ -69,8 +68,6 @@ class BibleDBImpl(BibleCommon):
def create_chapter(self, bookid, chap, textlist):
log.debug(u'create_chapter %s,%s', bookid, chap)
#log.debug(u'Text %s ", textlist)
#metadata.bind.echo = False
#text list has book and chapter as first to elements of the array
for verse_number, verse_text in textlist.iteritems():
verse = Verse()
@ -83,7 +80,6 @@ class BibleDBImpl(BibleCommon):
def create_book(self, bookname, bookabbrev, testament=1):
log.debug(u'create_book %s,%s', bookname, bookabbrev)
#metadata.bind.echo = False
book = Book()
book.testament_id = testament
book.name = bookname
@ -94,7 +90,6 @@ class BibleDBImpl(BibleCommon):
def save_meta(self, key, value):
log.debug(u'save_meta %s/%s', key, value)
#metadata.bind.echo = False
bmeta = BibleMeta()
bmeta.key = key
bmeta.value = value
@ -116,7 +111,6 @@ class BibleDBImpl(BibleCommon):
def _load_testament(self, testament):
log.debug(u'load_testaments %s', testament)
#metadata.bind.echo = False
test = ONTestament()
test.name = testament
self.session.add(test)
@ -128,17 +122,11 @@ class BibleDBImpl(BibleCommon):
def get_max_bible_book_verses(self, bookname, chapter):
log.debug(u'get_max_bible_book_verses %s, %s', bookname, chapter)
#metadata.bind.echo = False
#s = text (u'select max(verse.verse) from verse,book where chapter = :c and book_id = book.id and book.name = :b ')
#return self.db.execute(s, c=chapter, b=bookname).fetchone()
verse = self.session.query(Verse).join(Book).filter(Book.name==bookname).filter(Verse.chapter==chapter).order_by(Verse.verse.desc()).first()
return verse.verse
def get_max_bible_book_chapter(self, bookname):
log.debug(u'get_max_bible_book_chapter %s', bookname)
#metadata.bind.echo = False
#s = text (u'select max(verse.chapter) from verse,book where book_id = book.id and book.name = :b')
#return self.db.execute(s, b=bookname).fetchone()
verse = self.session.query(Verse).join(Book).filter(Book.name==bookname).order_by(Verse.chapter.desc()).first()
return verse.chapter
@ -151,34 +139,24 @@ class BibleDBImpl(BibleCommon):
def get_bible_chapter(self, id, chapter):
log.debug(u'get_bible_chapter %s, %s', id, chapter)
#metadata.bind.echo = False
return self.session.query(Verse).filter_by(chapter=chapter).filter_by(book_id=id).first()
def get_bible_text(self, bookname, chapter, sverse, everse):
log.debug(u'get_bible_text %s, %s, %s, %s', bookname, chapter, sverse, everse)
#metadata.bind.echo = False
#bookname = bookname + u"%"
#s = text (u'select name,chapter,verse.verse, verse.text FROM verse , book where verse.book_id == book.id AND verse.chapter == :c AND (verse.verse between :v1 and :v2) and (book.name like :b)')
#return self.db.execute(s, c=chapter, v1=sverse , v2=everse, b=bookname).fetchall()
verses = self.session.query(Verse).join(Book).filter(Book.name==bookname).filter(Verse.chapter==chapter).filter(Verse.verse>=sverse).filter(Verse.verse<=everse).order_by(Verse.verse).all()
return verses
def get_verses_from_text(self, versetext):
log.debug(u'get_verses_from_text %s',versetext)
#metadata.bind.echo = False
versetext = u'%%%s%%' % versetext
#s = text (u'select book.name, verse.chapter, verse.verse, verse.text FROM verse , book where verse.book_id == book.id and verse.text like :t')
#return self.db.execute(s, t=versetext).fetchall()
verses = self.session.query(Verse).filter(Verse.text.like(versetext)).all()
return verses
def dump_bible(self):
log.debug( u'.........Dumping Bible Database')
log.debug( '...............................Books ')
#s = text (u'select * FROM book ')
books = self.session.query(Book).all()
log.debug(books)
log.debug( u'...............................Verses ')
#s = text (u'select * FROM verse ')
verses = self.session.query(Verse).all()
log.debug(verses)

View File

@ -29,8 +29,8 @@ from bibleCSVimpl import BibleCSVImpl
from bibleDBimpl import BibleDBImpl
from bibleHTTPimpl import BibleHTTPImpl
from openlp.plugins.bibles.lib.tables import *
from openlp.plugins.bibles.lib.classes import *
#from openlp.plugins.bibles.lib.tables import *
#from openlp.plugins.bibles.lib.classes import *
class BibleMode(object):
Full = 1

View File

@ -68,19 +68,14 @@ class Verse(BaseModel):
"""
pass
def init_models(db_url):
engine = create_engine(db_url)
metadata.bind = engine
session = scoped_session(sessionmaker(autoflush=True,
autocommit=False,
bind=engine))
# Don't think this is needed...
#metadata.bind.echo = False
#Define the tables and indexes
return metadata, session
metadata = MetaData()
meta_table = Table(u'metadata', metadata,
Column(u'key', types.Unicode(255), primary_key=True, index=True),

View File

@ -51,7 +51,8 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
Refresh the screen and rest fields
"""
self.AuthorListWidget.clear()
self.onClearButtonClick() # tidy up screen
# tidy up screen
self.onClearButtonClick()
authors = self.songmanager.get_authors()
for author in authors:
author_name = QtGui.QListWidgetItem(author.display_name)
@ -127,6 +128,9 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self.DisplayEdit.setFocus()
def _validate_form(self):
"""
Validate the form and set if Add button if valid.
"""
# We need at lease a display name
if len(self.DisplayEdit.displayText()) == 0:
self.AddUpdateButton.setEnabled(False)

View File

@ -178,9 +178,9 @@ class Ui_EditSongDialog(object):
self.AuthorRemoveItem = QtGui.QPushButton(self.AuthorRemoveWidget)
self.AuthorRemoveItem.setObjectName(u'AuthorRemoveItem')
self.AuthorRemoveLayout.addWidget(self.AuthorRemoveItem)
self.AddAuthorsButton = QtGui.QPushButton(self.AuthorRemoveWidget)
self.AddAuthorsButton.setObjectName(u'AddAuthorsButton')
self.AuthorRemoveLayout.addWidget(self.AddAuthorsButton)
# self.AddAuthorsButton = QtGui.QPushButton(self.AuthorRemoveWidget)
# self.AddAuthorsButton.setObjectName(u'AddAuthorsButton')
# self.AuthorRemoveLayout.addWidget(self.AddAuthorsButton)
self.AuthorsLayout.addWidget(self.AuthorRemoveWidget)
self.AdditionalLayout.addWidget(self.AuthorsGroupBox)
self.SongBookGroup = QtGui.QGroupBox(self.AdditionalWidget)
@ -197,14 +197,14 @@ class Ui_EditSongDialog(object):
self.SongbookCombo.setSizePolicy(sizePolicy)
self.SongbookCombo.setObjectName(u'SongbookCombo')
self.SongbookLayout.addWidget(self.SongbookCombo, 0, 0, 1, 1)
self.AddSongBookButton = QtGui.QPushButton(self.SongBookGroup)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.AddSongBookButton.sizePolicy().hasHeightForWidth())
self.AddSongBookButton.setSizePolicy(sizePolicy)
self.AddSongBookButton.setObjectName(u'AddSongBookButton')
self.SongbookLayout.addWidget(self.AddSongBookButton, 0, 1, 1, 1)
# self.AddSongBookButton = QtGui.QPushButton(self.SongBookGroup)
# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
# sizePolicy.setHorizontalStretch(0)
# sizePolicy.setVerticalStretch(0)
# sizePolicy.setHeightForWidth(self.AddSongBookButton.sizePolicy().hasHeightForWidth())
# self.AddSongBookButton.setSizePolicy(sizePolicy)
# self.AddSongBookButton.setObjectName(u'AddSongBookButton')
# self.SongbookLayout.addWidget(self.AddSongBookButton, 0, 1, 1, 1)
self.AdditionalLayout.addWidget(self.SongBookGroup)
self.TopicGroupBox = QtGui.QGroupBox(self.AdditionalWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
@ -255,9 +255,9 @@ class Ui_EditSongDialog(object):
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)
# self.AddTopicButton = QtGui.QPushButton(self.TopicRemoveWidget)
# self.AddTopicButton.setObjectName(u'AddTopicButton')
# self.TopicRemoveLayout.addWidget(self.AddTopicButton)
self.TopicLayout.addWidget(self.TopicRemoveWidget)
self.AdditionalLayout.addWidget(self.TopicGroupBox)
self.CopyrightgroupBox = QtGui.QGroupBox(self.AdditionalWidget)
@ -313,8 +313,9 @@ class Ui_EditSongDialog(object):
EditSongDialog.setTabOrder(self.AuthorAddtoSongItem, self.AuthorsListView)
EditSongDialog.setTabOrder(self.AuthorsListView, self.AuthorRemoveItem)
EditSongDialog.setTabOrder(self.AuthorRemoveItem, self.SongbookCombo)
EditSongDialog.setTabOrder(self.SongbookCombo, self.AddSongBookButton)
EditSongDialog.setTabOrder(self.AddSongBookButton, self.SongTopicCombo)
#EditSongDialog.setTabOrder(self.SongbookCombo, self.AddSongBookButton)
#EditSongDialog.setTabOrder(self.AddSongBookButton, self.SongTopicCombo)
EditSongDialog.setTabOrder(self.SongbookCombo, self.SongTopicCombo)
EditSongDialog.setTabOrder(self.SongTopicCombo, self.TopicsListView)
EditSongDialog.setTabOrder(self.TopicsListView, self.TopicRemoveItem)
EditSongDialog.setTabOrder(self.TopicRemoveItem, self.CopyrightEditItem)
@ -336,13 +337,13 @@ class Ui_EditSongDialog(object):
self.AuthorsGroupBox.setTitle(translate(u'EditSongDialog', u'Authors'))
self.AuthorAddtoSongItem.setText(translate(u'EditSongDialog', u'Add to Song'))
self.AuthorRemoveItem.setText(translate(u'EditSongDialog', u'Remove'))
self.AddAuthorsButton.setText(translate(u'EditSongDialog', u'Manage Authors'))
#self.AddAuthorsButton.setText(translate(u'EditSongDialog', u'Manage Authors'))
self.SongBookGroup.setTitle(translate(u'EditSongDialog', u'Song Book'))
self.AddSongBookButton.setText(translate(u'EditSongDialog', u'Manage Song Books'))
#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.TopicRemoveItem.setText(translate(u'EditSongDialog', u'Remove'))
self.AddTopicButton.setText(translate(u'EditSongDialog', u'Manage Topics'))
#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)'))
self.CCLILabel.setText(translate(u'EditSongDialog', u'CCLI Number:'))

View File

@ -40,24 +40,24 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
# Connecting signals and slots
QtCore.QObject.connect(self.AddAuthorsButton,
QtCore.SIGNAL(u'clicked()'), self.onAddAuthorsButtonClicked)
# QtCore.QObject.connect(self.AddAuthorsButton,
# QtCore.SIGNAL(u'clicked()'), self.onAddAuthorsButtonClicked)
QtCore.QObject.connect(self.AuthorAddtoSongItem,
QtCore.SIGNAL(u'clicked()'), self.onAuthorAddtoSongItemClicked)
QtCore.QObject.connect(self.AuthorRemoveItem,
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemovefromSongItemClicked)
QtCore.QObject.connect(self.AuthorsListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onAuthorsListViewPressed)
QtCore.QObject.connect(self.AddTopicButton,
QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked)
# 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(u'itemClicked(QListWidgetItem*)'), self.onTopicListViewPressed)
QtCore.QObject.connect(self.AddSongBookButton,
QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked)
# QtCore.QObject.connect(self.AddSongBookButton,
# QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked)
QtCore.QObject.connect(self.CopyrightInsertItem,
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertItemTriggered)
QtCore.QObject.connect(self.AddButton,
@ -75,9 +75,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
# Create other objects and forms
self.songmanager = songmanager
self.eventmanager = eventmanager
self.authors_form = AuthorsForm(self.songmanager)
self.topics_form = TopicsForm(self.songmanager)
self.song_book_form = SongBookForm(self.songmanager)
# self.authors_form = AuthorsForm(self.songmanager)
# self.topics_form = TopicsForm(self.songmanager)
# self.song_book_form = SongBookForm(self.songmanager)
self.verse_form = EditVerseForm()
self.initialise()
self.AuthorsListView.setSortingEnabled(False)
@ -207,15 +207,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onAuthorAddtoSongItemClicked(self):
item = int(self.AuthorsSelectionComboItem.currentIndex())
item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
author = self.songmanager.get_author(item_id)
self.song.authors.append(author)
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
self.AuthorsListView.addItem(author_item)
if item > -1:
item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
author = self.songmanager.get_author(item_id)
self.song.authors.append(author)
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):
if self.AuthorsListView.count() >1:
if self.AuthorsListView.count() > 1:
self.AuthorRemoveItem.setEnabled(True)
def onAuthorRemovefromSongItemClicked(self):
@ -229,12 +230,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onTopicAddtoSongItemClicked(self):
item = int(self.SongTopicCombo.currentIndex())
item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
topic = self.songmanager.get_topic(item_id)
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)
if item > -1:
item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
topic = self.songmanager.get_topic(item_id)
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)
@ -247,29 +249,30 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.topics.remove(topic)
row = self.TopicsListView.row(item)
self.TopicsListView.takeItem(row)
def onAddAuthorsButtonClicked(self):
"""
Slot documentation goes here.
"""
self.authors_form.load_form()
self.authors_form.exec_()
self.loadAuthors()
def onAddTopicButtonClicked(self):
"""
Slot documentation goes here.
"""
self.topics_form.load_form()
self.topics_form.exec_()
self.loadTopics()
def onAddSongBookButtonClicked(self):
"""
Slot documentation goes here.
"""
self.song_book_form.load_form()
self.song_book_form.exec_()
self.loadBooks()
# def onAddAuthorsButtonClicked(self):
# """
# Slot documentation goes here.
# """
# self.authors_form.load_form()
# self.authors_form.exec_()
# self.loadAuthors()
#
# def onAddTopicButtonClicked(self):
# """
# Slot documentation goes here.
# """
# self.topics_form.load_form()
# self.topics_form.exec_()
# self.loadTopics()
#
# def onAddSongBookButtonClicked(self):
# """
# Slot documentation goes here.
# """
# self.song_book_form.load_form()
# self.song_book_form.exec_()
# self.loadBooks()
def onSongBookComboChanged(self, item):
if item == 0:

View File

@ -22,7 +22,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser , contextMenuAction, contextMenuSeparator
from openlp.plugins.songs.forms import EditSongForm
from openlp.plugins.songs.forms import EditSongForm, AuthorsForm, TopicsForm, SongBookForm
class SongList(QtGui.QListWidget):
@ -59,6 +59,9 @@ class SongMediaItem(MediaManagerItem):
self.ConfigSection = u'song'
MediaManagerItem.__init__(self, parent, icon, title)
self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager)
self.authors_form = AuthorsForm(self.parent.songmanager)
self.topics_form = TopicsForm(self.parent.songmanager)
self.song_book_form = SongBookForm(self.parent.songmanager)
def setupUi(self):
# Add a toolbar
@ -90,6 +93,19 @@ class SongMediaItem(MediaManagerItem):
self.addToolbarButton(translate(u'SongMediaItem', u'Add Song To Service'),
translate(u'SongMediaItem', u'Add the selected song(s) to the service'),
':/system/system_add.png', self.onSongAddClick, 'SongAddItem')
self.addToolbarSeparator()
## Author Edit Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Edit Authors'),
translate(u'SongMediaItem', u'Maintain the list of Song Authors'),
':/songs/song_author_edit.png', self.onEditAuthorClick, 'SongAuthorEditItem')
## Author Edit Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Edit Books'),
translate(u'SongMediaItem', u'Maintain the list of Song Books'),
':/songs/song_book_edit.png', self.onEditBookClick, 'SongAuthorEditItem')
## Author Edit Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Edit Topics'),
translate(u'SongMediaItem', u'Maintain the list of Song Topics'),
':/songs/song_topic_edit.png', self.onEditTopicClick, 'SongAuthorEditItem')
## Add the songlist widget ##
# Create the tab widget
self.SongWidget = QtGui.QWidget(self)
@ -222,6 +238,18 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form.newSong()
self.edit_song_form.exec_()
def onEditAuthorClick(self):
self.authors_form.load_form()
self.authors_form.exec_()
def onEditTopicClick(self):
self.topics_form.load_form()
self.topics_form.exec_()
def onEditBookClick(self):
self.song_book_form.load_form()
self.song_book_form.exec_()
def onSongEditClick(self):
item = self.ListView.currentItem()
if item is not None:

View File

@ -4,6 +4,9 @@
<file>song_edit.png</file>
<file>song_export.png</file>
<file>song_new.png</file>
<file>song_author_edit.png</file>
<file>song_topic_edit.png</file>
<file>song_book_edit.png</file>
</qresource>
<qresource prefix="slides" >
<file>slide_close.png</file>