Cleaning up SongUsage

This commit is contained in:
Tim Bentley 2013-02-16 10:38:02 +00:00
parent c6ad115b10
commit ab31ffb775
5 changed files with 161 additions and 162 deletions

View File

@ -32,29 +32,30 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box
class Ui_SongUsageDeleteDialog(object):
def setupUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setObjectName(u'songUsageDeleteDialog')
songUsageDeleteDialog.resize(291, 243)
self.verticalLayout = QtGui.QVBoxLayout(songUsageDeleteDialog)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setContentsMargins(8, 8, 8, 8)
self.verticalLayout.setObjectName(u'verticalLayout')
self.deleteLabel = QtGui.QLabel(songUsageDeleteDialog)
self.deleteLabel.setObjectName(u'deleteLabel')
self.verticalLayout.addWidget(self.deleteLabel)
self.deleteCalendar = QtGui.QCalendarWidget(songUsageDeleteDialog)
self.deleteCalendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
self.deleteCalendar.setGridVisible(True)
self.deleteCalendar.setVerticalHeaderFormat(QtGui.QCalendarWidget.NoVerticalHeader)
self.deleteCalendar.setObjectName(u'deleteCalendar')
self.verticalLayout.addWidget(self.deleteCalendar)
self.button_box = create_button_box(songUsageDeleteDialog, u'button_box', [u'cancel', u'ok'])
self.verticalLayout.addWidget(self.button_box)
self.retranslateUi(songUsageDeleteDialog)
def retranslateUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setWindowTitle(translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Song Usage Data'))
self.deleteLabel.setText(
class Ui_SongUsageDeleteDialog(object):
def setupUi(self, song_usage_delete_dialog):
song_usage_delete_dialog.setObjectName(u'song_usage_delete_dialog')
song_usage_delete_dialog.resize(291, 243)
self.vertical_layout = QtGui.QVBoxLayout(song_usage_delete_dialog)
self.vertical_layout.setSpacing(8)
self.vertical_layout.setContentsMargins(8, 8, 8, 8)
self.vertical_layout.setObjectName(u'vertical_layout')
self.delete_label = QtGui.QLabel(song_usage_delete_dialog)
self.delete_label.setObjectName(u'delete_label')
self.vertical_layout.addWidget(self.delete_label)
self.delete_calendar = QtGui.QCalendarWidget(song_usage_delete_dialog)
self.delete_calendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
self.delete_calendar.setGridVisible(True)
self.delete_calendar.setVerticalHeaderFormat(QtGui.QCalendarWidget.NoVerticalHeader)
self.delete_calendar.setObjectName(u'delete_calendar')
self.vertical_layout.addWidget(self.delete_calendar)
self.button_box = create_button_box(song_usage_delete_dialog, u'button_box', [u'cancel', u'ok'])
self.vertical_layout.addWidget(self.button_box)
self.retranslateUi(song_usage_delete_dialog)
def retranslateUi(self, song_usage_delete_dialog):
song_usage_delete_dialog.setWindowTitle(translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Song Usage Data'))
self.delete_label.setText(
translate('SongUsagePlugin.SongUsageDeleteForm', 'Select the date up to which the song usage data '
'should be deleted. All data recorded before this date will be permanently deleted.'))

View File

@ -45,10 +45,9 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
self.manager = manager
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
QtCore.QObject.connect(self.button_box, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onButtonBoxClicked)
self.button_box.clicked.connect(self.on_button_box_clicked)
def onButtonBoxClicked(self, button):
def on_button_box_clicked(self, button):
if self.button_box.standardButton(button) == QtGui.QDialogButtonBox.Ok:
ret = QtGui.QMessageBox.question(self,
translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Selected Song Usage Events?'),
@ -56,12 +55,12 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
'Are you sure you want to delete selected Song Usage data?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
if ret == QtGui.QMessageBox.Yes:
deleteDate = self.deleteCalendar.selectedDate().toPyDate()
self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate)
delete_date = self.delete_calendar.selectedDate().toPyDate()
self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= delete_date)
self.main_window.information_message(
translate('SongUsagePlugin.SongUsageDeleteForm', 'Deletion Successful'),
translate(
'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully. ')
'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully.')
)
self.accept()
else:
@ -75,4 +74,4 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
self._main_window = Registry().get(u'main_window')
return self._main_window
main_window = property(_get_main_window)
main_window = property(_get_main_window)

View File

@ -32,56 +32,56 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
from openlp.core.lib.ui import create_button_box
class Ui_SongUsageDetailDialog(object):
def setupUi(self, songUsageDetailDialog):
songUsageDetailDialog.setObjectName(u'songUsageDetailDialog')
songUsageDetailDialog.resize(609, 413)
self.verticalLayout = QtGui.QVBoxLayout(songUsageDetailDialog)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setContentsMargins(8, 8, 8, 8)
self.verticalLayout.setObjectName(u'verticalLayout')
self.dateRangeGroupBox = QtGui.QGroupBox(songUsageDetailDialog)
self.dateRangeGroupBox.setObjectName(u'dateRangeGroupBox')
self.dateHorizontalLayout = QtGui.QHBoxLayout(self.dateRangeGroupBox)
self.dateHorizontalLayout.setSpacing(8)
self.dateHorizontalLayout.setContentsMargins(8, 8, 8, 8)
self.dateHorizontalLayout.setObjectName(u'dateHorizontalLayout')
self.fromDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.fromDate.setObjectName(u'fromDate')
self.dateHorizontalLayout.addWidget(self.fromDate)
self.toLabel = QtGui.QLabel(self.dateRangeGroupBox)
self.toLabel.setScaledContents(False)
self.toLabel.setAlignment(QtCore.Qt.AlignCenter)
self.toLabel.setObjectName(u'toLabel')
self.dateHorizontalLayout.addWidget(self.toLabel)
self.toDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.toDate.setObjectName(u'toDate')
self.dateHorizontalLayout.addWidget(self.toDate)
self.verticalLayout.addWidget(self.dateRangeGroupBox)
self.fileGroupBox = QtGui.QGroupBox(self.dateRangeGroupBox)
self.fileGroupBox.setObjectName(u'fileGroupBox')
self.fileHorizontalLayout = QtGui.QHBoxLayout(self.fileGroupBox)
self.fileHorizontalLayout.setSpacing(8)
self.fileHorizontalLayout.setContentsMargins(8, 8, 8, 8)
self.fileHorizontalLayout.setObjectName(u'fileHorizontalLayout')
self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox)
self.fileLineEdit.setObjectName(u'fileLineEdit')
self.fileLineEdit.setReadOnly(True)
self.fileHorizontalLayout.addWidget(self.fileLineEdit)
self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox)
self.saveFilePushButton.setMaximumWidth(self.saveFilePushButton.size().height())
self.saveFilePushButton.setIcon(build_icon(u':/general/general_open.png'))
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.fileHorizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout.addWidget(self.fileGroupBox)
self.vertical_layout = QtGui.QVBoxLayout(songUsageDetailDialog)
self.vertical_layout.setSpacing(8)
self.vertical_layout.setContentsMargins(8, 8, 8, 8)
self.vertical_layout.setObjectName(u'vertical_layout')
self.date_range_group_box = QtGui.QGroupBox(songUsageDetailDialog)
self.date_range_group_box.setObjectName(u'date_range_group_box')
self.date_horizontal_layout = QtGui.QHBoxLayout(self.date_range_group_box)
self.date_horizontal_layout.setSpacing(8)
self.date_horizontal_layout.setContentsMargins(8, 8, 8, 8)
self.date_horizontal_layout.setObjectName(u'date_horizontal_layout')
self.from_date = QtGui.QCalendarWidget(self.date_range_group_box)
self.from_date.setObjectName(u'from_date')
self.date_horizontal_layout.addWidget(self.from_date)
self.to_label = QtGui.QLabel(self.date_range_group_box)
self.to_label.setScaledContents(False)
self.to_label.setAlignment(QtCore.Qt.AlignCenter)
self.to_label.setObjectName(u'to_label')
self.date_horizontal_layout.addWidget(self.to_label)
self.to_date = QtGui.QCalendarWidget(self.date_range_group_box)
self.to_date.setObjectName(u'to_date')
self.date_horizontal_layout.addWidget(self.to_date)
self.vertical_layout.addWidget(self.date_range_group_box)
self.file_group_box = QtGui.QGroupBox(self.date_range_group_box)
self.file_group_box.setObjectName(u'file_group_box')
self.file_horizontal_layout = QtGui.QHBoxLayout(self.file_group_box)
self.file_horizontal_layout.setSpacing(8)
self.file_horizontal_layout.setContentsMargins(8, 8, 8, 8)
self.file_horizontal_layout.setObjectName(u'file_horizontal_layout')
self.file_line_edit = QtGui.QLineEdit(self.file_group_box)
self.file_line_edit.setObjectName(u'file_line_edit')
self.file_line_edit.setReadOnly(True)
self.file_horizontal_layout.addWidget(self.file_line_edit)
self.save_file_push_button = QtGui.QPushButton(self.file_group_box)
self.save_file_push_button.setMaximumWidth(self.save_file_push_button.size().height())
self.save_file_push_button.setIcon(build_icon(u':/general/general_open.png'))
self.save_file_push_button.setObjectName(u'save_file_push_button')
self.file_horizontal_layout.addWidget(self.save_file_push_button)
self.vertical_layout.addWidget(self.file_group_box)
self.button_box = create_button_box(songUsageDetailDialog, u'button_box', [u'cancel', u'ok'])
self.verticalLayout.addWidget(self.button_box)
self.vertical_layout.addWidget(self.button_box)
self.retranslateUi(songUsageDetailDialog)
QtCore.QObject.connect(self.saveFilePushButton, QtCore.SIGNAL(u'clicked()'),
songUsageDetailDialog.defineOutputLocation)
self.save_file_push_button.clicked.connect(songUsageDetailDialog.define_output_location)
def retranslateUi(self, songUsageDetailDialog):
songUsageDetailDialog.setWindowTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Song Usage Extraction'))
self.dateRangeGroupBox.setTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Select Date Range'))
self.toLabel.setText(translate('SongUsagePlugin.SongUsageDetailForm', 'to'))
self.fileGroupBox.setTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Report Location'))
self.date_range_group_box.setTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Select Date Range'))
self.to_label.setText(translate('SongUsagePlugin.SongUsageDetailForm', 'to'))
self.file_group_box.setTitle(translate('SongUsagePlugin.SongUsageDetailForm', 'Report Location'))

