Update UI

Fix database name retrival
Use ORM for get_Authors method.

bzr-revno: 269
This commit is contained in:
Tim Bentley 2009-01-06 18:36:54 +00:00
parent c9c3317483
commit d6462a6ff4
8 changed files with 319 additions and 371 deletions

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'editsongdialog.ui'
#
# Created: Thu Jan 1 09:56:53 2009
# Created: Mon Jan 5 19:38:13 2009
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
@ -49,20 +49,17 @@ class Ui_EditSongDialog(object):
self.LyricsTextEdit.setAcceptRichText(False)
self.LyricsTextEdit.setObjectName("LyricsTextEdit")
self.gridLayout.addWidget(self.LyricsTextEdit, 5, 0, 1, 1)
self.AuthorWidget = QtGui.QWidget(self.TopWidget)
self.AuthorWidget.setGeometry(QtCore.QRect(329, 0, 381, 431))
self.AuthorWidget.setObjectName("AuthorWidget")
self.AuthorsLabel = QtGui.QLabel(self.AuthorWidget)
self.AuthorsLabel.setGeometry(QtCore.QRect(0, 10, 45, 17))
self.AuthorsLabel.setObjectName("AuthorsLabel")
self.AuthorSelectWidget = QtGui.QWidget(self.AuthorWidget)
self.AuthorSelectWidget.setGeometry(QtCore.QRect(0, 25, 361, 27))
self.AuthorSelectWidget.setObjectName("AuthorSelectWidget")
self.AuthorSelectWidgetLayout = QtGui.QHBoxLayout(self.AuthorSelectWidget)
self.AuthorSelectWidgetLayout.setSpacing(8)
self.AuthorSelectWidgetLayout.setMargin(0)
self.AuthorSelectWidgetLayout.setObjectName("AuthorSelectWidgetLayout")
self.AuthorsSelectionComboItem = QtGui.QComboBox(self.AuthorSelectWidget)
self.Selectedroup = QtGui.QWidget(self.TopWidget)
self.Selectedroup.setGeometry(QtCore.QRect(329, 0, 381, 431))
self.Selectedroup.setObjectName("Selectedroup")
self.AuthorsGroupBox = QtGui.QGroupBox(self.Selectedroup)
self.AuthorsGroupBox.setGeometry(QtCore.QRect(0, 0, 381, 66))
self.AuthorsGroupBox.setObjectName("AuthorsGroupBox")
self.horizontalLayout = QtGui.QHBoxLayout(self.AuthorsGroupBox)
self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(2)
self.horizontalLayout.setObjectName("horizontalLayout")
self.AuthorsSelectionComboItem = QtGui.QComboBox(self.AuthorsGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
@ -73,89 +70,75 @@ class Ui_EditSongDialog(object):
self.AuthorsSelectionComboItem.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
self.AuthorsSelectionComboItem.setMinimumContentsLength(8)
self.AuthorsSelectionComboItem.setObjectName("AuthorsSelectionComboItem")
self.AuthorSelectWidgetLayout.addWidget(self.AuthorsSelectionComboItem)
self.AuthorAddtoSongItem = QtGui.QPushButton(self.AuthorSelectWidget)
self.horizontalLayout.addWidget(self.AuthorsSelectionComboItem)
self.AuthorAddtoSongItem = QtGui.QPushButton(self.AuthorsGroupBox)
self.AuthorAddtoSongItem.setMaximumSize(QtCore.QSize(110, 16777215))
self.AuthorAddtoSongItem.setObjectName("AuthorAddtoSongItem")
self.AuthorSelectWidgetLayout.addWidget(self.AuthorAddtoSongItem)
self.AddAuthorsButton = QtGui.QPushButton(self.AuthorSelectWidget)
self.horizontalLayout.addWidget(self.AuthorAddtoSongItem)
self.AddAuthorsButton = QtGui.QPushButton(self.AuthorsGroupBox)
self.AddAuthorsButton.setObjectName("AddAuthorsButton")
self.AuthorSelectWidgetLayout.addWidget(self.AddAuthorsButton)
self.SongBookGroup = QtGui.QWidget(self.AuthorWidget)
self.SongBookGroup.setGeometry(QtCore.QRect(0, 85, 351, 27))
self.horizontalLayout.addWidget(self.AddAuthorsButton)
self.SongBookGroup = QtGui.QGroupBox(self.Selectedroup)
self.SongBookGroup.setGeometry(QtCore.QRect(0, 65, 381, 61))
self.SongBookGroup.setObjectName("SongBookGroup")
self.layoutWidget = QtGui.QWidget(self.SongBookGroup)
self.layoutWidget.setGeometry(QtCore.QRect(0, 0, 351, 29))
self.layoutWidget.setObjectName("layoutWidget")
self.SongBookLayout = QtGui.QHBoxLayout(self.layoutWidget)
self.SongBookLayout.setObjectName("SongBookLayout")
self.SongbookCombo = QtGui.QComboBox(self.layoutWidget)
self.gridLayout_2 = QtGui.QGridLayout(self.SongBookGroup)
self.gridLayout_2.setMargin(2)
self.gridLayout_2.setSpacing(2)
self.gridLayout_2.setObjectName("gridLayout_2")
self.SongbookCombo = QtGui.QComboBox(self.SongBookGroup)
self.SongbookCombo.setObjectName("SongbookCombo")
self.SongBookLayout.addWidget(self.SongbookCombo)
self.AddSongBookButton = QtGui.QPushButton(self.layoutWidget)
self.gridLayout_2.addWidget(self.SongbookCombo, 0, 0, 1, 1)
self.AddSongBookButton = QtGui.QPushButton(self.SongBookGroup)
self.AddSongBookButton.setObjectName("AddSongBookButton")
self.SongBookLayout.addWidget(self.AddSongBookButton)
self.SelectedAuthorsLabel = QtGui.QLabel(self.AuthorWidget)
self.SelectedAuthorsLabel.setGeometry(QtCore.QRect(10, 160, 96, 17))
self.SelectedAuthorsLabel.setObjectName("SelectedAuthorsLabel")
self.CopyrightWidget = QtGui.QWidget(self.AuthorWidget)
self.CopyrightWidget.setGeometry(QtCore.QRect(0, 368, 147, 27))
self.CopyrightWidget.setObjectName("CopyrightWidget")
self.CopyrightWidgetLayout = QtGui.QHBoxLayout(self.CopyrightWidget)
self.CopyrightWidgetLayout.setSpacing(8)
self.CopyrightWidgetLayout.setMargin(0)
self.CopyrightWidgetLayout.setObjectName("CopyrightWidgetLayout")
self.SongBookLabel = QtGui.QLabel(self.AuthorWidget)
self.SongBookLabel.setGeometry(QtCore.QRect(0, 50, 57, 27))
self.SongBookLabel.setObjectName("SongBookLabel")
self.Topiclabel = QtGui.QLabel(self.AuthorWidget)
self.Topiclabel.setGeometry(QtCore.QRect(0, 110, 242, 27))
self.Topiclabel.setObjectName("Topiclabel")
self.SelectedTopicsLabel = QtGui.QLabel(self.AuthorWidget)
self.SelectedTopicsLabel.setGeometry(QtCore.QRect(180, 160, 96, 17))
self.SelectedTopicsLabel.setObjectName("SelectedTopicsLabel")
self.layoutWidget1 = QtGui.QWidget(self.AuthorWidget)
self.layoutWidget1.setGeometry(QtCore.QRect(10, 180, 341, 191))
self.layoutWidget1.setObjectName("layoutWidget1")
self.SelectedAuthorsGroup = QtGui.QHBoxLayout(self.layoutWidget1)
self.SelectedAuthorsGroup.setObjectName("SelectedAuthorsGroup")
self.AuthorsListView = QtGui.QTableWidget(self.layoutWidget1)
self.gridLayout_2.addWidget(self.AddSongBookButton, 0, 1, 1, 1)
self.TopicGroupBox = QtGui.QGroupBox(self.Selectedroup)
self.TopicGroupBox.setGeometry(QtCore.QRect(0, 130, 381, 66))
self.TopicGroupBox.setObjectName("TopicGroupBox")
self.gridLayout_3 = QtGui.QGridLayout(self.TopicGroupBox)
self.gridLayout_3.setMargin(2)
self.gridLayout_3.setSpacing(2)
self.gridLayout_3.setObjectName("gridLayout_3")
self.SongTopicCombo = QtGui.QComboBox(self.TopicGroupBox)
self.SongTopicCombo.setObjectName("SongTopicCombo")
self.gridLayout_3.addWidget(self.SongTopicCombo, 0, 0, 1, 1)
self.AddTopicsToSongButton = QtGui.QPushButton(self.TopicGroupBox)
self.AddTopicsToSongButton.setObjectName("AddTopicsToSongButton")
self.gridLayout_3.addWidget(self.AddTopicsToSongButton, 0, 1, 1, 1)
self.AddTopicButton = QtGui.QPushButton(self.TopicGroupBox)
self.AddTopicButton.setObjectName("AddTopicButton")
self.gridLayout_3.addWidget(self.AddTopicButton, 0, 2, 1, 1)
self.SelectedAuthorGroupBox = QtGui.QGroupBox(self.Selectedroup)
self.SelectedAuthorGroupBox.setGeometry(QtCore.QRect(0, 200, 191, 231))
self.SelectedAuthorGroupBox.setObjectName("SelectedAuthorGroupBox")
self.verticalLayout = QtGui.QVBoxLayout(self.SelectedAuthorGroupBox)
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(2)
self.verticalLayout.setObjectName("verticalLayout")
self.AuthorsListView = QtGui.QTableWidget(self.SelectedAuthorGroupBox)
self.AuthorsListView.setAlternatingRowColors(True)
self.AuthorsListView.setObjectName("AuthorsListView")
self.AuthorsListView.setColumnCount(0)
self.AuthorsListView.setRowCount(0)
self.SelectedAuthorsGroup.addWidget(self.AuthorsListView)
self.ToticsListView = QtGui.QTableWidget(self.layoutWidget1)
self.verticalLayout.addWidget(self.AuthorsListView)
self.AuthorRemoveItem = QtGui.QPushButton(self.SelectedAuthorGroupBox)
self.AuthorRemoveItem.setObjectName("AuthorRemoveItem")
self.verticalLayout.addWidget(self.AuthorRemoveItem)
self.SelectedTopicGroupBox = QtGui.QGroupBox(self.Selectedroup)
self.SelectedTopicGroupBox.setGeometry(QtCore.QRect(190, 200, 181, 231))
self.SelectedTopicGroupBox.setObjectName("SelectedTopicGroupBox")
self.verticalLayout_2 = QtGui.QVBoxLayout(self.SelectedTopicGroupBox)
self.verticalLayout_2.setSpacing(2)
self.verticalLayout_2.setMargin(2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.ToticsListView = QtGui.QTableWidget(self.SelectedTopicGroupBox)
self.ToticsListView.setAlternatingRowColors(True)
self.ToticsListView.setObjectName("ToticsListView")
self.ToticsListView.setColumnCount(0)
self.ToticsListView.setRowCount(0)
self.SelectedAuthorsGroup.addWidget(self.ToticsListView)
self.layoutWidget2 = QtGui.QWidget(self.AuthorWidget)
self.layoutWidget2.setGeometry(QtCore.QRect(3, 130, 341, 29))
self.layoutWidget2.setObjectName("layoutWidget2")
self.SongTopicLayout = QtGui.QHBoxLayout(self.layoutWidget2)
self.SongTopicLayout.setObjectName("SongTopicLayout")
self.comboBox = QtGui.QComboBox(self.layoutWidget2)
self.comboBox.setObjectName("comboBox")
self.SongTopicLayout.addWidget(self.comboBox)
self.AddTopicsToSongButton = QtGui.QPushButton(self.layoutWidget2)
self.AddTopicsToSongButton.setObjectName("AddTopicsToSongButton")
self.SongTopicLayout.addWidget(self.AddTopicsToSongButton)
self.AddTopicButton = QtGui.QPushButton(self.layoutWidget2)
self.AddTopicButton.setObjectName("AddTopicButton")
self.SongTopicLayout.addWidget(self.AddTopicButton)
self.layoutWidget3 = QtGui.QWidget(self.AuthorWidget)
self.layoutWidget3.setGeometry(QtCore.QRect(10, 380, 341, 29))
self.layoutWidget3.setObjectName("layoutWidget3")
self.RemoveAuthorsLayout = QtGui.QHBoxLayout(self.layoutWidget3)
self.RemoveAuthorsLayout.setObjectName("RemoveAuthorsLayout")
self.AuthorRemoveItem = QtGui.QPushButton(self.layoutWidget3)
self.AuthorRemoveItem.setObjectName("AuthorRemoveItem")
self.RemoveAuthorsLayout.addWidget(self.AuthorRemoveItem)
self.pushButton = QtGui.QPushButton(self.layoutWidget3)
self.verticalLayout_2.addWidget(self.ToticsListView)
self.pushButton = QtGui.QPushButton(self.SelectedTopicGroupBox)
self.pushButton.setObjectName("pushButton")
self.RemoveAuthorsLayout.addWidget(self.pushButton)
self.verticalLayout_2.addWidget(self.pushButton)
self.ThemeWidget = QtGui.QWidget(EditSongDialog)
self.ThemeWidget.setGeometry(QtCore.QRect(10, 520, 641, 45))
self.ThemeWidget.setObjectName("ThemeWidget")
@ -176,32 +159,39 @@ class Ui_EditSongDialog(object):
self.ButtonBox.setGeometry(QtCore.QRect(500, 570, 156, 27))
self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
self.ButtonBox.setObjectName("ButtonBox")
self.layoutWidget4 = QtGui.QWidget(EditSongDialog)
self.layoutWidget4.setGeometry(QtCore.QRect(20, 490, 311, 25))
self.layoutWidget4.setObjectName("layoutWidget4")
self.VerseOrderLayout = QtGui.QHBoxLayout(self.layoutWidget4)
self.layoutWidget = QtGui.QWidget(EditSongDialog)
self.layoutWidget.setGeometry(QtCore.QRect(20, 490, 311, 25))
self.layoutWidget.setObjectName("layoutWidget")
self.VerseOrderLayout = QtGui.QHBoxLayout(self.layoutWidget)
self.VerseOrderLayout.setObjectName("VerseOrderLayout")
self.VerseOrderLabel = QtGui.QLabel(self.layoutWidget4)
self.VerseOrderLabel = QtGui.QLabel(self.layoutWidget)
self.VerseOrderLabel.setObjectName("VerseOrderLabel")
self.VerseOrderLayout.addWidget(self.VerseOrderLabel)
self.VerseOrderEdit = QtGui.QLineEdit(self.layoutWidget4)
self.VerseOrderEdit = QtGui.QLineEdit(self.layoutWidget)
self.VerseOrderEdit.setObjectName("VerseOrderEdit")
self.VerseOrderLayout.addWidget(self.VerseOrderEdit)
self.layoutWidget5 = QtGui.QWidget(EditSongDialog)
self.layoutWidget5.setGeometry(QtCore.QRect(341, 461, 371, 52))
self.layoutWidget5.setObjectName("layoutWidget5")
self.CopyrightLayout = QtGui.QGridLayout(self.layoutWidget5)
self.layoutWidget1 = QtGui.QWidget(EditSongDialog)
self.layoutWidget1.setGeometry(QtCore.QRect(340, 440, 381, 110))
self.layoutWidget1.setObjectName("layoutWidget1")
self.CopyrightLayout = QtGui.QFormLayout(self.layoutWidget1)
self.CopyrightLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
self.CopyrightLayout.setObjectName("CopyrightLayout")
self.CopyrightInfoLabel = QtGui.QLabel(self.layoutWidget5)
self.CopyrightInfoLabel = QtGui.QLabel(self.layoutWidget1)
self.CopyrightInfoLabel.setObjectName("CopyrightInfoLabel")
self.CopyrightLayout.addWidget(self.CopyrightInfoLabel, 0, 0, 1, 1)
self.CopyrightEditItem = QtGui.QLineEdit(self.layoutWidget5)
self.CopyrightLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.CopyrightInfoLabel)
self.CopyrightEditItem = QtGui.QLineEdit(self.layoutWidget1)
self.CopyrightEditItem.setObjectName("CopyrightEditItem")
self.CopyrightLayout.addWidget(self.CopyrightEditItem, 1, 0, 1, 1)
self.CopyrightInsertItem = QtGui.QPushButton(self.layoutWidget5)
self.CopyrightLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.CopyrightEditItem)
self.CCLLabel = QtGui.QLabel(self.layoutWidget1)
self.CCLLabel.setObjectName("CCLLabel")
self.CopyrightLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.CCLLabel)
self.CCLNumberEdit = QtGui.QLineEdit(self.layoutWidget1)
self.CCLNumberEdit.setObjectName("CCLNumberEdit")
self.CopyrightLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.CCLNumberEdit)
self.CopyrightInsertItem = QtGui.QPushButton(self.layoutWidget1)
self.CopyrightInsertItem.setMaximumSize(QtCore.QSize(29, 16777215))
self.CopyrightInsertItem.setObjectName("CopyrightInsertItem")
self.CopyrightLayout.addWidget(self.CopyrightInsertItem, 1, 1, 1, 1)
self.CopyrightLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.CopyrightInsertItem)
self.retranslateUi(EditSongDialog)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), EditSongDialog.close)
@ -213,20 +203,22 @@ class Ui_EditSongDialog(object):
self.TitleLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Title:", None, QtGui.QApplication.UnicodeUTF8))
self.AlternativeTitleLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Alternative Title:", None, QtGui.QApplication.UnicodeUTF8))
self.LyricsLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Lyrics:", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorsLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Authors:", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorsGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Authors", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorAddtoSongItem.setText(QtGui.QApplication.translate("EditSongDialog", "Add to Song", None, QtGui.QApplication.UnicodeUTF8))
self.AddAuthorsButton.setText(QtGui.QApplication.translate("EditSongDialog", "Add Authors", None, QtGui.QApplication.UnicodeUTF8))
self.SongBookGroup.setTitle(QtGui.QApplication.translate("EditSongDialog", "SongBook", None, QtGui.QApplication.UnicodeUTF8))
self.AddSongBookButton.setText(QtGui.QApplication.translate("EditSongDialog", "Add Song Book", None, QtGui.QApplication.UnicodeUTF8))
self.SelectedAuthorsLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Selected Authors:", None, QtGui.QApplication.UnicodeUTF8))
self.SongBookLabel.setText(QtGui.QApplication.translate("EditSongDialog", "SongBook", None, QtGui.QApplication.UnicodeUTF8))
self.Topiclabel.setText(QtGui.QApplication.translate("EditSongDialog", "SongTopic", None, QtGui.QApplication.UnicodeUTF8))
self.SelectedTopicsLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Selected Topics:", None, QtGui.QApplication.UnicodeUTF8))
self.TopicGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Topic", None, QtGui.QApplication.UnicodeUTF8))
self.AddTopicsToSongButton.setText(QtGui.QApplication.translate("EditSongDialog", "Add to Song", None, QtGui.QApplication.UnicodeUTF8))
self.AddTopicButton.setText(QtGui.QApplication.translate("EditSongDialog", "Add Topic", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorRemoveItem.setText(QtGui.QApplication.translate("EditSongDialog", "Remove Selected Author(s)", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("EditSongDialog", "Remove Selected Topics", None, QtGui.QApplication.UnicodeUTF8))
self.SelectedAuthorGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Selected Authors", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorRemoveItem.setText(QtGui.QApplication.translate("EditSongDialog", "Remove", None, QtGui.QApplication.UnicodeUTF8))
self.SelectedTopicGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Selected Topics", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("EditSongDialog", "Remove", None, QtGui.QApplication.UnicodeUTF8))
self.ThemeLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Theme", None, QtGui.QApplication.UnicodeUTF8))
self.ThemeAddItem.setText(QtGui.QApplication.translate("EditSongDialog", "Add a Theme", None, QtGui.QApplication.UnicodeUTF8))
self.VerseOrderLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Verse Order:", None, QtGui.QApplication.UnicodeUTF8))
self.CopyrightInfoLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Copyright Info:", None, QtGui.QApplication.UnicodeUTF8))
self.CCLLabel.setText(QtGui.QApplication.translate("EditSongDialog", "CCL Number:", None, QtGui.QApplication.UnicodeUTF8))
self.CopyrightInsertItem.setText(QtGui.QApplication.translate("EditSongDialog", "©", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -27,6 +27,8 @@ from songbookform import SongBookForm
from editsongdialog import Ui_EditSongDialog
from openlp.plugins.songs.lib.songtable import Author
class EditSongForm(QWidget, Ui_EditSongDialog):
"""
Class documentation goes here.
@ -46,9 +48,8 @@ class EditSongForm(QWidget, Ui_EditSongDialog):
def initialise(self):
list = self.songmanager.get_authors()
self.AuthorsSelectionComboItem.clear()
#print list
for l in list:
self.AuthorsSelectionComboItem.addItem(str(l[1]))
for i in list:
self.AuthorsSelectionComboItem.addItem( i.get_author_name())
def load_song(self, songid):
self.songid = songid

View File

@ -15,7 +15,8 @@ You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
import os, os.path
import os
import os.path
import sys
import time
import datetime
@ -25,10 +26,12 @@ import string
from sqlalchemy import *
from sqlalchemy.sql import select
from sqlalchemy.orm import sessionmaker, mapper
from sqlalchemy.types import Text, Unicode
from openlp.plugins.bibles.lib.biblecommon import BibleCommon
from openlp.core.utils import ConfigHelper
from songtable import Author
import logging
class SongDBException(Exception):
@ -40,40 +43,30 @@ metadata = MetaData()
author_table = Table('authors', metadata,
Column('authorid', Integer, primary_key=True),
Column('authorname', String(40)),
Column('first_name', String(40)),
Column('last_name', String(40)),
Column('authorname', Unicode(length=40)),
Column('first_name', Unicode(length=40)),
Column('last_name',Unicode(length=40)),
)
class Author(object):
def __init__(self, authorname, first_name, last_name):
#self.authorid = authorid
self.authorname =authorname
self.first_name =first_name
self.last_name =last_name
def __repr__(self):
return "<authormeta(%s,%s,%s)>" , self.authorname, self.first_name, self.last_name
mapper(Author,author_table)
class SongDBImpl(BibleCommon):
class SongDBImpl():
global log
log=logging.getLogger("SongDBImpl")
log.info("SongDBImpl loaded")
def __init__(self, songpath , suffix, btype = 'sqlite'):
def __init__(self, songpath , songname, suffix, btype = 'sqlite'):
# Connect to database
self.songfile = os.path.join(songpath, "songs."+suffix)
self.songfile = os.path.join(songpath, songname)
log.debug( "Load Song on path %s", self.songfile)
if btype == 'sqlite':
self.db = create_engine("sqlite:///"+self.songfile, convert_unicode=True)
self.db = create_engine("sqlite:///"+self.songfile, encoding='utf-8' , convert_unicode=False, assert_unicode=False)
elif btype == 'mysql':
self.db = create_engine("mysql://tim:@192.168.0.100:3306/openlp_rsv_bible")
self.db = create_engine("mysql://tim:@192.168.0.100:3306/openlp_song")
else:
raise BibleInvalidDatabaseError("Database not mysql or sqlite")
raise SongInvalidDatabaseError("Database not mysql or sqlite")
self.db.echo = True
self.db.convert_unicode=False
#self.db.convert_unicode=False
metadata.bind = self.db
metadata.bind.echo = False
self.Session = sessionmaker(autoflush=True, autocommit=False)
@ -83,17 +76,6 @@ class SongDBImpl(BibleCommon):
#self.songauthors = Table('songauthors', metadata, autoload=True)
#self.songs = Table('songs', metadata, autoload=True)
def create_tables(self):
log.debug( "createTables")
if os.path.exists(self.biblefile): # delete bible file and set it up again
os.remove(self.biblefile)
meta_table.create()
testament_table.create()
book_table.create()
verse_table.create()
self.save_meta("dbversion", "2")
self._loadTestaments()
def add_author(self, author_name, first_name, last_name):
log.debug( "add_author %s,%s,%s", author_name, first_name, last_name)
metadata.bind.echo = True
@ -127,8 +109,8 @@ class SongDBImpl(BibleCommon):
def get_authors(self):
log.debug( "get_authors ")
metadata.bind.echo = False
s = text (""" select authorid, authorname FROM authors order by authorname """)
return self.db.execute(s).fetchall()
session = self.Session()
return session.query(Author).order_by(Author.authorname).all()
def get_author(self, authorid):
log.debug( "get_author %s" , authorid)
@ -160,42 +142,6 @@ class SongDBImpl(BibleCommon):
s = text (""" select * FROM songauthors where songid = :c """)
return self.db.execute(s, c=songid).fetchall()
def get_max_bible_book_verses(self, bookname, chapter):
log.debug( "get_max_bible_book_verses %s,%s ", bookname , chapter)
metadata.bind.echo = False
s = text (""" 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()
def get_max_bible_book_chapter(self, bookname):
log.debug( "get_max_bible_book_chapter %s ", bookname )
metadata.bind.echo = False
s = text (""" select max(verse.chapter) from verse,book where book_id = book.id and book.name = :b """)
return self.db.execute(s, b=bookname).fetchone()
def get_bible_book(self, bookname):
log.debug( "get_bible_book %s", bookname)
metadata.bind.echo = False
s = text (""" select name FROM book where book.name == :b """)
return self.db.execute(s, b=bookname).fetchone()
def get_bible_book_Id(self, bookname):
log.debug( "get_bible_book_id %s", bookname)
metadata.bind.echo = False
s = text (""" select id FROM book where book.name == :b """)
return self.db.execute(s, b=bookname).fetchone()
def get_bible_chapter(self, bookname, chapter):
log.debug( "get_bible_chapter %s,%s", bookname, chapter )
metadata.bind.echo = False
s = text (""" select book.name FROM verse,book where verse.book_id == book.id AND verse.chapter == :c and book.name == :b """)
return self.db.execute(s, c=chapter, b=bookname).fetchone()
def get_bible_text(self, bookname, chapter, sverse, everse):
log.debug( "get_bible_text %s,%s,%s,%s ", bookname, chapter, sverse, everse)
metadata.bind.echo = False
s = text (""" 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 == :b """)
return self.db.execute(s, c=chapter, v1=sverse , v2=everse, b=bookname).fetchall()
def get_song_from_lyrics(self,searchtext):
log.debug( "get_song_from_lyrics %s",searchtext)
metadata.bind.echo = False

View File

@ -23,7 +23,6 @@ import sys
from songDBimpl import SongDBImpl
import logging
class SongManager():
@ -40,6 +39,7 @@ class SongManager():
"""
self.config = config
log.debug( "Song Initialising")
self.songDBCache = None
self.authorcache = None
self.songPath = self.config.get_data_path()
self.songSuffix = self.config.get_config("suffix name", u'olp3,sqlite')
@ -49,9 +49,14 @@ class SongManager():
files = self.config.get_files()
if len(files) > 0:
log.debug("Song File %s", files )
self.songDBCache = SongDBImpl(self.songPath, self.songSuffix)
self.songDBCache = SongDBImpl(self.songPath,files[0], self.songSuffix)
log.debug( "Song Initialised")
def have_song_database(self):
if self.songDBCache == None:
return False
return True
def process_dialog(self, dialogobject):
self.dialogobject = dialogobject

View File

@ -52,7 +52,7 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<item row="0" column="1" colspan="4">
<widget class="QLineEdit" name="DisplayEdit"/>
</item>
<item row="1" column="0">
@ -62,7 +62,7 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<item row="1" column="1" colspan="4">
<widget class="QLineEdit" name="FirstNameEdit"/>
</item>
<item row="2" column="0">
@ -72,7 +72,7 @@
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<item row="2" column="1" colspan="4">
<widget class="QLineEdit" name="LastNameEdit"/>
</item>
<item row="3" column="0" colspan="2">
@ -88,7 +88,7 @@
</property>
</spacer>
</item>
<item row="3" column="2">
<item row="3" column="3">
<widget class="QPushButton" name="DeleteButton">
<property name="toolTip">
<string>Delete Author</string>
@ -102,7 +102,7 @@
</property>
</widget>
</item>
<item row="3" column="3">
<item row="3" column="4">
<widget class="QPushButton" name="AddUpdateButton">
<property name="toolTip">
<string>Add Update Author</string>
@ -116,6 +116,20 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="ClearButton">
<property name="toolTip">
<string>Clear Selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/song_edit.png</normaloff>:/songs/song_edit.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="MessageLabel">
@ -140,14 +154,21 @@
<height>301</height>
</rect>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="columnCount">
<number>2</number>
<number>0</number>
</property>
<column/>
<column/>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</widget>
<resources>

View File

@ -82,7 +82,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="AuthorWidget" native="true">
<widget class="QWidget" name="Selectedroup" native="true">
<property name="geometry">
<rect>
<x>329</x>
@ -91,34 +91,24 @@
<height>431</height>
</rect>
</property>
<widget class="QLabel" name="AuthorsLabel">
<widget class="QGroupBox" name="AuthorsGroupBox">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>45</width>
<height>17</height>
<y>0</y>
<width>381</width>
<height>66</height>
</rect>
</property>
<property name="text">
<string>Authors:</string>
<property name="title">
<string>Authors</string>
</property>
</widget>
<widget class="QWidget" name="AuthorSelectWidget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>25</y>
<width>361</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="AuthorSelectWidgetLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>8</number>
<number>2</number>
</property>
<property name="margin">
<number>0</number>
<number>2</number>
</property>
<item>
<widget class="QComboBox" name="AuthorsSelectionComboItem">
@ -164,155 +154,67 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="SongBookGroup" native="true">
<widget class="QGroupBox" name="SongBookGroup">
<property name="geometry">
<rect>
<x>0</x>
<y>85</y>
<width>351</width>
<height>27</height>
<y>65</y>
<width>381</width>
<height>61</height>
</rect>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>29</height>
</rect>
</property>
<layout class="QHBoxLayout" name="SongBookLayout">
<item>
<widget class="QComboBox" name="SongbookCombo"/>
</item>
<item>
<widget class="QPushButton" name="AddSongBookButton">
<property name="text">
<string>Add Song Book</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QLabel" name="SelectedAuthorsLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>160</y>
<width>96</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Selected Authors:</string>
</property>
</widget>
<widget class="QWidget" name="CopyrightWidget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>368</y>
<width>147</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="CopyrightWidgetLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QLabel" name="SongBookLabel">
<property name="geometry">
<rect>
<x>0</x>
<y>50</y>
<width>57</width>
<height>27</height>
</rect>
</property>
<property name="text">
<property name="title">
<string>SongBook</string>
</property>
</widget>
<widget class="QLabel" name="Topiclabel">
<property name="geometry">
<rect>
<x>0</x>
<y>110</y>
<width>242</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>SongTopic</string>
</property>
</widget>
<widget class="QLabel" name="SelectedTopicsLabel">
<property name="geometry">
<rect>
<x>180</x>
<y>160</y>
<width>96</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Selected Topics:</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>341</width>
<height>191</height>
</rect>
</property>
<layout class="QHBoxLayout" name="SelectedAuthorsGroup">
<item>
<widget class="QTableWidget" name="AuthorsListView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="SongbookCombo"/>
</item>
<item>
<widget class="QTableWidget" name="ToticsListView">
<property name="alternatingRowColors">
<bool>true</bool>
<item row="0" column="1">
<widget class="QPushButton" name="AddSongBookButton">
<property name="text">
<string>Add Song Book</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QGroupBox" name="TopicGroupBox">
<property name="geometry">
<rect>
<x>3</x>
<x>0</x>
<y>130</y>
<width>341</width>
<height>29</height>
<width>381</width>
<height>66</height>
</rect>
</property>
<layout class="QHBoxLayout" name="SongTopicLayout">
<item>
<widget class="QComboBox" name="comboBox"/>
<property name="title">
<string>Topic</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="SongTopicCombo"/>
</item>
<item>
<item row="0" column="1">
<widget class="QPushButton" name="AddTopicsToSongButton">
<property name="text">
<string>Add to Song</string>
</property>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="QPushButton" name="AddTopicButton">
<property name="text">
<string>Add Topic</string>
@ -321,33 +223,79 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QGroupBox" name="SelectedAuthorGroupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>380</y>
<width>341</width>
<height>29</height>
<x>0</x>
<y>200</y>
<width>191</width>
<height>231</height>
</rect>
</property>
<layout class="QHBoxLayout" name="RemoveAuthorsLayout">
<property name="title">
<string>Selected Authors</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QTableWidget" name="AuthorsListView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="AuthorRemoveItem">
<property name="text">
<string>Remove Selected Author(s)</string>
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="SelectedTopicGroupBox">
<property name="geometry">
<rect>
<x>190</x>
<y>200</y>
<width>181</width>
<height>231</height>
</rect>
</property>
<property name="title">
<string>Selected Topics</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QTableWidget" name="ToticsListView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Remove Selected Topics</string>
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<zorder>Selectedroup</zorder>
<zorder>TextWidget</zorder>
</widget>
<widget class="QWidget" name="ThemeWidget" native="true">
<property name="geometry">
@ -428,13 +376,16 @@
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>341</x>
<y>461</y>
<width>371</width>
<height>52</height>
<x>340</x>
<y>440</y>
<width>381</width>
<height>110</height>
</rect>
</property>
<layout class="QGridLayout" name="CopyrightLayout">
<layout class="QFormLayout" name="CopyrightLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="CopyrightInfoLabel">
<property name="text">
@ -445,6 +396,16 @@
<item row="1" column="0">
<widget class="QLineEdit" name="CopyrightEditItem"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="CCLLabel">
<property name="text">
<string>CCL Number:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="CCLNumberEdit"/>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="CopyrightInsertItem">
<property name="maximumSize">
@ -460,11 +421,6 @@
</item>
</layout>
</widget>
<zorder>layoutWidget</zorder>
<zorder>TopWidget</zorder>
<zorder>ThemeWidget</zorder>
<zorder>ButtonBox</zorder>
<zorder>layoutWidget</zorder>
</widget>
<resources>
<include location="../images/openlp-2.qrc"/>

View File

@ -30,7 +30,7 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<item row="0" column="1" colspan="4">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="1" column="0">
@ -40,7 +40,7 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<item row="1" column="1" colspan="4">
<widget class="QLineEdit" name="PublisherEdit"/>
</item>
<item row="2" column="0" colspan="2">
@ -56,7 +56,7 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<item row="2" column="3">
<widget class="QPushButton" name="DeleteButton">
<property name="toolTip">
<string>Delete Author</string>
@ -70,7 +70,7 @@
</property>
</widget>
</item>
<item row="2" column="3">
<item row="2" column="4">
<widget class="QPushButton" name="AddUpdateButton">
<property name="toolTip">
<string>Add Update Author</string>
@ -84,6 +84,20 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="ClearButton">
<property name="toolTip">
<string>Clear Selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/song_edit.png</normaloff>:/songs/song_edit.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -14,9 +14,6 @@
<string>Topic Maintenance</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTableWidget" name="TopicsListView"/>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="TopicGroupBox">
<property name="title">
@ -30,7 +27,7 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<item row="0" column="1" colspan="4">
<widget class="QLineEdit" name="TopicNameEdit"/>
</item>
<item row="1" column="0" colspan="2">
@ -46,7 +43,7 @@
</property>
</spacer>
</item>
<item row="1" column="2">
<item row="1" column="3">
<widget class="QPushButton" name="DeleteButton">
<property name="toolTip">
<string>Delete Author</string>
@ -60,7 +57,7 @@
</property>
</widget>
</item>
<item row="1" column="3">
<item row="1" column="4">
<widget class="QPushButton" name="AddUpdateButton">
<property name="toolTip">
<string>Add Update Author</string>
@ -74,9 +71,33 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="ClearButton">
<property name="toolTip">
<string>Clear Selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/song_edit.png</normaloff>:/songs/song_edit.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="MessageLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTableWidget" name="TopicsListView"/>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="ButtonBox">
<property name="orientation">
@ -87,16 +108,8 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="MessageLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
<zorder>TopicGroupBox</zorder>
<zorder>TopicListView</zorder>
<zorder>MessageLabel</zorder>
<zorder>TopicsListView</zorder>
<zorder>ButtonBox</zorder>