Finish the cleanup of Songs.

bzr-revno: 467
This commit is contained in:
Tim Bentley 2009-06-14 19:35:17 +01:00
commit e84e2a8a54
12 changed files with 293 additions and 363 deletions

View File

@ -1,115 +1,121 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
# Form implementation generated from reading ui file 'authorsdialog.ui'
#
# Created: Sat Jan 3 11:48:36 2009
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
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
"""
from PyQt4 import QtCore, QtGui
from openlp.plugins.songs.lib import TextListData
from openlp.core.lib import translate
class Ui_AuthorsDialog(object):
def setupUi(self, AuthorsDialog):
AuthorsDialog.setObjectName("AuthorsDialog")
AuthorsDialog.setObjectName(u'AuthorsDialog')
AuthorsDialog.resize(410, 505)
self.DialogLayout = QtGui.QVBoxLayout(AuthorsDialog)
self.DialogLayout.setSpacing(8)
self.DialogLayout.setMargin(8)
self.DialogLayout.setObjectName("DialogLayout")
self.AuthorListView = QtGui.QListView()
self.AuthorListView.setAlternatingRowColors(True)
self.AuthorListData = TextListData()
self.AuthorListView.setModel(self.AuthorListData)
self.DialogLayout.addWidget(self.AuthorListView)
self.DialogLayout.setObjectName(u'DialogLayout')
self.AuthorListWidget = QtGui.QListWidget()
self.AuthorListWidget.setAlternatingRowColors(True)
self.DialogLayout.addWidget(self.AuthorListWidget)
self.AuthorDetails = QtGui.QGroupBox(AuthorsDialog)
self.AuthorDetails.setMinimumSize(QtCore.QSize(0, 0))
self.AuthorDetails.setObjectName("AuthorDetails")
self.AuthorDetails.setObjectName(u'AuthorDetails')
self.AuthorLayout = QtGui.QVBoxLayout(self.AuthorDetails)
self.AuthorLayout.setSpacing(8)
self.AuthorLayout.setMargin(8)
self.AuthorLayout.setObjectName("AuthorLayout")
self.AuthorLayout.setObjectName(u'AuthorLayout')
self.DetailsWidget = QtGui.QWidget(self.AuthorDetails)
self.DetailsWidget.setObjectName("DetailsWidget")
self.DetailsWidget.setObjectName(u'DetailsWidget')
self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)
self.DetailsLayout.setMargin(0)
self.DetailsLayout.setSpacing(8)
self.DetailsLayout.setObjectName("DetailsLayout")
self.DetailsLayout.setObjectName(u'DetailsLayout')
self.DisplayLabel = QtGui.QLabel(self.DetailsWidget)
self.DisplayLabel.setObjectName("DisplayLabel")
self.DisplayLabel.setObjectName(u'DisplayLabel')
self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.DisplayLabel)
self.DisplayEdit = QtGui.QLineEdit(self.DetailsWidget)
self.DisplayEdit.setObjectName("DisplayEdit")
self.DisplayEdit.setObjectName(u'DisplayEdit')
self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.DisplayEdit)
self.FirstNameLabel = QtGui.QLabel(self.DetailsWidget)
self.FirstNameLabel.setObjectName("FirstNameLabel")
self.FirstNameLabel.setObjectName(u'FirstNameLabel')
self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.FirstNameLabel)
self.FirstNameEdit = QtGui.QLineEdit(self.DetailsWidget)
self.FirstNameEdit.setObjectName("FirstNameEdit")
self.FirstNameEdit.setObjectName(u'FirstNameEdit')
self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.FirstNameEdit)
self.LastNameLabel = QtGui.QLabel(self.DetailsWidget)
self.LastNameLabel.setObjectName("LastNameLabel")
self.LastNameLabel.setObjectName(u'LastNameLabel')
self.DetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.LastNameLabel)
self.LastNameEdit = QtGui.QLineEdit(self.DetailsWidget)
self.LastNameEdit.setObjectName("LastNameEdit")
self.LastNameEdit.setObjectName(u'LastNameEdit')
self.DetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.LastNameEdit)
self.AuthorLayout.addWidget(self.DetailsWidget)
self.MessageLabel = QtGui.QLabel(self.AuthorDetails)
self.MessageLabel.setObjectName("MessageLabel")
self.MessageLabel.setObjectName(u'MessageLabel')
self.AuthorLayout.addWidget(self.MessageLabel)
self.ButtonWidget = QtGui.QWidget(self.AuthorDetails)
self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))
self.ButtonWidget.setObjectName("ButtonWidget")
self.ButtonWidget.setObjectName(u'ButtonWidget')
self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)
self.ButtonLayout.setSpacing(8)
self.ButtonLayout.setMargin(0)
self.ButtonLayout.setObjectName("ButtonLayout")
self.ButtonLayout.setObjectName(u'ButtonLayout')
spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.ButtonLayout.addItem(spacerItem)
self.ClearButton = QtGui.QPushButton(self.ButtonWidget)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ClearButton.setIcon(icon)
self.ClearButton.setObjectName("ClearButton")
self.ClearButton.setObjectName(u'ClearButton')
self.ButtonLayout.addWidget(self.ClearButton)
self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.AddUpdateButton.setIcon(icon1)
self.AddUpdateButton.setObjectName("AddUpdateButton")
self.AddUpdateButton.setObjectName(u'AddUpdateButton')
self.ButtonLayout.addWidget(self.AddUpdateButton)
self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon2.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DeleteButton.setIcon(icon2)
self.DeleteButton.setObjectName("DeleteButton")
self.DeleteButton.setObjectName(u'DeleteButton')
self.ButtonLayout.addWidget(self.DeleteButton)
self.AuthorLayout.addWidget(self.ButtonWidget)
self.DialogLayout.addWidget(self.AuthorDetails)
self.buttonBox = QtGui.QDialogButtonBox(AuthorsDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.buttonBox.setObjectName(u'buttonBox')
self.DialogLayout.addWidget(self.buttonBox)
self.retranslateUi(AuthorsDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), AuthorsDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), AuthorsDialog.reject)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), AuthorsDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), AuthorsDialog.reject)
QtCore.QMetaObject.connectSlotsByName(AuthorsDialog)
def retranslateUi(self, AuthorsDialog):
AuthorsDialog.setWindowTitle(QtGui.QApplication.translate("AuthorsDialog", "Author Maintenance", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorDetails.setTitle(QtGui.QApplication.translate("AuthorsDialog", "Author Details", None, QtGui.QApplication.UnicodeUTF8))
self.DisplayLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Display Name:", None, QtGui.QApplication.UnicodeUTF8))
self.FirstNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "First Name:", None, QtGui.QApplication.UnicodeUTF8))
self.LastNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Last Name:", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
self.buttonBox.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Exit Screen", None, QtGui.QApplication.UnicodeUTF8))
AuthorsDialog.setWindowTitle(translate(u'AuthorsDialog', u'Author Maintenance'))
self.AuthorDetails.setTitle(translate(u'AuthorsDialog', u'Author Details'))
self.DisplayLabel.setText(translate(u'AuthorsDialog', u'Display Name:'))
self.FirstNameLabel.setText(translate(u'AuthorsDialog', u'First Name:'))
self.LastNameLabel.setText(translate(u'AuthorsDialog', u'Last Name:'))
self.ClearButton.setToolTip(translate(u'AuthorsDialog', u'Clear Selection'))
self.ClearButton.setText(translate(u'AuthorsDialog', u'Clear'))
self.AddUpdateButton.setToolTip(translate(u'AuthorsDialog', u'Add Update Author'))
self.AddUpdateButton.setText(translate(u'AuthorsDialog', u'Save'))
self.DeleteButton.setToolTip(translate(u'AuthorsDialog', u'Delete Author'))
self.DeleteButton.setText(translate(u'AuthorsDialog', u'Delete'))
self.buttonBox.setToolTip(translate(u'AuthorsDialog', u'Exit Screen'))

View File

@ -19,7 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from PyQt4 import QtGui, QtCore
from openlp.core.lib import translate
from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
from openlp.plugins.songs.lib import TextListData
from openlp.plugins.songs.lib.classes import Author
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
"""
@ -43,27 +43,24 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
QtCore.QObject.connect(self.DisplayEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onDisplayEditLostFocus)
QtCore.QObject.connect(self.AuthorListView,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListViewItemClicked)
QtCore.QObject.connect(self.AuthorListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListWidgetItemClicked)
def load_form(self):
"""
Refresh the screen and rest fields
"""
self.AuthorListData.resetStore()
self.AuthorListWidget.clear()
self.onClearButtonClick() # tidy up screen
authors = self.songmanager.get_authors()
for author in authors:
self.AuthorListData.addRow(author.id,author.display_name)
#rowCount is number of rows BUT test should be Zero based
row_count = self.AuthorListData.rowCount(None) - 1
if self.currentRow > row_count:
# in case we have delete the last row of the table
self.currentRow = row_count
row = self.AuthorListData.createIndex(self.currentRow, 0)
if row.isValid():
self.AuthorListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
author_name = QtGui.QListWidgetItem(author.display_name)
author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
self.AuthorListWidget.addItem(author_name)
if self.currentRow >= self.AuthorListWidget.count() :
self.AuthorListWidget.setCurrentRow(self.AuthorListWidget.count() - 1)
else:
self.AuthorListWidget.setCurrentRow(self.currentRow)
self._validate_form()
def onDeleteButtonClick(self):
@ -101,15 +98,15 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self.author = None
self._validate_form()
def onAuthorListViewItemClicked(self, index):
def onAuthorListWidgetItemClicked(self, index):
"""
An Author has been selected display it
If the author is attached to a Song prevent delete
"""
self.currentRow = index.row()
id = int(self.AuthorListData.getId(index))
self.author = self.songmanager.get_author(id)
self.currentRow = self.AuthorListWidget.currentRow()
item = self.AuthorListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.author = self.songmanager.get_author(item_id)
self.DisplayEdit.setText(self.author.display_name)
self.FirstNameEdit.setText(self.author.first_name)
self.LastNameEdit.setText(self.author.last_name)

