Start to add data to database

bzr-revno: 412
This commit is contained in:
Tim Bentley 2009-03-13 06:12:22 +00:00
parent 90a91aa788
commit 71a3ac4c78
3 changed files with 37 additions and 32 deletions

View File

@ -20,6 +20,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from PyQt4 import Qt, QtCore, QtGui from PyQt4 import Qt, QtCore, QtGui
from editcustomdialog import Ui_customEditDialog 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): class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
""" """
@ -55,9 +57,20 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def accept(self): def accept(self):
self.validate() self.validate()
for i in range (0, self.VerseListView.count()):
print self.VerseListView.item(i).text()
if self.valid: 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() self.close()
def rejected(self): def rejected(self):

View File

@ -21,6 +21,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from manager import CustomManager from manager import CustomManager
from customtab import CustomTab from customtab import CustomTab
from mediaitem import CustomMediaItem from mediaitem import CustomMediaItem
from textlistdata import TextListData
__all__ = ['CustomManager', 'CustomTab', 'CustomMediaItem'] __all__ = ['CustomManager', 'CustomTab', 'CustomMediaItem', 'TextListData']

View File

@ -3,7 +3,7 @@
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman 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 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 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): # def process_dialog(self, dialogobject):
# self.dialogobject = dialogobject # self.dialogobject = dialogobject
# #
# def get_songs(self): def get_all_slides(self):
# """ """
# Returns the details of a song Returns the details of a song
# """ """
# return self.session.query(Song).order_by(title).all() return self.session.query(CustomSlide).order_by(CustomSlide.title).all()
#
# def search_song_title(self, keywords): def get_custom(self, id=None):
# """ """
# Searches the song title for keywords. Returns the details of a song
# """ """
# return self.session.query(Song).filter(Song.search_title.like(u'%' + keywords + u'%')).order_by(Song.search_title.asc()).all() if id is None:
# return CustomeSlide()
# def search_song_lyrics(self, keywords): else:
# """ return self.session.query(CustomSlide).get(id)
# Searches the song lyrics for keywords.
# """ def save_slide(self, customslide):
# 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):
""" """
Saves a song to the database Saves a song to the database
""" """
log.debug('Custom Slide added')
try: try:
self.session.add(customslide) self.session.add(customslide)
self.session.commit() self.session.commit()
log.debug('Custom Slide saved')
return True return True
except: except:
log.debug('Custom Slide failed')
return False return False
# #
# def delete_song(self, song): # def delete_song(self, song):