diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 3efc03858..6cb117b2b 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -53,7 +53,10 @@ class RenderManager(object): self.screen_list = screen_list self.theme_manager = theme_manager self.displays = len(screen_list) - self.current_display = screen_number + if (screen_number + 1) > len(screen_list): + self.current_display = 0 + else: + self.current_display = screen_number self.renderer = Renderer() self.calculate_default(self.screen_list[self.current_display][u'size']) self.theme = u'' diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index 26b623778..4bc392b81 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -23,6 +23,7 @@ from topicsform import TopicsForm from songbookform import SongBookForm from editverseform import EditVerseForm from editsongform import EditSongForm +from songmaintenanceform import SongMaintenanceForm from openlpexportform import OpenLPExportForm from openlpimportform import OpenLPImportForm diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py new file mode 100644 index 000000000..e91ce735c --- /dev/null +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -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)) + diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py new file mode 100644 index 000000000..c39bcd5ec --- /dev/null +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -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!')) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b49bcac95..5b9dbae38 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -20,9 +20,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser , contextMenuAction, contextMenuSeparator - -from openlp.plugins.songs.forms import EditSongForm, AuthorsForm, TopicsForm, SongBookForm +from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \ + SongXMLParser, contextMenuAction, contextMenuSeparator +from openlp.plugins.songs.forms import EditSongForm, AuthorsForm, \ + TopicsForm, SongBookForm, SongMaintenanceForm class SongList(QtGui.QListWidget): @@ -62,6 +63,7 @@ class SongMediaItem(MediaManagerItem): self.authors_form = AuthorsForm(self.parent.songmanager) self.topics_form = TopicsForm(self.parent.songmanager) self.song_book_form = SongBookForm(self.parent.songmanager) + self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager) def setupUi(self): # Add a toolbar @@ -95,17 +97,21 @@ class SongMediaItem(MediaManagerItem): ':/system/system_add.png', self.onSongAddClick, 'SongAddItem') self.addToolbarSeparator() ## Author Edit Button ## - self.addToolbarButton(translate(u'SongMediaItem', u'Edit Authors'), - translate(u'SongMediaItem', u'Maintain the list of Song Authors'), - ':/songs/song_author_edit.png', self.onEditAuthorClick, 'SongAuthorEditItem') + #self.addToolbarButton(translate(u'SongMediaItem', u'Edit Authors'), + # translate(u'SongMediaItem', u'Maintain the list of Song Authors'), + # ':/songs/song_author_edit.png', self.onEditAuthorClick, 'SongAuthorEditItem') ## Author Edit Button ## - self.addToolbarButton(translate(u'SongMediaItem', u'Edit Books'), - translate(u'SongMediaItem', u'Maintain the list of Song Books'), - ':/songs/song_book_edit.png', self.onEditBookClick, 'SongAuthorEditItem') - ## Author Edit Button ## - self.addToolbarButton(translate(u'SongMediaItem', u'Edit Topics'), - translate(u'SongMediaItem', u'Maintain the list of Song Topics'), - ':/songs/song_topic_edit.png', self.onEditTopicClick, 'SongAuthorEditItem') + #self.addToolbarButton(translate(u'SongMediaItem', u'Edit Books'), + # translate(u'SongMediaItem', u'Maintain the list of Song Books'), + # ':/songs/song_book_edit.png', self.onEditBookClick, 'SongAuthorEditItem') + # ## Author Edit Button ## + #self.addToolbarButton(translate(u'SongMediaItem', u'Edit Topics'), + # translate(u'SongMediaItem', u'Maintain the list of Song Topics'), + # ':/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 ## # Create the tab widget self.SongWidget = QtGui.QWidget(self) @@ -250,6 +256,9 @@ class SongMediaItem(MediaManagerItem): self.song_book_form.load_form() self.song_book_form.exec_() + def onSongMaintenanceClick(self): + self.song_maintenance_form.exec_() + def onSongEditClick(self): item = self.ListView.currentItem() if item is not None: diff --git a/resources/forms/songmaintenance.ui b/resources/forms/songmaintenance.ui index 444e444ec..dd06797fb 100644 --- a/resources/forms/songmaintenance.ui +++ b/resources/forms/songmaintenance.ui @@ -2,6 +2,9 @@ SongMaintenanceDialog + + Qt::ApplicationModal + 0 @@ -13,7 +16,7 @@ Song Maintenance - + 8 @@ -22,7 +25,7 @@ - + 8 @@ -30,37 +33,94 @@ 0 - + + + + 0 + 0 + + + + + 130 + 0 + + - 150 + 130 16777215 false + + false + + + QAbstractItemView::SingleSelection + 32 32 - - QListView::TopToBottom + + false - - 0 + + false - - QListView::IconMode - - + + false + + true - - + + + false + + + false + + + false + + + true + + + false + + + false + + - Authors + New Row + + + + + New Row + + + + + New Row + + + + + Types + + + + + +Authors AlignHCenter|AlignVCenter|AlignCenter @@ -69,13 +129,11 @@ :/songs/author_maintenance.png:/songs/author_maintenance.png - - ItemIsSelectable|ItemIsEnabled - - + - Topics + +Topics AlignHCenter|AlignVCenter|AlignCenter @@ -84,13 +142,11 @@ :/songs/topic_maintenance.png:/songs/topic_maintenance.png - - ItemIsSelectable|ItemIsEnabled - - + - Books/Hymnals + +Books/Hymnals AlignHCenter|AlignVCenter|AlignCenter @@ -99,19 +155,16 @@ :/songs/book_maintenance.png:/songs/book_maintenance.png - - ItemIsSelectable|ItemIsEnabled - - 0 + 2 - + 8 @@ -122,8 +175,8 @@ - - + + 8 @@ -131,7 +184,7 @@ 0 - + Qt::Horizontal @@ -150,7 +203,7 @@ - :/songs/song_author_edit.png:/songs/song_author_edit.png + :/songs/author_add.png:/songs/author_add.png @@ -161,7 +214,7 @@ - :/songs/song_edit.png:/songs/song_edit.png + :/songs/author_edit.png:/songs/author_edit.png @@ -172,27 +225,177 @@ - :/songs/song_delete.png:/songs/song_delete.png + :/songs/author_delete.png:/songs/author_delete.png + + + + Qt::Horizontal + + + - - - - - - 30 - 20 - 256 - 192 - + + + + 8 - + + 0 + + + + + + + + + 8 + + + 0 + + + + + Qt::Horizontal + + + + 54 + 20 + + + + + + + + Add + + + + :/songs/topic_add.png:/songs/topic_add.png + + + + + + + Edit + + + + :/songs/topic_edit.png:/songs/topic_edit.png + + + + + + + Delete + + + + :/songs/topic_delete.png:/songs/topic_delete.png + + + + + + + + + + Qt::Horizontal + + + + + + + + + 8 + + + 0 + + + + + + + + + 8 + + + 0 + + + + + Qt::Horizontal + + + + 54 + 20 + + + + + + + + Add + + + + :/songs/book_add.png:/songs/book_add.png + + + + + + + Edit + + + + :/songs/book_edit.png:/songs/book_edit.png + + + + + + + Delete + + + + :/songs/book_delete.png:/songs/book_delete.png + + + + + + + + + + Qt::Horizontal + + + + @@ -217,7 +420,7 @@ MaintenanceButtonBox - accepted() + rejected() SongMaintenanceDialog accept() @@ -232,17 +435,17 @@ - TypeListWidget - currentRowChanged(int) + TypeTableWidget + cellClicked(int,int) TypeStackedWidget setCurrentIndex(int) - 82 + 72 163 - 321 + 311 163 diff --git a/resources/images/author_add.png b/resources/images/author_add.png new file mode 100644 index 000000000..a12a38467 Binary files /dev/null and b/resources/images/author_add.png differ diff --git a/resources/images/author_delete.png b/resources/images/author_delete.png new file mode 100644 index 000000000..8a9391fd9 Binary files /dev/null and b/resources/images/author_delete.png differ diff --git a/resources/images/author_edit.png b/resources/images/author_edit.png new file mode 100644 index 000000000..354522f4e Binary files /dev/null and b/resources/images/author_edit.png differ diff --git a/resources/images/book_add.png b/resources/images/book_add.png new file mode 100644 index 000000000..a2d5c8413 Binary files /dev/null and b/resources/images/book_add.png differ diff --git a/resources/images/book_delete.png b/resources/images/book_delete.png new file mode 100644 index 000000000..293cf9666 Binary files /dev/null and b/resources/images/book_delete.png differ diff --git a/resources/images/book_edit.png b/resources/images/book_edit.png new file mode 100644 index 000000000..b708578e9 Binary files /dev/null and b/resources/images/book_edit.png differ diff --git a/resources/images/book_maintenance.png b/resources/images/book_maintenance.png index 062249fe9..a850e97c6 100644 Binary files a/resources/images/book_maintenance.png and b/resources/images/book_maintenance.png differ diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index de5da6a9f..98480206a 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -1,5 +1,14 @@ + topic_edit.png + author_add.png + author_delete.png + book_add.png + topic_add.png + book_delete.png + book_edit.png + author_edit.png + topic_delete.png book_maintenance.png author_maintenance.png topic_maintenance.png diff --git a/resources/images/topic_add.png b/resources/images/topic_add.png new file mode 100644 index 000000000..3754fc60e Binary files /dev/null and b/resources/images/topic_add.png differ diff --git a/resources/images/topic_delete.png b/resources/images/topic_delete.png new file mode 100644 index 000000000..38a2ad5b5 Binary files /dev/null and b/resources/images/topic_delete.png differ diff --git a/resources/images/topic_edit.png b/resources/images/topic_edit.png new file mode 100644 index 000000000..03b8167d0 Binary files /dev/null and b/resources/images/topic_edit.png differ