View File

@ -39,6 +39,7 @@ from songusagedetaildialog import Ui_SongUsageDetailDialog
log = logging.getLogger(__name__)
class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
"""
Class documentation goes here.
@ -57,13 +58,13 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
"""
We need to set up the screen
"""
toDate = Settings().value(self.plugin.settingsSection + u'/to date')
fromDate = Settings().value(self.plugin.settingsSection + u'/from date')
self.fromDate.setSelectedDate(fromDate)
self.toDate.setSelectedDate(toDate)
self.fileLineEdit.setText(Settings().value(self.plugin.settingsSection + u'/last directory export'))
to_date = Settings().value(self.plugin.settingsSection + u'/to date')
from_date = Settings().value(self.plugin.settingsSection + u'/from date')
self.from_date.setSelectedDate(from_date)
self.to_date.setSelectedDate(to_date)
self.file_line_edit.setText(Settings().value(self.plugin.settingsSection + u'/last directory export'))
def defineOutputLocation(self):
def define_output_location(self):
"""
Triggered when the Directory selection button is clicked
"""
@ -72,14 +73,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
Settings().value(self.plugin.settingsSection + u'/last directory export'))
if path:
Settings().setValue(self.plugin.settingsSection + u'/last directory export', path)
self.fileLineEdit.setText(path)
self.file_line_edit.setText(path)
def accept(self):
"""
Ok was triggered so lets save the data and run the report
"""
log.debug(u'accept')
path = self.fileLineEdit.text()
path = self.file_line_edit.text()
if not path:
self.main_window.error_message(
translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'),
@ -88,36 +89,36 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
)
return
check_directory_exists(path)
filename = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % (
self.fromDate.selectedDate().toString(u'ddMMyyyy'),
self.toDate.selectedDate().toString(u'ddMMyyyy'))
Settings().setValue(u'songusage/from date', self.fromDate.selectedDate())
Settings().setValue(u'songusage/to date', self.toDate.selectedDate())
file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % (
self.from_date.selectedDate().toString(u'ddMMyyyy'),
self.to_date.selectedDate().toString(u'ddMMyyyy'))
Settings().setValue(u'songusage/from date', self.from_date.selectedDate())
Settings().setValue(u'songusage/to date', self.to_date.selectedDate())
usage = self.plugin.manager.get_all_objects(
SongUsageItem, and_(
SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(),
SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()),
SongUsageItem.usagedate >= self.from_date.selectedDate().toPyDate(),
SongUsageItem.usagedate < self.to_date.selectedDate().toPyDate()),
[SongUsageItem.usagedate, SongUsageItem.usagetime])
outname = os.path.join(path, filename)
fileHandle = None
report_file_name = os.path.join(path, file_name)
file_handle = None
try:
fileHandle = open(outname, u'w')
file_handle = open(report_file_name, u'w')
for instance in usage:
record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",' \
u'\"%s\",\"%s\"\n' % (instance.usagedate,
instance.usagetime, instance.title, instance.copyright,
instance.ccl_number, instance.authors, instance.plugin_name, instance.source)
fileHandle.write(record.encode(u'utf-8'))
file_handle.write(record.encode(u'utf-8'))
self.main_window.information_message(
translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),
translate('SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n'
'has been successfully created. ') % outname
'has been successfully created. ') % report_file_name
)
except IOError:
log.exception(u'Failed to write out song usage records')
finally:
if fileHandle:
fileHandle.close()
if file_handle:
file_handle.close()
self.close()
def _get_main_window(self):
@ -128,4 +129,4 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
self._main_window = Registry().get(u'main_window')
return self._main_window
main_window = property(_get_main_window)
main_window = property(_get_main_window)

View File

@ -42,7 +42,6 @@ from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem
log = logging.getLogger(__name__)
YEAR = QtCore.QDate().currentDate().year()
if QtCore.QDate().currentDate().month() < 9:
YEAR -= 1
@ -54,7 +53,7 @@ __default_settings__ = {
u'songusage/to date': QtCore.QDate(YEAR, 8, 31),
u'songusage/from date': QtCore.QDate(YEAR - 1, 9, 1),
u'songusage/last directory export': u''
}
}
class SongUsagePlugin(Plugin):
@ -83,59 +82,59 @@ class SongUsagePlugin(Plugin):
"""
log.info(u'add tools menu')
self.toolsMenu = tools_menu
self.songUsageMenu = QtGui.QMenu(tools_menu)
self.songUsageMenu.setObjectName(u'songUsageMenu')
self.songUsageMenu.setTitle(translate('SongUsagePlugin', '&Song Usage Tracking'))
self.song_usage_menu = QtGui.QMenu(tools_menu)
self.song_usage_menu.setObjectName(u'song_usage_menu')
self.song_usage_menu.setTitle(translate('SongUsagePlugin', '&Song Usage Tracking'))
# SongUsage Delete
self.songUsageDelete = create_action(tools_menu, u'songUsageDelete',
self.song_usage_delete = create_action(tools_menu, u'songUsageDelete',
text=translate('SongUsagePlugin', '&Delete Tracking Data'),
statustip=translate('SongUsagePlugin', 'Delete song usage data up to a specified date.'),
triggers=self.onSongUsageDelete)
triggers=self.on_song_usage_delete)
# SongUsage Report
self.songUsageReport = create_action(tools_menu, u'songUsageReport',
self.song_usage_report = create_action(tools_menu, u'songUsageReport',
text=translate('SongUsagePlugin', '&Extract Tracking Data'),
statustip=translate('SongUsagePlugin', 'Generate a report on song usage.'),
triggers=self.onSongUsageReport)
triggers=self.on_song_usage_report)
# SongUsage activation
self.songUsageStatus = create_action(tools_menu, u'songUsageStatus',
self.song_usage_status = create_action(tools_menu, u'songUsageStatus',
text=translate('SongUsagePlugin', 'Toggle Tracking'),
statustip=translate('SongUsagePlugin', 'Toggle the tracking of song usage.'), checked=False,
shortcuts=[QtCore.Qt.Key_F4], triggers=self.toggleSongUsageState)
shortcuts=[QtCore.Qt.Key_F4], triggers=self.toggle_song_usage_state)
# Add Menus together
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
self.songUsageMenu.addAction(self.songUsageStatus)
self.songUsageMenu.addSeparator()
self.songUsageMenu.addAction(self.songUsageReport)
self.songUsageMenu.addAction(self.songUsageDelete)
self.songUsageActiveButton = QtGui.QToolButton(self.main_window.statusBar)
self.songUsageActiveButton.setCheckable(True)
self.songUsageActiveButton.setAutoRaise(True)
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')
self.main_window.statusBar.insertPermanentWidget(1, self.songUsageActiveButton)
self.songUsageActiveButton.hide()
self.toolsMenu.addAction(self.song_usage_menu.menuAction())
self.song_usage_menu.addAction(self.song_usage_status)
self.song_usage_menu.addSeparator()
self.song_usage_menu.addAction(self.song_usage_report)
self.song_usage_menu.addAction(self.song_usage_delete)
self.song_usage_active_button = QtGui.QToolButton(self.main_window.statusBar)
self.song_usage_active_button.setCheckable(True)
self.song_usage_active_button.setAutoRaise(True)
self.song_usage_active_button.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.'))
self.song_usage_active_button.setObjectName(u'song_usage_active_button')
self.main_window.statusBar.insertPermanentWidget(1, self.song_usage_active_button)
self.song_usage_active_button.hide()
# Signals and slots
QtCore.QObject.connect(self.songUsageStatus, QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.songUsageStatus.setChecked)
QtCore.QObject.connect(self.songUsageActiveButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState)
self.songUsageMenu.menuAction().setVisible(False)
QtCore.QObject.connect(self.song_usage_status, QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.song_usage_status.setChecked)
self.song_usage_active_button.toggled.connect(self.toggle_song_usage_state)
self.song_usage_menu.menuAction().setVisible(False)
def initialise(self):
log.info(u'SongUsage Initialising')
Plugin.initialise(self)
Registry().register_function(u'slidecontroller_live_started', self.display_song_usage)
Registry().register_function(u'print_service_started', self.print_song_usage)
self.songUsageActive = Settings().value(self.settingsSection + u'/active')
self.song_usage_active = Settings().value(self.settingsSection + u'/active')
# Set the button and checkbox state
self.setButtonState()
self.set_button_state()
action_list = ActionList.get_instance()
action_list.add_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage'))
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.main_window)
self.songUsageDetailForm = SongUsageDetailForm(self, self.main_window)
self.songUsageMenu.menuAction().setVisible(True)
self.songUsageActiveButton.show()
action_list.add_action(self.song_usage_status, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.song_usage_delete, translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.song_usage_report, translate('SongUsagePlugin', 'Song Usage'))
self.song_usage_delete_form = SongUsageDeleteForm(self.manager, self.main_window)
self.song_usage_detail_form = SongUsageDetailForm(self, self.main_window)
self.song_usage_menu.menuAction().setVisible(True)
self.song_usage_active_button.show()
def finalise(self):
"""
@ -144,44 +143,43 @@ class SongUsagePlugin(Plugin):
log.info(u'Plugin Finalise')
self.manager.finalise()
Plugin.finalise(self)
self.songUsageMenu.menuAction().setVisible(False)
self.song_usage_menu.menuAction().setVisible(False)
action_list = ActionList.get_instance()
action_list.remove_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage'))
self.songUsageActiveButton.hide()
action_list.remove_action(self.song_usage_status, translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.song_usage_delete, translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.song_usage_report, translate('SongUsagePlugin', 'Song Usage'))
self.song_usage_active_button.hide()
# stop any events being processed
self.songUsageActive = False
self.song_usage_active = False
def toggleSongUsageState(self):
def toggle_song_usage_state(self):
"""
Manage the state of the audit collection and amend
the UI when necessary,
"""
self.songUsageActive = not self.songUsageActive
Settings().setValue(self.settingsSection + u'/active', self.songUsageActive)
self.setButtonState()
self.song_usage_active = not self.song_usage_active
Settings().setValue(self.settingsSection + u'/active', self.song_usage_active)
self.set_button_state()
def setButtonState(self):
def set_button_state(self):
"""
Keep buttons inline. Turn of signals to stop dead loop but we need the
button and check box set correctly.
"""
self.songUsageActiveButton.blockSignals(True)
self.songUsageStatus.blockSignals(True)
self.song_usage_active_button.blockSignals(True)
self.song_usage_status.blockSignals(True)
if self.songUsageActive:
self.songUsageActiveButton.setIcon(self.activeIcon)
self.songUsageStatus.setChecked(True)
self.songUsageActiveButton.setChecked(True)
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is active.'))
self.song_usage_active_button.setIcon(self.activeIcon)
self.song_usage_status.setChecked(True)
self.song_usage_active_button.setChecked(True)
self.song_usage_active_button.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is active.'))
else:
self.songUsageActiveButton.setIcon(self.inactiveIcon)
self.songUsageStatus.setChecked(False)
self.songUsageActiveButton.setChecked(False)
self.songUsageActiveButton.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is inactive.'))
self.songUsageActiveButton.blockSignals(False)
self.songUsageStatus.blockSignals(False)
self.song_usage_active_button.setIcon(self.inactiveIcon)
self.song_usage_status.setChecked(False)
self.song_usage_active_button.setChecked(False)
self.song_usage_active_button.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is inactive.'))
self.song_usage_active_button.blockSignals(False)
self.song_usage_status.blockSignals(False)
def display_song_usage(self, item):
"""
@ -209,12 +207,12 @@ class SongUsagePlugin(Plugin):
song_usage_item.source = source
self.manager.save_object(song_usage_item)
def onSongUsageDelete(self):
self.songUsageDeleteForm.exec_()
def on_song_usage_delete(self):
self.song_usage_delete_form.exec_()
def onSongUsageReport(self):
self.songUsageDetailForm.initialise()
self.songUsageDetailForm.exec_()
def on_song_usage_report(self):
self.song_usage_detail_form.initialise()
self.song_usage_detail_form.exec_()
def about(self):
about_text = translate('SongUsagePlugin', '<strong>SongUsage Plugin'