Fix song editing so it works

Added now images for Song editors
Fix up Alert code so now works.

bzr-revno: 495
This commit is contained in:
Tim Bentley 2009-07-21 19:07:40 +01:00
commit 131abc4aa6
19 changed files with 188 additions and 135 deletions

5
cnvdb.py Normal file → Executable file
View File

@ -21,7 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
import codecs import codecs
import sys import sys
def convert_file(self, inname, outname): def convert_file(inname, outname):
""" """
Convert a file from another encoding into UTF-8. Convert a file from another encoding into UTF-8.
@ -35,7 +35,8 @@ def convert_file(self, inname, outname):
writefile = codecs.open(outname, 'w', encoding='utf-8') writefile = codecs.open(outname, 'w', encoding='utf-8')
for line in infile: for line in infile:
#replace the quotes with quotes #replace the quotes with quotes
line = line.replace(u'\'\'', u'\'') #TODO fix double quotes
#line = line.replace(u'\'\'', u'@')
writefile.write(line) writefile.write(line)
infile.close() infile.close()
writefile.close() writefile.close()

View File

@ -243,3 +243,9 @@ class Plugin(object):
""" """
pass 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: for plugin in self.plugins:
plugin.initialise() 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

@ -18,7 +18,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from PyQt4 import QtCore, QtGui, QtTest from PyQt4 import QtCore, QtGui
from time import sleep from time import sleep
from openlp.core.lib import translate from openlp.core.lib import translate
@ -41,6 +41,7 @@ class MainDisplay(QtGui.QWidget):
self.alertactive = False self.alertactive = False
self.alerttext = u'' self.alerttext = u''
self.alertTab = None self.alertTab = None
self.timer_id = 0
def setup(self, screenNumber): def setup(self, screenNumber):
""" """
@ -69,11 +70,18 @@ class MainDisplay(QtGui.QWidget):
self.frameView(self.blankFrame) self.frameView(self.blankFrame)
def frameView(self, frame): def frameView(self, frame):
"""
Called from a slide controller to display a frame
if the alert is in progress the alert is added on top
``frame``
Image frame to be rendered
"""
self.frame = frame self.frame = frame
if not self.displayBlank: if self.timer_id != 0 :
self.display.setPixmap(QtGui.QPixmap.fromImage(frame))
elif self.alertactive:
self.displayAlert() self.displayAlert()
elif not self.displayBlank:
self.display.setPixmap(QtGui.QPixmap.fromImage(frame))
def blankDisplay(self): def blankDisplay(self):
if not self.displayBlank: if not self.displayBlank:
@ -85,17 +93,17 @@ class MainDisplay(QtGui.QWidget):
def alert(self, alertTab, text): def alert(self, alertTab, text):
""" """
Called from the Alert Tab Called from the Alert Tab to display an alert
alertTab = details from AlertTab ``alertTab``
text = display text details from AlertTab
screen = screen number to be displayed on.
``text``
display text
""" """
self.alerttext = text self.alerttext = text
self.alertTab = alertTab self.alertTab = alertTab
if len(text) > 0: if len(text) > 0:
self.alertactive = True
self.displayAlert() self.displayAlert()
self.alertactive = False
def displayAlert(self): def displayAlert(self):
alertframe = QtGui.QPixmap.fromImage(self.frame) alertframe = QtGui.QPixmap.fromImage(self.frame)
@ -113,5 +121,12 @@ class MainDisplay(QtGui.QWidget):
painter.drawText(x, y+metrics.height()-metrics.descent()-1, self.alerttext) painter.drawText(x, y+metrics.height()-metrics.descent()-1, self.alerttext)
painter.end() painter.end()
self.display.setPixmap(alertframe) self.display.setPixmap(alertframe)
QtTest.QTest.qWait(self.alertTab.timeout*1000) # check to see if we have a timer running
if self.timer_id == 0:
self.timer_id = self.startTimer(int(self.alertTab.timeout) * 1000)
def timerEvent(self, event):
if event.timerId() == self.timer_id:
self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame)) self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame))
self.killTimer(self.timer_id)
self.timer_id = 0

View File

