From b0b89fdc054ff84bccd8f12cfaa770acfe932129 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 Feb 2013 00:01:41 +0200 Subject: [PATCH] Some code cleanups to make PyLint happier. --- openlp/plugins/alerts/forms/alertform.py | 15 ++- openlp/plugins/custom/forms/editcustomform.py | 54 ++++++--- .../custom/forms/editcustomslideform.py | 14 ++- openlp/plugins/songs/forms/songbookform.py | 12 +- openlp/plugins/songs/forms/songimportform.py | 105 ++++++++++-------- .../songs/forms/songmaintenanceform.py | 34 +++++- openlp/plugins/songs/forms/topicsform.py | 9 +- 7 files changed, 172 insertions(+), 71 deletions(-) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index cedb7acfc..c09180702 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -34,6 +34,7 @@ from openlp.plugins.alerts.lib.db import AlertItem from alertdialog import Ui_AlertDialog + class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ Provide UI for the alert system @@ -45,7 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.manager = plugin.manager self.plugin = plugin self.item_id = None - QtGui.QDialog.__init__(self, self.plugin.main_window) + super(AlertForm, self).__init__(self.plugin.main_window) self.setupUi(self) QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) QtCore.QObject.connect(self.displayCloseButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked) @@ -57,6 +58,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) def exec_(self): + """ + Execute the dialog and return the exit code. + """ self.displayButton.setEnabled(False) self.displayCloseButton.setEnabled(False) self.alertTextEdit.setText(u'') @@ -77,9 +81,15 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertListWidget.setCurrentRow(self.alertListWidget.row(item_name)) def onDisplayClicked(self): + """ + Display the current alert text. + """ self.triggerAlert(self.alertTextEdit.text()) def onDisplayCloseClicked(self): + """ + Close the alert preview. + """ if self.triggerAlert(self.alertTextEdit.text()): self.close() @@ -97,6 +107,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertTextEdit.setText(u'') def onNewClick(self): + """ + Create a new alert. + """ if not self.alertTextEdit.text(): QtGui.QMessageBox.information(self, translate('AlertsPlugin.AlertForm', 'New Alert'), diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 8e7c18bdf..18f3ab736 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -41,35 +41,42 @@ from editcustomslideform import EditCustomSlideForm log = logging.getLogger(__name__) + class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Class documentation goes here. """ log.info(u'Custom Editor loaded') + def __init__(self, mediaitem, parent, manager): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(EditCustomForm, self).__init__(parent) self.manager = manager self.mediaitem = mediaitem self.setupUi(self) # Create other objects and forms. self.editSlideForm = EditCustomSlideForm(self) # Connecting signals and slots - QtCore.QObject.connect(self.previewButton, QtCore.SIGNAL(u'clicked()'), self.onPreviewButtonClicked) - QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked) - QtCore.QObject.connect(self.editButton, QtCore.SIGNAL(u'clicked()'), self.onEditButtonClicked) - QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'clicked()'), self.onEditAllButtonClicked) + self.previewButton.clicked.connect(self.on_preview_button_clicked) + self.addButton.clicked.connect(self.on_add_button_clicked) + self.editButton.clicked.connect(self.on_edit_button_clicked) + self.editAllButton.clicked.connect(self.on_edit_all_button_clicked) + self.slideListView.currentRowChanged.connect(self.on_current_row_changed) + self.slideListView.doubleClicked.connect(self.on_edit_button_clicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) - QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) - QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.onEditButtonClicked) - def loadThemes(self, themelist): + def loadThemes(self, theme_list): + """ + Load a list of themes into the themes combo box. + + ``theme_list`` + The list of themes to load. + """ self.themeComboBox.clear() self.themeComboBox.addItem(u'') - self.themeComboBox.addItems(themelist) + self.themeComboBox.addItems(theme_list) def loadCustom(self, id, preview=False): """ @@ -103,6 +110,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.previewButton.setVisible(preview) def accept(self): + """ + Override the QDialog method to check if the custom slide has been saved before closing the dialog. + """ log.debug(u'accept') if self.saveCustom(): QtGui.QDialog.accept(self) @@ -125,6 +135,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): return success def onUpButtonClicked(self): + """ + Move a slide up in the list when the "Up" button is clicked. + """ selectedRow = self.slideListView.currentRow() if selectedRow != 0: qw = self.slideListView.takeItem(selectedRow) @@ -132,6 +145,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.setCurrentRow(selectedRow - 1) def onDownButtonClicked(self): + """ + Move a slide down in the list when the "Down" button is clicked. + """ selectedRow = self.slideListView.currentRow() # zero base arrays if selectedRow != self.slideListView.count() - 1: @@ -139,17 +155,23 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.insertItem(selectedRow + 1, qw) self.slideListView.setCurrentRow(selectedRow + 1) - def onAddButtonClicked(self): + def on_add_button_clicked(self): + """ + Add a new blank slide. + """ self.editSlideForm.setText(u'') if self.editSlideForm.exec_(): self.slideListView.addItems(self.editSlideForm.getText()) - def onEditButtonClicked(self): + def on_edit_button_clicked(self): + """ + Edit the currently selected slide. + """ self.editSlideForm.setText(self.slideListView.currentItem().text()) if self.editSlideForm.exec_(): self.updateSlideList(self.editSlideForm.getText()) - def onEditAllButtonClicked(self): + def on_edit_all_button_clicked(self): """ Edits all slides. """ @@ -163,7 +185,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if self.editSlideForm.exec_(): self.updateSlideList(self.editSlideForm.getText(), True) - def onPreviewButtonClicked(self): + def on_preview_button_clicked(self): """ Save the custom item and preview it. """ @@ -203,9 +225,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Removes the current row from the list. """ self.slideListView.takeItem(self.slideListView.currentRow()) - self.onCurrentRowChanged(self.slideListView.currentRow()) + self.on_current_row_changed(self.slideListView.currentRow()) - def onCurrentRowChanged(self, row): + def on_current_row_changed(self, row): """ Called when the *slideListView*'s current row has been changed. This enables or disables buttons which require an slide to act on. diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index fce51c4e3..755237345 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -1,3 +1,4 @@ +#lint:disable # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 @@ -35,16 +36,18 @@ from editcustomslidedialog import Ui_CustomSlideEditDialog log = logging.getLogger(__name__) + class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): """ Class documentation goes here. """ log.info(u'Custom Verse Editor loaded') + def __init__(self, parent=None): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(EditCustomeEditCustomSlideForm, self).__init__(parent) self.setupUi(self) # Connecting signals and slots QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked) @@ -88,9 +91,10 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): """ full_text = self.slideTextEdit.toPlainText() position = self.slideTextEdit.textCursor().position() - if position and full_text[position-1] != u'\n': - text = u'\n' + text - if position == len(full_text) or full_text[position] != u'\n': - text += u'\n' + if position and full_text[position - 1] != u'\n': + text = u'\n' + text + if position == len(full_text) or full_text[position] != u'\n': + text += u'\n' self.slideTextEdit.insertPlainText(text) +#lint:enable diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 96e893a49..85b8e9011 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -33,6 +33,7 @@ from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.songbookdialog import Ui_SongBookDialog + class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): """ Class documentation goes here. @@ -41,10 +42,16 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(SongBookForm, self).__init__(parent) self.setupUi(self) def exec_(self, clear=True): + """ + Execute the song book form. + + ``clear`` + Clear the fields on the form before displaying it. + """ if clear: self.nameEdit.clear() self.publisherEdit.clear() @@ -52,6 +59,9 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): return QtGui.QDialog.exec_(self) def accept(self): + """ + Override the inherited method to check that the name of the book has been typed in. + """ if not self.nameEdit.text(): critical_error_message_box( message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.')) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index efadd6b61..0e014ba96 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,13 +35,14 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsManager, translate, UiStrings +from openlp.core.lib import Receiver, Settings, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect log = logging.getLogger(__name__) + class SongImportForm(OpenLPWizard): """ This is the Song Import Wizard, which allows easy importing of Songs @@ -211,17 +212,17 @@ class SongImportForm(OpenLPWizard): if self.currentPage() == self.welcomePage: return True elif self.currentPage() == self.sourcePage: - format = self.currentFormat - Settings().setValue(u'songs/last import type', format) - select_mode, class_, error_msg = SongFormat.get(format, u'selectMode', u'class', u'invalidSourceMsg') + this_format = self.currentFormat + Settings().setValue(u'songs/last import type', this_format) + select_mode, class_, error_msg = SongFormat.get(this_format, u'selectMode', u'class', u'invalidSourceMsg') if select_mode == SongFormatSelect.MultipleFiles: - import_source = self.getListOfFiles(self.formatWidgets[format][u'fileListWidget']) + import_source = self.getListOfFiles(self.formatWidgets[this_format][u'fileListWidget']) error_title = UiStrings().IFSp - focus_button = self.formatWidgets[format][u'addButton'] + focus_button = self.formatWidgets[this_format][u'addButton'] else: - import_source = self.formatWidgets[format][u'filepathEdit'].text() + import_source = self.formatWidgets[this_format][u'filepathEdit'].text() error_title = (UiStrings().IFSs if select_mode == SongFormatSelect.SingleFile else UiStrings().IFdSs) - focus_button = self.formatWidgets[format][u'browseButton'] + focus_button = self.formatWidgets[this_format][u'browseButton'] if not class_.isValidSource(import_source): critical_error_message_box(error_title, error_msg) focus_button.setFocus() @@ -271,25 +272,35 @@ class SongImportForm(OpenLPWizard): del item def onBrowseButtonClicked(self): - format = self.currentFormat - select_mode, format_name, filter = SongFormat.get(format, u'selectMode', + """ + Browse for files or a directory. + """ + this_format = self.currentFormat + select_mode, format_name, ext_filter = SongFormat.get(this_format, u'selectMode', u'name', u'filter') - filepathEdit = self.formatWidgets[format][u'filepathEdit'] + filepathEdit = self.formatWidgets[this_format][u'filepathEdit'] if select_mode == SongFormatSelect.SingleFile: - self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, u'last directory import', filter) + self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, + u'last directory import', ext_filter) elif select_mode == SongFormatSelect.SingleFolder: self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit, u'last directory import') def onAddButtonClicked(self): - format = self.currentFormat - select_mode, format_name, filter, custom_title = \ - SongFormat.get(format, u'selectMode', u'name', u'filter', u'getFilesTitle') + """ + Add a file or directory. + """ + this_format = self.currentFormat + select_mode, format_name, ext_filter, custom_title = \ + SongFormat.get(this_format, u'selectMode', u'name', u'filter', u'getFilesTitle') title = custom_title if custom_title else WizardStrings.OpenTypeFile % format_name if select_mode == SongFormatSelect.MultipleFiles: - self.getFiles(title, self.formatWidgets[format][u'fileListWidget'], filter) + self.getFiles(title, self.formatWidgets[this_format][u'fileListWidget'], ext_filter) self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()')) def onRemoveButtonClicked(self): + """ + Remove a file from the list. + """ self.removeSelectedItems( self.formatWidgets[self.currentFormat][u'fileListWidget']) self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()')) @@ -340,10 +351,10 @@ class SongImportForm(OpenLPWizard): select_mode = SongFormat.get(source_format, u'selectMode') if select_mode == SongFormatSelect.SingleFile: importer = self.plugin.importSongs(source_format, - filename = self.formatWidgets[source_format][u'filepathEdit'].text()) + filename=self.formatWidgets[source_format][u'filepathEdit'].text()) elif select_mode == SongFormatSelect.SingleFolder: importer = self.plugin.importSongs(source_format, - folder = self.formatWidgets[source_format][u'filepathEdit'].text()) + folder=self.formatWidgets[source_format][u'filepathEdit'].text()) else: importer = self.plugin.importSongs(source_format, filenames=self.getListOfFiles(self.formatWidgets[source_format][u'fileListWidget'])) @@ -369,9 +380,12 @@ class SongImportForm(OpenLPWizard): report_file.close() def addFileSelectItem(self): - format = self.currentFormat + """ + Add a file selection page. + """ + this_format = self.currentFormat prefix, can_disable, description_text, select_mode = \ - SongFormat.get(format, u'prefix', u'canDisable', u'descriptionText', u'selectMode') + SongFormat.get(this_format, u'prefix', u'canDisable', u'descriptionText', u'selectMode') page = QtGui.QWidget() page.setObjectName(prefix + u'Page') if can_disable: @@ -392,8 +406,8 @@ class SongImportForm(OpenLPWizard): descriptionLabel.setObjectName(prefix + u'DescriptionLabel') descriptionLayout.addWidget(descriptionLabel) importLayout.addLayout(descriptionLayout) - self.formatWidgets[format][u'descriptionLabel'] = descriptionLabel - self.formatWidgets[format][u'descriptionSpacer'] = descriptionSpacer + self.formatWidgets[this_format][u'descriptionLabel'] = descriptionLabel + self.formatWidgets[this_format][u'descriptionSpacer'] = descriptionSpacer if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder: filepathLayout = QtGui.QHBoxLayout() filepathLayout.setObjectName(prefix + u'FilepathLayout') @@ -412,11 +426,11 @@ class SongImportForm(OpenLPWizard): filepathLayout.addWidget(browseButton) importLayout.addLayout(filepathLayout) importLayout.addSpacerItem(self.stackSpacer) - self.formatWidgets[format][u'filepathLabel'] = filepathLabel - self.formatWidgets[format][u'filepathSpacer'] = filepathSpacer - self.formatWidgets[format][u'filepathLayout'] = filepathLayout - self.formatWidgets[format][u'filepathEdit'] = filepathEdit - self.formatWidgets[format][u'browseButton'] = browseButton + self.formatWidgets[this_format][u'filepathLabel'] = filepathLabel + self.formatWidgets[this_format][u'filepathSpacer'] = filepathSpacer + self.formatWidgets[this_format][u'filepathLayout'] = filepathLayout + self.formatWidgets[this_format][u'filepathEdit'] = filepathEdit + self.formatWidgets[this_format][u'browseButton'] = browseButton elif select_mode == SongFormatSelect.MultipleFiles: fileListWidget = QtGui.QListWidget(importWidget) fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) @@ -434,18 +448,21 @@ class SongImportForm(OpenLPWizard): removeButton.setObjectName(prefix + u'RemoveButton') buttonLayout.addWidget(removeButton) importLayout.addLayout(buttonLayout) - self.formatWidgets[format][u'fileListWidget'] = fileListWidget - self.formatWidgets[format][u'buttonLayout'] = buttonLayout - self.formatWidgets[format][u'addButton'] = addButton - self.formatWidgets[format][u'removeButton'] = removeButton + self.formatWidgets[this_format][u'fileListWidget'] = fileListWidget + self.formatWidgets[this_format][u'buttonLayout'] = buttonLayout + self.formatWidgets[this_format][u'addButton'] = addButton + self.formatWidgets[this_format][u'removeButton'] = removeButton self.formatStack.addWidget(page) - self.formatWidgets[format][u'page'] = page - self.formatWidgets[format][u'importLayout'] = importLayout + self.formatWidgets[this_format][u'page'] = page + self.formatWidgets[this_format][u'importLayout'] = importLayout self.formatComboBox.addItem(u'') def disablableWidget(self, page, prefix): - format = self.currentFormat - self.disablableFormats.append(format) + """ + Disable a widget. + """ + this_format = self.currentFormat + self.disablableFormats.append(this_format) layout = QtGui.QVBoxLayout(page) layout.setMargin(0) layout.setSpacing(0) @@ -465,11 +482,11 @@ class SongImportForm(OpenLPWizard): importWidget = QtGui.QWidget(page) importWidget.setObjectName(prefix + u'ImportWidget') layout.addWidget(importWidget) - self.formatWidgets[format][u'layout'] = layout - self.formatWidgets[format][u'disabledWidget'] = disabledWidget - self.formatWidgets[format][u'disabledLayout'] = disabledLayout - self.formatWidgets[format][u'disabledLabel'] = disabledLabel - self.formatWidgets[format][u'importWidget'] = importWidget + self.formatWidgets[this_format][u'layout'] = layout + self.formatWidgets[this_format][u'disabledWidget'] = disabledWidget + self.formatWidgets[this_format][u'disabledLayout'] = disabledLayout + self.formatWidgets[this_format][u'disabledLabel'] = disabledLabel + self.formatWidgets[this_format][u'importWidget'] = importWidget return importWidget @@ -489,14 +506,14 @@ class SongImportSourcePage(QtGui.QWizardPage): When this method returns True, the wizard's Next button is enabled. """ wizard = self.wizard() - format = wizard.currentFormat - select_mode, format_available = SongFormat.get(format, u'selectMode', u'availability') + this_format = wizard.currentFormat + select_mode, format_available = SongFormat.get(this_format, u'selectMode', u'availability') if format_available: if select_mode == SongFormatSelect.MultipleFiles: - if wizard.formatWidgets[format][u'fileListWidget'].count() > 0: + if wizard.formatWidgets[this_format][u'fileListWidget'].count() > 0: return True else: - filepath = unicode(wizard.formatWidgets[format][u'filepathEdit'].text()) + filepath = unicode(wizard.formatWidgets[this_format][u'filepathEdit'].text()) if filepath: if select_mode == SongFormatSelect.SingleFile and os.path.isfile(filepath): return True diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 474e68040..0c823571b 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -39,6 +39,7 @@ from songmaintenancedialog import Ui_SongMaintenanceDialog log = logging.getLogger(__name__) + class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Class documentation goes here. @@ -47,7 +48,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(SongMaintenanceForm, self).__init__(parent) self.setupUi(self) self.manager = manager self.authorform = AuthorsForm(self) @@ -93,8 +94,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.typeListWidget.setFocus() return QtGui.QDialog.exec_(self) - def _getCurrentItemId(self, listWidget): - item = listWidget.currentItem() + def _getCurrentItemId(self, list_widget): + """ + Get the ID of the currently selected item. + + ``list_widget`` + The list widget to examine. + """ + item = list_widget.currentItem() if item: item_id = (item.data(QtCore.Qt.UserRole)) return item_id @@ -102,6 +109,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): return -1 def _deleteItem(self, itemClass, listWidget, resetFunc, dlgTitle, del_text, err_text): + """ + Delete an item. + """ item_id = self._getCurrentItemId(listWidget) if item_id != -1: item = self.manager.get_object(itemClass, item_id) @@ -196,6 +206,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): return True def onAuthorAddButtonClicked(self): + """ + Add an author to the list. + """ self.authorform.setAutoDisplayName(True) if self.authorform.exec_(): author = Author.populate( @@ -213,6 +226,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'This author already exists.')) def onTopicAddButtonClicked(self): + """ + Add a topic to the list. + """ if self.topicform.exec_(): topic = Topic.populate(name=self.topicform.nameEdit.text()) if self.checkTopic(topic): @@ -226,6 +242,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'This topic already exists.')) def onBookAddButtonClicked(self): + """ + Add a book to the list. + """ if self.bookform.exec_(): book = Book.populate(name=self.bookform.nameEdit.text(), publisher=self.bookform.publisherEdit.text()) @@ -240,6 +259,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'This book already exists.')) def onAuthorEditButtonClicked(self): + """ + Edit an author. + """ author_id = self._getCurrentItemId(self.authorsListWidget) if author_id == -1: return @@ -283,6 +305,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'Could not save your modified author, because the author already exists.')) def onTopicEditButtonClicked(self): + """ + Edit a topic. + """ topic_id = self._getCurrentItemId(self.topicsListWidget) if topic_id == -1: return @@ -311,6 +336,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'Could not save your modified topic, because it already exists.')) def onBookEditButtonClicked(self): + """ + Edit a book. + """ book_id = self._getCurrentItemId(self.booksListWidget) if book_id == -1: return diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 1fefc5204..70e86efe4 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -33,6 +33,7 @@ from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog + class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): """ Class documentation goes here. @@ -41,16 +42,22 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(TopicsForm, self).__init__(parent) self.setupUi(self) def exec_(self, clear=True): + """ + Execute the dialog. + """ if clear: self.nameEdit.clear() self.nameEdit.setFocus() return QtGui.QDialog.exec_(self) def accept(self): + """ + Override the inherited method to check before we close. + """ if not self.nameEdit.text(): critical_error_message_box(message=translate('SongsPlugin.TopicsForm', 'You need to type in a topic name.'))