Fix up song usage extract processing

This commit is contained in:
Tim Bentley 2010-02-11 18:39:28 +00:00
parent 73d6a24792
commit 944f45c8c8
15 changed files with 280 additions and 160 deletions

View File

@ -28,11 +28,9 @@ from maindisplay import MainDisplay
from amendthemeform import AmendThemeForm
from slidecontroller import SlideController
from splashscreen import SplashScreen
from alertstab import AlertsTab
from generaltab import GeneralTab
from themestab import ThemesTab
from aboutform import AboutForm
from alertform import AlertForm
from pluginform import PluginForm
from settingsform import SettingsForm
from mediadockmanager import MediaDockManager

View File

@ -120,8 +120,6 @@ class MainDisplay(DisplayWidget):
self.hasTransition = False
self.alertList = []
self.mediaBackground = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -218,6 +216,12 @@ class MainDisplay(DisplayWidget):
self.screen[u'size'].height() )
self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame))
def addAlertImage(self, frame, blank=False):
if blank:
self.display_alert.setPixmap(self.transparent)
else:
self.display_alert.setPixmap(frame)
def frameView(self, frame, transition=False):
"""
Called from a slide controller to display a frame
@ -257,64 +261,6 @@ class MainDisplay(DisplayWidget):
if self.display_frame:
self.frameView(self.display_frame)
def displayAlert(self, text=u''):
"""
Called from the Alert Tab to display an alert
``text``
display text
"""
log.debug(u'display alert called %s' % text)
self.parent.StatusBar.showMessage(self.trUtf8(u''))
self.alertList.append(text)
if self.timer_id != 0 or self.mediaLoaded:
self.parent.StatusBar.showMessage(\
self.trUtf8(u'Alert message created and delayed'))
return
self.generateAlert()
def generateAlert(self):
log.debug(u'Generate Alert called')
if len(self.alertList) == 0:
return
text = self.alertList.pop(0)
alertTab = self.parent.settingsForm.AlertsTab
alertframe = \
QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight)
alertframe.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(alertframe)
painter.fillRect(alertframe.rect(), QtCore.Qt.transparent)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.fillRect(
QtCore.QRect(
0, 0, alertframe.rect().width(),
alertframe.rect().height()),
QtGui.QColor(alertTab.bg_color))
font = QtGui.QFont()
font.setFamily(alertTab.font_face)
font.setBold(True)
font.setPointSize(40)
painter.setFont(font)
painter.setPen(QtGui.QColor(alertTab.font_color))
x, y = (0, 0)
metrics = QtGui.QFontMetrics(font)
painter.drawText(
x, y + metrics.height() - metrics.descent() - 1, text)
painter.end()
self.display_alert.setPixmap(alertframe)
self.display_alert.setVisible(True)
# check to see if we have a timer running
if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
def timerEvent(self, event):
if event.timerId() == self.timer_id:
self.display_alert.setPixmap(self.transparent)
self.killTimer(self.timer_id)
self.timer_id = 0
self.generateAlert()
def onMediaQueue(self, message):
log.debug(u'Queue new media message %s' % message)
self.display_image.close()

View File

@ -29,7 +29,7 @@ import time
from PyQt4 import QtCore, QtGui
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
from openlp.core.ui import AboutForm, SettingsForm, \
ServiceManager, ThemeManager, MainDisplay, SlideController, \
PluginForm, MediaDockManager
from openlp.core.lib import RenderManager, PluginConfig, build_icon, \
@ -227,13 +227,8 @@ class Ui_MainWindow(object):
self.settingsmanager.showServiceManager)
self.ViewServiceManagerItem.setIcon(ServiceManagerIcon)
self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem')
self.ToolsAlertItem = QtGui.QAction(MainWindow)
AlertIcon = build_icon(u':/tools/tools_alert.png')
self.ToolsAlertItem.setIcon(AlertIcon)
self.ToolsAlertItem.setObjectName(u'ToolsAlertItem')
self.PluginItem = QtGui.QAction(MainWindow)
#PluginIcon = build_icon(u':/tools/tools_alert.png')
self.PluginItem.setIcon(AlertIcon)
#self.PluginItem.setIcon(AlertIcon)
self.PluginItem.setObjectName(u'PluginItem')
self.HelpDocumentationItem = QtGui.QAction(MainWindow)
ContentsIcon = build_icon(u':/system/system_help_contents.png')
@ -292,7 +287,6 @@ class Ui_MainWindow(object):
self.OptionsMenu.addAction(self.OptionsViewMenu.menuAction())
self.OptionsMenu.addSeparator()
self.OptionsMenu.addAction(self.OptionsSettingsItem)
self.ToolsMenu.addAction(self.ToolsAlertItem)
self.ToolsMenu.addAction(self.PluginItem)
self.ToolsMenu.addSeparator()
self.ToolsMenu.addAction(self.ToolsAddToolItem)
@ -394,9 +388,6 @@ class Ui_MainWindow(object):
self.action_Preview_Panel.setStatusTip(
self.trUtf8('Toggle the visibility of the Preview Panel'))
self.action_Preview_Panel.setShortcut(self.trUtf8('F11'))
self.ToolsAlertItem.setText(self.trUtf8('&Alert'))
self.ToolsAlertItem.setStatusTip(self.trUtf8('Show an alert message'))
self.ToolsAlertItem.setShortcut(self.trUtf8('F7'))
self.PluginItem.setText(self.trUtf8('&Plugin List'))
self.PluginItem.setStatusTip(self.trUtf8('List the Plugins'))
self.PluginItem.setShortcut(self.trUtf8('Alt+F7'))
@ -440,7 +431,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.settingsmanager = SettingsManager(screens)
self.generalConfig = PluginConfig(u'General')
self.mainDisplay = MainDisplay(self, screens)
self.alertForm = AlertForm(self)
self.aboutForm = AboutForm(self, applicationVersion)
self.settingsForm = SettingsForm(self.screens, self, self)
# Set up the path with plugins
@ -485,8 +475,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.action_Preview_Panel.setChecked)
QtCore.QObject.connect(self.HelpAboutItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked)
QtCore.QObject.connect(self.ToolsAlertItem,
QtCore.SIGNAL(u'triggered()'), self.onToolsAlertItemClicked)
QtCore.QObject.connect(self.PluginItem,
QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
QtCore.QObject.connect(self.OptionsSettingsItem,
@ -605,12 +593,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.aboutForm.applicationVersion = self.applicationVersion
self.aboutForm.exec_()
def onToolsAlertItemClicked(self):
"""
Show the Alert form
"""
self.alertForm.exec_()
def onPluginItemClicked(self):
"""
Show the Plugin form

