The new song maintenance dialog... getting there.

This commit is contained in:
Raoul Snyman 2009-07-23 22:20:49 +02:00
parent cf5b415640
commit af9b8edd6f
17 changed files with 723 additions and 66 deletions

View File

@ -53,6 +53,9 @@ class RenderManager(object):
self.screen_list = screen_list self.screen_list = screen_list
self.theme_manager = theme_manager self.theme_manager = theme_manager
self.displays = len(screen_list) self.displays = len(screen_list)
if (screen_number + 1) > len(screen_list):
self.current_display = 0
else:
self.current_display = screen_number self.current_display = screen_number
self.renderer = Renderer() self.renderer = Renderer()
self.calculate_default(self.screen_list[self.current_display][u'size']) self.calculate_default(self.screen_list[self.current_display][u'size'])

View File

@ -23,6 +23,7 @@ from topicsform import TopicsForm
from songbookform import SongBookForm from songbookform import SongBookForm
from editverseform import EditVerseForm from editverseform import EditVerseForm
from editsongform import EditSongForm from editsongform import EditSongForm
from songmaintenanceform import SongMaintenanceForm
from openlpexportform import OpenLPExportForm from openlpexportform import OpenLPExportForm
from openlpimportform import OpenLPImportForm from openlpimportform import OpenLPImportForm

View File