View File

@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
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
"""
from openlp.core.lib import translate
from PyQt4 import QtCore, QtGui

View File

@ -99,20 +99,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
authors = self.songmanager.get_authors()
self.AuthorsSelectionComboItem.clear()
for author in authors:
row = self.AuthorsSelectionComboItem.count()
self.AuthorsSelectionComboItem.addItem(author.display_name)
self.AuthorsSelectionComboItem.setItemData(row, QtCore.QVariant(author.id))
def loadTopics(self):
topics = self.songmanager.get_topics()
self.SongTopicCombo.clear()
for topic in topics:
row = self.SongTopicCombo.count()
self.SongTopicCombo.addItem(topic.name)
self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id))
def loadBooks(self):
books = self.songmanager.get_books()
self.SongbookCombo.clear()
self.SongbookCombo.addItem(u' ')
for book in books:
row = self.SongbookCombo.count()
self.SongbookCombo.addItem(book.name)
self.SongbookCombo.setItemData(row, QtCore.QVariant(book.id))
def loadThemes(self, theme_list):
self.ThemeSelectionComboItem.clear()
@ -180,8 +186,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.title_change = False
def onAuthorAddtoSongItemClicked(self):
author_name = unicode(self.AuthorsSelectionComboItem.currentText())
author = self.songmanager.get_author_by_name(author_name)
item = int(self.AuthorsSelectionComboItem.currentIndex())
item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
author = self.songmanager.get_author(item_id)
self.song.authors.append(author)
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
@ -201,8 +208,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.AuthorsListView.takeItem(row)
def onTopicAddtoSongItemClicked(self):
topic_name = unicode(self.SongTopicCombo.currentText())
topic = self.songmanager.get_topic_by_name(topic_name)
item = int(self.SongTopicCombo.currentIndex())
item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
topic = self.songmanager.get_topic(item_id)
self.song.topics.append(topic)
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
@ -248,9 +256,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if item == 0:
self.song.song_book_id = 0
else:
book_name = unicode(self.SongbookCombo.itemText(item))
book = self.songmanager.get_book_by_name(book_name)
self.song.song_book_id = book.id
item = int(self.SongbookCombo.currentIndex())
self.song.song_book_id = (self.SongbookCombo.itemData(item)).toInt()[0]
def onThemeComboChanged(self, item):
if item == 0:
@ -293,22 +300,25 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
valid = True
if len(self.TitleEditItem.displayText()) == 0:
valid = False
self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
else:
self.TitleEditItem.setStyleSheet(u'')
if len(self.CopyrightEditItem.displayText()) == 0:
valid = False
self.CopyrightEditItem.setStyleSheet(u'background-color: red; color: white')
else:
self.CopyrightEditItem.setStyleSheet(u'')
if self.VerseListWidget.count() == 0:
valid = False
self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
else:
self.VerseListWidget.setStyleSheet(u'')
if self.AuthorsListView.count() == 0:
valid = False
return valid
def _color_widget(self, slot, invalid):
r = Qt.QPalette(slot.palette())
if invalid == True:
r.setColor(Qt.QPalette.Base, Qt.QColor(u'darkRed'))
self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
else:
r.setColor(Qt.QPalette.Base, Qt.QColor(u'white'))
slot.setPalette(r)
slot.setAutoFillBackground(True)
self.AuthorsListView.setStyleSheet(u'')
return valid
def on_TitleEditItem_lostFocus(self):
self.song.title = self.TitleEditItem.text()

View File

@ -1,60 +1,66 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
# Form implementation generated from reading ui file 'songbookdialog.ui'
#
# Created: Sun Jan 4 08:43:12 2009
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
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
"""
from PyQt4 import QtCore, QtGui
from openlp.plugins.songs.lib import TextListData
from openlp.core.lib import translate
class Ui_SongBookDialog(object):
def setupUi(self, SongBookDialog):
SongBookDialog.setObjectName("SongBookDialog")
SongBookDialog.setObjectName(u'SongBookDialog')
SongBookDialog.resize(387, 531)
self.DialogLayout = QtGui.QVBoxLayout(SongBookDialog)
self.DialogLayout.setSpacing(8)
self.DialogLayout.setMargin(8)
self.DialogLayout.setObjectName("DialogLayout")
self.BookSongListView = QtGui.QListView()
self.BookSongListView.setAlternatingRowColors(True)
self.BookSongListData = TextListData()
self.BookSongListView.setModel(self.BookSongListData)
self.DialogLayout.addWidget(self.BookSongListView)
self.DialogLayout.addWidget(self.BookSongListView)
self.DialogLayout.setObjectName(u'DialogLayout')
self.BookSongListWidget = QtGui.QListWidget()
self.BookSongListWidget.setAlternatingRowColors(True)
self.DialogLayout.addWidget(self.BookSongListWidget)
self.DialogLayout.addWidget(self.BookSongListWidget)
self.SongBookGroup = QtGui.QGroupBox(SongBookDialog)
self.SongBookGroup.setMinimumSize(QtCore.QSize(0, 200))
self.SongBookGroup.setObjectName("SongBookGroup")
self.SongBookGroup.setObjectName(u'SongBookGroup')
self.SongBookLayout = QtGui.QVBoxLayout(self.SongBookGroup)
self.SongBookLayout.setSpacing(8)
self.SongBookLayout.setMargin(8)
self.SongBookLayout.setObjectName("SongBookLayout")
self.SongBookLayout.setObjectName(u'SongBookLayout')
self.DetailsWidget = QtGui.QWidget(self.SongBookGroup)
self.DetailsWidget.setMinimumSize(QtCore.QSize(0, 0))
self.DetailsWidget.setObjectName("DetailsWidget")
self.DetailsWidget.setObjectName(u'DetailsWidget')
self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)
self.DetailsLayout.setMargin(0)
self.DetailsLayout.setSpacing(8)
self.DetailsLayout.setObjectName("DetailsLayout")
self.DetailsLayout.setObjectName(u'DetailsLayout')
self.NameLabel = QtGui.QLabel(self.DetailsWidget)
self.NameLabel.setObjectName("NameLabel")
self.NameLabel.setObjectName(u'NameLabel')
self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.NameLabel)
self.NameEdit = QtGui.QLineEdit(self.DetailsWidget)
self.NameEdit.setObjectName("NameEdit")
self.NameEdit.setObjectName(u'NameEdit')
self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.NameEdit)
self.PublisherLabel = QtGui.QLabel(self.DetailsWidget)
self.PublisherLabel.setObjectName("PublisherLabel")
self.PublisherLabel.setObjectName(u'PublisherLabel')
self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.PublisherLabel)
self.PublisherEdit = QtGui.QLineEdit(self.DetailsWidget)
self.PublisherEdit.setObjectName("PublisherEdit")
self.PublisherEdit.setObjectName(u'PublisherEdit')
self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.PublisherEdit)
self.SongBookLayout.addWidget(self.DetailsWidget)
self.MessageLabel = QtGui.QLabel(self.SongBookGroup)
self.MessageLabel.setObjectName("MessageLabel")
self.MessageLabel.setObjectName(u'MessageLabel')
self.SongBookLayout.addWidget(self.MessageLabel)
self.ButtonWidget = QtGui.QWidget(self.SongBookGroup)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
@ -63,52 +69,51 @@ class Ui_SongBookDialog(object):
sizePolicy.setHeightForWidth(self.ButtonWidget.sizePolicy().hasHeightForWidth())
self.ButtonWidget.setSizePolicy(sizePolicy)
self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))
self.ButtonWidget.setObjectName("ButtonWidget")
self.ButtonWidget.setObjectName(u'ButtonWidget')
self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)
self.ButtonLayout.setSpacing(8)
self.ButtonLayout.setMargin(0)
self.ButtonLayout.setObjectName("ButtonLayout")
self.ButtonLayout.setObjectName(u'ButtonLayout')
spacerItem = QtGui.QSpacerItem(61, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.ButtonLayout.addItem(spacerItem)
self.ClearButton = QtGui.QPushButton(self.ButtonWidget)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ClearButton.setIcon(icon)
self.ClearButton.setObjectName("ClearButton")
self.ClearButton.setObjectName(u'ClearButton')
self.ButtonLayout.addWidget(self.ClearButton)
self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.AddUpdateButton.setIcon(icon1)
self.AddUpdateButton.setObjectName("AddUpdateButton")
self.AddUpdateButton.setObjectName(u'AddUpdateButton')
self.ButtonLayout.addWidget(self.AddUpdateButton)
self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon2.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DeleteButton.setIcon(icon2)
self.DeleteButton.setObjectName("DeleteButton")
self.DeleteButton.setObjectName(u'DeleteButton')
self.ButtonLayout.addWidget(self.DeleteButton)
self.SongBookLayout.addWidget(self.ButtonWidget)
self.DialogLayout.addWidget(self.SongBookGroup)
self.ButtonBox = QtGui.QDialogButtonBox(SongBookDialog)
self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.ButtonBox.setObjectName("ButtonBox")
self.ButtonBox.setObjectName(u'ButtonBox')
self.DialogLayout.addWidget(self.ButtonBox)
self.retranslateUi(SongBookDialog)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), SongBookDialog.accept)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), SongBookDialog.reject)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), SongBookDialog.accept)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), SongBookDialog.reject)
QtCore.QMetaObject.connectSlotsByName(SongBookDialog)
def retranslateUi(self, SongBookDialog):
SongBookDialog.setWindowTitle(QtGui.QApplication.translate("SongBookDialog", "Book Song Maintenance", None, QtGui.QApplication.UnicodeUTF8))
self.SongBookGroup.setTitle(QtGui.QApplication.translate("SongBookDialog", "Song Book", None, QtGui.QApplication.UnicodeUTF8))
self.NameLabel.setText(QtGui.QApplication.translate("SongBookDialog", "Name:", None, QtGui.QApplication.UnicodeUTF8))
self.PublisherLabel.setText(QtGui.QApplication.translate("SongBookDialog", "Publisher:", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setText(QtGui.QApplication.translate("SongBookDialog", "New", None, QtGui.QApplication.UnicodeUTF8))
self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
self.AddUpdateButton.setText(QtGui.QApplication.translate("SongBookDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setText(QtGui.QApplication.translate("SongBookDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
SongBookDialog.setWindowTitle(translate(u'SongBookDialog', u'Book Song Maintenance'))
self.SongBookGroup.setTitle(translate(u'SongBookDialog', u'Song Book'))
self.NameLabel.setText(translate(u'SongBookDialog', u'Name:'))
self.PublisherLabel.setText(translate(u'SongBookDialog', u'Publisher:'))
self.ClearButton.setToolTip(translate(u'SongBookDialog', u'Clear Selection'))
self.ClearButton.setText(translate(u'SongBookDialog', u'Clear'))
self.AddUpdateButton.setToolTip(translate(u'SongBookDialog', u'Add Update Author'))
self.AddUpdateButton.setText(translate(u'SongBookDialog', u'Save'))
self.DeleteButton.setToolTip(translate(u'SongBookDialog', u'Delete Author'))
self.DeleteButton.setText(translate(u'SongBookDialog', u'Delete'))

View File

@ -44,28 +44,24 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
QtCore.QObject.connect(self.NameEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onBookNameEditLostFocus)
QtCore.QObject.connect(self.BookSongListView,
QtCore.QObject.connect(self.BookSongListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onBooksListViewItemClicked)
def load_form(self):
"""
Refresh the screen and rest fields
"""
self.BookSongListData.resetStore()
self.BookSongListWidget.clear()
self.onClearButtonClick() # tidy up screen
Books = self.songmanager.get_books()
for Book in Books:
self.BookSongListData.addRow(Book.id,Book.name)
#rowCount is number of rows BUT test should be Zero based
row_count = self.BookSongListData.rowCount(None) - 1
if self.currentRow > row_count:
# in case we have delete the last row of the table
self.currentRow = row_count
row = self.BookSongListData.createIndex(self.currentRow, 0)
if row.isValid():
self.BookSongListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self._validate_form()
books = self.songmanager.get_books()
for book in books:
book_name = QtGui.QListWidgetItem(book.name)
book_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(book.id))
self.BookSongListWidget.addItem(book_name)
if self.currentRow >= self.BookSongListWidget.count() :
self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
else:
self.BookSongListWidget.setCurrentRow(self.currentRow)
def onDeleteButtonClick(self):
"""
@ -106,10 +102,10 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
An Book has been selected display it
If the Book is attached to a Song prevent delete
"""
self.currentRow = index.row()
id = int(self.BookSongListData.getId(index))
self.Book = self.songmanager.get_book(id)
self.currentRow = self.BookSongListWidget.currentRow()
item = self.BookSongListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.Book = self.songmanager.get_book(item_id)
self.NameEdit.setText(self.Book.name)
self.PublisherEdit.setText(self.Book.publisher)
if len(self.Book.songs) > 0:

View File

@ -1,82 +1,88 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
# Form implementation generated from reading ui file 'topicsdialog.ui'
#
# Created: Sun Jan 4 08:42:59 2009
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
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
"""
from PyQt4 import QtCore, QtGui
from openlp.plugins.songs.lib import TextListData
from openlp.core.lib import translate
class Ui_TopicsDialog(object):
def setupUi(self, TopicsDialog):
TopicsDialog.setObjectName("TopicsDialog")
TopicsDialog.setObjectName(u'TopicsDialog')
TopicsDialog.resize(387, 463)
self.gridLayout_2 = QtGui.QGridLayout(TopicsDialog)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout_2.setObjectName(u'gridLayout_2')
self.TopicGroupBox = QtGui.QGroupBox(TopicsDialog)
self.TopicGroupBox.setObjectName("TopicGroupBox")
self.TopicGroupBox.setObjectName(u'TopicGroupBox')
self.gridLayout = QtGui.QGridLayout(self.TopicGroupBox)
self.gridLayout.setObjectName("gridLayout")
self.gridLayout.setObjectName(u'gridLayout')
self.TopicNameLabel = QtGui.QLabel(self.TopicGroupBox)
self.TopicNameLabel.setObjectName("TopicNameLabel")
self.TopicNameLabel.setObjectName(u'TopicNameLabel')
self.gridLayout.addWidget(self.TopicNameLabel, 0, 0, 1, 1)
self.TopicNameEdit = QtGui.QLineEdit(self.TopicGroupBox)
self.TopicNameEdit.setObjectName("TopicNameEdit")
self.TopicNameEdit.setObjectName(u'TopicNameEdit')
self.gridLayout.addWidget(self.TopicNameEdit, 0, 1, 1, 4)
spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 1, 0, 1, 2)
self.DeleteButton = QtGui.QPushButton(self.TopicGroupBox)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DeleteButton.setIcon(icon)
self.DeleteButton.setObjectName("DeleteButton")
self.DeleteButton.setObjectName(u'DeleteButton')
self.gridLayout.addWidget(self.DeleteButton, 1, 3, 1, 1)
self.AddUpdateButton = QtGui.QPushButton(self.TopicGroupBox)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.AddUpdateButton.setIcon(icon1)
self.AddUpdateButton.setObjectName("AddUpdateButton")
self.AddUpdateButton.setObjectName(u'AddUpdateButton')
self.gridLayout.addWidget(self.AddUpdateButton, 1, 4, 1, 1)
self.ClearButton = QtGui.QPushButton(self.TopicGroupBox)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon2.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ClearButton.setIcon(icon2)
self.ClearButton.setObjectName("ClearButton")
self.ClearButton.setObjectName(u'ClearButton')
self.gridLayout.addWidget(self.ClearButton, 1, 2, 1, 1)
self.gridLayout_2.addWidget(self.TopicGroupBox, 1, 0, 1, 1)
self.MessageLabel = QtGui.QLabel(TopicsDialog)
self.MessageLabel.setObjectName("MessageLabel")
self.MessageLabel.setObjectName(u'MessageLabel')
self.gridLayout_2.addWidget(self.MessageLabel, 3, 0, 1, 1)
self.TopicsListView = QtGui.QListView()
self.TopicsListView.setAlternatingRowColors(True)
self.TopicsListData = TextListData()
self.TopicsListView.setModel(self.TopicsListData)
self.gridLayout_2.addWidget(self.TopicsListView, 0, 0, 1, 1)
self.TopicsListWidget = QtGui.QListWidget()
self.TopicsListWidget.setAlternatingRowColors(True)
self.gridLayout_2.addWidget(self.TopicsListWidget, 0, 0, 1, 1)
self.ButtonBox = QtGui.QDialogButtonBox(TopicsDialog)
self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.ButtonBox.setObjectName("ButtonBox")
self.ButtonBox.setObjectName(u'ButtonBox')
self.gridLayout_2.addWidget(self.ButtonBox, 2, 0, 1, 1)
self.retranslateUi(TopicsDialog)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), TopicsDialog.accept)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), TopicsDialog.reject)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), TopicsDialog.accept)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), TopicsDialog.reject)
QtCore.QMetaObject.connectSlotsByName(TopicsDialog)
def retranslateUi(self, TopicsDialog):
TopicsDialog.setWindowTitle(QtGui.QApplication.translate("TopicsDialog", "Topic Maintenance", None, QtGui.QApplication.UnicodeUTF8))
self.TopicGroupBox.setTitle(QtGui.QApplication.translate("TopicsDialog", "Topic", None, QtGui.QApplication.UnicodeUTF8))
self.TopicNameLabel.setText(QtGui.QApplication.translate("TopicsDialog", "Topic Name:", None, QtGui.QApplication.UnicodeUTF8))
TopicsDialog.setWindowTitle(translate(u'TopicsDialog', u'Topic Maintenance'))
self.TopicGroupBox.setTitle(translate(u'TopicsDialog', u'Topic'))
self.TopicNameLabel.setText(translate(u'TopicsDialog', u'Topic Name:'))
self.DeleteButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setText(QtGui.QApplication.translate("TopicsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setToolTip(translate(u'TopicsDialog', u'Delete Author'))
self.DeleteButton.setText(translate(u'AuthorsDialog', u'Delete'))
self.AddUpdateButton.setToolTip(translate(u'TopicsDialog', u'Add Update Author'))
self.AddUpdateButton.setText(translate(u'AuthorsDialog', u'Save'))
self.ClearButton.setToolTip(translate(u'TopicsDialog', u'Clear Selection'))
self.ClearButton.setText(translate(u'TopicsDialog', u'Clear'))

View File

@ -18,7 +18,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
"""
from PyQt4 import QtGui, QtCore
from openlp.core.lib import translate
from openlp.plugins.songs.lib import TextListData
from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog
from openlp.plugins.songs.lib.classes import Topic
@ -44,27 +43,24 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
QtCore.QObject.connect(self.TopicNameEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onTopicNameEditLostFocus)
QtCore.QObject.connect(self.TopicsListView,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListViewItemClicked)
QtCore.QObject.connect(self.TopicsListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListWidgetItemClicked)
def load_form(self):
"""
Refresh the screen and rest fields
"""
self.TopicsListData.resetStore()
self.TopicsListWidget.clear()
self.onClearButtonClick() # tidy up screen
topics = self.songmanager.get_topics()
for topic in topics:
self.TopicsListData.addRow(topic.id,topic.name)
#rowCount is number of rows BUT test should be Zero based
row_count = self.TopicsListData.rowCount(None) - 1
if self.currentRow > row_count:
# in case we have delete the last row of the table
self.currentRow = row_count
row = self.TopicsListData.createIndex(self.currentRow, 0)
if row.isValid():
self.TopicsListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
topic_name = QtGui.QListWidgetItem(topic.name)
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.TopicsListWidget.addItem(topic_name)
if self.currentRow >= self.TopicsListWidget.count() :
self.TopicsListWidget.setCurrentRow(self.TopicsListWidget.count() - 1)
else:
self.TopicsListWidget.setCurrentRow(self.currentRow)
self._validate_form()
def onDeleteButtonClick(self):
@ -99,15 +95,15 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
self.topic = None
self._validate_form()
def onTopicsListViewItemClicked(self, index):
def onTopicsListWidgetItemClicked(self, index):
"""
An Topic has been selected display it
If the Topic is attached to a Song prevent delete
"""
self.currentRow = index.row()
id = int(self.TopicsListData.getId(index))
self.topic = self.songmanager.get_topic(id)
self.currentRow = self.TopicsListWidget.currentRow()
item = self.TopicsListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.topic = self.songmanager.get_topic(item_id)
self.TopicNameEdit.setText(self.topic.name)
if len(self.topic.songs) > 0:
self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))

View File

@ -17,7 +17,6 @@ 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
"""
from textlistdata import TextListData
from manager import SongManager
from songstab import SongsTab
from mediaitem import SongMediaItem

View File

@ -127,12 +127,6 @@ class SongManager():
"""
return self.session.query(Author).get(id)
def get_author_by_name(self, name):
"""
Details of the Author
"""
return self.session.query(Author).filter_by(display_name = name).first()
def save_author(self, author):
"""
Save the Author and refresh the cache
@ -172,12 +166,6 @@ class SongManager():
"""
return self.session.query(Topic).get(id)
def get_topic_by_name(self, name):
"""
Details of the Topic
"""
return self.session.query(Topic).filter_by(name = name).first()
def save_topic(self, topic):
"""
Save the Topic
@ -217,12 +205,6 @@ class SongManager():
"""
return self.session.query(Book).get(id)
def get_book_by_name(self, name):
"""
Details of the Books
"""
return self.session.query(Book).filter_by(name = name).first()
def save_book(self, book):
"""
Save the Book

View File

@ -23,12 +23,11 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser
from openlp.plugins.songs.forms import EditSongForm
from openlp.plugins.songs.lib import TextListData
class SongList(QtGui.QListView):
class SongList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
QtGui.QListWidget.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
@ -119,14 +118,12 @@ class SongMediaItem(MediaManagerItem):
self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
# Add the song widget to the page layout
self.PageLayout.addWidget(self.SongWidget)
self.SongListView = SongList()
self.SongListView.setAlternatingRowColors(True)
self.SongListData = TextListData()
self.SongListView.setModel(self.SongListData)
self.SongListView.setDragEnabled(True)
self.SongListView.setObjectName(u'SongListView')
self.PageLayout.addWidget(self.SongListView)
self.SongListView.setDragEnabled(True)
self.SongListWidget = SongList()
self.SongListWidget.setAlternatingRowColors(True)
self.SongListWidget.setDragEnabled(True)
self.SongListWidget.setObjectName(u'SongListWidget')
self.PageLayout.addWidget(self.SongListWidget)
self.SongListWidget.setDragEnabled(True)
# Signals and slots
QtCore.QObject.connect(self.SearchTextButton,
QtCore.SIGNAL(u'pressed()'), self.onSearchTextButtonClick)
@ -134,21 +131,21 @@ class SongMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'pressed()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.SearchTextEdit,
QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
QtCore.QObject.connect(self.SongListView,
QtCore.QObject.connect(self.SongListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
#define and add the context menu
self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
self.SongListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
':/songs/song_new.png', translate(u'SongMediaItem', u'&Edit Song'),
self.onSongEditClick))
self.SongListView.addAction(self.contextMenuSeparator(self.SongListView))
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
self.SongListWidget.addAction(self.contextMenuSeparator(self.SongListWidget))
self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
self.onSongPreviewClick))
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
self.onSongLiveClick))
self.SongListView.addAction(self.contextMenuAction(self.SongListView,
self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
self.onSongAddClick))
@ -165,7 +162,7 @@ class SongMediaItem(MediaManagerItem):
def displayResults(self, searchresults):
log.debug(u'display results')
self.SongListData.resetStore()
self.SongListWidget.clear()
#log.debug(u'Records returned from search %s", len(searchresults))
for song in searchresults:
author_list = u''
@ -174,7 +171,9 @@ class SongMediaItem(MediaManagerItem):
author_list = author_list + u', '
author_list = author_list + author.display_name
song_detail = unicode(u'%s (%s)' % (unicode(song.title), unicode(author_list)))
self.SongListData.addRow(song.id,song_detail)
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.SongListWidget.addItem(song_name)
def onClearTextButtonClick(self):
"""
@ -209,18 +208,16 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form.exec_()
def onSongEditClick(self):
indexes = self.SongListView.selectedIndexes()
for index in indexes:
id = self.SongListData.getId(index)
self.edit_song_form.loadSong(id)
self.edit_song_form.exec_()
item = self.SongListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.edit_song_form.loadSong(item_id)
self.edit_song_form.exec_()
def onSongDeleteClick(self):
indexes = self.SongListView.selectedIndexes()
for index in indexes:
id = self.SongListData.getId(index)
self.parent.songmanager.delete_song(id)
self.SongListData.deleteRow(index)
item = self.SongListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.songmanager.delete_song(id)
self.SongListWidget.removeItem(item)
def onSongPreviewClick(self):
service_item = ServiceItem(self.parent)
@ -233,29 +230,28 @@ class SongMediaItem(MediaManagerItem):
raw_footer = []
author_list = u''
ccl = u''
indexes = self.SongListView.selectedIndexes()
for index in indexes:
id = self.SongListData.getId(index)
song = self.parent.songmanager.get_song(id)
service_item.theme = song.theme_name
if song.lyrics.startswith(u'<?xml version='):
songXML=SongXMLParser(song.lyrics)
verseList = songXML.get_verses()
for verse in verseList:
service_item.add_from_text(verse[1][:30], verse[1])
else:
verses = song.lyrics.split(u'\n\n')
for slide in verses:
service_item.add_from_text(slide[:30], slide)
service_item.title = song.title
for author in song.authors:
if len(author_list) > 1:
author_list = author_list + u', '
author_list = author_list + unicode(author.display_name)
if song.ccli_number == None or len(song.ccli_number) == 0:
ccl = self.parent.settings.GeneralTab.CCLNumber
else:
ccl = unicode(song.ccli_number)
item = self.SongListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
song = self.parent.songmanager.get_song(item_id)
service_item.theme = song.theme_name
if song.lyrics.startswith(u'<?xml version='):
songXML=SongXMLParser(song.lyrics)
verseList = songXML.get_verses()
for verse in verseList:
service_item.add_from_text(verse[1][:30], verse[1])
else:
verses = song.lyrics.split(u'\n\n')
for slide in verses:
service_item.add_from_text(slide[:30], slide)
service_item.title = song.title
for author in song.authors:
if len(author_list) > 1:
author_list = author_list + u', '
author_list = author_list + unicode(author.display_name)
if song.ccli_number == None or len(song.ccli_number) == 0:
ccl = self.parent.settings.GeneralTab.CCLNumber
else:
ccl = unicode(song.ccli_number)
raw_footer.append(song.title)
raw_footer.append(author_list)
raw_footer.append(song.copyright )

View File

@ -1,81 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
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 logging
from PyQt4 import QtCore, QtGui
class TextListData(QtCore.QAbstractListModel):
"""
An abstract list of strings
"""
global log
log = logging.getLogger(u'TextListData')
log.info(u'started')
def __init__(self):
QtCore.QAbstractListModel.__init__(self)
self.items = [] # will be a list of (database id , title) tuples
def resetStore(self):
#reset list so can be reloaded
self.items = []
def rowCount(self, parent):
return len(self.items)
def insertRow(self, row, id, title):
self.beginInsertRows(QtCore.QModelIndex(),row,row)
self.items.insert(row, (id, title))
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QtCore.QModelIndex(), row,row)
self.items.pop(row)
self.endRemoveRows()
def addRow(self, id, title):
self.insertRow(len(self.items), id, title)
def data(self, index, role):
row = index.row()
if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
return QtCore.QVariant()
if role == QtCore.Qt.DisplayRole:
if row == self.rowCount(None):
row -= 1
retval = self.items[row][1]
else:
retval = QtCore.QVariant()
if type(retval) is not type(QtCore.QVariant):
return QtCore.QVariant(retval)
else:
return retval
def getIdList(self):
filelist = [item[0] for item in self.items];
return filelist
def getId(self, index):
row = index.row()
return self.items[row][0]
def deleteRow(self, index):
row = index.row()
self.removeRow(row)