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

View File

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

View File

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