View File

@ -27,7 +27,7 @@ import logging
from PyQt4 import QtGui
from openlp.core.ui import GeneralTab, ThemesTab, AlertsTab
from openlp.core.ui import GeneralTab, ThemesTab
from openlp.core.lib import Receiver
from settingsdialog import Ui_SettingsDialog
@ -44,9 +44,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
# Themes tab
self.ThemesTab = ThemesTab(mainWindow)
self.addTab(u'Themes', self.ThemesTab)
# Alert tab
self.AlertsTab = AlertsTab()
self.addTab(u'Alerts', self.AlertsTab)
def addTab(self, name, tab):
log.info(u'Adding %s tab' % tab.tabTitle)
@ -73,4 +70,4 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
def postSetUp(self):
for tab_index in range(0, self.SettingsTabWidget.count()):
self.SettingsTabWidget.widget(tab_index).postSetUp()
self.SettingsTabWidget.widget(tab_index).postSetUp()

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################

View File

@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from datetime import datetime
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus
#from openlp.plugins.alerts.lib import alertsManager
from openlp.plugins.alerts.forms import AlertsTab, AlertForm
#from openlp.plugins.alerts.lib.models import alertsItem
class alertsPlugin(Plugin):
global log
log = logging.getLogger(u'alertsPlugin')
log.info(u'alerts Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'alerts', u'1.9.1', plugin_helpers)
self.weight = -3
self.icon = build_icon(u':/media/media_image.png')
self.alertsmanager = None
self.alertForm = AlertForm(self)
self.status = PluginStatus.Active
def get_settings_tab(self):
return AlertsTab(self.name)
def add_tools_menu_item(self, tools_menu):
"""
Give the alerts plugin the opportunity to add items to the
**Tools** menu.
``tools_menu``
The actual **Tools** menu item, so that your actions can
use it as their parent.
"""
log.info(u'add tools menu')
self.toolsAlertItem = QtGui.QAction(tools_menu)
AlertIcon = build_icon(u':/tools/tools_alert.png')
self.toolsAlertItem.setIcon(AlertIcon)
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
self.toolsAlertItem.setText(self.trUtf8('&Alert'))
self.toolsAlertItem.setStatusTip(self.trUtf8('Show an alert message'))
self.toolsAlertItem.setShortcut(self.trUtf8('F7'))
self.service_manager.parent.ToolsMenu.addAction(self.toolsAlertItem)
QtCore.QObject.connect(self.toolsAlertItem,
QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger)
self.toolsAlertItem.setVisible(False)
def initialise(self):
log.info(u'alerts Initialising')
Plugin.initialise(self)
self.toolsAlertItem.setVisible(True)
def finalise(self):
log.info(u'Plugin Finalise')
self.toolsAlertItem.setVisible(False)
#stop any events being processed
def togglealertsState(self):
self.alertsActive = not self.alertsActive
self.config.set_config(u'active', self.alertsActive)
def onAlertsTrigger(self):
self.alertForm.exec_()
def onalertsReport(self):
self.alertsdetailform.initialise()
self.alertsdetailform.exec_()
def about(self):
about_text = self.trUtf8('<b>Alerts Plugin</b><br>This plugin '
'controls the displaying of alerts on the presentations screen')
return about_text

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from alertstab import AlertsTab
from alertform import AlertForm

View File

@ -31,11 +31,11 @@ class AlertForm(QtGui.QDialog):
global log
log = logging.getLogger(u'AlertForm')
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
def __init__(self, parent):
QtGui.QDialog.__init__(self, None)
self.parent = parent
self.setupUi(self)
log.debug(u'Defined')
log.debug(u'AlertForm Defined')
def setupUi(self, AlertForm):
AlertForm.setObjectName(u'AlertForm')
@ -85,9 +85,7 @@ class AlertForm(QtGui.QDialog):
self.CancelButton.setObjectName(u'CancelButton')
self.horizontalLayout.addWidget(self.CancelButton)
self.AlertFormLayout.addWidget(self.ButtonBoxWidget)
self.retranslateUi(AlertForm)
QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL(u'clicked()'), AlertForm.close)
QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked)
QtCore.QMetaObject.connectSlotsByName(AlertForm)