@ -139,16 +139,24 @@ class MainWindow(object):
if ret == QtGui.QMessageBox.Save: if ret == QtGui.QMessageBox.Save:
self.ServiceManagerContents.onSaveService() self.ServiceManagerContents.onSaveService()
self.mainDisplay.close() self.mainDisplay.close()
self.cleanUp()
event.accept() event.accept()
elif ret == QtGui.QMessageBox.Discard: elif ret == QtGui.QMessageBox.Discard:
self.mainDisplay.close() self.mainDisplay.close()
self.cleanUp()
event.accept() event.accept()
else: else:
event.ignore() event.ignore()
else: else:
self.mainDisplay.close() self.mainDisplay.close()
self.cleanUp()
event.accept() 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): def OosChanged(self, reset = False, oosName = None):
""" """
Hook to change the title if the OOS has been changed Hook to change the title if the OOS has been changed

View File

@ -137,8 +137,7 @@ class MigrateSongs():
self.db_url = u'sqlite:///' + self.data_path + u'/songs.sqlite' self.db_url = u'sqlite:///' + self.data_path + u'/songs.sqlite'
print self.db_url print self.db_url
self.session = init_models(self.db_url) self.session = init_models(self.db_url)
if not songs_table.exists(): metadata.create_all(checkfirst=True)
metadata.create_all()
results = self.session.query(TSong).order_by(TSong.songid).all() results = self.session.query(TSong).order_by(TSong.songid).all()
for songs_temp in results: for songs_temp in results:
song = Song() song = Song()
@ -151,11 +150,14 @@ class MigrateSongs():
aa = self.session.execute(u'select * from songauthors_temp where songid =' + unicode(songs_temp.songid) ) aa = self.session.execute(u'select * from songauthors_temp where songid =' + unicode(songs_temp.songid) )
for row in aa: for row in aa:
a = row['authorid'] a = row['authorid']
author = Author()
authors_temp = self.session.query(TAuthor).get(a) authors_temp = self.session.query(TAuthor).get(a)
bb = self.session.execute(u'select * from authors where display_name = \"%s\"' % unicode(authors_temp.authorname) ).fetchone()
if bb is None:
author = Author()
author.display_name = authors_temp.authorname author.display_name = authors_temp.authorname
author.first_name = u'' else:
author.last_name = u'' id = int(bb[0])
author = self.session.query(Author).get(bb[0])
song.authors.append(author) song.authors.append(author)
try: try:
self.session.add(song) self.session.add(song)
@ -184,5 +186,4 @@ class MigrateSongs():
conn.execute(u'drop table songauthors_temp;') conn.execute(u'drop table songauthors_temp;')
conn.commit() conn.commit()
conn.execute(u'drop table settings;') conn.execute(u'drop table settings;')
conn.commit() conn.commit()

View File

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

View File

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

View File

