Added last bits of streamlining of Song Maintenance form.

This commit is contained in:
Raoul Snyman 2010-06-18 21:55:45 +02:00
parent cc2db3a5f4
commit d48daa2c98
3 changed files with 80 additions and 60 deletions

View File

@ -439,58 +439,58 @@ class Ui_EditSongDialog(object):
def retranslateUi(self, EditSongDialog):
EditSongDialog.setWindowTitle(
translate(u'SongsPlugin.EditSongForm', u'Song Editor'))
translate('SongsPlugin.EditSongForm', 'Song Editor'))
self.TitleLabel.setText(
translate(u'SongsPlugin.EditSongForm', u'Title:'))
translate('SongsPlugin.EditSongForm', '&Title:'))
self.AlternativeTitleLabel.setText(
translate(u'SongsPlugin.EditSongForm', u'Alternative Title:'))
translate('SongsPlugin.EditSongForm', 'Alt&ernative Title:'))
self.LyricsLabel.setText(
translate(u'SongsPlugin.EditSongForm', u'Lyrics:'))
translate('SongsPlugin.EditSongForm', '&Lyrics:'))
self.VerseOrderLabel.setText(
translate(u'SongsPlugin.EditSongForm', u'Verse Order:'))
translate('SongsPlugin.EditSongForm', '&Verse Order:'))
self.VerseAddButton.setText(
translate(u'SongsPlugin.EditSongForm', u'Add'))
translate('SongsPlugin.EditSongForm', '&Add'))
self.VerseEditButton.setText(
translate(u'SongsPlugin.EditSongForm', u'Edit'))
translate('SongsPlugin.EditSongForm', '&Edit'))
self.VerseEditAllButton.setText(
translate(u'SongsPlugin.EditSongForm', u'Edit All'))
translate('SongsPlugin.EditSongForm', 'Ed&it All'))
self.VerseDeleteButton.setText(
translate(u'SongsPlugin.EditSongForm', u'Delete'))
translate('SongsPlugin.EditSongForm', '&Delete'))
self.SongTabWidget.setTabText(
self.SongTabWidget.indexOf(self.LyricsTab),
translate(u'SongsPlugin.EditSongForm', u'Title && Lyrics'))
translate('SongsPlugin.EditSongForm', 'Title && Lyrics'))
self.AuthorsGroupBox.setTitle(
translate(u'SongsPlugin.EditSongForm', u'Authors'))
translate('SongsPlugin.EditSongForm', 'Authors'))
self.AuthorAddButton.setText(
translate(u'SongsPlugin.EditSongForm', u'&Add to Song'))
translate('SongsPlugin.EditSongForm', '&Add to Song'))
self.AuthorRemoveButton.setText(
translate(u'SongsPlugin.EditSongForm', u'&Remove'))
self.MaintenanceButton.setText(translate(u'SongsPlugin.EditSongForm',
u'&Manage Authors, Topics, Books'))
translate('SongsPlugin.EditSongForm', '&Remove'))
self.MaintenanceButton.setText(translate('SongsPlugin.EditSongForm',
'&Manage Authors, Topics, Books'))
self.TopicGroupBox.setTitle(
translate(u'SongsPlugin.EditSongForm', u'Topic'))
translate('SongsPlugin.EditSongForm', 'Topic'))
self.TopicAddButton.setText(
translate(u'SongsPlugin.EditSongForm', u'A&dd to Song'))
translate('SongsPlugin.EditSongForm', 'A&dd to Song'))
self.TopicRemoveButton.setText(
translate(u'SongsPlugin.EditSongForm', u'R&emove'))
translate('SongsPlugin.EditSongForm', 'R&emove'))
self.SongBookGroup.setTitle(
translate(u'SongsPlugin.EditSongForm', u'Song Book'))
translate('SongsPlugin.EditSongForm', 'Song Book'))
self.SongTabWidget.setTabText(
self.SongTabWidget.indexOf(self.AuthorsTab),
translate(u'SongsPlugin.EditSongForm', u'Authors, Topics && Book'))
translate('SongsPlugin.EditSongForm', 'Authors, Topics && Book'))
self.ThemeGroupBox.setTitle(
translate(u'SongsPlugin.EditSongForm', u'Theme'))
translate('SongsPlugin.EditSongForm', 'Theme'))
self.ThemeAddButton.setText(
translate(u'SongsPlugin.EditSongForm', u'Add a Theme'))
translate('SongsPlugin.EditSongForm', 'Add a &Theme'))
self.CopyrightGroupBox.setTitle(
translate(u'SongsPlugin.EditSongForm', u'Copyright Information'))
translate('SongsPlugin.EditSongForm', 'Copyright Information'))
self.CopyrightInsertButton.setText(
translate(u'SongsPlugin.EditSongForm', u'\xa9'))
translate('SongsPlugin.EditSongForm', u'\xa9'))
self.CCLILabel.setText(
translate(u'SongsPlugin.EditSongForm', u'CCLI Number:'))
translate('SongsPlugin.EditSongForm', 'CCLI Number:'))
self.CommentsGroupBox.setTitle(
translate(u'SongsPlugin.EditSongForm', u'Comments'))
translate('SongsPlugin.EditSongForm', 'Comments'))
self.SongTabWidget.setTabText(
self.SongTabWidget.indexOf(self.ThemeTab),
translate(u'SongsPlugin.EditSongForm',
u'Theme, Copyright Info && Comments'))
translate('SongsPlugin.EditSongForm',
'Theme, Copyright Info && Comments'))

View File

