Head832 + fix

This commit is contained in:
Tim Bentley 2010-06-06 16:59:01 +01:00
commit cb35fb7be4
3 changed files with 31 additions and 41 deletions

View File

@ -101,6 +101,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtCore.QObject.connect(self.VerseOrderEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus)
self.previewButton = QtGui.QPushButton()
self.previewButton.setObjectName(u'previewButton')
self.previewButton.setText(self.trUtf8('Save && Preview'))
self.ButtonBox.addButton(
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
@ -370,7 +371,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item.setText(afterText)
self.VerseListWidget.setRowCount(
self.VerseListWidget.rowCount() + 1)
self.VerseListWidget.setItem(int(self.VerseListWidget.rowCount() - 1), 0, item)
self.VerseListWidget.setItem(
int(self.VerseListWidget.rowCount() - 1), 0, item)
self.VerseListWidget.setColumnWidth(0, self.width)
self.VerseListWidget.resizeRowsToContents()
self.tagRows()
@ -484,19 +486,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
return True, u''
def onTitleEditItemLostFocus(self):
self.song.title = self.TitleEditItem.text()
self.song.title = unicode(self.TitleEditItem.text())
def onVerseOrderEditLostFocus(self):
self.song.verse_order = self.VerseOrderEdit.text()
self.song.verse_order = unicode(self.VerseOrderEdit.text())
def onCommentsEditLostFocus(self):
self.song.comments = self.CommentsEdit.text()
self.song.comments = unicode(self.CommentsEdit.text())
def onCCLNumberEditLostFocus(self):
self.song.ccli_number = self.CCLNumberEdit.text()
def onCopyrightInsertButtonTriggered(self):
text = self.CopyrightEditItem.displayText()
text = self.CopyrightEditItem.text()
pos = self.CopyrightEditItem.cursorPosition()
text = text[:pos] + u'©' + text[pos:]
self.CopyrightEditItem.setText(text)
@ -515,8 +517,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
The Song is valid so as the plugin to add it to preview to see.
"""
log.debug(u'onPreview')
if button.text() == unicode(self.trUtf8('Save && Preview')) \
and self.saveSong():
if unicode(button.objectName()) == u'previewButton' and self.saveSong():
Receiver.send_message(u'songs_preview')
def closePressed(self):
@ -536,13 +537,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self, self.trUtf8('Error'), message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
return False
self.song.title = unicode(self.TitleEditItem.displayText())
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
self.song.search_title = unicode(self.TitleEditItem.displayText()) + \
u'@'+ unicode(self.AlternativeEdit.displayText())
self.song.title = unicode(self.TitleEditItem.text())
self.song.copyright = unicode(self.CopyrightEditItem.text())
self.song.search_title = unicode(self.TitleEditItem.text()) + \
u'@'+ unicode(self.AlternativeEdit.text())
self.song.comments = unicode(self.CommentsEdit.toPlainText())
self.song.verse_order = unicode(self.VerseOrderEdit.text())
self.song.ccli_number = unicode(self.CCLNumberEdit.displayText())
self.song.ccli_number = unicode(self.CCLNumberEdit.text())
self.processLyrics()
self.processTitle()
self.songmanager.save_song(self.song)
@ -579,6 +580,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def processTitle(self):
log.debug(u'processTitle')
self.song.search_title = unicode(self.song.search_title)
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'')
@ -590,6 +592,5 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
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)

View File

@ -129,12 +129,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
self.authorform.setAutoDisplayName(True)
if self.authorform.exec_():
author = Author.populate(
first_name=unicode(
self.authorform.FirstNameEdit.text(), u'utf-8'),
last_name=unicode(
self.authorform.LastNameEdit.text(), u'utf-8'),
display_name=unicode(
self.authorform.DisplayEdit.text(), u'utf-8'))
first_name=unicode(self.authorform.FirstNameEdit.text()),
last_name=unicode(self.authorform.LastNameEdit.text()),
display_name=unicode(self.authorform.DisplayEdit.text()))
if self.songmanager.save_author(author):
self.resetAuthors()
else:
@ -144,8 +141,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
def onTopicAddButtonClick(self):
if self.topicform.exec_():
topic = Topic.populate(
name=unicode(self.topicform.NameEdit.text(), u'utf-8'))
topic = Topic.populate(name=unicode(self.topicform.NameEdit.text()))
if self.songmanager.save_topic(topic):
self.resetTopics()
else:
@ -156,8 +152,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
def onBookAddButtonClick(self):
if self.bookform.exec_():
book = Book.populate(
name=unicode(self.bookform.NameEdit.text(), u'utf-8'),
publisher=unicode(self.bookform.PublisherEdit.text(), u'utf-8'))
name=unicode(self.bookform.NameEdit.text()),
publisher=unicode(self.bookform.PublisherEdit.text()))
if self.songmanager.save_book(book):
self.resetBooks()
else:
@ -174,12 +170,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
self.authorform.LastNameEdit.setText(author.last_name)
self.authorform.DisplayEdit.setText(author.display_name)
if self.authorform.exec_(False):
author.first_name = unicode(
self.authorform.FirstNameEdit.text(), u'utf-8')
author.last_name = unicode(
self.authorform.LastNameEdit.text(), u'utf-8')
author.display_name = unicode(
self.authorform.DisplayEdit.text(), u'utf-8')
author.first_name = unicode(
self.authorform.FirstNameEdit.text())
author.last_name = unicode(self.authorform.LastNameEdit.text())
author.display_name = unicode(
self.authorform.DisplayEdit.text())
if self.songmanager.save_author(author):
self.resetAuthors()
else:
@ -193,7 +188,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
topic = self.songmanager.get_topic(topic_id)
self.topicform.NameEdit.setText(topic.name)
if self.topicform.exec_(False):
topic.name = unicode(self.topicform.NameEdit.text(), u'utf-8')
topic.name = unicode(self.topicform.NameEdit.text())
if self.songmanager.save_topic(topic):
self.resetTopics()
else:
@ -208,9 +203,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
self.bookform.NameEdit.setText(book.name)
self.bookform.PublisherEdit.setText(book.publisher)
if self.bookform.exec_(False):
book.name = unicode(self.bookform.NameEdit.text(), u'utf-8')
book.publisher = unicode(
self.bookform.PublisherEdit.text(), u'utf-8')
book.name = unicode(self.bookform.NameEdit.text())
book.publisher = unicode(self.bookform.PublisherEdit.text())
if self.songmanager.save_book(book):
self.resetBooks()
else:

View File

@ -187,12 +187,7 @@ class SongMediaItem(MediaManagerItem):
if author_list != u'':
author_list = author_list + u', '
author_list = author_list + author.display_name
if not isinstance(author_list, unicode):
author_list = unicode(author_list, u'utf8')
if isinstance(song.title, unicode):
song_title = song.title
else:
song_title = unicode(song.title, u'utf8')
song_title = unicode(song.title)
song_detail = u'%s (%s)' % (song_title, author_list)
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
@ -203,8 +198,8 @@ class SongMediaItem(MediaManagerItem):
self.ListView.clear()
for author in searchresults:
for song in author.songs:
song_detail = unicode(self.trUtf8('%s (%s)' % \
(unicode(author.display_name), unicode(song.title))))
song_detail = unicode(self.trUtf8('%s (%s)') % \
(author.display_name, song.title)
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.ListView.addItem(song_name)