@ -68,19 +68,14 @@ class Verse(BaseModel):
""" """
pass pass
def init_models(db_url): def init_models(db_url):
engine = create_engine(db_url) engine = create_engine(db_url)
metadata.bind = engine metadata.bind = engine
session = scoped_session(sessionmaker(autoflush=True, session = scoped_session(sessionmaker(autoflush=True,
autocommit=False, autocommit=False,
bind=engine)) bind=engine))
# Don't think this is needed...
#metadata.bind.echo = False
#Define the tables and indexes
return metadata, session return metadata, session
metadata = MetaData() metadata = MetaData()
meta_table = Table(u'metadata', metadata, meta_table = Table(u'metadata', metadata,
Column(u'key', types.Unicode(255), primary_key=True, index=True), 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 Refresh the screen and rest fields
""" """
self.AuthorListWidget.clear() self.AuthorListWidget.clear()
self.onClearButtonClick() # tidy up screen # tidy up screen
self.onClearButtonClick()
authors = self.songmanager.get_authors() authors = self.songmanager.get_authors()
for author in authors: for author in authors:
author_name = QtGui.QListWidgetItem(author.display_name) author_name = QtGui.QListWidgetItem(author.display_name)
@ -127,6 +128,9 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self.DisplayEdit.setFocus() self.DisplayEdit.setFocus()
def _validate_form(self): def _validate_form(self):
"""
Validate the form and set if Add button if valid.
"""
# We need at lease a display name # We need at lease a display name
if len(self.DisplayEdit.displayText()) == 0: if len(self.DisplayEdit.displayText()) == 0:
self.AddUpdateButton.setEnabled(False) self.AddUpdateButton.setEnabled(False)

View File

@ -178,9 +178,9 @@ class Ui_EditSongDialog(object):
self.AuthorRemoveItem = QtGui.QPushButton(self.AuthorRemoveWidget) self.AuthorRemoveItem = QtGui.QPushButton(self.AuthorRemoveWidget)
self.AuthorRemoveItem.setObjectName(u'AuthorRemoveItem') self.AuthorRemoveItem.setObjectName(u'AuthorRemoveItem')
self.AuthorRemoveLayout.addWidget(self.AuthorRemoveItem) self.AuthorRemoveLayout.addWidget(self.AuthorRemoveItem)
self.AddAuthorsButton = QtGui.QPushButton(self.AuthorRemoveWidget) # self.AddAuthorsButton = QtGui.QPushButton(self.AuthorRemoveWidget)
self.AddAuthorsButton.setObjectName(u'AddAuthorsButton') # self.AddAuthorsButton.setObjectName(u'AddAuthorsButton')
self.AuthorRemoveLayout.addWidget(self.AddAuthorsButton) # self.AuthorRemoveLayout.addWidget(self.AddAuthorsButton)
self.AuthorsLayout.addWidget(self.AuthorRemoveWidget) self.AuthorsLayout.addWidget(self.AuthorRemoveWidget)
self.AdditionalLayout.addWidget(self.AuthorsGroupBox) self.AdditionalLayout.addWidget(self.AuthorsGroupBox)
self.SongBookGroup = QtGui.QGroupBox(self.AdditionalWidget) self.SongBookGroup = QtGui.QGroupBox(self.AdditionalWidget)
@ -197,14 +197,14 @@ class Ui_EditSongDialog(object):
self.SongbookCombo.setSizePolicy(sizePolicy) self.SongbookCombo.setSizePolicy(sizePolicy)
self.SongbookCombo.setObjectName(u'SongbookCombo') self.SongbookCombo.setObjectName(u'SongbookCombo')
self.SongbookLayout.addWidget(self.SongbookCombo, 0, 0, 1, 1) self.SongbookLayout.addWidget(self.SongbookCombo, 0, 0, 1, 1)
self.AddSongBookButton = QtGui.QPushButton(self.SongBookGroup) # self.AddSongBookButton = QtGui.QPushButton(self.SongBookGroup)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) # sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0) # sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) # sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.AddSongBookButton.sizePolicy().hasHeightForWidth()) # sizePolicy.setHeightForWidth(self.AddSongBookButton.sizePolicy().hasHeightForWidth())
self.AddSongBookButton.setSizePolicy(sizePolicy) # self.AddSongBookButton.setSizePolicy(sizePolicy)
self.AddSongBookButton.setObjectName(u'AddSongBookButton') # self.AddSongBookButton.setObjectName(u'AddSongBookButton')
self.SongbookLayout.addWidget(self.AddSongBookButton, 0, 1, 1, 1) # self.SongbookLayout.addWidget(self.AddSongBookButton, 0, 1, 1, 1)
self.AdditionalLayout.addWidget(self.SongBookGroup) self.AdditionalLayout.addWidget(self.SongBookGroup)
self.TopicGroupBox = QtGui.QGroupBox(self.AdditionalWidget) self.TopicGroupBox = QtGui.QGroupBox(self.AdditionalWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) 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 = QtGui.QPushButton(self.TopicRemoveWidget)
self.TopicRemoveItem.setObjectName(u'TopicRemoveItem') self.TopicRemoveItem.setObjectName(u'TopicRemoveItem')
self.TopicRemoveLayout.addWidget(self.TopicRemoveItem) self.TopicRemoveLayout.addWidget(self.TopicRemoveItem)
self.AddTopicButton = QtGui.QPushButton(self.TopicRemoveWidget) # self.AddTopicButton = QtGui.QPushButton(self.TopicRemoveWidget)
self.AddTopicButton.setObjectName(u'AddTopicButton') # self.AddTopicButton.setObjectName(u'AddTopicButton')
self.TopicRemoveLayout.addWidget(self.AddTopicButton) # self.TopicRemoveLayout.addWidget(self.AddTopicButton)
self.TopicLayout.addWidget(self.TopicRemoveWidget) self.TopicLayout.addWidget(self.TopicRemoveWidget)
self.AdditionalLayout.addWidget(self.TopicGroupBox) self.AdditionalLayout.addWidget(self.TopicGroupBox)
self.CopyrightgroupBox = QtGui.QGroupBox(self.AdditionalWidget) self.CopyrightgroupBox = QtGui.QGroupBox(self.AdditionalWidget)
@ -313,8 +313,9 @@ class Ui_EditSongDialog(object):
EditSongDialog.setTabOrder(self.AuthorAddtoSongItem, self.AuthorsListView) EditSongDialog.setTabOrder(self.AuthorAddtoSongItem, self.AuthorsListView)
EditSongDialog.setTabOrder(self.AuthorsListView, self.AuthorRemoveItem) EditSongDialog.setTabOrder(self.AuthorsListView, self.AuthorRemoveItem)
EditSongDialog.setTabOrder(self.AuthorRemoveItem, self.SongbookCombo) EditSongDialog.setTabOrder(self.AuthorRemoveItem, self.SongbookCombo)
EditSongDialog.setTabOrder(self.SongbookCombo, self.AddSongBookButton) #EditSongDialog.setTabOrder(self.SongbookCombo, self.AddSongBookButton)
EditSongDialog.setTabOrder(self.AddSongBookButton, self.SongTopicCombo) #EditSongDialog.setTabOrder(self.AddSongBookButton, self.SongTopicCombo)
EditSongDialog.setTabOrder(self.SongbookCombo, self.SongTopicCombo)
EditSongDialog.setTabOrder(self.SongTopicCombo, self.TopicsListView) EditSongDialog.setTabOrder(self.SongTopicCombo, self.TopicsListView)
EditSongDialog.setTabOrder(self.TopicsListView, self.TopicRemoveItem) EditSongDialog.setTabOrder(self.TopicsListView, self.TopicRemoveItem)
EditSongDialog.setTabOrder(self.TopicRemoveItem, self.CopyrightEditItem) EditSongDialog.setTabOrder(self.TopicRemoveItem, self.CopyrightEditItem)
@ -336,13 +337,13 @@ class Ui_EditSongDialog(object):
self.AuthorsGroupBox.setTitle(translate(u'EditSongDialog', u'Authors')) self.AuthorsGroupBox.setTitle(translate(u'EditSongDialog', u'Authors'))
self.AuthorAddtoSongItem.setText(translate(u'EditSongDialog', u'Add to Song')) self.AuthorAddtoSongItem.setText(translate(u'EditSongDialog', u'Add to Song'))
self.AuthorRemoveItem.setText(translate(u'EditSongDialog', u'Remove')) 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.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.TopicGroupBox.setTitle(translate(u'EditSongDialog', u'Topic'))
self.AddTopicsToSongButton.setText(translate(u'EditSongDialog', u'Add to Song')) self.AddTopicsToSongButton.setText(translate(u'EditSongDialog', u'Add to Song'))
self.TopicRemoveItem.setText(translate(u'EditSongDialog', u'Remove')) 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.CopyrightgroupBox.setTitle(translate(u'EditSongDialog', u'Copyright Infomaton'))
self.CopyrightInsertItem.setText(translate(u'EditSongDialog', u'(c)')) self.CopyrightInsertItem.setText(translate(u'EditSongDialog', u'(c)'))
self.CCLILabel.setText(translate(u'EditSongDialog', u'CCLI Number:')) 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) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
# Connecting signals and slots # Connecting signals and slots
QtCore.QObject.connect(self.AddAuthorsButton, # QtCore.QObject.connect(self.AddAuthorsButton,
QtCore.SIGNAL(u'clicked()'), self.onAddAuthorsButtonClicked) # QtCore.SIGNAL(u'clicked()'), self.onAddAuthorsButtonClicked)
QtCore.QObject.connect(self.AuthorAddtoSongItem, QtCore.QObject.connect(self.AuthorAddtoSongItem,
QtCore.SIGNAL(u'clicked()'), self.onAuthorAddtoSongItemClicked) QtCore.SIGNAL(u'clicked()'), self.onAuthorAddtoSongItemClicked)
QtCore.QObject.connect(self.AuthorRemoveItem, QtCore.QObject.connect(self.AuthorRemoveItem,
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemovefromSongItemClicked) QtCore.SIGNAL(u'clicked()'), self.onAuthorRemovefromSongItemClicked)
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.AddTopicButton, # QtCore.QObject.connect(self.AddTopicButton,
QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked) # QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked)
QtCore.QObject.connect(self.AddTopicsToSongButton, QtCore.QObject.connect(self.AddTopicsToSongButton,
QtCore.SIGNAL(u'clicked()'), self.onTopicAddtoSongItemClicked) QtCore.SIGNAL(u'clicked()'), self.onTopicAddtoSongItemClicked)
QtCore.QObject.connect(self.TopicRemoveItem, QtCore.QObject.connect(self.TopicRemoveItem,
QtCore.SIGNAL(u'clicked()'), self.onTopicRemovefromSongItemClicked) QtCore.SIGNAL(u'clicked()'), self.onTopicRemovefromSongItemClicked)
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.AddSongBookButton, # QtCore.QObject.connect(self.AddSongBookButton,
QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked) # QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked)
QtCore.QObject.connect(self.CopyrightInsertItem, QtCore.QObject.connect(self.CopyrightInsertItem,
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertItemTriggered) QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertItemTriggered)
QtCore.QObject.connect(self.AddButton, QtCore.QObject.connect(self.AddButton,
@ -75,9 +75,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
# Create other objects and forms # Create other objects and forms
self.songmanager = songmanager self.songmanager = songmanager
self.eventmanager = eventmanager self.eventmanager = eventmanager
self.authors_form = AuthorsForm(self.songmanager) # self.authors_form = AuthorsForm(self.songmanager)
self.topics_form = TopicsForm(self.songmanager) # self.topics_form = TopicsForm(self.songmanager)
self.song_book_form = SongBookForm(self.songmanager) # self.song_book_form = SongBookForm(self.songmanager)
self.verse_form = EditVerseForm() self.verse_form = EditVerseForm()
self.initialise() self.initialise()
self.AuthorsListView.setSortingEnabled(False) self.AuthorsListView.setSortingEnabled(False)
@ -86,9 +86,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.TopicsListView.setAlternatingRowColors(True) self.TopicsListView.setAlternatingRowColors(True)
def initialise(self): def initialise(self):
self.loadAuthors()
self.loadTopics()
self.loadBooks()
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
self.AuthorRemoveItem.setEnabled(False) self.AuthorRemoveItem.setEnabled(False)
@ -140,26 +137,32 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.TopicsListView.clear() self.TopicsListView.clear()
self.title_change = False self.title_change = False
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason) self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
self.loadAuthors()
self.loadTopics()
self.loadBooks()
def loadSong(self, id): def loadSong(self, id):
log.debug(u'Load Song') log.debug(u'Load Song')
self.loadAuthors()
self.loadTopics()
self.loadBooks()
self.song = self.songmanager.get_song(id) self.song = self.songmanager.get_song(id)
self.TitleEditItem.setText(self.song.title) self.TitleEditItem.setText(self.song.title)
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), 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
book_name.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.SongbookCombo.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
self.song.theme_name = None self.song.theme_name = None
self.SongbookCombo.setCurrentIndex(id) self.ThemeSelectionComboItem.setCurrentIndex(id)
if len(title) > 1: if len(title) > 1:
self.AlternativeEdit.setText(title[1]) self.AlternativeEdit.setText(title[1])
if self.song.copyright is not None: if self.song.copyright is not None:
@ -207,6 +210,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onAuthorAddtoSongItemClicked(self): def onAuthorAddtoSongItemClicked(self):
item = int(self.AuthorsSelectionComboItem.currentIndex()) item = int(self.AuthorsSelectionComboItem.currentIndex())
if item > -1:
item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0] item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
author = self.songmanager.get_author(item_id) author = self.songmanager.get_author(item_id)
self.song.authors.append(author) self.song.authors.append(author)
@ -229,6 +233,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onTopicAddtoSongItemClicked(self): def onTopicAddtoSongItemClicked(self):
item = int(self.SongTopicCombo.currentIndex()) item = int(self.SongTopicCombo.currentIndex())
if item > -1:
item_id = (self.SongTopicCombo.itemData(item)).toInt()[0] item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
topic = self.songmanager.get_topic(item_id) topic = self.songmanager.get_topic(item_id)
self.song.topics.append(topic) self.song.topics.append(topic)
@ -247,29 +252,30 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.topics.remove(topic) self.song.topics.remove(topic)
row = self.TopicsListView.row(item) row = self.TopicsListView.row(item)
self.TopicsListView.takeItem(row) 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): # def onAddAuthorsButtonClicked(self):
""" # """
Slot documentation goes here. # Slot documentation goes here.
""" # """
self.topics_form.load_form() # self.authors_form.load_form()
self.topics_form.exec_() # self.authors_form.exec_()
self.loadTopics() # self.loadAuthors()
#
def onAddSongBookButtonClicked(self): # def onAddTopicButtonClicked(self):
""" # """
Slot documentation goes here. # Slot documentation goes here.
""" # """
self.song_book_form.load_form() # self.topics_form.load_form()
self.song_book_form.exec_() # self.topics_form.exec_()
self.loadBooks() # 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): def onSongBookComboChanged(self, item):
if item == 0: if item == 0:
@ -301,7 +307,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verse_form.setVerse(item.text()) self.verse_form.setVerse(item.text())
self.verse_form.exec_() self.verse_form.exec_()
item.setText(self.verse_form.getVerse()) item.setText(self.verse_form.getVerse())
self.VerseListWidget.update() self.VerseListWidget.repaint()
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
@ -367,7 +373,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.ccli_number = unicode(self.CCLNumberEdit.displayText()) self.song.ccli_number = unicode(self.CCLNumberEdit.displayText())
self.processLyrics() self.processLyrics()
self.processTitle() self.processTitle()
self.song.song_book_id = 0
self.songmanager.save_song(self.song) self.songmanager.save_song(self.song)
if self.title_change: if self.title_change:
self.eventmanager.post_event(Event(EventType.LoadSongList)) self.eventmanager.post_event(Event(EventType.LoadSongList))

