From 9569042275b41de8acdffe9bb43425ea62d5bd36 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Oct 2009 05:36:19 +0000 Subject: [PATCH 1/9] Yet more audit work --- openlp/plugins/audit/forms/auditdetailform.py | 15 ++++++++++----- openlp/plugins/audit/lib/manager.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/audit/forms/auditdetailform.py b/openlp/plugins/audit/forms/auditdetailform.py index 275de3229..7d087835b 100644 --- a/openlp/plugins/audit/forms/auditdetailform.py +++ b/openlp/plugins/audit/forms/auditdetailform.py @@ -21,6 +21,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import os from PyQt4 import QtCore, QtGui @@ -97,10 +98,6 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): self.ThirdToTimeEdit.setEnabled(True) def accept(self): - print self.DetailedReport.isChecked() - print self.SummaryReport.isChecked() - print self.FromDateEdit.date() - print self.ToDateEdit.date() if self.DetailedReport.isChecked(): self.detailedReport() else: @@ -112,7 +109,15 @@ class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): filename = u'audit_det_%s_%s.txt' % \ (self.FromDateEdit.date().toString(u'ddMMyyyy'), self.ToDateEdit.date().toString(u'ddMMyyyy')) - print filename + audits = self.parent.auditmanager.get_all_audits() + outname = os.path.join(unicode(self.FileLineEdit.text()), filename) + file = open(outname, u'w') + for audit in audits: + record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n' % \ + (audit.auditdate,audit.audittime, audit.title, + audit.copyright, audit.ccl_number , audit.authors) + file.write(record) + file.close() def summaryReport(self): print "summary" diff --git a/openlp/plugins/audit/lib/manager.py b/openlp/plugins/audit/lib/manager.py index 63c064969..bd2027e20 100644 --- a/openlp/plugins/audit/lib/manager.py +++ b/openlp/plugins/audit/lib/manager.py @@ -63,7 +63,7 @@ class AuditManager(): """ Returns the details of a audit """ - return self.session.query(AuditItem).order_by(AuditItem.title).all() + return self.session.query(AuditItem).order_by(AuditItem.auditdate, AuditItem.audittime ).all() def insert_audit(self, audititem): """ From 19e27dbc95438cd6edee516bf2568f3c5e16a262 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Oct 2009 06:09:33 +0000 Subject: [PATCH 2/9] Add Song verses to menu bar --- openlp/core/ui/slidecontroller.py | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index ecde6ff30..c57699067 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -169,8 +169,25 @@ class SlideController(QtGui.QWidget): u'Image SpinBox', self.DelaySpinBox) self.DelaySpinBox.setSuffix(self.trUtf8(u's')) self.DelaySpinBox.setToolTip(self.trUtf8(u'Delay between slides in seconds')) - self.ControllerLayout.addWidget(self.Toolbar) + # Build the Song Toolbar + if isLive: + self.Songbar = OpenLPToolbar(self) + self.Songbar.addToolbarButton( + u'Bridge', u':/media/media_time.png', + self.trUtf8(u'Bridge'), + self.onSongBarHandler) + self.Songbar.addToolbarButton( + u'Chorus', u':/media/media_time.png', + self.trUtf8(u'Chorus'), + self.onSongBarHandler) + for verse in range(1, 9): + self.Songbar.addToolbarButton( + unicode(verse), u':/media/media_time.png', + unicode(self.trUtf8(u'Verse %s'))%verse, + self.onSongBarHandler) + self.ControllerLayout.addWidget(self.Songbar) + self.Songbar.setVisible(False) # Screen preview area self.PreviewFrame = QtGui.QFrame(self.Splitter) self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225)) @@ -225,6 +242,21 @@ class SlideController(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_change'), self.onSlideChange) + def onSongBarHandler(self): + request = self.sender().text() + if request == u'B': + pass + elif request == u'C': + pass + else: + #Remember list is 1 out! + slideno = int(request) - 1 + if slideno > self.PreviewListWidget.rowCount(): + self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount()) + else: + self.PreviewListWidget.selectRow(slideno) + self.onSlideSelected() + def receiveSpinDelay(self, value): self.DelaySpinBox.setValue(int(value)) @@ -346,6 +378,10 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount()) else: self.PreviewListWidget.selectRow(slideno) + if self.isLive: + self.Songbar.setVisible(False) + if self.serviceitem.name == u'Songs': + self.Songbar.setVisible(True) self.onSlideSelected() self.PreviewListWidget.setFocus() log.info(u'Display Rendering took %4s' % (time.time() - before)) From 4833f7cd0b8c76d474219652e7bdc99c0d14a95c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Oct 2009 06:30:08 +0000 Subject: [PATCH 3/9] Add Song Tab option to remove them --- openlp/core/ui/slidecontroller.py | 16 ++++++++------- openlp/plugins/songs/lib/songstab.py | 29 ++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index c57699067..79cbec7fb 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -26,7 +26,7 @@ import logging import time from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, Receiver, ServiceType +from openlp.core.lib import OpenLPToolbar, Receiver, ServiceType, str_to_bool, PluginConfig class SlideList(QtGui.QTableWidget): """ @@ -72,6 +72,7 @@ class SlideController(QtGui.QWidget): self.settingsmanager = settingsmanager self.isLive = isLive self.parent = parent + self.songsconfig = PluginConfig(u'Songs') self.image_list = [ u'Start Loop', u'Stop Loop', @@ -244,9 +245,9 @@ class SlideController(QtGui.QWidget): def onSongBarHandler(self): request = self.sender().text() - if request == u'B': + if request == u'Bridge': pass - elif request == u'C': + elif request == u'Chorus': pass else: #Remember list is 1 out! @@ -276,6 +277,11 @@ class SlideController(QtGui.QWidget): """ if item.service_item_type == ServiceType.Text: self.Toolbar.makeWidgetsInvisible(self.image_list) + if item.name == u'Songs' and \ + str_to_bool(self.songsconfig.get_config(u'display songbar', True)): + self.Songbar.setVisible(True) + else: + self.Songbar.setVisible(False) elif item.service_item_type == ServiceType.Image: #Not sensible to allow loops with 1 frame if len(item.frames) > 1: @@ -378,10 +384,6 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount()) else: self.PreviewListWidget.selectRow(slideno) - if self.isLive: - self.Songbar.setVisible(False) - if self.serviceitem.name == u'Songs': - self.Songbar.setVisible(True) self.onSlideSelected() self.PreviewListWidget.setFocus() log.info(u'Display Rendering took %4s' % (time.time() - before)) diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index d221e987d..c5c2adbdc 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -46,26 +46,43 @@ class SongsTab(SettingsTab): self.SearchAsTypeCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) self.SearchAsTypeCheckBox.setObjectName(u'SearchAsTypeCheckBox') self.SongsModeLayout.addWidget(self.SearchAsTypeCheckBox) + self.SongBarActiveCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) + self.SongBarActiveCheckBox.setObjectName(u'SearchAsTypeCheckBox') + self.SongsModeLayout.addWidget(self.SongBarActiveCheckBox) self.SongsLayout.setWidget( 0, QtGui.QFormLayout.LabelRole, self.SongsModeGroupBox) QtCore.QObject.connect(self.SearchAsTypeCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onSearchAsTypeCheckBoxChanged) + QtCore.QObject.connect(self.SongBarActiveCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.SongBarActiveCheckBoxChanged) def retranslateUi(self): self.SongsModeGroupBox.setTitle(self.trUtf8(u'Songs Mode')) self.SearchAsTypeCheckBox.setText(self.trUtf8(u'Enable search as you type:')) + self.SongBarActiveCheckBox.setText(self.trUtf8(u'Display Verses on Live Tool bar:')) def onSearchAsTypeCheckBoxChanged(self, check_state): - self.bible_search = False + self.song_search = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: - self.bible_search = True + self.song_search = True + + def SongBarActiveCheckBoxChanged(self, check_state): + self.song_bar = False + # we have a set value convert to True/False + if check_state == QtCore.Qt.Checked: + self.song_bar = True def load(self): - self.bible_search = str_to_bool( - self.config.get_config(u'search as type', u'False')) - self.SearchAsTypeCheckBox.setChecked(self.bible_search) + self.song_search = str_to_bool( + self.config.get_config(u'search as type', False)) + self.song_bar = str_to_bool( + self.config.get_config(u'display songbar', True)) + self.SearchAsTypeCheckBox.setChecked(self.song_search) + self.SongBarActiveCheckBox.setChecked(self.song_bar) def save(self): - self.config.set_config(u'search as type', unicode(self.bible_search)) + self.config.set_config(u'search as type', unicode(self.song_search)) + self.config.set_config(u'display songbar', unicode(self.song_bar)) From 6dd0db436e3372a3ea8b27d0ccb576addffda880 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Oct 2009 08:23:43 +0000 Subject: [PATCH 4/9] Split if line contains 3 --- can allow for spaces at end of line --- openlp/plugins/songs/forms/editsongform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 1144d2df9..a2fede617 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -339,7 +339,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse_list = self.verse_form.getVerse() verse_list = verse_list.replace(u'\r\n', u'\n') self.VerseListWidget.clear() - for row in verse_list.split(u'\n---\n'): + for row in verse_list.split(u'\n---'): self.VerseListWidget.addItem(row) self.VerseListWidget.repaint() From 3ee930f6ae7d6a2c9dbfa404f1794a21b34a3328 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 26 Oct 2009 16:19:26 +0000 Subject: [PATCH 5/9] Fix Line split code. Stop SlideController being editied --- openlp/core/ui/slidecontroller.py | 1 + openlp/plugins/bibles/lib/bibleHTTPimpl.py | 26 +++++++++------------- openlp/plugins/songs/forms/editsongform.py | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 79cbec7fb..035280157 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -120,6 +120,7 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.setColumnWidth(1, self.Controller.width()) self.PreviewListWidget.isLive = self.isLive self.PreviewListWidget.setObjectName(u'PreviewListWidget') + self.PreviewListWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.ControllerLayout.addWidget(self.PreviewListWidget) # Build the full toolbar self.Toolbar = OpenLPToolbar(self) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index a79195876..061d594e6 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -35,27 +35,24 @@ class BGExtract(BibleCommon): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl - def get_bible_chapter(self, version, bookid, bookname, chapter) : + def get_bible_chapter(self, version, bookname, chapter) : """ Access and decode bibles via the BibleGateway website ``Version`` The version of the bible like 31 for New International version - ``bookid`` - Book id for the book of the bible - eg 1 for Genesis - ``bookname`` - Not used + Name of the Book ``chapter`` Chapter number """ - log.debug(u'get_bible_chapter %s,%s,%s,%s', - version, bookid, bookname, chapter) - urlstring = u'http://www.biblegateway.com/passage/?book_id=' + \ - unicode(bookid) + u'&chapter' + unicode(chapter) + u'&version=' + \ - unicode(version) + log.debug(u'get_bible_chapter %s,%s,%s', + version, bookname, chapter) + urlstring = \ + u'http://www.biblegateway.com/passage/?search=%s %s&version=%s' % \ + (bookname, unicode(chapter) , version) xml_string = self._get_web_text(urlstring, self.proxyurl) VerseSearch = u'class=' + u'"' + u'sup' + u'"' + u'>' verse = 1 @@ -95,18 +92,15 @@ class CWExtract(BibleCommon): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl - def get_bible_chapter(self, version, bookid, bookname, chapter) : - log.debug(u'getBibleChapter %s,%s,%s,%s', - version, bookid, bookname, chapter) + def get_bible_chapter(self, version, bookname, chapter) : + log.debug(u'getBibleChapter %s,%s,%s', + version,bookname, chapter) """ Access and decode bibles via the Crosswalk website ``version`` The version of the bible like niv for New International Version - ``bookid`` - Not used - ``bookname`` Text name of in english e.g. 'gen' for Genesis diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index a2fede617..1144d2df9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -339,7 +339,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse_list = self.verse_form.getVerse() verse_list = verse_list.replace(u'\r\n', u'\n') self.VerseListWidget.clear() - for row in verse_list.split(u'\n---'): + for row in verse_list.split(u'\n---\n'): self.VerseListWidget.addItem(row) self.VerseListWidget.repaint() From 03ba804be72bb09e8a2aa449e82c828832a785e2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Oct 2009 07:20:01 +0000 Subject: [PATCH 6/9] Biblegateway addition --- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/plugindialog.py | 1 - openlp/plugins/audit/auditplugin.py | 14 +++---- .../plugins/bibles/forms/bibleimportdialog.py | 3 ++ openlp/plugins/bibles/lib/bibleHTTPimpl.py | 41 ++++++++++--------- openlp/plugins/bibles/lib/manager.py | 11 ++--- openlp/plugins/songs/forms/editsongform.py | 4 +- 7 files changed, 42 insertions(+), 34 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index f78047712..4a79f6cae 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -529,7 +529,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): version = check_latest_version(self.generalConfig, applicationVersion) if applicationVersion != version: version_text = unicode(self.trUtf8(u'OpenLP version %s has been updated ' - u'to version %s')) + u'to version %s\nWould you like to get it?')) QtGui.QMessageBox.question(None, self.trUtf8(u'OpenLP Version Updated'), version_text % (applicationVersion, version), diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index f733b8e2f..2f3551f1a 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -105,4 +105,3 @@ class Ui_PluginViewDialog(object): self.StatusLabel.setText(self.trUtf8(u'Status:')) self.StatusComboBox.setItemText(0, self.trUtf8(u'Active')) self.StatusComboBox.setItemText(1, self.trUtf8(u'Inactive')) - diff --git a/openlp/plugins/audit/auditplugin.py b/openlp/plugins/audit/auditplugin.py index a02146022..99e8a6b5a 100644 --- a/openlp/plugins/audit/auditplugin.py +++ b/openlp/plugins/audit/auditplugin.py @@ -62,18 +62,18 @@ class AuditPlugin(Plugin): self.toolsMenu = tools_menu self.AuditMenu = QtGui.QMenu(tools_menu) self.AuditMenu.setObjectName(u'AuditMenu') - self.AuditMenu.setTitle(tools_menu.trUtf8(u'&Audit')) + self.AuditMenu.setTitle(tools_menu.trUtf8(u'&Song Usage')) #Audit Delete self.AuditDelete = QtGui.QAction(tools_menu) - self.AuditDelete.setText(tools_menu.trUtf8(u'Audit &Delete')) + self.AuditDelete.setText(tools_menu.trUtf8(u'&Delete recorded data')) self.AuditDelete.setStatusTip( - tools_menu.trUtf8(u'Delete all audit data to sepecified date')) + tools_menu.trUtf8(u'Delete sing usage to sepecified date')) self.AuditDelete.setObjectName(u'AuditDelete') #Audit Report self.AuditReport = QtGui.QAction(tools_menu) - self.AuditReport.setText(tools_menu.trUtf8(u'Au&dit &Extract')) + self.AuditReport.setText(tools_menu.trUtf8(u'&Extract recoreded data')) self.AuditReport.setStatusTip( - tools_menu.trUtf8(u'Generate Extracts on Audit Data')) + tools_menu.trUtf8(u'Generate Extracts on Song Usage')) self.AuditReport.setObjectName(u'AuditReport') #Audit activation AuditIcon = buildIcon(u':/tools/tools_alert.png') @@ -81,9 +81,9 @@ class AuditPlugin(Plugin): self.AuditStatus.setIcon(AuditIcon) self.AuditStatus.setCheckable(True) self.AuditStatus.setChecked(False) - self.AuditStatus.setText(tools_menu.trUtf8(u'A&udit Status')) + self.AuditStatus.setText(tools_menu.trUtf8(u'Song Usage Status')) self.AuditStatus.setStatusTip( - tools_menu.trUtf8(u'Start/Stop live song auditing')) + tools_menu.trUtf8(u'Start/Stop live song usage recording')) self.AuditStatus.setShortcut(u'F4') self.AuditStatus.setObjectName(u'AuditStatus') #Add Menus together diff --git a/openlp/plugins/bibles/forms/bibleimportdialog.py b/openlp/plugins/bibles/forms/bibleimportdialog.py index 1f275718a..8243fc72d 100644 --- a/openlp/plugins/bibles/forms/bibleimportdialog.py +++ b/openlp/plugins/bibles/forms/bibleimportdialog.py @@ -162,6 +162,7 @@ class Ui_BibleImportDialog(object): self.LocationComboBox = QtGui.QComboBox(self.OptionsGroupBox) self.LocationComboBox.setObjectName(u'LocationComboBox') self.LocationComboBox.addItem(QtCore.QString()) + self.LocationComboBox.addItem(QtCore.QString()) self.horizontalLayout_4.addWidget(self.LocationComboBox) self.verticalLayout.addLayout(self.horizontalLayout_4) self.horizontalLayout_5 = QtGui.QHBoxLayout() @@ -173,6 +174,7 @@ class Ui_BibleImportDialog(object): self.BibleComboBox.setObjectName(u'BibleComboBox') self.BibleComboBox.addItem(QtCore.QString()) self.BibleComboBox.setItemText(0, u'') + self.BibleComboBox.setItemText(1, u'') self.BibleComboBox.addItem(QtCore.QString()) self.BibleComboBox.addItem(QtCore.QString()) self.horizontalLayout_5.addWidget(self.BibleComboBox) @@ -246,6 +248,7 @@ class Ui_BibleImportDialog(object): self.OptionsGroupBox.setTitle(self.trUtf8(u'Download Options')) self.LocationLabel.setText(self.trUtf8(u'Location:')) self.LocationComboBox.setItemText(0, self.trUtf8(u'Crosswalk')) + self.LocationComboBox.setItemText(1, self.trUtf8(u'BibleGateway')) self.BibleLabel.setText(self.trUtf8(u'Bible:')) self.BibleComboBox.setItemText(1, self.trUtf8(u'NIV')) self.BibleComboBox.setItemText(2, self.trUtf8(u'KJV')) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 061d594e6..51c9b7c3f 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -50,38 +50,41 @@ class BGExtract(BibleCommon): """ log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter) + version=u'nasb' urlstring = \ u'http://www.biblegateway.com/passage/?search=%s %s&version=%s' % \ (bookname, unicode(chapter) , version) xml_string = self._get_web_text(urlstring, self.proxyurl) - VerseSearch = u'class=' + u'"' + u'sup' + u'"' + u'>' + #print xml_string + verseSearch = u' -1: # clear out string verseText = u'' - versePos = xml_string.find(u'', versePos) + 6 + i = xml_string.find(verseSearch, versePos + 1) + #print versePos, i, xml_string[versePos:i]#, xml_string if i == -1: - i = xml_string.find(u' 0 and j < i: i = j verseText = xml_string[versePos + 7 : i ] bible[verse] = self._clean_text(verseText) # store the verse versePos = -1 else: - i = xml_string[:i].rfind(u' - # Chop off verse 1 - xml_string = xml_string[i - 1 :len(xml_string)] - versePos = xml_string.find(VerseSearch) #look for the next verse + verseText = xml_string[versePos: i] + # Chop off verse and start again + xml_string = xml_string[i:] + #print "C", xml_string + versePos = xml_string.find(verseSearch) #look for the next verse bible[verse] = self._clean_text(verseText) # store the verse verse += 1 - return bible + return SearchResults(bookname, chapter, bible) class CWExtract(BibleCommon): global log @@ -107,8 +110,8 @@ class CWExtract(BibleCommon): ``chapter`` Chapter number """ - log.debug(u'get_bible_chapter %s,%s,%s,%s', - version, bookid, bookname, chapter) + log.debug(u'get_bible_chapter %s,%s,%s', + version, bookname, chapter) bookname = bookname.replace(u' ', u'') urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s'\ % (bookname, chapter, version) @@ -200,18 +203,18 @@ class BibleHTTPImpl(): log.debug(u'set_bible_source %s', biblesource) self.biblesource = biblesource - def get_bible_chapter(self, version, bookid, bookname, chapter): + def get_bible_chapter(self, version, bookname, chapter): """ Receive the request and call the relevant handler methods """ - log.debug(u'get_bible_chapter %s,%s,%s,%s', - version, bookid, bookname, chapter) + log.debug(u'get_bible_chapter %s,%s,%s', + version, bookname, chapter) log.debug(u'biblesource = %s', self.biblesource) try: if self.biblesource.lower() == u'crosswalk': ev = CWExtract(self.proxyurl) else: ev = BGExtract(self.proxyurl) - return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter) + return ev.get_bible_chapter(self.bibleid, bookname, chapter) except: log.exception("Failed to get bible chapter") diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index a259af0c2..9200a3b0a 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -351,10 +351,10 @@ class BibleManager(object): log.debug(u'get_verse_text : new book') for chapter in range(schapter, echapter + 1): self.media.setQuickMessage( - self.trUtf8(u'Downloading %s: %s') % (bookname, chapter)) + unicode(self.media.trUtf8(u'Downloading %s: %s')) % (bookname, chapter)) search_results = \ self.bible_http_cache[bible].get_bible_chapter( - bible, 0, bookname, chapter) + bible, bookname, chapter) if search_results.has_verselist() : ## We have found a book of the bible lets check to see ## if it was there. By reusing the returned book name @@ -380,7 +380,7 @@ class BibleManager(object): book.id, chapter) if v is None: self.media.setQuickMessage( - self.trUtf8(u'%Downloading %s: %s')\ + unicode(self.media.trUtf8(u'%Downloading %s: %s'))\ % (bookname, chapter)) self.bible_db_cache[bible].create_chapter( book.id, chapter, @@ -392,8 +392,9 @@ class BibleManager(object): book.id, chapter) if v is None: try: - self.media.setQuickMessage \ - (u'Downloading %s: %s'% (bookname, chapter)) + self.media.setQuickMessage =\ + unicode(self.media.trUtf8(u'Downloading %s: %s') + % (bookname, chapter)) search_results = \ self.bible_http_cache[bible].get_bible_chapter( bible, book.id, bookname, chapter) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 1144d2df9..9ddbeb4fe 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -65,6 +65,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.SIGNAL(u'clicked()'), self.onCopyrightInsertButtonTriggered) QtCore.QObject.connect(self.VerseAddButton, QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked) + QtCore.QObject.connect(self.VerseListWidget, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onVerseEditButtonClicked) QtCore.QObject.connect(self.VerseEditButton, QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked) QtCore.QObject.connect(self.VerseEditAllButton, @@ -94,7 +96,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.VerseOrderEdit, QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus) previewButton = QtGui.QPushButton() - previewButton.setText(self.trUtf8(u'Save & Preview')) + previewButton.setText(self.trUtf8(u'Save && Preview')) self.ButtonBox.addButton(previewButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview) From 60649e36247c2e762dfb450846a3242911803b48 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Oct 2009 08:38:02 +0000 Subject: [PATCH 7/9] Move Audit to SongUsage --- openlp/core/lib/eventreceiver.py | 4 +- openlp/core/ui/slidecontroller.py | 4 +- openlp/plugins/audit/auditplugin.py | 169 ---------------- .../plugins/{audit => songusage}/__init__.py | 0 .../{audit => songusage}/forms/__init__.py | 4 +- .../forms/auditdetaildialog.py | 0 .../forms/auditdetailform.py | 0 .../forms/songusagedeletedialog.py} | 2 +- .../forms/songusagedeleteform.py} | 4 +- .../songusage/forms/songusagedetaildialog.py | 181 ++++++++++++++++++ .../songusage/forms/songusagedetailform.py | 127 ++++++++++++ .../{audit => songusage}/lib/__init__.py | 2 +- .../{audit => songusage}/lib/classes.py | 2 +- .../{audit => songusage}/lib/manager.py | 62 +++--- .../plugins/{audit => songusage}/lib/meta.py | 0 .../{audit => songusage}/lib/models.py | 8 +- .../{audit => songusage}/lib/tables.py | 10 +- openlp/plugins/songusage/songusageplugin.py | 158 +++++++++++++++ 18 files changed, 518 insertions(+), 219 deletions(-) delete mode 100644 openlp/plugins/audit/auditplugin.py rename openlp/plugins/{audit => songusage}/__init__.py (100%) rename openlp/plugins/{audit => songusage}/forms/__init__.py (94%) rename openlp/plugins/{audit => songusage}/forms/auditdetaildialog.py (100%) rename openlp/plugins/{audit => songusage}/forms/auditdetailform.py (100%) rename openlp/plugins/{audit/forms/auditdeletedialog.py => songusage/forms/songusagedeletedialog.py} (97%) rename openlp/plugins/{audit/forms/auditdeleteform.py => songusage/forms/songusagedeleteform.py} (95%) create mode 100644 openlp/plugins/songusage/forms/songusagedetaildialog.py create mode 100644 openlp/plugins/songusage/forms/songusagedetailform.py rename openlp/plugins/{audit => songusage}/lib/__init__.py (97%) rename openlp/plugins/{audit => songusage}/lib/classes.py (98%) rename openlp/plugins/{audit => songusage}/lib/manager.py (68%) rename openlp/plugins/{audit => songusage}/lib/meta.py (100%) rename openlp/plugins/{audit => songusage}/lib/models.py (91%) rename openlp/plugins/{audit => songusage}/lib/tables.py (88%) create mode 100644 openlp/plugins/songusage/songusageplugin.py diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index c4e6b8e6f..299e8e216 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -78,7 +78,7 @@ class EventReceiver(QtCore.QObject): ``{plugin}_stop`` Requests a plugin to handle a stop event - ``audit_live`` + ``songusage_live`` Sends live song audit requests to the audit component ``audit_changed`` @@ -154,4 +154,4 @@ class Receiver(): """ Get the global ``eventreceiver`` instance. """ - return Receiver.eventreceiver + return Receiver.eventreceiver \ No newline at end of file diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 035280157..534b5986b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -388,8 +388,8 @@ class SlideController(QtGui.QWidget): self.onSlideSelected() self.PreviewListWidget.setFocus() log.info(u'Display Rendering took %4s' % (time.time() - before)) - if self.serviceitem.audit != u'': - Receiver().send_message(u'audit_live', self.serviceitem.audit) + if self.serviceitem.audit != u'' and self.isLive: + Receiver().send_message(u'songusage_live', self.serviceitem.audit) log.debug(u'displayServiceManagerItems End') #Screen event methods diff --git a/openlp/plugins/audit/auditplugin.py b/openlp/plugins/audit/auditplugin.py deleted file mode 100644 index 99e8a6b5a..000000000 --- a/openlp/plugins/audit/auditplugin.py +++ /dev/null @@ -1,169 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2009 Raoul Snyman # -# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # -# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # -# --------------------------------------------------------------------------- # -# 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, buildIcon -from openlp.plugins.audit.lib import AuditManager -from openlp.plugins.audit.forms import AuditDetailForm, AuditDeleteForm -from openlp.plugins.audit.lib.models import AuditItem - -class AuditPlugin(Plugin): - global log - log = logging.getLogger(u'AuditPlugin') - log.info(u'Audit Plugin loaded') - - def __init__(self, plugin_helpers): - # Call the parent constructor - Plugin.__init__(self, u'Audit', u'1.9.0', plugin_helpers) - self.weight = -4 - # Create the plugin icon - self.icon = buildIcon(u':/media/media_image.png') - self.auditmanager = None - self.auditActive = False - - def can_be_disabled(self): - return True - - def add_tools_menu_item(self, tools_menu): - """ - Give the Audit 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.toolsMenu = tools_menu - self.AuditMenu = QtGui.QMenu(tools_menu) - self.AuditMenu.setObjectName(u'AuditMenu') - self.AuditMenu.setTitle(tools_menu.trUtf8(u'&Song Usage')) - #Audit Delete - self.AuditDelete = QtGui.QAction(tools_menu) - self.AuditDelete.setText(tools_menu.trUtf8(u'&Delete recorded data')) - self.AuditDelete.setStatusTip( - tools_menu.trUtf8(u'Delete sing usage to sepecified date')) - self.AuditDelete.setObjectName(u'AuditDelete') - #Audit Report - self.AuditReport = QtGui.QAction(tools_menu) - self.AuditReport.setText(tools_menu.trUtf8(u'&Extract recoreded data')) - self.AuditReport.setStatusTip( - tools_menu.trUtf8(u'Generate Extracts on Song Usage')) - self.AuditReport.setObjectName(u'AuditReport') - #Audit activation - AuditIcon = buildIcon(u':/tools/tools_alert.png') - self.AuditStatus = QtGui.QAction(tools_menu) - self.AuditStatus.setIcon(AuditIcon) - self.AuditStatus.setCheckable(True) - self.AuditStatus.setChecked(False) - self.AuditStatus.setText(tools_menu.trUtf8(u'Song Usage Status')) - self.AuditStatus.setStatusTip( - tools_menu.trUtf8(u'Start/Stop live song usage recording')) - self.AuditStatus.setShortcut(u'F4') - self.AuditStatus.setObjectName(u'AuditStatus') - #Add Menus together - self.toolsMenu.addAction(self.AuditMenu.menuAction()) - self.AuditMenu.addAction(self.AuditStatus) - self.AuditMenu.addSeparator() - self.AuditMenu.addAction(self.AuditDelete) - self.AuditMenu.addAction(self.AuditReport) - # Signals and slots - QtCore.QObject.connect(self.AuditStatus, - QtCore.SIGNAL(u'visibilityChanged(bool)'), - self.AuditStatus.setChecked) - QtCore.QObject.connect(self.AuditStatus, - QtCore.SIGNAL(u'triggered(bool)'), - self.toggleAuditState) - QtCore.QObject.connect(self.AuditDelete, - QtCore.SIGNAL(u'triggered()'), self.onAuditDelete) - QtCore.QObject.connect(self.AuditReport, - QtCore.SIGNAL(u'triggered()'), self.onAuditReport) - self.AuditMenu.menuAction().setVisible(False) - - def initialise(self): - log.info(u'audit Initialising') - Plugin.initialise(self) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'audit_changed'), self.onUpdateAudit) - self.auditActive = str_to_bool( - self.config.get_config(u'audit active', False)) - self.AuditStatus.setChecked(self.auditActive) - if self.auditmanager is None: - self.auditmanager = AuditManager(self.config) - self.auditdeleteform = AuditDeleteForm(self.auditmanager) - self.auditdetailform = AuditDetailForm(self) - self.AuditMenu.menuAction().setVisible(True) - - def finalise(self): - log.info(u'Plugin Finalise') - self.AuditMenu.menuAction().setVisible(False) - #stop any events being processed - self.auditActive = False - - 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: - audititem = AuditItem() - audititem.auditdate = datetime.today() - audititem.audittime = datetime.now().time() - audititem.title = auditData[0] - audititem.copyright = auditData[2] - audititem.ccl_number = auditData[3] - audititem.authors = u'' - for author in auditData[1]: - audititem.authors += author + u' ' - self.auditmanager.insert_audit(audititem) - - def onUpdateAudit(self): - """ - Someone may have changed to audit details - Sort out the file and the auditing state - """ - self.auditActive = str_to_bool( - self.config.get_config(u'audit active', False)) - self.AuditStatus.setEnabled(True) - - def onAuditDelete(self): - self.auditdeleteform.exec_() - - def onAuditReport(self): - self.auditdetailform.initialise() - self.auditdetailform.exec_() - - def about(self): - about_text = u'Audit Plugin
This plugin records the use '\ - u'of songs and when they have been used during a live service' - return about_text diff --git a/openlp/plugins/audit/__init__.py b/openlp/plugins/songusage/__init__.py similarity index 100% rename from openlp/plugins/audit/__init__.py rename to openlp/plugins/songusage/__init__.py diff --git a/openlp/plugins/audit/forms/__init__.py b/openlp/plugins/songusage/forms/__init__.py similarity index 94% rename from openlp/plugins/audit/forms/__init__.py rename to openlp/plugins/songusage/forms/__init__.py index 70276cbdd..47ecbc90c 100644 --- a/openlp/plugins/audit/forms/__init__.py +++ b/openlp/plugins/songusage/forms/__init__.py @@ -22,5 +22,5 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from auditdeleteform import AuditDeleteForm -from auditdetailform import AuditDetailForm +from songusagedeleteform import SongUsageDeleteForm +from songusagedetailform import SongUsageDetailForm diff --git a/openlp/plugins/audit/forms/auditdetaildialog.py b/openlp/plugins/songusage/forms/auditdetaildialog.py similarity index 100% rename from openlp/plugins/audit/forms/auditdetaildialog.py rename to openlp/plugins/songusage/forms/auditdetaildialog.py diff --git a/openlp/plugins/audit/forms/auditdetailform.py b/openlp/plugins/songusage/forms/auditdetailform.py similarity index 100% rename from openlp/plugins/audit/forms/auditdetailform.py rename to openlp/plugins/songusage/forms/auditdetailform.py diff --git a/openlp/plugins/audit/forms/auditdeletedialog.py b/openlp/plugins/songusage/forms/songusagedeletedialog.py similarity index 97% rename from openlp/plugins/audit/forms/auditdeletedialog.py rename to openlp/plugins/songusage/forms/songusagedeletedialog.py index 75ff8b63d..29f914dfb 100644 --- a/openlp/plugins/audit/forms/auditdeletedialog.py +++ b/openlp/plugins/songusage/forms/songusagedeletedialog.py @@ -9,7 +9,7 @@ from PyQt4 import QtCore, QtGui -class Ui_AuditDeleteDialog(object): +class Ui_SongUsageDeleteDialog(object): def setupUi(self, AuditDeleteDialog): AuditDeleteDialog.setObjectName(u'AuditDeleteDialog') AuditDeleteDialog.resize(291, 243) diff --git a/openlp/plugins/audit/forms/auditdeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py similarity index 95% rename from openlp/plugins/audit/forms/auditdeleteform.py rename to openlp/plugins/songusage/forms/songusagedeleteform.py index d2e647a44..ae11f00dd 100644 --- a/openlp/plugins/audit/forms/auditdeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -26,9 +26,9 @@ from datetime import date from PyQt4 import QtGui -from auditdeletedialog import Ui_AuditDeleteDialog +from songusagedeletedialog import Ui_SongUsageDeleteDialog -class AuditDeleteForm(QtGui.QDialog, Ui_AuditDeleteDialog): +class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): """ Class documentation goes here. """ diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py new file mode 100644 index 000000000..496de9382 --- /dev/null +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -0,0 +1,181 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'auditdetaildialog.ui' +# +# Created: Sun Oct 11 11:40:02 2009 +# by: PyQt4 UI code generator 4.5.4 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_SongUsageDetailDialog(object): + def setupUi(self, AuditDetailDialog): + AuditDetailDialog.setObjectName(u'AuditDetailDialog') + AuditDetailDialog.resize(593, 501) + self.buttonBox = QtGui.QDialogButtonBox(AuditDetailDialog) + self.buttonBox.setGeometry(QtCore.QRect(420, 470, 170, 25)) + self.buttonBox.setStandardButtons( + QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(u'buttonBox') + self.FileGroupBox = QtGui.QGroupBox(AuditDetailDialog) + self.FileGroupBox.setGeometry(QtCore.QRect(10, 370, 571, 70)) + self.FileGroupBox.setObjectName(u'FileGroupBox') + self.verticalLayout_4 = QtGui.QVBoxLayout(self.FileGroupBox) + self.verticalLayout_4.setObjectName(u'verticalLayout_4') + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName(u'horizontalLayout') + self.FileLineEdit = QtGui.QLineEdit(self.FileGroupBox) + self.FileLineEdit.setObjectName(u'FileLineEdit') + self.horizontalLayout.addWidget(self.FileLineEdit) + self.SaveFilePushButton = QtGui.QPushButton(self.FileGroupBox) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(u':/exports/export_load.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.SaveFilePushButton.setIcon(icon) + self.SaveFilePushButton.setObjectName(u'SaveFilePushButton') + self.horizontalLayout.addWidget(self.SaveFilePushButton) + self.verticalLayout_4.addLayout(self.horizontalLayout) + self.layoutWidget = QtGui.QWidget(AuditDetailDialog) + self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 561, 361)) + self.layoutWidget.setObjectName(u'layoutWidget') + self.verticalLayout_3 = QtGui.QVBoxLayout(self.layoutWidget) + self.verticalLayout_3.setObjectName(u'verticalLayout_3') + self.ReportTypeGroup = QtGui.QGroupBox(self.layoutWidget) + self.ReportTypeGroup.setObjectName(u'ReportTypeGroup') + self.layoutWidget1 = QtGui.QWidget(self.ReportTypeGroup) + self.layoutWidget1.setGeometry(QtCore.QRect(50, 40, 481, 23)) + self.layoutWidget1.setObjectName(u'layoutWidget1') + self.ReportHorizontalLayout = QtGui.QHBoxLayout(self.layoutWidget1) + self.ReportHorizontalLayout.setObjectName(u'ReportHorizontalLayout') + self.SummaryReport = QtGui.QRadioButton(self.layoutWidget1) + self.SummaryReport.setObjectName(u'SummaryReport') + self.ReportHorizontalLayout.addWidget(self.SummaryReport) + self.DetailedReport = QtGui.QRadioButton(self.layoutWidget1) + self.DetailedReport.setChecked(True) + self.DetailedReport.setObjectName(u'DetailedReport') + self.ReportHorizontalLayout.addWidget(self.DetailedReport) + self.verticalLayout_3.addWidget(self.ReportTypeGroup) + self.DateRangeGroupBox = QtGui.QGroupBox(self.layoutWidget) + self.DateRangeGroupBox.setObjectName(u'DateRangeGroupBox') + self.verticalLayout_2 = QtGui.QVBoxLayout(self.DateRangeGroupBox) + self.verticalLayout_2.setObjectName(u'verticalLayout_2') + self.DateHorizontalLayout = QtGui.QHBoxLayout() + self.DateHorizontalLayout.setObjectName(u'DateHorizontalLayout') + self.FromDateEdit = QtGui.QDateEdit(self.DateRangeGroupBox) + self.FromDateEdit.setCalendarPopup(True) + self.FromDateEdit.setObjectName(u'FromDateEdit') + self.DateHorizontalLayout.addWidget(self.FromDateEdit) + self.To = QtGui.QLabel(self.DateRangeGroupBox) + self.To.setObjectName(u'To') + self.DateHorizontalLayout.addWidget(self.To) + self.ToDateEdit = QtGui.QDateEdit(self.DateRangeGroupBox) + self.ToDateEdit.setCalendarPopup(True) + self.ToDateEdit.setObjectName(u'ToDateEdit') + self.DateHorizontalLayout.addWidget(self.ToDateEdit) + self.verticalLayout_2.addLayout(self.DateHorizontalLayout) + self.verticalLayout_3.addWidget(self.DateRangeGroupBox) + self.TimePeriodGroupBox = QtGui.QGroupBox(self.layoutWidget) + self.TimePeriodGroupBox.setObjectName(u'TimePeriodGroupBox') + self.verticalLayout = QtGui.QVBoxLayout(self.TimePeriodGroupBox) + self.verticalLayout.setObjectName(u'verticalLayout') + self.FirstHorizontalLayout = QtGui.QHBoxLayout() + self.FirstHorizontalLayout.setObjectName(u'FirstHorizontalLayout') + self.FirstCheckBox = QtGui.QCheckBox(self.TimePeriodGroupBox) + self.FirstCheckBox.setChecked(True) + self.FirstCheckBox.setObjectName(u'FirstCheckBox') + self.FirstHorizontalLayout.addWidget(self.FirstCheckBox) + self.FirstFromTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) + self.FirstFromTimeEdit.setTime(QtCore.QTime(9, 0, 0)) + self.FirstFromTimeEdit.setObjectName(u'FirstFromTimeEdit') + self.FirstHorizontalLayout.addWidget(self.FirstFromTimeEdit) + self.FirstTo = QtGui.QLabel(self.TimePeriodGroupBox) + self.FirstTo.setObjectName(u'FirstTo') + self.FirstHorizontalLayout.addWidget(self.FirstTo) + self.FirstToTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) + self.FirstToTimeEdit.setCalendarPopup(True) + self.FirstToTimeEdit.setTime(QtCore.QTime(10, 0, 0)) + self.FirstToTimeEdit.setObjectName(u'FirstToTimeEdit') + self.FirstHorizontalLayout.addWidget(self.FirstToTimeEdit) + self.verticalLayout.addLayout(self.FirstHorizontalLayout) + self.SecondHorizontalLayout = QtGui.QHBoxLayout() + self.SecondHorizontalLayout.setObjectName(u'SecondHorizontalLayout') + self.SecondCheckBox = QtGui.QCheckBox(self.TimePeriodGroupBox) + self.SecondCheckBox.setChecked(True) + self.SecondCheckBox.setObjectName(u'SecondCheckBox') + self.SecondHorizontalLayout.addWidget(self.SecondCheckBox) + self.SecondFromTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) + self.SecondFromTimeEdit.setTime(QtCore.QTime(10, 45, 0)) + self.SecondFromTimeEdit.setObjectName(u'SecondFromTimeEdit') + self.SecondHorizontalLayout.addWidget(self.SecondFromTimeEdit) + self.SecondTo = QtGui.QLabel(self.TimePeriodGroupBox) + self.SecondTo.setObjectName(u'SecondTo') + self.SecondHorizontalLayout.addWidget(self.SecondTo) + self.SecondToTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) + self.SecondToTimeEdit.setObjectName(u'SecondToTimeEdit') + self.SecondHorizontalLayout.addWidget(self.SecondToTimeEdit) + self.verticalLayout.addLayout(self.SecondHorizontalLayout) + self.ThirdHorizontalLayout = QtGui.QHBoxLayout() + self.ThirdHorizontalLayout.setObjectName(u'ThirdHorizontalLayout') + self.ThirdCheckBox = QtGui.QCheckBox(self.TimePeriodGroupBox) + self.ThirdCheckBox.setChecked(True) + self.ThirdCheckBox.setObjectName(u'ThirdCheckBox') + self.ThirdHorizontalLayout.addWidget(self.ThirdCheckBox) + self.ThirdFromTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) + self.ThirdFromTimeEdit.setTime(QtCore.QTime(18, 30, 0)) + self.ThirdFromTimeEdit.setObjectName(u'ThirdFromTimeEdit') + self.ThirdHorizontalLayout.addWidget(self.ThirdFromTimeEdit) + self.ThirdTo = QtGui.QLabel(self.TimePeriodGroupBox) + self.ThirdTo.setObjectName(u'ThirdTo') + self.ThirdHorizontalLayout.addWidget(self.ThirdTo) + self.ThirdToTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) + self.ThirdToTimeEdit.setTime(QtCore.QTime(19, 30, 0)) + self.ThirdToTimeEdit.setObjectName(u'ThirdToTimeEdit') + self.ThirdHorizontalLayout.addWidget(self.ThirdToTimeEdit) + self.verticalLayout.addLayout(self.ThirdHorizontalLayout) + self.verticalLayout_3.addWidget(self.TimePeriodGroupBox) + + self.retranslateUi(AuditDetailDialog) + QtCore.QObject.connect( + self.buttonBox, QtCore.SIGNAL(u'accepted()'), + AuditDetailDialog.accept) + QtCore.QObject.connect( + self.buttonBox, QtCore.SIGNAL(u'rejected()'), + AuditDetailDialog.close) + QtCore.QObject.connect( + self.FirstCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), + AuditDetailDialog.changeFirstService) + QtCore.QObject.connect( + self.SecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), + AuditDetailDialog.changeSecondService) + QtCore.QObject.connect( + self.ThirdCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), + AuditDetailDialog.changeThirdService) + QtCore.QObject.connect( + self.SaveFilePushButton, QtCore.SIGNAL(u'pressed()'), + AuditDetailDialog.defineOutputLocation) + QtCore.QMetaObject.connectSlotsByName(AuditDetailDialog) + + def retranslateUi(self, AuditDetailDialog): + AuditDetailDialog.setWindowTitle(self.trUtf8(u'Audit Detail Extraction')) + self.FileGroupBox.setTitle(self.trUtf8(u'Report Location')) + self.ReportTypeGroup.setTitle(self.trUtf8(u'Report Type')) + self.SummaryReport.setText(self.trUtf8(u'Summary')) + self.DetailedReport.setText(self.trUtf8(u'Detailed')) + self.DateRangeGroupBox.setTitle(self.trUtf8(u'Select Date Range')) + self.FromDateEdit.setDisplayFormat(self.trUtf8(u'dd/MM/yyyy')) + self.To.setText(self.trUtf8(u'to')) + self.ToDateEdit.setDisplayFormat(self.trUtf8(u'dd/MM/yyyy')) + self.TimePeriodGroupBox.setTitle(self.trUtf8(u'Select Time Periods')) + self.FirstCheckBox.setText(self.trUtf8(u'First Service')) + self.FirstFromTimeEdit.setDisplayFormat(self.trUtf8(u'hh:mm AP')) + self.FirstTo.setText(self.trUtf8(u'to')) + self.FirstToTimeEdit.setDisplayFormat(self.trUtf8(u'hh:mm AP')) + self.SecondCheckBox.setText(self.trUtf8(u'Second Service')) + self.SecondFromTimeEdit.setDisplayFormat(self.trUtf8(u'hh:mm AP')) + self.SecondTo.setText(self.trUtf8(u'to')) + self.SecondToTimeEdit.setDisplayFormat(self.trUtf8(u'hh:mm AP')) + self.ThirdCheckBox.setText(self.trUtf8(u'Third Service')) + self.ThirdFromTimeEdit.setDisplayFormat(self.trUtf8(u'hh:mm AP')) + self.ThirdTo.setText(self.trUtf8(u'to')) + self.ThirdToTimeEdit.setDisplayFormat(self.trUtf8(u'hh:mm AP')) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py new file mode 100644 index 000000000..a55f10a17 --- /dev/null +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +import os + +from PyQt4 import QtCore, QtGui + +from songusagedetaildialog import Ui_SongUsageDetailDialog + +class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): + """ + Class documentation goes here. + """ + def __init__(self, parent=None): + """ + Constructor + """ + QtGui.QDialog.__init__(self, None) + self.parent = parent + 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.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, + self.trUtf8(u'Output File Location'), + self.parent.config.get_last_dir(1) ) + path = unicode(path) + if path != u'': + 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): + print "detailed" + filename = u'audit_det_%s_%s.txt' % \ + (self.FromDateEdit.date().toString(u'ddMMyyyy'), + self.ToDateEdit.date().toString(u'ddMMyyyy')) + audits = self.parent.auditmanager.get_all_audits() + outname = os.path.join(unicode(self.FileLineEdit.text()), filename) + file = open(outname, u'w') + for audit in audits: + record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n' % \ + (audit.auditdate,audit.audittime, audit.title, + audit.copyright, audit.ccl_number , audit.authors) + file.write(record) + file.close() + + def summaryReport(self): + print "summary" + filename = u'audit_sum_%s_%s.txt' % \ + (self.FromDateEdit.date().toString(u'ddMMyyyy'), + self.ToDateEdit.date().toString(u'ddMMyyyy')) + print filename diff --git a/openlp/plugins/audit/lib/__init__.py b/openlp/plugins/songusage/lib/__init__.py similarity index 97% rename from openlp/plugins/audit/lib/__init__.py rename to openlp/plugins/songusage/lib/__init__.py index a5bd43550..cdcd45c74 100644 --- a/openlp/plugins/audit/lib/__init__.py +++ b/openlp/plugins/songusage/lib/__init__.py @@ -22,4 +22,4 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from manager import AuditManager +from manager import SongUsageManager diff --git a/openlp/plugins/audit/lib/classes.py b/openlp/plugins/songusage/lib/classes.py similarity index 98% rename from openlp/plugins/audit/lib/classes.py rename to openlp/plugins/songusage/lib/classes.py index 6883bca14..258b3af6a 100644 --- a/openlp/plugins/audit/lib/classes.py +++ b/openlp/plugins/songusage/lib/classes.py @@ -38,7 +38,7 @@ class BaseModel(object): me.__setattr__(key, kwargs[key]) return me -class AuditItem(BaseModel): +class SongUsageItem(BaseModel): """ Audit model """ diff --git a/openlp/plugins/audit/lib/manager.py b/openlp/plugins/songusage/lib/manager.py similarity index 68% rename from openlp/plugins/audit/lib/manager.py rename to openlp/plugins/songusage/lib/manager.py index bd2027e20..8f94e119f 100644 --- a/openlp/plugins/audit/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -24,17 +24,17 @@ import logging -from openlp.plugins.audit.lib.models import init_models, metadata, AuditItem +from openlp.plugins.songusage.lib.models import init_models, metadata, SongUsageItem -class AuditManager(): +class SongUsageManager(): """ The Song Manager provides a central location for all database code. This class takes care of connecting to the database and running all the queries. """ global log - log = logging.getLogger(u'AuditManager') - log.info(u'Audit manager loaded') + log = logging.getLogger(u'SongUsageManager') + log.info(u'SongUsage manager loaded') def __init__(self, config): """ @@ -42,11 +42,11 @@ class AuditManager(): don't exist. """ self.config = config - log.debug(u'Audit Initialising') + log.debug(u'SongUsage Initialising') self.db_url = u'' db_type = self.config.get_config(u'db type', u'sqlite') if db_type == u'sqlite': - self.db_url = u'sqlite:///%s/audit.sqlite' % \ + self.db_url = u'sqlite:///%s/songusage.sqlite' % \ self.config.get_data_path() else: self.db_url = u'%s://%s:%s@%s/%s' % \ @@ -57,76 +57,78 @@ class AuditManager(): self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - log.debug(u'Audit Initialised') + log.debug(u'SongUsage Initialised') - def get_all_audits(self): + def get_all_songusage(self): """ - Returns the details of a audit + Returns the details of SongUsage """ - return self.session.query(AuditItem).order_by(AuditItem.auditdate, AuditItem.audittime ).all() + return self.session.query(SongUsageItem).\ + order_by(SongUsageItem.usagedate, SongUsageItem.usagetime ).all() - def insert_audit(self, audititem): + def insert_songusage(self, songusageitem): """ - Saves an audit to the database + Saves an SongUsage to the database """ - log.debug(u'Audit added') + log.debug(u'SongUsage added') try: - self.session.add(audititem) + self.session.add(songusageitem) self.session.commit() return True except: self.session.rollback() - log.exception(u'Audit item failed to save') + log.exception(u'SongUsage item failed to save') return False - def get_audit(self, id=None): + def get_songusage(self, id=None): """ - Returns the details of an audit + Returns the details of a SongUsage """ if id is None: - return AuditItem() + return SongUsageItem() else: - return self.session.query(AuditItem).get(id) + return self.session.query(SongUsageItem).get(id) - def delete_audit(self, id): + def delete_songusage(self, id): """ - Delete a audit record + Delete a SongUsage record """ if id !=0: - audititem = self.get_audit(id) + songusageitem = self.get_songusage(id) try: - self.session.delete(audititem) + self.session.delete(songusageitem) self.session.commit() return True except: self.session.rollback() - log.excertion(u'Audit Item failed to delete') + log.excertion(u'SongUsage Item failed to delete') return False else: return True def delete_all(self): """ - Delete all audit records + Delete all Song Usage records """ try: - self.session.query(AuditItem).delete(synchronize_session=False) + self.session.query(SongUsageItem).delete(synchronize_session=False) self.session.commit() return True except: self.session.rollback() - log.excertion(u'Failed to delete all audit items') + log.excertion(u'Failed to delete all Song Usage items') return False def delete_to_date(self, date): """ - Delete audit records before given date + Delete SongUsage records before given date """ try: - self.session.query(AuditItem).filter(AuditItem.auditdate <= date).delete(synchronize_session=False) + self.session.query(SongUsageItem).\ + filter(SongUsageItem.usagedate <= date).delete(synchronize_session=False) self.session.commit() return True except: self.session.rollback() - log.excertion(u'Failed to delete all audit items to %s' % date) + log.excertion(u'Failed to delete all Song Usage items to %s' % date) return False diff --git a/openlp/plugins/audit/lib/meta.py b/openlp/plugins/songusage/lib/meta.py similarity index 100% rename from openlp/plugins/audit/lib/meta.py rename to openlp/plugins/songusage/lib/meta.py diff --git a/openlp/plugins/audit/lib/models.py b/openlp/plugins/songusage/lib/models.py similarity index 91% rename from openlp/plugins/audit/lib/models.py rename to openlp/plugins/songusage/lib/models.py index 9ae901537..4d91029cb 100644 --- a/openlp/plugins/audit/lib/models.py +++ b/openlp/plugins/songusage/lib/models.py @@ -25,14 +25,14 @@ from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker, mapper -from openlp.plugins.audit.lib.meta import metadata -from openlp.plugins.audit.lib.tables import * -from openlp.plugins.audit.lib.classes import * +from openlp.plugins.songusage.lib.meta import metadata +from openlp.plugins.songusage.lib.tables import * +from openlp.plugins.songusage.lib.classes import * def init_models(url): engine = create_engine(url) metadata.bind = engine session = scoped_session(sessionmaker(autoflush=True, autocommit=False, bind=engine)) - mapper(AuditItem, audit_table) + mapper(SongUsageItem, songusage_table) return session diff --git a/openlp/plugins/audit/lib/tables.py b/openlp/plugins/songusage/lib/tables.py similarity index 88% rename from openlp/plugins/audit/lib/tables.py rename to openlp/plugins/songusage/lib/tables.py index 24b787b21..b8e4e1665 100644 --- a/openlp/plugins/audit/lib/tables.py +++ b/openlp/plugins/songusage/lib/tables.py @@ -24,13 +24,13 @@ from sqlalchemy import Column, Table, types -from openlp.plugins.audit.lib.meta import metadata +from openlp.plugins.songusage.lib.meta import metadata -# Definition of the "songs" table -audit_table = Table(u'audit_data', metadata, +# Definition of the "songusage" table +songusage_table = Table(u'songusage_data', metadata, Column(u'id', types.Integer(), primary_key=True), - Column(u'auditdate', types.Date, index=True, nullable=False), - Column(u'audittime', types.Time, index=True, nullable=False), + Column(u'usagedate', types.Date, index=True, nullable=False), + Column(u'usagetime', types.Time, index=True, nullable=False), Column(u'title', types.Unicode(255), nullable=False), Column(u'authors', types.Unicode(255), nullable=False), Column(u'copyright', types.Unicode(255)), diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py new file mode 100644 index 000000000..a0f7e2f35 --- /dev/null +++ b/openlp/plugins/songusage/songusageplugin.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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, buildIcon +from openlp.plugins.songusage.lib import SongUsageManager +from openlp.plugins.songusage.forms import SongUsageDetailForm, SongUsageDeleteForm +from openlp.plugins.songusage.lib.models import SongUsageItem + +class SongUsagePlugin(Plugin): + global log + log = logging.getLogger(u'SongUsagePlugin') + log.info(u'SongUsage Plugin loaded') + + def __init__(self, plugin_helpers): + # Call the parent constructor + Plugin.__init__(self, u'SongUsage', u'1.9.0', plugin_helpers) + self.weight = -4 + # Create the plugin icon + self.icon = buildIcon(u':/media/media_image.png') + self.songusagemanager = None + self.songusageActive = False + + def can_be_disabled(self): + return True + + def add_tools_menu_item(self, tools_menu): + """ + Give the SongUsage 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.toolsMenu = tools_menu + self.SongUsageMenu = QtGui.QMenu(tools_menu) + self.SongUsageMenu.setObjectName(u'SongUsageMenu') + self.SongUsageMenu.setTitle(tools_menu.trUtf8(u'&Song Usage')) + #SongUsage Delete + self.SongUsageDelete = QtGui.QAction(tools_menu) + self.SongUsageDelete.setText(tools_menu.trUtf8(u'&Delete recorded data')) + self.SongUsageDelete.setStatusTip( + tools_menu.trUtf8(u'Delete sing usage to sepecified date')) + self.SongUsageDelete.setObjectName(u'SongUsageDelete') + #SongUsage Report + self.SongUsageReport = QtGui.QAction(tools_menu) + self.SongUsageReport.setText(tools_menu.trUtf8(u'&Extract recoreded data')) + self.SongUsageReport.setStatusTip( + tools_menu.trUtf8(u'Generate Extracts on Song Usage')) + self.SongUsageReport.setObjectName(u'SongUsageReport') + #SongUsage activation + SongUsageIcon = buildIcon(u':/tools/tools_alert.png') + self.SongUsageStatus = QtGui.QAction(tools_menu) + self.SongUsageStatus.setIcon(SongUsageIcon) + self.SongUsageStatus.setCheckable(True) + self.SongUsageStatus.setChecked(False) + self.SongUsageStatus.setText(tools_menu.trUtf8(u'Song Usage Status')) + self.SongUsageStatus.setStatusTip( + tools_menu.trUtf8(u'Start/Stop live song usage recording')) + self.SongUsageStatus.setShortcut(u'F4') + self.SongUsageStatus.setObjectName(u'SongUsageStatus') + #Add Menus together + self.toolsMenu.addAction(self.SongUsageMenu.menuAction()) + self.SongUsageMenu.addAction(self.SongUsageStatus) + self.SongUsageMenu.addSeparator() + self.SongUsageMenu.addAction(self.SongUsageDelete) + self.SongUsageMenu.addAction(self.SongUsageReport) + # Signals and slots + QtCore.QObject.connect(self.SongUsageStatus, + QtCore.SIGNAL(u'visibilityChanged(bool)'), + self.SongUsageStatus.setChecked) + QtCore.QObject.connect(self.SongUsageStatus, + QtCore.SIGNAL(u'triggered(bool)'), + self.toggleSongUsageState) + QtCore.QObject.connect(self.SongUsageDelete, + QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) + QtCore.QObject.connect(self.SongUsageReport, + QtCore.SIGNAL(u'triggered()'), self.onSongUsageReport) + self.SongUsageMenu.menuAction().setVisible(False) + + def initialise(self): + log.info(u'SongUsage Initialising') + Plugin.initialise(self) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'songusage_live'), self.onReceiveSongUsage) + self.SongUsageActive = str_to_bool( + self.config.get_config(u'audit active', False)) + self.SongUsageStatus.setChecked(self.SongUsageActive) + if self.songusagemanager is None: + self.songusagemanager = SongUsageManager(self.config) + self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager) + self.SongUsagedetailform = SongUsageDetailForm(self) + self.SongUsageMenu.menuAction().setVisible(True) + + def finalise(self): + log.info(u'Plugin Finalise') + self.SongUsageMenu.menuAction().setVisible(False) + #stop any events being processed + self.SongUsageActive = False + + def toggleSongUsageState(self): + self.SongUsageActive = not self.SongUsageActive + self.config.set_config(u'SongUsage active', self.SongUsageActive) + + def onReceiveSongUsage(self, SongUsageData): + """ + SongUsage a live song from SlideController + """ + if self.SongUsageActive: + SongUsageitem = SongUsageItem() + SongUsageitem.usagedate = datetime.today() + SongUsageitem.usagetime = datetime.now().time() + SongUsageitem.title = SongUsageData[0] + SongUsageitem.copyright = SongUsageData[2] + SongUsageitem.ccl_number = SongUsageData[3] + SongUsageitem.authors = u'' + for author in SongUsageData[1]: + SongUsageitem.authors += author + u' ' + self.songusagemanager.insert_SongUsage(SongUsageitem) + + def onSongUsageDelete(self): + self.SongUsagedeleteform.exec_() + + def onSongUsageReport(self): + self.SongUsagedetailform.initialise() + self.SongUsagedetailform.exec_() + + def about(self): + about_text = u'SongUsage Plugin
This plugin records the use '\ + u'of songs and when they have been used during a live service' + return about_text From 1c0ce26e54f3c6967c5dbf4becfe0ebb3977aab2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Oct 2009 16:55:09 +0000 Subject: [PATCH 8/9] More BibleGateway work --- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 9 +++++++-- openlp/plugins/bibles/lib/common.py | 2 +- openlp/plugins/bibles/lib/manager.py | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 51c9b7c3f..304941ac6 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -56,7 +56,8 @@ class BGExtract(BibleCommon): (bookname, unicode(chapter) , version) xml_string = self._get_web_text(urlstring, self.proxyurl) #print xml_string - verseSearch = u'', versePos) + 6 i = xml_string.find(verseSearch, versePos + 1) - #print versePos, i, xml_string[versePos:i]#, xml_string if i == -1: i = xml_string.find(u' -1: + end_tag = verseText.find(u'') + verseText = verseText[:start_tag] + verseText[end_tag + 6:len(verseText)] + start_tag = verseText.find(verseFootnote) # Chop off verse and start again xml_string = xml_string[i:] #print "C", xml_string diff --git a/openlp/plugins/bibles/lib/common.py b/openlp/plugins/bibles/lib/common.py index 6d05f247e..a7c39dca9 100644 --- a/openlp/plugins/bibles/lib/common.py +++ b/openlp/plugins/bibles/lib/common.py @@ -163,5 +163,5 @@ class BibleCommon(object): text = text[:start_tag] + text[end_tag + 1:] start_tag = text.find(u'<') text = text.replace(u'>', u'') - return text.rstrip() + return text.rstrip().lstrip() diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 9200a3b0a..2948ddb88 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -392,12 +392,12 @@ class BibleManager(object): book.id, chapter) if v is None: try: - self.media.setQuickMessage =\ - unicode(self.media.trUtf8(u'Downloading %s: %s') + self.media.setQuickMessage(\ + unicode(self.media.trUtf8(u'Downloading %s: %s')) % (bookname, chapter)) search_results = \ self.bible_http_cache[bible].get_bible_chapter( - bible, book.id, bookname, chapter) + bible, bookname, chapter) if search_results.has_verselist(): self.bible_db_cache[bible].create_chapter( book.id, search_results.get_chapter(), From 0e5ed927c1a516d6773f564d1320441a823ec61b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Oct 2009 17:25:58 +0000 Subject: [PATCH 9/9] More BibleGateway work - no prints --- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 304941ac6..6359e828e 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -85,7 +85,6 @@ class BGExtract(BibleCommon): start_tag = verseText.find(verseFootnote) # Chop off verse and start again xml_string = xml_string[i:] - #print "C", xml_string versePos = xml_string.find(verseSearch) #look for the next verse bible[verse] = self._clean_text(verseText) # store the verse verse += 1