forked from openlp/openlp
Start to add data to database
bzr-revno: 412
This commit is contained in:
parent
90a91aa788
commit
71a3ac4c78
@ -20,6 +20,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from PyQt4 import Qt, QtCore, QtGui
|
||||
|
||||
from editcustomdialog import Ui_customEditDialog
|
||||
from openlp.core.lib import SongXMLBuilder
|
||||
from openlp.plugins.custom.lib.models import CustomSlide
|
||||
|
||||
class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
"""
|
||||
@ -55,9 +57,20 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
|
||||
def accept(self):
|
||||
self.validate()
|
||||
for i in range (0, self.VerseListView.count()):
|
||||
print self.VerseListView.item(i).text()
|
||||
if self.valid:
|
||||
sxml=SongXMLBuilder()
|
||||
sxml.new_document()
|
||||
sxml.add_lyrics_to_song()
|
||||
count = 1
|
||||
for i in range (0, self.VerseListView.count()):
|
||||
sxml.add_verse_to_lyrics(u'custom', str(count), str(self.VerseListView.item(i).text()))
|
||||
count += 1
|
||||
sxml.dump_xml()
|
||||
customSlide = CustomSlide()
|
||||
customSlide.title = str(self.TitleEdit.displayText())
|
||||
customSlide.text = str(sxml.extract_xml())
|
||||
customSlide.credits = str(self.CreditEdit.displayText())
|
||||
self.custommanager.save_slide(customSlide)
|
||||
self.close()
|
||||
|
||||
def rejected(self):
|
||||
|
@ -21,6 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from manager import CustomManager
|
||||
from customtab import CustomTab
|
||||
from mediaitem import CustomMediaItem
|
||||
from textlistdata import TextListData
|
||||
|
||||
__all__ = ['CustomManager', 'CustomTab', 'CustomMediaItem']
|
||||
__all__ = ['CustomManager', 'CustomTab', 'CustomMediaItem', 'TextListData']
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
|
||||
Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -64,42 +64,33 @@ class CustomManager():
|
||||
# def process_dialog(self, dialogobject):
|
||||
# self.dialogobject = dialogobject
|
||||
#
|
||||
# def get_songs(self):
|
||||
# """
|
||||
# Returns the details of a song
|
||||
# """
|
||||
# return self.session.query(Song).order_by(title).all()
|
||||
#
|
||||
# def search_song_title(self, keywords):
|
||||
# """
|
||||
# Searches the song title for keywords.
|
||||
# """
|
||||
# return self.session.query(Song).filter(Song.search_title.like(u'%' + keywords + u'%')).order_by(Song.search_title.asc()).all()
|
||||
#
|
||||
# def search_song_lyrics(self, keywords):
|
||||
# """
|
||||
# Searches the song lyrics for keywords.
|
||||
# """
|
||||
# return self.session.query(Song).filter(Song.search_lyrics.like(u'%' + keywords + u'%')).order_by(Song.search_lyrics.asc()).all()
|
||||
#
|
||||
# def get_song(self, id=None):
|
||||
# """
|
||||
# Returns the details of a song
|
||||
# """
|
||||
# if id is None:
|
||||
# return Song()
|
||||
# else:
|
||||
# return self.session.query(Song).get(id)
|
||||
#
|
||||
def save_slides(self, customslide):
|
||||
def get_all_slides(self):
|
||||
"""
|
||||
Returns the details of a song
|
||||
"""
|
||||
return self.session.query(CustomSlide).order_by(CustomSlide.title).all()
|
||||
|
||||
def get_custom(self, id=None):
|
||||
"""
|
||||
Returns the details of a song
|
||||
"""
|
||||
if id is None:
|
||||
return CustomeSlide()
|
||||
else:
|
||||
return self.session.query(CustomSlide).get(id)
|
||||
|
||||
def save_slide(self, customslide):
|
||||
"""
|
||||
Saves a song to the database
|
||||
"""
|
||||
log.debug('Custom Slide added')
|
||||
try:
|
||||
self.session.add(customslide)
|
||||
self.session.commit()
|
||||
log.debug('Custom Slide saved')
|
||||
return True
|
||||
except:
|
||||
log.debug('Custom Slide failed')
|
||||
return False
|
||||
#
|
||||
# def delete_song(self, song):
|
||||
|
Loading…
Reference in New Issue
Block a user