View File

@ -55,13 +55,9 @@ class SongManager():
self.config.get_config(u'db hostname') + u'/' + \ self.config.get_config(u'db hostname') + u'/' + \
self.config.get_config(u'db database') self.config.get_config(u'db database')
self.session = init_models(self.db_url) self.session = init_models(self.db_url)
if not songs_table.exists(): metadata.create_all(checkfirst=True)
metadata.create_all()
log.debug(u'Song Initialised') log.debug(u'Song Initialised')
# def process_dialog(self, dialogobject):
# self.dialogobject = dialogobject
def get_songs(self): def get_songs(self):
""" """
Returns the details of a song Returns the details of a song

View File

@ -22,7 +22,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser , contextMenuAction, contextMenuSeparator 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): class SongList(QtGui.QListWidget):
@ -59,6 +59,9 @@ class SongMediaItem(MediaManagerItem):
self.ConfigSection = u'song' self.ConfigSection = u'song'
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager) 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): def setupUi(self):
# Add a toolbar # Add a toolbar
@ -90,6 +93,19 @@ class SongMediaItem(MediaManagerItem):
self.addToolbarButton(translate(u'SongMediaItem', u'Add Song To Service'), self.addToolbarButton(translate(u'SongMediaItem', u'Add Song To Service'),
translate(u'SongMediaItem', u'Add the selected song(s) to the service'), translate(u'SongMediaItem', u'Add the selected song(s) to the service'),
':/system/system_add.png', self.onSongAddClick, 'SongAddItem') ':/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 ## ## Add the songlist widget ##
# Create the tab widget # Create the tab widget
self.SongWidget = QtGui.QWidget(self) self.SongWidget = QtGui.QWidget(self)
@ -222,6 +238,18 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form.newSong() self.edit_song_form.newSong()
self.edit_song_form.exec_() 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): def onSongEditClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:

View File

@ -4,6 +4,9 @@
<file>song_edit.png</file> <file>song_edit.png</file>
<file>song_export.png</file> <file>song_export.png</file>
<file>song_new.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>
<qresource prefix="slides" > <qresource prefix="slides" >
<file>slide_close.png</file> <file>slide_close.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

5
songcnv.sh Executable file
View File

@ -0,0 +1,5 @@
/usr/bin/sqlite ~/.local/share/openlp/songs/songs.olp .dump > ~/.local/share/openlp/songs/songs.dmp
./cnvdb.py ~/.local/share/openlp/songs/songs.dmp ~/.local/share/openlp/songs/songs.dmp2
rm ~/.local/share/openlp/songs/songs.sqlite
sqlite3 ~/.local/share/openlp/songs/songs.sqlite < ~/.local/share/openlp/songs/songs.dmp2
./openlpcnv.pyw