@ -0,0 +1,251 @@
# -*- 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 PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
class Ui_SongMaintenanceDialog(object):
def setupUi(self, SongMaintenanceDialog):
SongMaintenanceDialog.setObjectName("SongMaintenanceDialog")
SongMaintenanceDialog.setWindowModality(QtCore.Qt.ApplicationModal)
SongMaintenanceDialog.resize(486, 361)
self.DialogLayout = QtGui.QVBoxLayout(SongMaintenanceDialog)
self.DialogLayout.setSpacing(8)
self.DialogLayout.setMargin(8)
self.DialogLayout.setObjectName("DialogLayout")
self.ContentWidget = QtGui.QWidget(SongMaintenanceDialog)
self.ContentWidget.setObjectName("ContentWidget")
self.ContentLayout = QtGui.QHBoxLayout(self.ContentWidget)
self.ContentLayout.setSpacing(8)
self.ContentLayout.setMargin(0)
self.ContentLayout.setObjectName("ContentLayout")
self.TypeListWidget = QtGui.QListWidget(self.ContentWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.TypeListWidget.sizePolicy().hasHeightForWidth())
self.TypeListWidget.setSizePolicy(sizePolicy)
self.TypeListWidget.setProperty("showDropIndicator", QtCore.QVariant(False))
#self.TypeListWidget.setFlow(QtGui.QListView.TopToBottom)
self.TypeListWidget.setSpacing(0)
self.TypeListWidget.setViewMode(QtGui.QListView.IconMode)
self.TypeListWidget.setIconSize(QtCore.QSize(128, 100));
self.TypeListWidget.setMovement(QtGui.QListView.Static);
self.TypeListWidget.setMaximumWidth(128);
self.TypeListWidget.setSpacing(3);
self.TypeListWidget.setUniformItemSizes(True)
self.TypeListWidget.setObjectName("TypeListWidget")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/songs/author_maintenance.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
item = QtGui.QListWidgetItem(self.TypeListWidget)
item.setIcon(icon)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/songs/topic_maintenance.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
item = QtGui.QListWidgetItem(self.TypeListWidget)
item.setIcon(icon1)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/songs/book_maintenance.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
item = QtGui.QListWidgetItem(self.TypeListWidget)
item.setIcon(icon2)
self.ContentLayout.addWidget(self.TypeListWidget)
self.TypeStackedWidget = QtGui.QStackedWidget(self.ContentWidget)
self.TypeStackedWidget.setObjectName("TypeStackedWidget")
self.AuthorsPage = QtGui.QWidget()
self.AuthorsPage.setObjectName("AuthorsPage")
self.AuthorsLayout = QtGui.QVBoxLayout(self.AuthorsPage)
self.AuthorsLayout.setSpacing(8)
self.AuthorsLayout.setMargin(0)
self.AuthorsLayout.setObjectName("AuthorsLayout")
self.AuthorsListWidget = QtGui.QListWidget(self.AuthorsPage)
self.AuthorsListWidget.setObjectName("AuthorsListWidget")
self.AuthorsLayout.addWidget(self.AuthorsListWidget)
self.AuthorsErrorLabel = QtGui.QLabel(self.AuthorsPage)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.AuthorsErrorLabel.sizePolicy().hasHeightForWidth())
self.AuthorsErrorLabel.setSizePolicy(sizePolicy)
self.AuthorsErrorLabel.setSize(QtCore.QSize(0, 0))
self.AuthorsErrorLabel.setMargin(4)
self.AuthorsErrorLabel.setStyleSheet(u'background-color: #900; color: #fff;')
self.AuthorsErrorLabel.setObjectName("AuthorsErrorLabel")
self.AuthorsLayout.addWidget(self.AuthorsErrorLabel)
self.AuthorButtonWidget = QtGui.QWidget(self.AuthorsPage)
self.AuthorButtonWidget.setObjectName("AuthorButtonWidget")
self.AuthorButtonsLayout = QtGui.QHBoxLayout(self.AuthorButtonWidget)
self.AuthorButtonsLayout.setSpacing(8)
self.AuthorButtonsLayout.setMargin(0)
self.AuthorButtonsLayout.setObjectName("AuthorButtonsLayout")
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.AuthorButtonsLayout.addItem(spacerItem)
self.AuthorAddButton = QtGui.QPushButton(self.AuthorButtonWidget)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/songs/author_add.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.AuthorAddButton.setIcon(icon3)
self.AuthorAddButton.setObjectName("AuthorAddButton")
self.AuthorButtonsLayout.addWidget(self.AuthorAddButton)
self.AuthorEditButton = QtGui.QPushButton(self.AuthorButtonWidget)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(":/songs/author_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.AuthorEditButton.setIcon(icon4)
self.AuthorEditButton.setObjectName("AuthorEditButton")
self.AuthorButtonsLayout.addWidget(self.AuthorEditButton)
self.AuthorDeleteButton = QtGui.QPushButton(self.AuthorButtonWidget)
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap(":/songs/author_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.AuthorDeleteButton.setIcon(icon5)
self.AuthorDeleteButton.setObjectName("AuthorDeleteButton")
self.AuthorButtonsLayout.addWidget(self.AuthorDeleteButton)
self.AuthorsLayout.addWidget(self.AuthorButtonWidget)
self.AuthorsLine = QtGui.QFrame(self.AuthorsPage)
self.AuthorsLine.setFrameShape(QtGui.QFrame.HLine)
self.AuthorsLine.setFrameShadow(QtGui.QFrame.Sunken)
self.AuthorsLine.setObjectName("AuthorsLine")
self.AuthorsLayout.addWidget(self.AuthorsLine)
self.TypeStackedWidget.addWidget(self.AuthorsPage)
self.TopicsPage = QtGui.QWidget()
self.TopicsPage.setObjectName("TopicsPage")
self.TopicLayout = QtGui.QVBoxLayout(self.TopicsPage)
self.TopicLayout.setSpacing(4)
self.TopicLayout.setMargin(0)
self.TopicLayout.setObjectName("TopicLayout")
self.TopicsListWidget = QtGui.QListWidget(self.TopicsPage)
self.TopicsListWidget.setObjectName("TopicsListWidget")
self.TopicLayout.addWidget(self.TopicsListWidget)
self.TopicsErrorLabel = QtGui.QLabel(self.TopicsPage)
self.TopicsErrorLabel.setMaximumHeight(0)
self.TopicsErrorLabel.setMinimumHeight(0)
self.TopicsErrorLabel.setIndent(4)
self.TopicsErrorLabel.setStyleSheet(u'background-color: #900; color: #fff;')
self.TopicsErrorLabel.setObjectName("TopicsErrorLabel")
self.TopicLayout.addWidget(self.TopicsErrorLabel)
self.TopicButtonWidget = QtGui.QWidget(self.TopicsPage)
self.TopicButtonWidget.setObjectName("TopicButtonWidget")
self.TopicButtonLayout = QtGui.QHBoxLayout(self.TopicButtonWidget)
self.TopicButtonLayout.setSpacing(8)
self.TopicButtonLayout.setMargin(0)
self.TopicButtonLayout.setObjectName("TopicButtonLayout")
spacerItem1 = QtGui.QSpacerItem(54, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.TopicButtonLayout.addItem(spacerItem1)
self.TopicAddButton = QtGui.QPushButton(self.TopicButtonWidget)
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap(":/songs/topic_add.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.TopicAddButton.setIcon(icon6)
self.TopicAddButton.setObjectName("TopicAddButton")
self.TopicButtonLayout.addWidget(self.TopicAddButton)
self.TopicEditButton = QtGui.QPushButton(self.TopicButtonWidget)
icon7 = QtGui.QIcon()
icon7.addPixmap(QtGui.QPixmap(":/songs/topic_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.TopicEditButton.setIcon(icon7)
self.TopicEditButton.setObjectName("TopicEditButton")
self.TopicButtonLayout.addWidget(self.TopicEditButton)
self.TopicDeleteButton = QtGui.QPushButton(self.TopicButtonWidget)
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(":/songs/topic_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.TopicDeleteButton.setIcon(icon8)
self.TopicDeleteButton.setObjectName("TopicDeleteButton")
self.TopicButtonLayout.addWidget(self.TopicDeleteButton)
self.TopicLayout.addWidget(self.TopicButtonWidget)
self.TopicsLine = QtGui.QFrame(self.TopicsPage)
self.TopicsLine.setFrameShape(QtGui.QFrame.HLine)
self.TopicsLine.setFrameShadow(QtGui.QFrame.Sunken)
self.TopicsLine.setObjectName("TopicsLine")
self.TopicLayout.addWidget(self.TopicsLine)
self.TypeStackedWidget.addWidget(self.TopicsPage)
self.BooksPage = QtGui.QWidget()
self.BooksPage.setObjectName("BooksPage")
self.BookLayout = QtGui.QVBoxLayout(self.BooksPage)
self.BookLayout.setSpacing(4)
self.BookLayout.setMargin(0)
self.BookLayout.setObjectName("BookLayout")
self.BooksListWidget = QtGui.QListWidget(self.BooksPage)
self.BooksListWidget.setObjectName("BooksListWidget")
self.BookLayout.addWidget(self.BooksListWidget)
self.BooksErrorLabel = QtGui.QLabel(self.BooksPage)
self.BooksErrorLabel.setMaximumHeight(0)
self.BooksErrorLabel.setMinimumHeight(0)
self.BooksErrorLabel.setIndent(4)
self.BooksErrorLabel.setStyleSheet(u'background-color: #900; color: #fff;')
self.BooksErrorLabel.setObjectName("BooksErrorLabel")
self.BookLayout.addWidget(self.BooksErrorLabel)
self.BookButtonWidget = QtGui.QWidget(self.BooksPage)
self.BookButtonWidget.setObjectName("BookButtonWidget")
self.BookButtonLayout = QtGui.QHBoxLayout(self.BookButtonWidget)
self.BookButtonLayout.setSpacing(8)
self.BookButtonLayout.setMargin(0)
self.BookButtonLayout.setObjectName("BookButtonLayout")
spacerItem2 = QtGui.QSpacerItem(54, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.BookButtonLayout.addItem(spacerItem2)
self.BookAddButton = QtGui.QPushButton(self.BookButtonWidget)
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(":/songs/book_add.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.BookAddButton.setIcon(icon9)
self.BookAddButton.setObjectName("BookAddButton")
self.BookButtonLayout.addWidget(self.BookAddButton)
self.BookEditButton = QtGui.QPushButton(self.BookButtonWidget)
icon10 = QtGui.QIcon()
icon10.addPixmap(QtGui.QPixmap(":/songs/book_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.BookEditButton.setIcon(icon10)
self.BookEditButton.setObjectName("BookEditButton")
self.BookButtonLayout.addWidget(self.BookEditButton)
self.BookDeleteButton = QtGui.QPushButton(self.BookButtonWidget)
icon11 = QtGui.QIcon()
icon11.addPixmap(QtGui.QPixmap(":/songs/book_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.BookDeleteButton.setIcon(icon11)
self.BookDeleteButton.setObjectName("BookDeleteButton")
self.BookButtonLayout.addWidget(self.BookDeleteButton)
self.BookLayout.addWidget(self.BookButtonWidget)
self.BooksLine = QtGui.QFrame(self.BooksPage)
self.BooksLine.setFrameShape(QtGui.QFrame.HLine)
self.BooksLine.setFrameShadow(QtGui.QFrame.Sunken)
self.BooksLine.setObjectName("BooksLine")
self.BookLayout.addWidget(self.BooksLine)
self.TypeStackedWidget.addWidget(self.BooksPage)
self.ContentLayout.addWidget(self.TypeStackedWidget)
self.DialogLayout.addWidget(self.ContentWidget)
self.MaintenanceButtonBox = QtGui.QDialogButtonBox(SongMaintenanceDialog)
self.MaintenanceButtonBox.setOrientation(QtCore.Qt.Horizontal)
self.MaintenanceButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close)
self.MaintenanceButtonBox.setObjectName("MaintenanceButtonBox")
self.DialogLayout.addWidget(self.MaintenanceButtonBox)
self.retranslateUi(SongMaintenanceDialog)
self.TypeStackedWidget.setCurrentIndex(2)
QtCore.QObject.connect(self.MaintenanceButtonBox, QtCore.SIGNAL("rejected()"), SongMaintenanceDialog.accept)
QtCore.QObject.connect(self.TypeListWidget, QtCore.SIGNAL("currentRowChanged(int)"), self.TypeStackedWidget.setCurrentIndex)
QtCore.QMetaObject.connectSlotsByName(SongMaintenanceDialog)
def retranslateUi(self, SongMaintenanceDialog):
SongMaintenanceDialog.setWindowTitle(QtGui.QApplication.translate("SongMaintenanceDialog", "Song Maintenance", None, QtGui.QApplication.UnicodeUTF8))
__sortingEnabled = self.TypeListWidget.isSortingEnabled()
self.TypeListWidget.setSortingEnabled(False)
self.TypeListWidget.item(0).setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Authors", None, QtGui.QApplication.UnicodeUTF8))
self.TypeListWidget.item(1).setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Topics", None, QtGui.QApplication.UnicodeUTF8))
self.TypeListWidget.item(2).setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Books/Hymnals", None, QtGui.QApplication.UnicodeUTF8))
self.TypeListWidget.setSortingEnabled(__sortingEnabled)
self.AuthorAddButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Add", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorEditButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8))
self.AuthorDeleteButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
self.TopicAddButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Add", None, QtGui.QApplication.UnicodeUTF8))
self.TopicEditButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8))
self.TopicDeleteButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
self.BookAddButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Add", None, QtGui.QApplication.UnicodeUTF8))
self.BookEditButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8))
self.BookDeleteButton.setText(QtGui.QApplication.translate("SongMaintenanceDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -0,0 +1,181 @@
# -*- coding: utf-8 -*-
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
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 QtGui, QtCore
from openlp.core.lib import translate
from openlp.plugins.songs.forms import SongBookForm
from openlp.plugins.songs.lib.classes import Author, Book, Topic
from songmaintenancedialog import Ui_SongMaintenanceDialog
class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
"""
Class documentation goes here.
"""
def __init__(self, songmanager, parent=None):
"""
Constructor
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.songmanager = songmanager
self.timer = QtCore.QTimer()
QtCore.QObject.connect(self.timer,
QtCore.SIGNAL(u'timeout()'), self._hideErrors)
QtCore.QObject.connect(self.AuthorDeleteButton,
QtCore.SIGNAL(u'pressed()'), self.onAuthorDeleteButtonClick)
QtCore.QObject.connect(self.TopicDeleteButton,
QtCore.SIGNAL(u'pressed()'), self.onTopicDeleteButtonClick)
QtCore.QObject.connect(self.BookDeleteButton,
QtCore.SIGNAL(u'pressed()'), self.onBookDeleteButtonClick)
def exec_(self):
self.resetAuthors()
self.resetTopics()
self.resetBooks()
return QtGui.QDialog.exec_(self)
def _getCurrentItemId(self, ListWidget):
item = ListWidget.currentItem()
print item
if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
return item_id
else:
return -1
def _showError(self, error):
self.AuthorsErrorLabel.setSize(QtCore.QSize(0, 32))
self.AuthorsErrorLabel.setText(error)
self.TopicsErrorLabel.setMaximumHeight(32)
self.TopicsErrorLabel.setMinimumHeight(32)
self.TopicsErrorLabel.setText(error)
self.BooksErrorLabel.setMaximumHeight(32)
self.BooksErrorLabel.setMinimumHeight(32)
self.BooksErrorLabel.setText(error)
self.timer.start(2000)
def _hideErrors(self):
self.timer.stop()
self.AuthorsErrorLabel.setMaximumHeight(0)
self.AuthorsErrorLabel.setMinimumHeight(0)
self.AuthorsErrorLabel.clear()
self.TopicsErrorLabel.setMaximumHeight(0)
self.TopicsErrorLabel.setMinimumHeight(0)
self.TopicsErrorLabel.clear()
self.BooksErrorLabel.setMaximumHeight(0)
self.BooksErrorLabel.setMinimumHeight(0)
self.BooksErrorLabel.clear()
def resetAuthors(self):
self.AuthorsListWidget.clear()
authors = self.songmanager.get_authors()
for author in authors:
if author.display_name is not None and author.display_name != u'':
author_name = QtGui.QListWidgetItem(author.display_name)
else:
author_name = QtGui.QListWidgetItem(
u'%s %s' % (author.first_name, author.last_name))
author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
self.AuthorsListWidget.addItem(author_name)
def resetTopics(self):
self.TopicsListWidget.clear()
topics = self.songmanager.get_topics()
for topic in topics:
topic_name = QtGui.QListWidgetItem(topic.name)
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.TopicsListWidget.addItem(topic_name)
def resetBooks(self):
self.BooksListWidget.clear()
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.BooksListWidget.addItem(book_name)
def onAuthorDeleteButtonClick(self):
"""
Delete the author if the author is not attached to any songs
"""
author_id = self._getCurrentItemId(self.AuthorsListWidget)
if author_id != -1:
author = self.songmanager.get_author(author_id)
if QtGui.QMessageBox.warning(None,
translate(u'SongMaintenanceForm', u'Delete Author'),
translate(u'SongMaintenanceForm', u'Are you sure you want to delete the selected author?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
) == QtGui.QMessageBox.Yes:
if len(author.songs) == 0:
self.songmanager.delete_author(author.id)
self.resetAuthors()
else:
QtGui.QMessageBox.critical(None,
translate(u'SongMaintenanceForm', u'Delete Author'),
translate(u'SongMaintenanceForm', u'This author can\'t be deleted, they are currently assigned to at least one song!'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
else:
self._showError(translate(u'SongMaintenanceForm', u'No author selected!'))
def onTopicDeleteButtonClick(self):
"""
Delete the Book is the Book is not attached to any songs
"""
topic_id = self._getCurrentItemId(self.TopicsListWidget)
if topic_id != -1:
topic = self.songmanager.get_topic(topic_id)
if QtGui.QMessageBox.warning(None,
translate(u'SongMaintenanceForm', u'Delete Topic'),
translate(u'SongMaintenanceForm', u'Are you sure you want to delete the selected topic?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
) == QtGui.QMessageBox.Yes:
if len(topic.songs) == 0:
self.songmanager.delete_topic(topic.id)
self.resetTopics()
else:
#QtGui.QMessageBox.critical(None,
# translate(u'SongMaintenanceForm', u'Delete Topic'),
# translate(u'SongMaintenanceForm', u'This topic can\'t be deleted, it is currently assigned to at least one song!'),
# QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self._showError(translate(u'SongMaintenanceForm', u'This topic can\'t be deleted, it is currently assigned to at least one song!'))
else:
self._showError(translate(u'SongMaintenanceForm', u'No topic selected!'))
def onBookDeleteButtonClick(self):
"""
Delete the Book is the Book is not attached to any songs
"""
book_id = self._getCurrentItemId(self.BooksListWidget)
if book_id != -1:
book = self.songmanager.get_book(book_id)
if QtGui.QMessageBox.warning(None,
translate(u'SongMaintenanceForm', u'Delete Book'),
translate(u'SongMaintenanceForm', u'Are you sure you want to delete the selected book?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
) == QtGui.QMessageBox.Yes:
if len(book.songs) == 0:
self.songmanager.delete_book(book.id)
self.resetBooks()
else:
QtGui.QMessageBox.critical(None,
translate(u'SongMaintenanceForm', u'Delete Book'),
translate(u'SongMaintenanceForm', u'This book can\'t be deleted, it is currently assigned to at least one song!'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
else:
self._showError(translate(u'SongMaintenanceForm', u'No book selected!'))

View File

@ -20,9 +20,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA
import logging import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser , contextMenuAction, contextMenuSeparator from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \
SongXMLParser, contextMenuAction, contextMenuSeparator
from openlp.plugins.songs.forms import EditSongForm, AuthorsForm, TopicsForm, SongBookForm from openlp.plugins.songs.forms import EditSongForm, AuthorsForm, \
TopicsForm, SongBookForm, SongMaintenanceForm
class SongList(QtGui.QListWidget): class SongList(QtGui.QListWidget):
@ -62,6 +63,7 @@ class SongMediaItem(MediaManagerItem):
self.authors_form = AuthorsForm(self.parent.songmanager) self.authors_form = AuthorsForm(self.parent.songmanager)
self.topics_form = TopicsForm(self.parent.songmanager) self.topics_form = TopicsForm(self.parent.songmanager)
self.song_book_form = SongBookForm(self.parent.songmanager) self.song_book_form = SongBookForm(self.parent.songmanager)
self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager)
def setupUi(self): def setupUi(self):
# Add a toolbar # Add a toolbar
@ -95,17 +97,21 @@ class SongMediaItem(MediaManagerItem):
':/system/system_add.png', self.onSongAddClick, 'SongAddItem') ':/system/system_add.png', self.onSongAddClick, 'SongAddItem')
self.addToolbarSeparator() self.addToolbarSeparator()
## Author Edit Button ## ## Author Edit Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Edit Authors'), #self.addToolbarButton(translate(u'SongMediaItem', u'Edit Authors'),
translate(u'SongMediaItem', u'Maintain the list of Song Authors'), # translate(u'SongMediaItem', u'Maintain the list of Song Authors'),
':/songs/song_author_edit.png', self.onEditAuthorClick, 'SongAuthorEditItem') # ':/songs/song_author_edit.png', self.onEditAuthorClick, 'SongAuthorEditItem')
## Author Edit Button ## ## Author Edit Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Edit Books'), #self.addToolbarButton(translate(u'SongMediaItem', u'Edit Books'),
translate(u'SongMediaItem', u'Maintain the list of Song Books'), # translate(u'SongMediaItem', u'Maintain the list of Song Books'),
':/songs/song_book_edit.png', self.onEditBookClick, 'SongAuthorEditItem') # ':/songs/song_book_edit.png', self.onEditBookClick, 'SongAuthorEditItem')
## Author Edit Button ## # ## Author Edit Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Edit Topics'), #self.addToolbarButton(translate(u'SongMediaItem', u'Edit Topics'),
translate(u'SongMediaItem', u'Maintain the list of Song Topics'), # translate(u'SongMediaItem', u'Maintain the list of Song Topics'),
':/songs/song_topic_edit.png', self.onEditTopicClick, 'SongAuthorEditItem') # ':/songs/song_topic_edit.png', self.onEditTopicClick, 'SongAuthorEditItem')
## Song Maintenance Button ##
self.addToolbarButton(translate(u'SongMediaItem', u'Song Maintenance'),
translate(u'SongMediaItem', u'Maintain the lists of authors, topics and books'),
':/songs/song_author_edit.png', self.onSongMaintenanceClick, 'SongMaintenanceItem')
## Add the songlist widget ## ## Add the songlist widget ##
# Create the tab widget # Create the tab widget
self.SongWidget = QtGui.QWidget(self) self.SongWidget = QtGui.QWidget(self)
@ -250,6 +256,9 @@ class SongMediaItem(MediaManagerItem):
self.song_book_form.load_form() self.song_book_form.load_form()
self.song_book_form.exec_() self.song_book_form.exec_()
def onSongMaintenanceClick(self):
self.song_maintenance_form.exec_()
def onSongEditClick(self): def onSongEditClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:

View File

@ -2,6 +2,9 @@
<ui version="4.0"> <ui version="4.0">
<class>SongMaintenanceDialog</class> <class>SongMaintenanceDialog</class>
<widget class="QDialog" name="SongMaintenanceDialog"> <widget class="QDialog" name="SongMaintenanceDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -13,7 +16,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Song Maintenance</string> <string>Song Maintenance</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="DialogLayout">
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
@ -22,7 +25,7 @@
</property> </property>
<item> <item>
<widget class="QWidget" name="ContentWidget" native="true"> <widget class="QWidget" name="ContentWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="ContentLayout">
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
@ -30,37 +33,94 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QListWidget" name="TypeListWidget"> <widget class="QTableWidget" name="TypeTableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>150</width> <width>130</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="showDropIndicator" stdset="0"> <property name="showDropIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>32</width> <width>32</width>
<height>32</height> <height>32</height>
</size> </size>
</property> </property>
<property name="flow"> <property name="showGrid">
<enum>QListView::TopToBottom</enum> <bool>false</bool>
</property> </property>
<property name="spacing"> <property name="cornerButtonEnabled">
<number>0</number> <bool>false</bool>
</property> </property>
<property name="viewMode"> <attribute name="horizontalHeaderVisible">
<enum>QListView::IconMode</enum> <bool>false</bool>
</property> </attribute>
<property name="uniformItemSizes"> <attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool> <bool>true</bool>
</property> </attribute>
<item> <attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<row>
<property name="text"> <property name="text">
<string>Authors</string> <string>New Row</string>
</property>
</row>
<row>
<property name="text">
<string>New Row</string>
</property>
</row>
<row>
<property name="text">
<string>New Row</string>
</property>
</row>
<column>
<property name="text">
<string>Types</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>
Authors</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignHCenter|AlignVCenter|AlignCenter</set>
@ -69,13 +129,11 @@
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/author_maintenance.png</normaloff>:/songs/author_maintenance.png</iconset> <normaloff>:/songs/author_maintenance.png</normaloff>:/songs/author_maintenance.png</iconset>
</property> </property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
</property>
</item> </item>
<item> <item row="1" column="0">
<property name="text"> <property name="text">
<string>Topics</string> <string>
Topics</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignHCenter|AlignVCenter|AlignCenter</set>
@ -84,13 +142,11 @@
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/topic_maintenance.png</normaloff>:/songs/topic_maintenance.png</iconset> <normaloff>:/songs/topic_maintenance.png</normaloff>:/songs/topic_maintenance.png</iconset>
</property> </property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
</property>
</item> </item>
<item> <item row="2" column="0">
<property name="text"> <property name="text">
<string>Books/Hymnals</string> <string>
Books/Hymnals</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignHCenter|AlignVCenter|AlignCenter</set>
@ -99,19 +155,16 @@
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/book_maintenance.png</normaloff>:/songs/book_maintenance.png</iconset> <normaloff>:/songs/book_maintenance.png</normaloff>:/songs/book_maintenance.png</iconset>
</property> </property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
</property>
</item> </item>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QStackedWidget" name="TypeStackedWidget"> <widget class="QStackedWidget" name="TypeStackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="AuthorsPage"> <widget class="QWidget" name="AuthorsPage">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="AuthorsLayout">
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
@ -122,8 +175,8 @@
<widget class="QListWidget" name="AuthorsListWidget"/> <widget class="QListWidget" name="AuthorsListWidget"/>
</item> </item>
<item> <item>
<widget class="QWidget" name="AuthorWidget" native="true"> <widget class="QWidget" name="AuthorButtonWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="AuthorButtonsLayout">
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
@ -131,7 +184,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<spacer name="AuthorSpacer"> <spacer name="AuthorButtonSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -150,7 +203,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/song_author_edit.png</normaloff>:/songs/song_author_edit.png</iconset> <normaloff>:/songs/author_add.png</normaloff>:/songs/author_add.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -161,7 +214,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/song_edit.png</normaloff>:/songs/song_edit.png</iconset> <normaloff>:/songs/author_edit.png</normaloff>:/songs/author_edit.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -172,27 +225,177 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/song_delete.png</normaloff>:/songs/song_delete.png</iconset> <normaloff>:/songs/author_delete.png</normaloff>:/songs/author_delete.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="AuthorsLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="TopicsPage">
<layout class="QVBoxLayout" name="TopicLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="TopicsListWidget"/>
</item>
<item>
<widget class="QWidget" name="TopicButtonWidget" native="true">
<layout class="QHBoxLayout" name="TopicButtonLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="TopicButtonSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>54</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="TopicAddButton">
<property name="text">
<string>Add</string>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/topic_add.png</normaloff>:/songs/topic_add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="TopicEditButton">
<property name="text">
<string>Edit</string>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/topic_edit.png</normaloff>:/songs/topic_edit.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="TopicDeleteButton">
<property name="text">
<string>Delete</string>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/topic_delete.png</normaloff>:/songs/topic_delete.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="TopicsLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="TopicsPage"/>
<widget class="QWidget" name="BooksPage"> <widget class="QWidget" name="BooksPage">
<widget class="QListWidget" name="listWidget"> <layout class="QVBoxLayout" name="BookLayout">
<property name="geometry"> <property name="spacing">
<rect> <number>8</number>
<x>30</x> </property>
<y>20</y> <property name="margin">
<width>256</width> <number>0</number>
<height>192</height> </property>
</rect> <item>
<widget class="QListWidget" name="BooksListWidget"/>
</item>
<item>
<widget class="QWidget" name="BookButtonWidget" native="true">
<layout class="QHBoxLayout" name="BookButtonLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer name="BookButtonSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>54</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="BookAddButton">
<property name="text">
<string>Add</string>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/book_add.png</normaloff>:/songs/book_add.png</iconset>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QPushButton" name="BookEditButton">
<property name="text">
<string>Edit</string>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/book_edit.png</normaloff>:/songs/book_edit.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="BookDeleteButton">
<property name="text">
<string>Delete</string>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/songs/book_delete.png</normaloff>:/songs/book_delete.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="BooksLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -217,7 +420,7 @@
<connections> <connections>
<connection> <connection>
<sender>MaintenanceButtonBox</sender> <sender>MaintenanceButtonBox</sender>
<signal>accepted()</signal> <signal>rejected()</signal>
<receiver>SongMaintenanceDialog</receiver> <receiver>SongMaintenanceDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
@ -232,17 +435,17 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>TypeListWidget</sender> <sender>TypeTableWidget</sender>
<signal>currentRowChanged(int)</signal> <signal>cellClicked(int,int)</signal>
<receiver>TypeStackedWidget</receiver> <receiver>TypeStackedWidget</receiver>
<slot>setCurrentIndex(int)</slot> <slot>setCurrentIndex(int)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>82</x> <x>72</x>
<y>163</y> <y>163</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>321</x> <x>311</x>
<y>163</y> <y>163</y>
</hint> </hint>
</hints> </hints>

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,5 +1,14 @@
<RCC> <RCC>
<qresource prefix="songs" > <qresource prefix="songs" >
<file>topic_edit.png</file>
<file>author_add.png</file>
<file>author_delete.png</file>
<file>book_add.png</file>
<file>topic_add.png</file>
<file>book_delete.png</file>
<file>book_edit.png</file>
<file>author_edit.png</file>
<file>topic_delete.png</file>
<file>book_maintenance.png</file> <file>book_maintenance.png</file>
<file>author_maintenance.png</file> <file>author_maintenance.png</file>
<file>topic_maintenance.png</file> <file>topic_maintenance.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1007 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB