2008-12-01 13:15:31 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
"""
|
|
|
|
OpenLP - Open Source Lyrics Projection
|
|
|
|
Copyright (c) 2008 Raoul Snyman
|
2009-06-03 16:14:56 +00:00
|
|
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
2008-12-01 13:15:31 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2009-06-13 06:46:13 +00:00
|
|
|
import logging
|
2009-01-12 19:31:29 +00:00
|
|
|
from PyQt4 import Qt, QtCore, QtGui
|
2009-06-14 07:25:39 +00:00
|
|
|
from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, EventType, EventManager
|
2009-03-09 12:49:55 +00:00
|
|
|
from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm, \
|
|
|
|
EditVerseForm
|
2009-06-12 17:20:40 +00:00
|
|
|
from openlp.plugins.songs.lib.models import Song
|
2009-01-01 10:03:09 +00:00
|
|
|
|
2008-12-24 07:28:25 +00:00
|
|
|
from editsongdialog import Ui_EditSongDialog
|
|
|
|
|
2009-02-28 23:19:45 +00:00
|
|
|
class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
2008-12-24 07:28:25 +00:00
|
|
|
"""
|
2009-06-13 06:46:13 +00:00
|
|
|
Class to manage the editing of a song
|
2008-12-24 07:28:25 +00:00
|
|
|
"""
|
2009-06-13 06:46:13 +00:00
|
|
|
global log
|
|
|
|
log = logging.getLogger(u'EditSongForm')
|
|
|
|
log.info(u'Song Editor loaded')
|
2009-06-14 07:25:39 +00:00
|
|
|
def __init__(self, songmanager, eventmanager, parent=None):
|
2008-12-24 07:28:25 +00:00
|
|
|
"""
|
|
|
|
Constructor
|
|
|
|
"""
|
2009-02-28 23:19:45 +00:00
|
|
|
QtGui.QDialog.__init__(self, parent)
|
2008-12-24 07:28:25 +00:00
|
|
|
self.setupUi(self)
|
2009-02-19 22:25:58 +00:00
|
|
|
# Connecting signals and slots
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.AddAuthorsButton,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onAddAuthorsButtonClicked)
|
2009-06-13 06:46:13 +00:00
|
|
|
QtCore.QObject.connect(self.AuthorAddtoSongItem,
|
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onAuthorAddtoSongItemClicked)
|
|
|
|
QtCore.QObject.connect(self.AuthorRemoveItem,
|
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onAuthorRemovefromSongItemClicked)
|
|
|
|
QtCore.QObject.connect(self.AuthorsListView,
|
|
|
|
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onAuthorsListViewPressed)
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.AddTopicButton,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onAddTopicButtonClicked)
|
2009-06-14 06:30:09 +00:00
|
|
|
QtCore.QObject.connect(self.AddTopicsToSongButton,
|
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onTopicAddtoSongItemClicked)
|
|
|
|
QtCore.QObject.connect(self.TopicRemoveItem,
|
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onTopicRemovefromSongItemClicked)
|
|
|
|
QtCore.QObject.connect(self.TopicsListView,
|
|
|
|
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onTopicListViewPressed)
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.AddSongBookButton,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onAddSongBookButtonClicked)
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.CopyrightInsertItem,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertItemTriggered)
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.AddButton,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onAddVerseButtonClicked)
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.EditButton,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onEditVerseButtonClicked)
|
2009-03-07 21:38:59 +00:00
|
|
|
QtCore.QObject.connect(self.DeleteButton,
|
2009-06-10 17:12:03 +00:00
|
|
|
QtCore.SIGNAL(u'clicked()'), self.onDeleteVerseButtonClicked)
|
2009-06-13 06:46:13 +00:00
|
|
|
QtCore.QObject.connect(self.VerseListWidget,
|
|
|
|
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onVerseListViewPressed)
|
2009-06-14 06:48:38 +00:00
|
|
|
QtCore.QObject.connect(self.SongbookCombo,
|
|
|
|
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
2009-06-14 07:02:58 +00:00
|
|
|
QtCore.QObject.connect(self.ThemeSelectionComboItem,
|
|
|
|
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
|
2009-02-19 22:25:58 +00:00
|
|
|
# Create other objects and forms
|
2008-12-24 07:28:25 +00:00
|
|
|
self.songmanager = songmanager
|
2009-06-14 07:25:39 +00:00
|
|
|
self.eventmanager = eventmanager
|
2009-01-01 10:03:09 +00:00
|
|
|
self.authors_form = AuthorsForm(self.songmanager)
|
|
|
|
self.topics_form = TopicsForm(self.songmanager)
|
2009-01-17 13:58:16 +00:00
|
|
|
self.song_book_form = SongBookForm(self.songmanager)
|
2009-03-07 21:38:59 +00:00
|
|
|
self.verse_form = EditVerseForm()
|
2008-12-24 07:28:25 +00:00
|
|
|
self.initialise()
|
2009-01-17 13:58:16 +00:00
|
|
|
self.AuthorsListView.setSortingEnabled(False)
|
2009-01-10 08:33:31 +00:00
|
|
|
self.AuthorsListView.setAlternatingRowColors(True)
|
2009-06-12 17:20:40 +00:00
|
|
|
self.TopicsListView.setSortingEnabled(False)
|
|
|
|
self.TopicsListView.setAlternatingRowColors(True)
|
2009-01-17 13:58:16 +00:00
|
|
|
|
2008-12-24 07:28:25 +00:00
|
|
|
def initialise(self):
|
2009-03-09 18:47:37 +00:00
|
|
|
self.loadAuthors()
|
2009-06-04 19:00:41 +00:00
|
|
|
self.loadTopics()
|
2009-06-04 20:06:32 +00:00
|
|
|
self.loadBooks()
|
2009-06-13 06:46:13 +00:00
|
|
|
self.EditButton.setEnabled(False)
|
|
|
|
self.DeleteButton.setEnabled(False)
|
|
|
|
self.AuthorRemoveItem.setEnabled(False)
|
2009-06-14 06:30:09 +00:00
|
|
|
self.TopicRemoveItem.setEnabled(False)
|
2009-06-14 07:25:39 +00:00
|
|
|
self.title_change = False
|
2009-03-09 18:47:37 +00:00
|
|
|
|
|
|
|
def loadAuthors(self):
|
|
|
|
authors = self.songmanager.get_authors()
|
2008-12-24 14:07:27 +00:00
|
|
|
self.AuthorsSelectionComboItem.clear()
|
2009-03-09 18:47:37 +00:00
|
|
|
for author in authors:
|
|
|
|
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
2008-12-24 14:07:27 +00:00
|
|
|
|
2009-06-04 19:00:41 +00:00
|
|
|
def loadTopics(self):
|
2009-06-04 20:06:32 +00:00
|
|
|
topics = self.songmanager.get_topics()
|
2009-06-04 19:00:41 +00:00
|
|
|
self.SongTopicCombo.clear()
|
|
|
|
for topic in topics:
|
|
|
|
self.SongTopicCombo.addItem(topic.name)
|
|
|
|
|
2009-06-04 20:06:32 +00:00
|
|
|
def loadBooks(self):
|
|
|
|
books = self.songmanager.get_books()
|
|
|
|
self.SongbookCombo.clear()
|
2009-06-13 06:46:13 +00:00
|
|
|
self.SongbookCombo.addItem(u' ')
|
2009-06-04 20:06:32 +00:00
|
|
|
for book in books:
|
|
|
|
self.SongbookCombo.addItem(book.name)
|
|
|
|
|
2009-06-14 07:02:58 +00:00
|
|
|
def loadThemes(self, theme_list):
|
|
|
|
self.ThemeSelectionComboItem.clear()
|
|
|
|
self.ThemeSelectionComboItem.addItem(u' ')
|
|
|
|
for theme in theme_list:
|
|
|
|
self.ThemeSelectionComboItem.addItem(theme)
|
|
|
|
|
2009-06-12 17:20:40 +00:00
|
|
|
def newSong(self):
|
2009-06-13 06:46:13 +00:00
|
|
|
log.debug(u'New Song')
|
2009-06-12 17:20:40 +00:00
|
|
|
self.song = Song()
|
|
|
|
self.TitleEditItem.setText(u'')
|
|
|
|
self.AlternativeEdit.setText(u'')
|
|
|
|
self.CopyrightEditItem.setText(u'')
|
|
|
|
self.VerseListWidget.clear()
|
|
|
|
self.AuthorsListView.clear()
|
|
|
|
self.TopicsListView.clear()
|
2009-06-14 07:25:39 +00:00
|
|
|
self.title_change = False
|
2009-06-12 17:20:40 +00:00
|
|
|
|
2009-02-19 22:25:58 +00:00
|
|
|
def loadSong(self, id):
|
2009-06-13 06:46:13 +00:00
|
|
|
log.debug(u'Load Song')
|
2009-02-19 22:25:58 +00:00
|
|
|
self.song = self.songmanager.get_song(id)
|
2009-01-17 13:58:16 +00:00
|
|
|
self.TitleEditItem.setText(self.song.title)
|
2009-06-12 05:13:54 +00:00
|
|
|
title = self.song.search_title.split(u'@')
|
2009-06-13 06:46:13 +00:00
|
|
|
if self.song.song_book_id != 0:
|
|
|
|
book_name = self.songmanager.get_book(self.song.song_book_id)
|
2009-06-14 06:48:38 +00:00
|
|
|
id = self.SongbookCombo.findText(unicode(book_name), QtCore.Qt.MatchExactly)
|
|
|
|
if id == -1:
|
|
|
|
# Not Found
|
|
|
|
id = 0
|
|
|
|
book_name.setCurrentIndex(id)
|
2009-06-14 07:02:58 +00:00
|
|
|
if self.song.theme_name is not None and len(self.song.theme_name) > 0:
|
|
|
|
id = self.SongbookCombo.findText(unicode(self.song.theme_name), QtCore.Qt.MatchExactly)
|
|
|
|
if id == -1:
|
|
|
|
# Not Found
|
|
|
|
id = 0
|
|
|
|
self.song.theme_name = None
|
|
|
|
self.SongbookCombo.setCurrentIndex(id)
|
2009-06-12 05:13:54 +00:00
|
|
|
if len(title) > 1:
|
|
|
|
self.AlternativeEdit.setText(title[1])
|
2009-01-12 19:31:29 +00:00
|
|
|
self.CopyrightEditItem.setText(self.song.copyright)
|
2009-06-12 05:13:54 +00:00
|
|
|
self.VerseListWidget.clear()
|
2009-06-12 17:20:40 +00:00
|
|
|
#lazy xml migration for now
|
|
|
|
if self.song.lyrics.startswith(u'<?xml version='):
|
|
|
|
songXML=SongXMLParser(self.song.lyrics)
|
|
|
|
verseList = songXML.get_verses()
|
|
|
|
for verse in verseList:
|
|
|
|
self.VerseListWidget.addItem(verse[1])
|
|
|
|
else:
|
|
|
|
verses = self.song.lyrics.split(u'\n\n')
|
|
|
|
for verse in verses:
|
|
|
|
self.VerseListWidget.addItem(verse)
|
2009-06-11 05:13:10 +00:00
|
|
|
# clear the results
|
|
|
|
self.AuthorsListView.clear()
|
2009-01-12 19:31:29 +00:00
|
|
|
for author in self.song.authors:
|
2009-06-11 21:14:12 +00:00
|
|
|
author_name = QtGui.QListWidgetItem(unicode(author.display_name))
|
2009-06-11 05:13:10 +00:00
|
|
|
author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
|
|
|
self.AuthorsListView.addItem(author_name)
|
2009-06-12 17:20:40 +00:00
|
|
|
# clear the results
|
|
|
|
self.TopicsListView.clear()
|
2009-06-14 06:30:09 +00:00
|
|
|
for topic in self.song.topics:
|
|
|
|
topic_name = QtGui.QListWidgetItem(unicode(topic.name))
|
|
|
|
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
|
|
|
self.TopicsListView.addItem(topic_name)
|
2009-01-17 13:58:16 +00:00
|
|
|
self._validate_song()
|
2009-06-14 07:25:39 +00:00
|
|
|
self.title_change = False
|
2008-12-01 13:15:31 +00:00
|
|
|
|
2009-06-13 06:46:13 +00:00
|
|
|
def onAuthorAddtoSongItemClicked(self):
|
|
|
|
author_name = unicode(self.AuthorsSelectionComboItem.currentText())
|
|
|
|
author = self.songmanager.get_author_by_name(author_name)
|
|
|
|
self.song.authors.append(author)
|
2009-06-14 06:30:09 +00:00
|
|
|
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
|
|
|
|
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
|
|
|
self.AuthorsListView.addItem(author_item)
|
2009-06-13 06:46:13 +00:00
|
|
|
|
|
|
|
def onAuthorsListViewPressed(self):
|
2009-06-14 06:30:09 +00:00
|
|
|
if self.AuthorsListView.count() >1:
|
|
|
|
self.AuthorRemoveItem.setEnabled(True)
|
2009-06-13 06:46:13 +00:00
|
|
|
|
|
|
|
def onAuthorRemovefromSongItemClicked(self):
|
|
|
|
self.AuthorRemoveItem.setEnabled(False)
|
|
|
|
item = self.AuthorsListView.currentItem()
|
|
|
|
author_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
|
|
|
author = self.songmanager.get_author(author_id)
|
|
|
|
self.song.authors.remove(author)
|
|
|
|
row = self.AuthorsListView.row(item)
|
|
|
|
self.AuthorsListView.takeItem(row)
|
2009-06-14 06:30:09 +00:00
|
|
|
|
|
|
|
def onTopicAddtoSongItemClicked(self):
|
|
|
|
topic_name = unicode(self.SongTopicCombo.currentText())
|
|
|
|
topic = self.songmanager.get_topic_by_name(topic_name)
|
|
|
|
self.song.topics.append(topic)
|
|
|
|
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
|
|
|
topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
|
|
|
self.TopicsListView.addItem(topic_item)
|
|
|
|
|
|
|
|
def onTopicListViewPressed(self):
|
|
|
|
self.TopicRemoveItem.setEnabled(True)
|
|
|
|
|
|
|
|
def onTopicRemovefromSongItemClicked(self):
|
|
|
|
self.TopicRemoveItem.setEnabled(False)
|
|
|
|
item = self.TopicsListView.currentItem()
|
|
|
|
topic_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
|
|
|
topic = self.songmanager.get_topic(topic_id)
|
|
|
|
self.song.topics.remove(topic)
|
|
|
|
row = self.TopicsListView.row(item)
|
|
|
|
self.TopicsListView.takeItem(row)
|
2009-06-13 06:46:13 +00:00
|
|
|
|
2009-02-19 22:25:58 +00:00
|
|
|
def onAddAuthorsButtonClicked(self):
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
|
|
|
Slot documentation goes here.
|
|
|
|
"""
|
|
|
|
self.authors_form.load_form()
|
2009-02-19 22:25:58 +00:00
|
|
|
self.authors_form.exec_()
|
2009-03-09 18:47:37 +00:00
|
|
|
self.loadAuthors()
|
2009-01-01 10:03:09 +00:00
|
|
|
|
2009-02-19 22:25:58 +00:00
|
|
|
def onAddTopicButtonClicked(self):
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
|
|
|
Slot documentation goes here.
|
|
|
|
"""
|
|
|
|
self.topics_form.load_form()
|
2009-02-19 22:25:58 +00:00
|
|
|
self.topics_form.exec_()
|
2009-06-04 19:00:41 +00:00
|
|
|
self.loadTopics()
|
2009-01-17 13:58:16 +00:00
|
|
|
|
2009-02-28 23:19:45 +00:00
|
|
|
def onAddSongBookButtonClicked(self):
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
|
|
|
Slot documentation goes here.
|
|
|
|
"""
|
|
|
|
self.song_book_form.load_form()
|
2009-02-19 22:25:58 +00:00
|
|
|
self.song_book_form.exec_()
|
2009-06-04 20:06:32 +00:00
|
|
|
self.loadBooks()
|
2009-01-17 13:58:16 +00:00
|
|
|
|
2009-06-14 06:48:38 +00:00
|
|
|
def onSongBookComboChanged(self, item):
|
|
|
|
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
|
|
|
|
|
2009-06-14 07:02:58 +00:00
|
|
|
def onThemeComboChanged(self, item):
|
|
|
|
if item == 0:
|
|
|
|
#None means no Theme
|
|
|
|
self.song.song_theme = None
|
|
|
|
else:
|
|
|
|
them_name = unicode(self.ThemeSelectionComboItem.itemText(item))
|
|
|
|
self.song.theme_name = them_name
|
|
|
|
|
2009-06-13 06:46:13 +00:00
|
|
|
def onVerseListViewPressed(self):
|
|
|
|
self.EditButton.setEnabled(True)
|
|
|
|
self.DeleteButton.setEnabled(True)
|
|
|
|
|
2009-03-07 21:38:59 +00:00
|
|
|
def onAddVerseButtonClicked(self):
|
2009-06-10 17:12:03 +00:00
|
|
|
self.verse_form.setVerse(u'')
|
2009-03-07 21:38:59 +00:00
|
|
|
self.verse_form.exec_()
|
|
|
|
self.VerseListWidget.addItem(self.verse_form.getVerse())
|
|
|
|
|
|
|
|
def onEditVerseButtonClicked(self):
|
|
|
|
item = self.VerseListWidget.currentItem()
|
2009-06-13 06:46:13 +00:00
|
|
|
if item is not None:
|
|
|
|
self.verse_form.setVerse(item.text())
|
|
|
|
self.verse_form.exec_()
|
|
|
|
item.setText(self.verse_form.getVerse())
|
|
|
|
self.EditButton.setEnabled(False)
|
|
|
|
self.DeleteButton.setEnabled(False)
|
2009-03-07 21:38:59 +00:00
|
|
|
|
|
|
|
def onDeleteVerseButtonClicked(self):
|
|
|
|
item = self.VerseListWidget.takeItem(self.VerseListWidget.currentRow())
|
|
|
|
item = None
|
2009-06-13 06:46:13 +00:00
|
|
|
self.EditButton.setEnabled(False)
|
|
|
|
self.DeleteButton.setEnabled(False)
|
2009-03-07 21:38:59 +00:00
|
|
|
|
2009-01-12 19:31:29 +00:00
|
|
|
def _validate_song(self):
|
|
|
|
"""
|
|
|
|
Check the validity of the form. Only display the 'save' if the data can be saved.
|
2009-01-17 13:58:16 +00:00
|
|
|
"""
|
2009-06-13 06:46:13 +00:00
|
|
|
log.debug(u'Validate Song')
|
|
|
|
# Lets be nice and assume the data is correct.
|
|
|
|
valid = True
|
2009-06-10 18:04:32 +00:00
|
|
|
if len(self.TitleEditItem.displayText()) == 0:
|
2009-01-12 19:31:29 +00:00
|
|
|
valid = False
|
2009-06-10 18:04:32 +00:00
|
|
|
if len(self.CopyrightEditItem.displayText()) == 0:
|
2009-01-12 19:31:29 +00:00
|
|
|
valid = False
|
2009-06-13 06:46:13 +00:00
|
|
|
if self.VerseListWidget.count() == 0:
|
|
|
|
valid = False
|
|
|
|
if self.AuthorsListView.count() == 0:
|
|
|
|
valid = False
|
|
|
|
return valid
|
2009-01-17 13:58:16 +00:00
|
|
|
|
2009-01-12 19:31:29 +00:00
|
|
|
def _color_widget(self, slot, invalid):
|
|
|
|
r = Qt.QPalette(slot.palette())
|
|
|
|
if invalid == True:
|
2009-06-10 17:12:03 +00:00
|
|
|
r.setColor(Qt.QPalette.Base, Qt.QColor(u'darkRed'))
|
2009-01-12 19:31:29 +00:00
|
|
|
else:
|
2009-06-10 17:12:03 +00:00
|
|
|
r.setColor(Qt.QPalette.Base, Qt.QColor(u'white'))
|
2009-01-12 19:31:29 +00:00
|
|
|
slot.setPalette(r)
|
2009-01-17 13:58:16 +00:00
|
|
|
slot.setAutoFillBackground(True)
|
|
|
|
|
2009-01-12 19:31:29 +00:00
|
|
|
def on_TitleEditItem_lostFocus(self):
|
2009-06-14 07:25:39 +00:00
|
|
|
self.song.title = self.TitleEditItem.text()
|
|
|
|
self.title_change = True
|
2009-02-17 21:01:27 +00:00
|
|
|
|
2009-02-19 22:25:58 +00:00
|
|
|
def onCopyrightInsertItemTriggered(self):
|
|
|
|
text = self.CopyrightEditItem.displayText()
|
|
|
|
pos = self.CopyrightEditItem.cursorPosition()
|
|
|
|
text = text[:pos] + u'©' + text[pos:]
|
|
|
|
self.CopyrightEditItem.setText(text)
|
|
|
|
self.CopyrightEditItem.setFocus()
|
|
|
|
self.CopyrightEditItem.setCursorPosition(pos + 1)
|
2009-06-10 17:12:03 +00:00
|
|
|
|
|
|
|
def onAccept(self):
|
2009-06-13 06:46:13 +00:00
|
|
|
log.debug(u'OnAccept')
|
2009-06-10 18:04:32 +00:00
|
|
|
#self.song.topics.append(9) << need opject here
|
2009-06-13 06:46:13 +00:00
|
|
|
if not self._validate_song():
|
|
|
|
return
|
2009-06-10 18:04:32 +00:00
|
|
|
self.song.title = unicode(self.TitleEditItem.displayText())
|
|
|
|
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
2009-06-12 05:13:54 +00:00
|
|
|
self.song.search_title = self.TitleEditItem.displayText() + u'@'+ self.AlternativeEdit.displayText()
|
2009-06-12 17:20:40 +00:00
|
|
|
self.processLyrics()
|
|
|
|
self.processTitle()
|
2009-06-13 06:46:13 +00:00
|
|
|
self.song.song_book_id = 0
|
2009-06-10 18:04:32 +00:00
|
|
|
self.songmanager.save_song(self.song)
|
2009-06-14 07:25:39 +00:00
|
|
|
if self.title_change:
|
|
|
|
self.eventmanager.post_event(Event(EventType.LoadSongList))
|
2009-06-10 18:04:32 +00:00
|
|
|
self.close()
|
2009-06-12 05:13:54 +00:00
|
|
|
|
2009-06-12 17:20:40 +00:00
|
|
|
def processLyrics(self):
|
2009-06-13 06:46:13 +00:00
|
|
|
log.debug(u'processLyrics')
|
2009-06-12 17:20:40 +00:00
|
|
|
sxml=SongXMLBuilder()
|
|
|
|
sxml.new_document()
|
|
|
|
sxml.add_lyrics_to_song()
|
|
|
|
count = 1
|
|
|
|
text = u' '
|
|
|
|
for i in range (0, self.VerseListWidget.count()):
|
|
|
|
sxml.add_verse_to_lyrics(u'Verse', unicode(count), unicode(self.VerseListWidget.item(i).text()))
|
|
|
|
text = text + unicode(self.VerseListWidget.item(i).text()) + u' '
|
|
|
|
count += 1
|
|
|
|
text = text.replace("'", u'')
|
|
|
|
text = text.replace(u',', u'')
|
|
|
|
text = text.replace(u';', u'')
|
|
|
|
text = text.replace(u':', u'')
|
|
|
|
text = text.replace(u'(', u'')
|
|
|
|
text = text.replace(u')', u'')
|
|
|
|
text = text.replace(u'{', u'')
|
|
|
|
text = text.replace(u'}', u'')
|
|
|
|
text = text.replace(u'?', u'')
|
|
|
|
self.song.search_lyrics = unicode(text)
|
|
|
|
self.song.lyrics = unicode(sxml.extract_xml())
|
|
|
|
|
|
|
|
def processTitle(self):
|
2009-06-13 06:46:13 +00:00
|
|
|
log.debug(u'processTitle')
|
2009-06-12 05:13:54 +00:00
|
|
|
self.song.search_title = self.song.search_title.replace("'", u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u',', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u';', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u':', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u'(', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u')', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u'{', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u'}', u'')
|
|
|
|
self.song.search_title = self.song.search_title.replace(u'?', u'')
|
|
|
|
self.song.search_title = unicode(self.song.search_title)
|