@ -228,6 +228,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.VerseListWidget.clear()
self.VerseListWidget.setRowCount(0)
self.VerseListWidget.setColumnWidth(0, self.width)
# This is just because occasionally the lyrics come back as a "buffer"
if isinstance(self.song.lyrics, buffer):
self.song.lyrics = unicode(self.song.lyrics)
if self.song.lyrics.startswith(u'<?xml version='):
@ -288,9 +289,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = unicode(self.AuthorsSelectionComboItem.currentText())
if item == 0 and text:
if QtGui.QMessageBox.question(self,
translate(u'EditSongForm', u'Add Author'),
translate(u'EditSongForm', u'This author does not exist, do '
u'you want to add them?'),
translate('SongsPlugin.EditSongForm', 'Add Author'),
translate('SongsPlugin.EditSongForm', 'This author does not '
'exist, do you want to add them?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
author = Author.populate(display_name=text)
@ -300,6 +301,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
self.AuthorsListView.addItem(author_item)
self.loadAuthors()
self.AuthorsSelectionComboItem.setCurrentIndex(0)
else:
return
elif item > 0:
@ -309,13 +311,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
self.AuthorsListView.addItem(author_item)
self.AuthorsSelectionComboItem.setCurrentIndex(0)
else:
QtGui.QMessageBox.warning(self,
translate(u'EditSongForm', u'No Author Selected'),
translate(u'EditSongForm', u'You have not selected a valid '
u'author. Either select an author from the list, or type '
u'in a new author and click the "Add Author to Song" '
u'button to add the new author.'),
translate('SongsPlugin.EditSongForm', 'No Author Selected'),
translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid author. Either select an author from the list, '
'or type in a new author and click the "Add Author to '
'Song" button to add the new author.'),
QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
def onAuthorsListViewPressed(self):
@ -336,9 +339,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = unicode(self.SongTopicCombo.currentText())
if item == 0 and text:
if QtGui.QMessageBox.question(self,
translate(u'EditSongForm', u'Add Topic'),
translate(u'EditSongForm', u'This topic does not exist, do '
u'you want to add it?'),
translate('SongsPlugin.EditSongForm', 'Add Topic'),
translate('SongsPlugin.EditSongForm', 'This topic does not '
'exist, do you want to add it?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
topic = Topic.populate(name=text)
@ -348,6 +351,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.TopicsListView.addItem(topic_item)
self.loadTopics()
self.SongTopicCombo.setCurrentIndex(0)
else:
return
elif item > 0:
@ -357,13 +361,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.TopicsListView.addItem(topic_item)
self.SongTopicCombo.setCurrentIndex(0)
else:
QtGui.QMessageBox.warning(self,
translate(u'EditSongForm', u'No Topic Selected'),
translate(u'EditSongForm', u'You have not selected a valid '
u'topic. Either select a topic from the list, or type '
u'in a new topic and click the "Add Topic to Song" '
u'button to add the new topic.'),
translate('SongsPlugin.EditSongForm', 'No Topic Selected'),
translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid topic. Either select a topic from the list, or '
'type in a new topic and click the "Add Topic to Song" '
'button to add the new topic.'),
QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
def onTopicListViewPressed(self):
@ -379,12 +384,27 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.TopicsListView.takeItem(row)
def onSongBookComboChanged(self, item):
if item == 0:
self.song.song_book_id = 0
else:
item = int(self.SongbookCombo.currentIndex())
text = unicode(self.SongbookCombo.currentText())
if item == 0 and text:
if QtGui.QMessageBox.question(self,
translate('SongsPlugin.EditSongForm', 'Add Book'),
translate('SongsPlugin.EditSongForm', 'This song book does '
'not exist, do you want to add it?'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
book = Book.populate(name=text)
self.songmanager.save_book(book)
self.song.book = book
self.loadBooks()
else:
return
elif item > 1:
item = int(self.SongbookCombo.currentIndex())
self.song.song_book_id = \
(self.SongbookCombo.itemData(item)).toInt()[0]
else:
self.song.song_book_id = 0
def onThemeComboChanged(self, item):
if item == 0:

View File

@ -211,28 +211,28 @@ class Ui_SongMaintenanceDialog(object):
def retranslateUi(self, SongMaintenanceDialog):
SongMaintenanceDialog.setWindowTitle(
translate(u'SongsPlugin.SongMaintenanceForm', u'Song Maintenance'))
translate('SongsPlugin.SongMaintenanceForm', 'Song Maintenance'))
self.TypeListWidget.item(0).setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Authors'))
translate('SongsPlugin.SongMaintenanceForm', 'Authors'))
self.TypeListWidget.item(1).setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Topics'))
translate('SongsPlugin.SongMaintenanceForm', 'Topics'))
self.TypeListWidget.item(2).setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Books/Hymnals'))
translate('SongsPlugin.SongMaintenanceForm', 'Books/Hymnals'))
self.AuthorAddButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Add'))
translate('SongsPlugin.SongMaintenanceForm', '&Add'))
self.AuthorEditButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Edit'))
translate('SongsPlugin.SongMaintenanceForm', '&Edit'))
self.AuthorDeleteButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Delete'))
translate('SongsPlugin.SongMaintenanceForm', '&Delete'))
self.TopicAddButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Add'))
translate('SongsPlugin.SongMaintenanceForm', '&Add'))
self.TopicEditButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Edit'))
translate('SongsPlugin.SongMaintenanceForm', '&Edit'))
self.TopicDeleteButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Delete'))
translate('SongsPlugin.SongMaintenanceForm', '&Delete'))
self.BookAddButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Add'))
translate('SongsPlugin.SongMaintenanceForm', '&Add'))
self.BookEditButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Edit'))
translate('SongsPlugin.SongMaintenanceForm', '&Edit'))
self.BookDeleteButton.setText(
translate(u'SongsPlugin.SongMaintenanceForm', u'Delete'))
translate('SongsPlugin.SongMaintenanceForm', '&Delete'))