# -*- 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 Qt, QtCore, QtGui from openlp.core.lib import SongXMLBuilder, SongXMLParser from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm, \ EditVerseForm from openlp.plugins.songs.lib.models import Song from editsongdialog import Ui_EditSongDialog class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ Class documentation goes here. """ def __init__(self, songmanager, parent=None): """ Constructor """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) # Connecting signals and slots QtCore.QObject.connect(self.AddAuthorsButton, QtCore.SIGNAL(u'clicked()'), self.onAddAuthorsButtonClicked) QtCore.QObject.connect(self.AddTopicButton, QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked) QtCore.QObject.connect(self.AddSongBookButton, QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked) QtCore.QObject.connect(self.CopyrightInsertItem, QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertItemTriggered) QtCore.QObject.connect(self.AddButton, QtCore.SIGNAL(u'clicked()'), self.onAddVerseButtonClicked) QtCore.QObject.connect(self.EditButton, QtCore.SIGNAL(u'clicked()'), self.onEditVerseButtonClicked) QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL(u'clicked()'), self.onDeleteVerseButtonClicked) # Create other objects and forms self.songmanager = songmanager self.authors_form = AuthorsForm(self.songmanager) self.topics_form = TopicsForm(self.songmanager) self.song_book_form = SongBookForm(self.songmanager) self.verse_form = EditVerseForm() self.initialise() self.AuthorsListView.setSortingEnabled(False) self.AuthorsListView.setAlternatingRowColors(True) self.TopicsListView.setSortingEnabled(False) self.TopicsListView.setAlternatingRowColors(True) def initialise(self): self.loadAuthors() self.loadTopics() self.loadBooks() def loadAuthors(self): authors = self.songmanager.get_authors() self.AuthorsSelectionComboItem.clear() for author in authors: self.AuthorsSelectionComboItem.addItem(author.display_name) def loadTopics(self): topics = self.songmanager.get_topics() self.SongTopicCombo.clear() for topic in topics: self.SongTopicCombo.addItem(topic.name) def loadBooks(self): books = self.songmanager.get_books() self.SongbookCombo.clear() for book in books: self.SongbookCombo.addItem(book.name) def newSong(self): self.song = Song() self.TitleEditItem.setText(u'') self.AlternativeEdit.setText(u'') self.CopyrightEditItem.setText(u'') self.VerseListWidget.clear() self.AuthorsListView.clear() self.TopicsListView.clear() def loadSong(self, id): self.song = self.songmanager.get_song(id) self.TitleEditItem.setText(self.song.title) title = self.song.search_title.split(u'@') if len(title) > 1: self.AlternativeEdit.setText(title[1]) self.CopyrightEditItem.setText(self.song.copyright) self.VerseListWidget.clear() #lazy xml migration for now if self.song.lyrics.startswith(u'