← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bugfixes into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bugfixes into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Fix up Audit state handing
Allow file to be changed
Fix up file writing 
-- 
https://code.launchpad.net/~trb143/openlp/bugfixes/+merge/12122
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/eventreceiver.py'
--- openlp/core/lib/eventreceiver.py	2009-09-16 18:37:25 +0000
+++ openlp/core/lib/eventreceiver.py	2009-09-19 19:31:18 +0000
@@ -80,6 +80,9 @@
 
     ``audit_live``
         Sends live song audit requests to the audit component
+
+    ``audit_changed``
+        Audit information may have changed
     """
     global log
     log = logging.getLogger(u'EventReceiver')

=== modified file 'openlp/plugins/audit/auditplugin.py'
--- openlp/plugins/audit/auditplugin.py	2009-09-18 10:47:57 +0000
+++ openlp/plugins/audit/auditplugin.py	2009-09-19 19:45:15 +0000
@@ -27,7 +27,7 @@
 from PyQt4 import QtCore, QtGui
 from datetime import date
 
-from openlp.core.lib import Plugin,  Receiver,  translate
+from openlp.core.lib import Plugin,  Receiver,  translate,  str_to_bool
 from openlp.plugins.audit.lib import AuditTab
 
 class AuditPlugin(Plugin):
@@ -95,17 +95,49 @@
         log.info(u'Plugin Initialising')
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit)
-        self.auditFile = open(u'openlp.aud', 'a')
-        self.auditActive = False
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'audit_changed'), self.onUpdateAudit)
+        self.auditFileName = self.config.get_config(u'audit file', u'')
+        self.auditActive = str_to_bool(self.config.get_config(u'audit active', False))
+        if self.auditFileName == u'':
+            self.auditActive = False
+            self.ToolsAuditItem.setEnabled(False)
+            self.auditFile = None
+        else:
+            self.auditFile = open(self.auditFileName, u'a')
+        self.ToolsAuditItem.setChecked(self.auditActive)
 
     def toggleAuditState(self):
         self.auditActive = not self.auditActive
+        self.config.set_config(u'audit active', self.auditActive)
 
     def onReceiveAudit(self, auditData):
+        """
+        Audit a live song from SlideController
+        """
         if self.auditActive:
-            self.auditFile.write(u'%s,%s\n' % (date.today(), auditData))
+            for author in auditData[1]:
+                self.auditFile.write(u'\"%s\",\"%s\",\"%s\",\"%s\"\n' % (date.today(), auditData[0], author,  auditData[2]))
             self.auditFile.flush()
 
+    def onUpdateAudit(self):
+        """
+        Someone may have changed to audit details
+        Sort out the file and the auditing state
+        """
+        self.auditFileNameNew = self.config.get_config(u'audit file', u'')
+        self.auditActive = str_to_bool(self.config.get_config(u'audit active', False))
+        if self.auditFileNameNew == u'':
+            self.auditActive = False
+            self.ToolsAuditItem.setChecked(self.auditActive)
+            self.ToolsAuditItem.setEnabled(False)
+            return
+        self.ToolsAuditItem.setEnabled(True)
+        if self.auditFileNameNew != self.auditFileName:
+            if self.auditFile is not None:
+                self.auditFile.close()
+            self.auditFile = open(self.auditFileNameNew, u'a')
+
     def finalise(self):
         log.debug(u'Finalise')
         if self.auditFile is not None:

=== modified file 'openlp/plugins/audit/lib/audittab.py'
--- openlp/plugins/audit/lib/audittab.py	2009-09-16 18:37:25 +0000
+++ openlp/plugins/audit/lib/audittab.py	2009-09-19 19:31:18 +0000
@@ -35,25 +35,30 @@
 
     def setupUi(self):
         self.setObjectName(u'AuditTab')
-        self.AuditLayout = QtGui.QFormLayout(self)
-        self.AuditLayout.setObjectName(u'AuditLayout')
         self.AuditModeGroupBox = QtGui.QGroupBox(self)
         self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox')
-        self.AuditModeLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox)
-        self.AuditModeLayout.setSpacing(8)
-        self.AuditModeLayout.setMargin(8)
-        self.AuditModeLayout.setObjectName(u'AuditModeLayout')
-        self.AuditPortSpinBox = QtGui.QSpinBox(self.AuditModeGroupBox)
-        self.AuditPortSpinBox.setObjectName(u'AuditPortSpinBox')
-        self.AuditPortSpinBox.setMaximum(32767)
-        self.AuditModeLayout.addWidget(self.AuditPortSpinBox)
-        self.AuditActive = QtGui.QCheckBox(self.AuditModeGroupBox)
-        self.AuditActive.setObjectName(u'AuditPortSpinBox')
-        self.AuditModeLayout.addWidget(self.AuditActive)
-        self.WarningLabel = QtGui.QLabel(self.AuditModeGroupBox)
-        self.WarningLabel.setObjectName(u'WarningLabel')
-        self.AuditModeLayout.addWidget(self.WarningLabel)
-        self.AuditLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AuditModeGroupBox)
+        self.verticalLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox)
+        self.verticalLayout.setObjectName("verticalLayout")
+        self.horizontalLayout = QtGui.QHBoxLayout()
+        self.horizontalLayout.setObjectName("horizontalLayout")
+        self.AuditFileName = QtGui.QLineEdit(self)
+        self.AuditFileName.setObjectName("AuditFileName")
+        self.horizontalLayout.addWidget(self.AuditFileName)
+        icon1 = QtGui.QIcon()
+        icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+        self.AuditFileButton = QtGui.QPushButton(self)
+        self.AuditFileButton.setObjectName("AuditFileButton")
+        self.AuditFileButton.setIcon(icon1)
+        self.horizontalLayout.addWidget(self.AuditFileButton)
+        self.verticalLayout.addLayout(self.horizontalLayout)
+        self.AuditActive = QtGui.QCheckBox(self)
+        self.AuditActive.setObjectName("AuditActive")
+        self.verticalLayout.addWidget(self.AuditActive)
+        self.WarningLabel = QtGui.QLabel(self)
+        self.WarningLabel.setObjectName("WarningLabel")
+        self.verticalLayout.addWidget(self.WarningLabel)
+        QtCore.QObject.connect(self.AuditFileButton,
+            QtCore.SIGNAL(u'pressed()'), self.onAuditFileButtonClicked)
 
     def retranslateUi(self):
         self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File'))
@@ -61,10 +66,16 @@
         self.WarningLabel.setText(translate(u'AuditTab', u'A restart is needed for this change to become effective'))
 
     def load(self):
-        self.AuditPortSpinBox.setValue(int(self.config.get_config(u'Audit port', 4316)))
+        self.AuditFileName.setText(self.config.get_config(u'Audit file', u''))
         self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0)))
 
+    def onAuditFileButtonClicked(self):
+        filename = QtGui.QFileDialog.getOpenFileName(self, u'Audit File',self.AuditFileName.text())
+        if filename != u'':
+            filename = unicode(filename)
+            self.AuditFileName.setText(filename)
+
     def save(self):
-        self.config.set_config(u'Audit port', unicode(self.AuditPortSpinBox.value()))
+        self.config.set_config(u'Audit file', unicode(self.AuditFileName.text()))
         self.config.set_config(u'startup', unicode(self.AuditActive.checkState()))
-
+        Receiver().send_message(u'audit_changed')

=== modified file 'resources/images/openlp-2.qrc'
--- resources/images/openlp-2.qrc	2009-09-16 04:59:38 +0000
+++ resources/images/openlp-2.qrc	2009-09-19 17:56:26 +0000
@@ -49,10 +49,6 @@
     <file>import_remove.png</file>
     <file>import_load.png</file>
   </qresource>
-  <qresource prefix="audit" >
-    <file>audit_start.png</file>
-    <file>audit_stop.png</file>
-  </qresource>
   <qresource prefix="exports" >
     <file>export_selectall.png</file>
     <file>export_remove.png</file>


Follow ups