From d6462a6ff4867200d8ac7dc8f66dbdccf62034e5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 6 Jan 2009 18:36:54 +0000 Subject: [PATCH] Update UI Fix database name retrival Use ORM for get_Authors method. bzr-revno: 269 --- openlp/plugins/songs/forms/editsongdialog.py | 204 +++++++------- openlp/plugins/songs/forms/editsongform.py | 7 +- openlp/plugins/songs/lib/songDBimpl.py | 90 ++---- openlp/plugins/songs/lib/songmanager.py | 9 +- resources/forms/authorsdialog.ui | 37 ++- resources/forms/editsongdialog.ui | 280 ++++++++----------- resources/forms/songbookdialog.ui | 22 +- resources/forms/topicsdialog.ui | 41 ++- 8 files changed, 319 insertions(+), 371 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 940618a9f..a4e9a87a5 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -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)) + diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 21aee873b..7273fd0a5 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -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 diff --git a/openlp/plugins/songs/lib/songDBimpl.py b/openlp/plugins/songs/lib/songDBimpl.py index d415b96a1..9050df175 100644 --- a/openlp/plugins/songs/lib/songDBimpl.py +++ b/openlp/plugins/songs/lib/songDBimpl.py @@ -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 "" , 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 diff --git a/openlp/plugins/songs/lib/songmanager.py b/openlp/plugins/songs/lib/songmanager.py index 01ebc5697..b76aa21ed 100644 --- a/openlp/plugins/songs/lib/songmanager.py +++ b/openlp/plugins/songs/lib/songmanager.py @@ -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 diff --git a/resources/forms/authorsdialog.ui b/resources/forms/authorsdialog.ui index 8c6735c7c..0760dfabb 100644 --- a/resources/forms/authorsdialog.ui +++ b/resources/forms/authorsdialog.ui @@ -52,7 +52,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -88,7 +88,7 @@ - + Delete Author @@ -102,7 +102,7 @@ - + Add Update Author @@ -116,6 +116,20 @@ + + + + Clear Selection + + + + + + + :/songs/song_edit.png:/songs/song_edit.png + + + @@ -140,14 +154,21 @@ 301 + + true + true - 2 + 0 - - + + false + + + false + diff --git a/resources/forms/editsongdialog.ui b/resources/forms/editsongdialog.ui index b13adb5dd..f01c851c8 100644 --- a/resources/forms/editsongdialog.ui +++ b/resources/forms/editsongdialog.ui @@ -82,7 +82,7 @@ - + 329 @@ -91,34 +91,24 @@ 431 - + 0 - 10 - 45 - 17 + 0 + 381 + 66 - - Authors: + + Authors - - - - - 0 - 25 - 361 - 27 - - - + - 8 + 2 - 0 + 2 @@ -164,155 +154,67 @@ - + 0 - 85 - 351 - 27 + 65 + 381 + 61 - - - - 0 - 0 - 351 - 29 - - - - - - - - - - Add Song Book - - - - - - - - - - 10 - 160 - 96 - 17 - - - - Selected Authors: - - - - - - 0 - 368 - 147 - 27 - - - - - 8 - - - 0 - - - - - - - 0 - 50 - 57 - 27 - - - + SongBook - - - - - 0 - 110 - 242 - 27 - - - - SongTopic - - - - - - 180 - 160 - 96 - 17 - - - - Selected Topics: - - - - - - 10 - 180 - 341 - 191 - - - - - - - true - - + + + 2 + + + 2 + + + - - - - true + + + + Add Song Book - + - 3 + 0 130 - 341 - 29 + 381 + 66 - - - + + Topic + + + + 2 + + + 2 + + + - + Add to Song - + Add Topic @@ -321,33 +223,79 @@ - + - 10 - 380 - 341 - 29 + 0 + 200 + 191 + 231 - + + Selected Authors + + + + 2 + + + 2 + + + + + true + + + - Remove Selected Author(s) + Remove + + + + + + + + + 190 + 200 + 181 + 231 + + + + Selected Topics + + + + 2 + + + 2 + + + + + true - Remove Selected Topics + Remove + Selectedroup + TextWidget @@ -428,13 +376,16 @@ - 341 - 461 - 371 - 52 + 340 + 440 + 381 + 110 - + + + QFormLayout::AllNonFixedFieldsGrow + @@ -445,6 +396,16 @@ + + + + CCL Number: + + + + + + @@ -460,11 +421,6 @@ - layoutWidget - TopWidget - ThemeWidget - ButtonBox - layoutWidget diff --git a/resources/forms/songbookdialog.ui b/resources/forms/songbookdialog.ui index 4aa4a25f4..d6e1198c0 100644 --- a/resources/forms/songbookdialog.ui +++ b/resources/forms/songbookdialog.ui @@ -30,7 +30,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -56,7 +56,7 @@ - + Delete Author @@ -70,7 +70,7 @@ - + Add Update Author @@ -84,6 +84,20 @@ + + + + Clear Selection + + + + + + + :/songs/song_edit.png:/songs/song_edit.png + + + diff --git a/resources/forms/topicsdialog.ui b/resources/forms/topicsdialog.ui index fe6f465fa..200c90572 100644 --- a/resources/forms/topicsdialog.ui +++ b/resources/forms/topicsdialog.ui @@ -14,9 +14,6 @@ Topic Maintenance - - - @@ -30,7 +27,7 @@ - + @@ -46,7 +43,7 @@ - + Delete Author @@ -60,7 +57,7 @@ - + Add Update Author @@ -74,9 +71,33 @@ + + + + Clear Selection + + + + + + + :/songs/song_edit.png:/songs/song_edit.png + + + + + + + + + + + + + @@ -87,16 +108,8 @@ - - - - - - - TopicGroupBox - TopicListView MessageLabel TopicsListView ButtonBox