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