From fbaa6678a975045e83a5d10cae8c186a9dd28518 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 26 Jan 2011 18:00:46 +0000 Subject: [PATCH 1/7] Up is Up and Down is Up ? --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d1a3e6762..14fe7a629 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -179,7 +179,7 @@ class ServiceManager(QtGui.QWidget): None, translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), - self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Up) + self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), From 139cf93541fd165a5b25b3e1d0dd6bbd5b15fbaa Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Jan 2011 18:41:37 +0000 Subject: [PATCH 2/7] SongUsage cleanup --- openlp/core/lib/__init__.py | 2 +- .../songusage/forms/songusagedetaildialog.py | 5 ++- .../songusage/forms/songusagedetailform.py | 41 ++++++++++++++----- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 76d7c0617..33280f83b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -315,7 +315,7 @@ def check_directory_exists(dir): ``dir`` Theme directory to make sure exists """ - log.debug(u'check_directory_exists') + log.debug(u'check_directory_exists %s' % dir) if not os.path.exists(dir): os.makedirs(dir) diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 9383e147d..87d2d5ffe 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -60,10 +60,11 @@ class Ui_SongUsageDetailDialog(object): self.horizontalLayout.setObjectName(u'horizontalLayout') self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit.setObjectName(u'fileLineEdit') + self.fileLineEdit.setReadOnly(True) self.horizontalLayout.addWidget(self.fileLineEdit) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton.setIcon( - build_icon(u':/general/general_load.png')) + build_icon(u':/general/general_open.png')) self.saveFilePushButton.setObjectName(u'saveFilePushButton') self.horizontalLayout.addWidget(self.saveFilePushButton) self.verticalLayout4.addLayout(self.horizontalLayout) @@ -96,4 +97,4 @@ class Ui_SongUsageDetailDialog(object): translate('SongUsagePlugin.SongUsageDetailForm', 'to')) self.fileGroupBox.setTitle( translate('SongUsagePlugin.SongUsageDetailForm', - 'Report Location')) \ No newline at end of file + 'Report Location')) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 8588ddcff..88e3b1450 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate +from openlp.core.lib import SettingsManager, translate, check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -51,49 +51,68 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.setupUi(self) def initialise(self): + """ + We need to set up the screen + """ 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) + toDate = QtCore.QSettings().value( + u'songusage/to date', + QtCore.QVariant(QtCore.QDate(year, 8, 31))).toDate() + fromDate = QtCore.QSettings().value( + u'songusage/from date', + QtCore.QVariant(QtCore.QDate(year - 1, 9, 1))).toDate() self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) def defineOutputLocation(self): + """ + Triggered when the Directory selection button is pressed + """ path = QtGui.QFileDialog.getExistingDirectory(self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) path = unicode(path) - if path != u'': + if path: SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) self.fileLineEdit.setText(path) def accept(self): - log.debug(u'Detailed report generated') + """ + Ok was pressed so lets save the data and run the report + """ + log.debug(u'accept') + path = unicode(self.fileLineEdit.text()) + check_directory_exists(path) filename = unicode(translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt')) % ( self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.toDate.selectedDate().toString(u'ddMMyyyy')) + QtCore.QSettings().setValue(u'songusage/from date', + QtCore.QVariant(self.fromDate.selectedDate())) + QtCore.QSettings().setValue(u'songusage/to date', + QtCore.QVariant(self.toDate.selectedDate())) usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()), [SongUsageItem.usagedate, SongUsageItem.usagetime]) - outname = os.path.join(unicode(self.fileLineEdit.text()), filename) - file = None + outname = os.path.join(path, filename) + fileHandle = None try: - file = open(outname, u'w') + fileHandle = open(outname, u'w') for instance in usage: record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n' % ( instance.usagedate, instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors) - file.write(record) + fileHandle.write(record.encode(u'utf-8')) except IOError: log.exception(u'Failed to write out song usage records') finally: - if file: - file.close() + if fileHandle: + fileHandle.close() self.close() From 8e7d29adf129c96d901ce753b9f10c71453ab46b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Jan 2011 19:46:55 +0000 Subject: [PATCH 3/7] Amend Service Item Title --- openlp/core/lib/serviceitem.py | 12 ++++++++++++ openlp/core/ui/servicemanager.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 276563eba..01a5623df 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -314,6 +314,18 @@ class ServiceItem(object): path, text_image[u'title'], text_image[u'image'] ) self._new_item() + def get_title(self): + """ + Returns the title of the service item. + """ + if self.is_text(): + return self.title + else: + if len(self._raw_frames) > 1: + return self.title + else: + return self._raw_frames[0][u'title'] + def merge(self, other): """ Updates the _uuid with the value from the original one diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9470b419f..8ae844940 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -833,7 +833,7 @@ class ServiceManager(QtGui.QWidget): else: treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) - treewidgetitem.setText(0, serviceitem.title) + treewidgetitem.setText(0, serviceitem.get_title()) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) @@ -1176,7 +1176,7 @@ class ServiceManager(QtGui.QWidget): for item in self.serviceItems: service_item = item[u'service_item'] data_item = {} - data_item[u'title'] = unicode(service_item.title) + data_item[u'title'] = unicode(service_item.get_title()) data_item[u'plugin'] = unicode(service_item.name) data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) From daf545bc06e5f36dc32b0e581f5db21f1e8d77fc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 07:53:21 +0000 Subject: [PATCH 4/7] Fix up service item display changes --- openlp/core/lib/serviceitem.py | 7 +++++-- openlp/core/ui/servicemanager.py | 4 ++-- openlp/plugins/presentations/lib/mediaitem.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 01a5623df..c74b89144 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -59,6 +59,7 @@ class ItemCapabilities(object): OnLoadUpdate = 8 AddIfNewItem = 9 ProvidesOwnDisplay = 10 + AllowsDetailedTitleDisplay = 11 class ServiceItem(object): @@ -314,14 +315,16 @@ class ServiceItem(object): path, text_image[u'title'], text_image[u'image'] ) self._new_item() - def get_title(self): + def get_display_title(self): """ Returns the title of the service item. """ if self.is_text(): return self.title else: - if len(self._raw_frames) > 1: + if ItemCapabilities.AllowsDetailedTitleDisplay in self.capabilities: + return self._raw_frames[0][u'title'] + elif len(self._raw_frames) > 1: return self.title else: return self._raw_frames[0][u'title'] diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8ae844940..57a82722e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -833,7 +833,7 @@ class ServiceManager(QtGui.QWidget): else: treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png')) - treewidgetitem.setText(0, serviceitem.get_title()) + treewidgetitem.setText(0, serviceitem.get_display_title()) treewidgetitem.setToolTip(0, serviceitem.notes) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) @@ -1176,7 +1176,7 @@ class ServiceManager(QtGui.QWidget): for item in self.serviceItems: service_item = item[u'service_item'] data_item = {} - data_item[u'title'] = unicode(service_item.get_title()) + data_item[u'title'] = unicode(service_item.get_display_title()) data_item[u'plugin'] = unicode(service_item.name) data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index e72d97be1..43cb3dab0 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -250,6 +250,7 @@ class PresentationMediaItem(MediaManagerItem): service_item.title = unicode(self.displayTypeComboBox.currentText()) service_item.shortname = unicode(self.displayTypeComboBox.currentText()) service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) + service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay) shortname = service_item.shortname if shortname: for item in items: From 5f46426f93f149ff6013513519073d3a76c3c9bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 08:26:14 +0000 Subject: [PATCH 5/7] More songusage cleanups --- openlp/plugins/songusage/forms/songusagedeleteform.py | 9 +++++++-- openlp/plugins/songusage/forms/songusagedetaildialog.py | 1 + openlp/plugins/songusage/forms/songusagedetailform.py | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index f83ec8c82..a4cfd84b7 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -26,7 +26,7 @@ from PyQt4 import QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, Receiver from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedeletedialog import Ui_SongUsageDeleteDialog @@ -55,4 +55,9 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): deleteDate = self.deleteCalendar.selectedDate().toPyDate() self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate) - self.close() \ No newline at end of file + Receiver.send_message(u'openlp_information_message', { + u'title': translate('SongUsagePlugin.SongUsageDeleteForm', + 'Deletion Sucessful'), + u'message': translate('SongUsagePlugin.SongUsageDeleteForm', + 'All requested data has been deleted sucessfully. ')}) + self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 87d2d5ffe..ec1f69d7e 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -61,6 +61,7 @@ class Ui_SongUsageDetailDialog(object): self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit.setObjectName(u'fileLineEdit') self.fileLineEdit.setReadOnly(True) + self.fileLineEdit.setEnabled(False) self.horizontalLayout.addWidget(self.fileLineEdit) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton.setIcon( diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 88e3b1450..f02820b0d 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -30,7 +30,8 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate, check_directory_exists +from openlp.core.lib import SettingsManager, translate, Receiver, \ + check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -110,6 +111,12 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): instance.usagedate, instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors) fileHandle.write(record.encode(u'utf-8')) + Receiver.send_message(u'openlp_information_message', { + u'title': translate('SongUsagePlugin.SongUsageDetailForm', + 'Report Creation'), + u'message': unicode(translate( + 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' + 'has been sucessfully created. ')) % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: From 003e572896a625e881dbf4cb3b0f08c0c70a38da Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 09:56:05 +0000 Subject: [PATCH 6/7] More Up / Down errors --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 57a82722e..22a873855 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -178,7 +178,7 @@ class ServiceManager(QtGui.QWidget): translate('OpenLP.ServiceManager', 'Move &down'), None, translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), + 'Moves the selection down the window.'), self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( From 336730d943fedac66ad9fe6de41696177bf99a12 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Jan 2011 10:01:29 +0000 Subject: [PATCH 7/7] Spellings --- openlp/plugins/songusage/forms/songusagedeleteform.py | 4 ++-- openlp/plugins/songusage/forms/songusagedetailform.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index a4cfd84b7..c03fe15a3 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -57,7 +57,7 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): SongUsageItem.usagedate <= deleteDate) Receiver.send_message(u'openlp_information_message', { u'title': translate('SongUsagePlugin.SongUsageDeleteForm', - 'Deletion Sucessful'), + 'Deletion Successful'), u'message': translate('SongUsagePlugin.SongUsageDeleteForm', - 'All requested data has been deleted sucessfully. ')}) + 'All requested data has been deleted successfully. ')}) self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index f02820b0d..ff8ec4858 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -116,7 +116,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): 'Report Creation'), u'message': unicode(translate( 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' - 'has been sucessfully created. ')) % outname}) + 'has been successfully created. ')) % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: