From 23022c095d8113d53aa7e0b02a059de30ef6c9b5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 31 Jul 2010 13:52:17 +0200 Subject: [PATCH] improved button behaviour --- .../plugins/songs/forms/songmaintenanceform.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index da4351fbc..83dba85a2 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -113,6 +113,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): u'%s %s' % (author.first_name, author.last_name)) author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) self.AuthorsListWidget.addItem(author_name) + if self.AuthorsListWidget.count() == 0: + self.AuthorDeleteButton.setEnabled(False) + self.AuthorEditButton.setEnabled(False) + else: + self.AuthorDeleteButton.setEnabled(True) + self.AuthorEditButton.setEnabled(True) def resetTopics(self): """ @@ -125,6 +131,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): topic_name = QtGui.QListWidgetItem(topic.name) topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) self.TopicsListWidget.addItem(topic_name) + if self.TopicsListWidget.count() == 0: + self.TopicDeleteButton.setEnabled(False) + self.TopicEditButton.setEnabled(False) + else: + self.TopicDeleteButton.setEnabled(True) + self.TopicEditButton.setEnabled(True) def resetBooks(self): """ @@ -137,6 +149,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.publisher)) book_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(book.id)) self.BooksListWidget.addItem(book_name) + if self.BooksListWidget.count() == 0: + self.BookDeleteButton.setEnabled(False) + self.BookEditButton.setEnabled(False) + else: + self.BookDeleteButton.setEnabled(True) + self.BookEditButton.setEnabled(True) def checkAuthor(self, new_author, edit=False): """