Only trivial changes:

- only allow to select one slide in the slidecontrollers
- make curosr busy when merging authors/topics/books
- cosmetic code change (saves 4 spaces all over the methods)

bzr-revno: 1251
This commit is contained in:
andreas 2011-01-28 16:57:14 +00:00 committed by Tim Bentley
commit 8c81afd9ec
2 changed files with 108 additions and 94 deletions

View File

@ -119,6 +119,8 @@ class SlideController(QtGui.QWidget):
self.previewListWidget.isLive = self.isLive self.previewListWidget.isLive = self.isLive
self.previewListWidget.setObjectName(u'PreviewListWidget') self.previewListWidget.setObjectName(u'PreviewListWidget')
self.previewListWidget.setSelectionBehavior(1) self.previewListWidget.setSelectionBehavior(1)
self.previewListWidget.setSelectionMode(
QtGui.QAbstractItemView.SingleSelection)
self.previewListWidget.setEditTriggers( self.previewListWidget.setEditTriggers(
QtGui.QAbstractItemView.NoEditTriggers) QtGui.QAbstractItemView.NoEditTriggers)
self.previewListWidget.setHorizontalScrollBarPolicy( self.previewListWidget.setHorizontalScrollBarPolicy(

View File

@ -278,117 +278,129 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
def onAuthorEditButtonClick(self): def onAuthorEditButtonClick(self):
author_id = self._getCurrentItemId(self.authorsListWidget) author_id = self._getCurrentItemId(self.authorsListWidget)
if author_id != -1: if author_id == -1:
author = self.manager.get_object(Author, author_id) return
self.authorform.setAutoDisplayName(False) author = self.manager.get_object(Author, author_id)
self.authorform.firstNameEdit.setText(author.first_name) self.authorform.setAutoDisplayName(False)
self.authorform.lastNameEdit.setText(author.last_name) self.authorform.firstNameEdit.setText(author.first_name)
self.authorform.displayEdit.setText(author.display_name) self.authorform.lastNameEdit.setText(author.last_name)
# Save the author's first and last name as well as the display name self.authorform.displayEdit.setText(author.display_name)
# for the case that they have to be restored. # Save the author's first and last name as well as the display name
temp_first_name = author.first_name # for the case that they have to be restored.
temp_last_name = author.last_name temp_first_name = author.first_name
temp_display_name = author.display_name temp_last_name = author.last_name
if self.authorform.exec_(False): temp_display_name = author.display_name
author.first_name = unicode( if self.authorform.exec_(False):
self.authorform.firstNameEdit.text()) author.first_name = unicode(
author.last_name = unicode(self.authorform.lastNameEdit.text()) self.authorform.firstNameEdit.text())
author.display_name = unicode( author.last_name = unicode(self.authorform.lastNameEdit.text())
self.authorform.displayEdit.text()) author.display_name = unicode(
if self.checkAuthor(author, True): self.authorform.displayEdit.text())
if self.manager.save_object(author): if self.checkAuthor(author, True):
self.resetAuthors() if self.manager.save_object(author):
Receiver.send_message(u'songs_load_list')
else:
criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your changes.'))
elif criticalErrorMessageBox(message=unicode(translate(
'SongsPlugin.SongMaintenanceForm', 'The author %s already '
'exists. Would you like to make songs with author %s use '
'the existing author %s?')) % (author.display_name,
temp_display_name, author.display_name),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.mergeAuthors(author)
self.resetAuthors() self.resetAuthors()
Receiver.send_message(u'songs_load_list') Receiver.send_message(u'songs_load_list')
else: else:
# We restore the author's old first and last name as well as
# his display name.
author.first_name = temp_first_name
author.last_name = temp_last_name
author.display_name = temp_display_name
criticalErrorMessageBox( criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm', message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your modified author, because the ' 'Could not save your changes.'))
'author already exists.')) elif criticalErrorMessageBox(message=unicode(translate(
'SongsPlugin.SongMaintenanceForm', 'The author %s already '
'exists. Would you like to make songs with author %s use '
'the existing author %s?')) % (author.display_name,
temp_display_name, author.display_name),
parent=self, question=True) == QtGui.QMessageBox.Yes:
Receiver.send_message(u'cursor_busy')
Receiver.send_message(u'openlp_process_events')
self.mergeAuthors(author)
self.resetAuthors()
Receiver.send_message(u'songs_load_list')
Receiver.send_message(u'cursor_normal')
else:
# We restore the author's old first and last name as well as
# his display name.
author.first_name = temp_first_name
author.last_name = temp_last_name
author.display_name = temp_display_name
criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your modified author, because the '
'author already exists.'))
def onTopicEditButtonClick(self): def onTopicEditButtonClick(self):
topic_id = self._getCurrentItemId(self.topicsListWidget) topic_id = self._getCurrentItemId(self.topicsListWidget)
if topic_id != -1: if topic_id == -1:
topic = self.manager.get_object(Topic, topic_id) return
self.topicform.nameEdit.setText(topic.name) topic = self.manager.get_object(Topic, topic_id)
# Save the topic's name for the case that he has to be restored. self.topicform.nameEdit.setText(topic.name)
temp_name = topic.name # Save the topic's name for the case that he has to be restored.
if self.topicform.exec_(False): temp_name = topic.name
topic.name = unicode(self.topicform.nameEdit.text()) if self.topicform.exec_(False):
if self.checkTopic(topic, True): topic.name = unicode(self.topicform.nameEdit.text())
if self.manager.save_object(topic): if self.checkTopic(topic, True):
self.resetTopics() if self.manager.save_object(topic):
else:
criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your changes.'))
elif criticalErrorMessageBox(
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
'The topic %s already exists. Would you like to make songs '
'with topic %s use the existing topic %s?')) % (topic.name,
temp_name, topic.name),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.mergeTopics(topic)
self.resetTopics() self.resetTopics()
else: else:
# We restore the topics's old name.
topic.name = temp_name
criticalErrorMessageBox( criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm', message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your modified topic, because it ' 'Could not save your changes.'))
'already exists.')) elif criticalErrorMessageBox(
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
'The topic %s already exists. Would you like to make songs '
'with topic %s use the existing topic %s?')) % (topic.name,
temp_name, topic.name),
parent=self, question=True) == QtGui.QMessageBox.Yes:
Receiver.send_message(u'cursor_busy')
Receiver.send_message(u'openlp_process_events')
self.mergeTopics(topic)
self.resetTopics()
Receiver.send_message(u'cursor_normal')
else:
# We restore the topics's old name.
topic.name = temp_name
criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your modified topic, because it '
'already exists.'))
def onBookEditButtonClick(self): def onBookEditButtonClick(self):
book_id = self._getCurrentItemId(self.booksListWidget) book_id = self._getCurrentItemId(self.booksListWidget)
if book_id != -1: if book_id == -1:
book = self.manager.get_object(Book, book_id) return
if book.publisher is None: book = self.manager.get_object(Book, book_id)
book.publisher = u'' if book.publisher is None:
self.bookform.nameEdit.setText(book.name) book.publisher = u''
self.bookform.publisherEdit.setText(book.publisher) self.bookform.nameEdit.setText(book.name)
# Save the book's name and publisher for the case that they have to self.bookform.publisherEdit.setText(book.publisher)
# be restored. # Save the book's name and publisher for the case that they have to
temp_name = book.name # be restored.
temp_publisher = book.publisher temp_name = book.name
if self.bookform.exec_(False): temp_publisher = book.publisher
book.name = unicode(self.bookform.nameEdit.text()) if self.bookform.exec_(False):
book.publisher = unicode(self.bookform.publisherEdit.text()) book.name = unicode(self.bookform.nameEdit.text())
if self.checkBook(book, True): book.publisher = unicode(self.bookform.publisherEdit.text())
if self.manager.save_object(book): if self.checkBook(book, True):
self.resetBooks() if self.manager.save_object(book):
else:
criticalErrorMessageBox(
message=translate('SongsPlugin.SongMaintenanceForm',
'Could not save your changes.'))
elif criticalErrorMessageBox(
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
'The book %s already exists. Would you like to make songs '
'with book %s use the existing book %s?')) % (book.name,
temp_name, book.name),
parent=self, question=True) == QtGui.QMessageBox.Yes:
self.mergeBooks(book)
self.resetBooks() self.resetBooks()
else: else:
# We restore the book's old name and publisher. criticalErrorMessageBox(
book.name = temp_name message=translate('SongsPlugin.SongMaintenanceForm',
book.publisher = temp_publisher 'Could not save your changes.'))
elif criticalErrorMessageBox(
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
'The book %s already exists. Would you like to make songs '
'with book %s use the existing book %s?')) % (book.name,
temp_name, book.name),
parent=self, question=True) == QtGui.QMessageBox.Yes:
Receiver.send_message(u'cursor_busy')
Receiver.send_message(u'openlp_process_events')
self.mergeBooks(book)
self.resetBooks()
Receiver.send_message(u'cursor_normal')
else:
# We restore the book's old name and publisher.
book.name = temp_name
book.publisher = temp_publisher
def mergeAuthors(self, old_author): def mergeAuthors(self, old_author):
""" """