View File

@ -31,10 +31,8 @@ class AlertsTab(SettingsTab):
"""
AlertsTab is the alerts settings tab in the settings dialog.
"""
def __init__(self):
SettingsTab.__init__(self, u'Alerts')
self.font_color = '#ffffff'
self.bg_color = '#660000'
def __init__(self, title, section=None):
SettingsTab.__init__(self, title, section)
def setupUi(self):
self.setObjectName(u'AlertsTab')
@ -159,7 +157,7 @@ class AlertsTab(SettingsTab):
self.PreviewLayout.setMargin(8)
self.PreviewLayout.setObjectName(u'PreviewLayout')
self.FontPreview = QtGui.QLineEdit(self.PreviewGroupBox)
self.FontPreview.setMinimumSize(QtCore.QSize(280, 100))
self.FontPreview.setFixedSize(QtCore.QSize(350, 100))
self.FontPreview.setReadOnly(True)
self.FontPreview.setFocusPolicy(QtCore.Qt.NoFocus)
self.FontPreview.setAlignment(

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from alertmanager import AlertManager

View File

@ -0,0 +1,75 @@
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import str_to_bool, Receiver
from openlp.core.lib import SettingsTab
class AlertManager(self):
"""
BiblesTab is the Bibles settings tab in the settings dialog.
"""
global log
log = logging.getLogger(u'AlertManager')
log.info(u'Alert Manager loaded')
def __init__(self):
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
def displayAlert(self, text=u''):
"""
Called from the Alert Tab to display an alert
``text``
display text
"""
log.debug(u'display alert called %s' % text)
self.parent.StatusBar.showMessage(self.trUtf8(u''))
self.alertList.append(text)
if self.timer_id != 0 or self.mediaLoaded:
self.parent.StatusBar.showMessage(\
self.trUtf8(u'Alert message created and delayed'))
return
self.generateAlert()
def generateAlert(self):
log.debug(u'Generate Alert called')
if len(self.alertList) == 0:
return
text = self.alertList.pop(0)
alertTab = self.parent.settingsForm.AlertsTab
alertframe = \
QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight)
alertframe.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(alertframe)
painter.fillRect(alertframe.rect(), QtCore.Qt.transparent)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.fillRect(
QtCore.QRect(
0, 0, alertframe.rect().width(),
alertframe.rect().height()),
QtGui.QColor(alertTab.bg_color))
font = QtGui.QFont()
font.setFamily(alertTab.font_face)
font.setBold(True)
font.setPointSize(alertTab.font_size)
painter.setFont(font)
painter.setPen(QtGui.QColor(alertTab.font_color))
x, y = (0, 0)
metrics = QtGui.QFontMetrics(font)
painter.drawText(
x, y + metrics.height() - metrics.descent() - 1, text)
painter.end()
self.display_alert.setPixmap(alertframe)
# check to see if we have a timer running
if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
def timerEvent(self, event):
if event.timerId() == self.timer_id:
self.display_alert.setPixmap(self.transparent)
self.killTimer(self.timer_id)
self.timer_id = 0
self.generateAlert()

View File

@ -50,7 +50,6 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
QtGui.QMessageBox.Cancel),
QtGui.QMessageBox.Cancel)
if ret == QtGui.QMessageBox.Ok:
qDeleteDate = self.DeleteCalendar.selectedDate()
deleteDate = date(qDeleteDate.year(), qDeleteDate.month(), qDeleteDate.day())
deleteDate = self.DeleteCalendar.selectedDate().toPyDate()
self.songusagemanager.delete_to_date(deleteDate)
self.close()

View File

@ -9,7 +9,7 @@
from PyQt4 import QtCore, QtGui
class Ui_AuditDetailDialog(object):
class Ui_SongUsageDetailDialog(object):
def setupUi(self, AuditDetailDialog):
AuditDetailDialog.setObjectName("AuditDetailDialog")
AuditDetailDialog.resize(609, 413)

View File

@ -45,33 +45,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
self.setupUi(self)
def initialise(self):
self.FirstCheckBox.setCheckState(
int(self.parent.config.get_config(u'first service', QtCore.Qt.Checked)))
self.SecondCheckBox.setCheckState(
int(self.parent.config.get_config(u'second service', QtCore.Qt.Checked)))
self.ThirdCheckBox.setCheckState(
int(self.parent.config.get_config(u'third service', QtCore.Qt.Checked)))
year = QtCore.QDate().currentDate().year()
if QtCore.QDate().currentDate().month() < 9:
year -= 1
toDate = QtCore.QDate(year, 8, 31)
fromDate = QtCore.QDate(year - 1, 9, 1)
self.FromDateEdit.setDate(fromDate)
self.ToDateEdit.setDate(toDate)
self.FromDate.setSelectedDate(fromDate)
self.ToDate.setSelectedDate(toDate)
self.FileLineEdit.setText(self.parent.config.get_last_dir(1))
self.resetWindow()
def changeFirstService(self, value):
self.parent.config.set_config(u'first service', value)
self.resetWindow()
def changeSecondService(self, value):
self.parent.config.set_config(u'second service', value)
self.resetWindow()
def changeThirdService(self, value):
self.parent.config.set_config(u'third service', value)
self.resetWindow()
def defineOutputLocation(self):
path = QtGui.QFileDialog.getExistingDirectory(self,
@ -82,39 +63,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
self.parent.config.set_last_dir(path, 1)
self.FileLineEdit.setText(path)
def resetWindow(self):
if self.FirstCheckBox.checkState() == QtCore.Qt.Unchecked:
self.FirstFromTimeEdit.setEnabled(False)
self.FirstToTimeEdit.setEnabled(False)
else:
self.FirstFromTimeEdit.setEnabled(True)
self.FirstToTimeEdit.setEnabled(True)
if self.SecondCheckBox.checkState() == QtCore.Qt.Unchecked:
self.SecondFromTimeEdit.setEnabled(False)
self.SecondToTimeEdit.setEnabled(False)
else:
self.SecondFromTimeEdit.setEnabled(True)
self.SecondToTimeEdit.setEnabled(True)
if self.ThirdCheckBox.checkState() == QtCore.Qt.Unchecked:
self.ThirdFromTimeEdit.setEnabled(False)
self.ThirdToTimeEdit.setEnabled(False)
else:
self.ThirdFromTimeEdit.setEnabled(True)
self.ThirdToTimeEdit.setEnabled(True)
def accept(self):
if self.DetailedReport.isChecked():
self.detailedReport()
else:
self.summaryReport()
self.close()
def detailedReport(self):
log.debug(u'Detailed report generated')
filename = u'usage_detail_%s_%s.txt' % \
(self.FromDateEdit.date().toString(u'ddMMyyyy'),
self.ToDateEdit.date().toString(u'ddMMyyyy'))
usage = self.parent.songusagemanager.get_all_songusage()
(self.FromDate.selectedDate().toString(u'ddMMyyyy'),
self.ToDate.selectedDate().toString(u'ddMMyyyy'))
usage = self.parent.songusagemanager.get_all_songusage(\
self.FromDate.selectedDate(), \
self.ToDate.selectedDate())
outname = os.path.join(unicode(self.FileLineEdit.text()), filename)
file = None
try:
@ -130,8 +86,3 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
if file:
file.close()
def summaryReport(self):
log.debug(u'Summary report generated')
filename = u'audit_sum_%s_%s.txt' % \
(self.FromDateEdit.date().toString(u'ddMMyyyy'),
self.ToDateEdit.date().toString(u'ddMMyyyy'))

View File

@ -60,12 +60,14 @@ class SongUsageManager():
log.debug(u'SongUsage Initialised')
def get_all_songusage(self):
def get_all_songusage(self, start_date, end_date):
"""
Returns the details of SongUsage
"""
return self.session.query(SongUsageItem).\
order_by(SongUsageItem.usagedate, SongUsageItem.usagetime ).all()
return self.session.query(SongUsageItem) \
.filter(SongUsageItem.usagedate >= start_date.toPyDate()) \
.filter(SongUsageItem.usagedate < end_date.toPyDate()) \
.order_by(SongUsageItem.usagedate, SongUsageItem.usagetime ).all()
def insert_songusage(self, songusageitem):
"""
@ -133,4 +135,4 @@ class SongUsageManager():
except:
self.session.rollback()
log.exception(u'Failed to delete all Song Usage items to %s' % date)
return False
return False