Head 1716

This commit is contained in:
Tim Bentley 2011-08-21 05:51:19 +01:00
commit 76c0881559
5 changed files with 65 additions and 45 deletions

View File

@ -223,7 +223,9 @@ class Manager(object):
query = self.session.query(object_class) query = self.session.query(object_class)
if filter_clause is not None: if filter_clause is not None:
query = query.filter(filter_clause) query = query.filter(filter_clause)
if order_by_ref is not None: if isinstance(order_by_ref, list):
return query.order_by(*order_by_ref).all()
elif order_by_ref is not None:
return query.order_by(order_by_ref).all() return query.order_by(order_by_ref).all()
return query.all() return query.all()

View File

@ -34,26 +34,33 @@ class Ui_SongUsageDeleteDialog(object):
def setupUi(self, songUsageDeleteDialog): def setupUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setObjectName(u'songUsageDeleteDialog') songUsageDeleteDialog.setObjectName(u'songUsageDeleteDialog')
songUsageDeleteDialog.resize(291, 243) songUsageDeleteDialog.resize(291, 243)
self.layoutWidget = QtGui.QWidget(songUsageDeleteDialog) self.verticalLayout = QtGui.QVBoxLayout(songUsageDeleteDialog)
self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 247, 181)) self.verticalLayout.setSpacing(8)
self.layoutWidget.setObjectName(u'layoutWidget') self.verticalLayout.setContentsMargins(8, 8, 8, 8)
self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget)
self.verticalLayout.setObjectName(u'verticalLayout') self.verticalLayout.setObjectName(u'verticalLayout')
self.deleteCalendar = QtGui.QCalendarWidget(self.layoutWidget) self.deleteLabel = QtGui.QLabel(songUsageDeleteDialog)
self.deleteLabel.setObjectName(u'deleteLabel')
self.verticalLayout.addWidget(self.deleteLabel)
self.deleteCalendar = QtGui.QCalendarWidget(songUsageDeleteDialog)
self.deleteCalendar.setFirstDayOfWeek(QtCore.Qt.Sunday) self.deleteCalendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
self.deleteCalendar.setGridVisible(True) self.deleteCalendar.setGridVisible(True)
self.deleteCalendar.setVerticalHeaderFormat( self.deleteCalendar.setVerticalHeaderFormat(
QtGui.QCalendarWidget.NoVerticalHeader) QtGui.QCalendarWidget.NoVerticalHeader)
self.deleteCalendar.setObjectName(u'deleteCalendar') self.deleteCalendar.setObjectName(u'deleteCalendar')
self.verticalLayout.addWidget(self.deleteCalendar) self.verticalLayout.addWidget(self.deleteCalendar)
self.buttonBox = create_accept_reject_button_box( self.buttonBox = QtGui.QDialogButtonBox(songUsageDeleteDialog)
songUsageDeleteDialog, True) self.buttonBox.setStandardButtons(
self.buttonBox.setGeometry(QtCore.QRect(30, 210, 245, 25)) QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
self.buttonBox.setObjectName(u'buttonBox') self.buttonBox.setObjectName(u'buttonBox')
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(songUsageDeleteDialog) self.retranslateUi(songUsageDeleteDialog)
QtCore.QMetaObject.connectSlotsByName(songUsageDeleteDialog)
def retranslateUi(self, songUsageDeleteDialog): def retranslateUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setWindowTitle( songUsageDeleteDialog.setWindowTitle(
translate('SongUsagePlugin.SongUsageDeleteForm', translate('SongUsagePlugin.SongUsageDeleteForm',
'Delete Song Usage Data')) 'Delete Song Usage Data'))
self.deleteLabel.setText(
translate('SongUsagePlugin.SongUsageDeleteForm',
'Select the date up to which the song usage data should be '
'deleted. All data recorded before this date will be '
'permanently deleted.'))

View File

@ -25,7 +25,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from PyQt4 import QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, Receiver from openlp.core.lib import translate, Receiver
from openlp.plugins.songusage.lib.db import SongUsageItem from openlp.plugins.songusage.lib.db import SongUsageItem
@ -42,23 +42,32 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
self.manager = manager self.manager = manager
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
QtCore.QObject.connect(
self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onButtonBoxClicked)
def accept(self): def onButtonBoxClicked(self, button):
if self.buttonBox.standardButton(button) == QtGui.QDialogButtonBox.Ok:
ret = QtGui.QMessageBox.question(self, ret = QtGui.QMessageBox.question(self,
translate('SongUsagePlugin.SongUsageDeleteForm', translate('SongUsagePlugin.SongUsageDeleteForm',
'Delete Selected Song Usage Events?'), 'Delete Selected Song Usage Events?'),
translate('SongUsagePlugin.SongUsageDeleteForm', translate('SongUsagePlugin.SongUsageDeleteForm',
'Are you sure you want to delete selected Song Usage data?'), 'Are you sure you want to delete selected Song Usage '
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok | 'data?'),
QtGui.QMessageBox.Cancel), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.Cancel) QtGui.QMessageBox.No),
if ret == QtGui.QMessageBox.Ok: QtGui.QMessageBox.No)
if ret == QtGui.QMessageBox.Yes:
deleteDate = self.deleteCalendar.selectedDate().toPyDate() deleteDate = self.deleteCalendar.selectedDate().toPyDate()
self.manager.delete_all_objects(SongUsageItem, self.manager.delete_all_objects(SongUsageItem,
SongUsageItem.usagedate <= deleteDate) SongUsageItem.usagedate <= deleteDate)
Receiver.send_message(u'openlp_information_message', { Receiver.send_message(u'openlp_information_message', {
u'title': translate('SongUsagePlugin.SongUsageDeleteForm', u'title': translate('SongUsagePlugin.SongUsageDeleteForm',
'Deletion Successful'), 'Deletion Successful'),
u'message': translate('SongUsagePlugin.SongUsageDeleteForm', u'message': translate(
'All requested data has been deleted successfully. ')}) 'SongUsagePlugin.SongUsageDeleteForm',
self.close() 'All requested data has been deleted successfully. ')}
)
self.accept()
else:
self.reject()

View File

@ -35,12 +35,14 @@ class Ui_SongUsageDetailDialog(object):
songUsageDetailDialog.setObjectName(u'songUsageDetailDialog') songUsageDetailDialog.setObjectName(u'songUsageDetailDialog')
songUsageDetailDialog.resize(609, 413) songUsageDetailDialog.resize(609, 413)
self.verticalLayout = QtGui.QVBoxLayout(songUsageDetailDialog) self.verticalLayout = QtGui.QVBoxLayout(songUsageDetailDialog)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setContentsMargins(8, 8, 8, 8)
self.verticalLayout.setObjectName(u'verticalLayout') self.verticalLayout.setObjectName(u'verticalLayout')
self.dateRangeGroupBox = QtGui.QGroupBox(songUsageDetailDialog) self.dateRangeGroupBox = QtGui.QGroupBox(songUsageDetailDialog)
self.dateRangeGroupBox.setObjectName(u'dateRangeGroupBox') self.dateRangeGroupBox.setObjectName(u'dateRangeGroupBox')
self.verticalLayout2 = QtGui.QVBoxLayout(self.dateRangeGroupBox) self.dateHorizontalLayout = QtGui.QHBoxLayout(self.dateRangeGroupBox)
self.verticalLayout2.setObjectName(u'verticalLayout2') self.dateHorizontalLayout.setSpacing(8)
self.dateHorizontalLayout = QtGui.QHBoxLayout() self.dateHorizontalLayout.setContentsMargins(8, 8, 8, 8)
self.dateHorizontalLayout.setObjectName(u'dateHorizontalLayout') self.dateHorizontalLayout.setObjectName(u'dateHorizontalLayout')
self.fromDate = QtGui.QCalendarWidget(self.dateRangeGroupBox) self.fromDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.fromDate.setObjectName(u'fromDate') self.fromDate.setObjectName(u'fromDate')
@ -53,26 +55,25 @@ class Ui_SongUsageDetailDialog(object):
self.toDate = QtGui.QCalendarWidget(self.dateRangeGroupBox) self.toDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.toDate.setObjectName(u'toDate') self.toDate.setObjectName(u'toDate')
self.dateHorizontalLayout.addWidget(self.toDate) self.dateHorizontalLayout.addWidget(self.toDate)
self.verticalLayout2.addLayout(self.dateHorizontalLayout) self.verticalLayout.addWidget(self.dateRangeGroupBox)
self.fileGroupBox = QtGui.QGroupBox(self.dateRangeGroupBox) self.fileGroupBox = QtGui.QGroupBox(self.dateRangeGroupBox)
self.fileGroupBox.setObjectName(u'fileGroupBox') self.fileGroupBox.setObjectName(u'fileGroupBox')
self.verticalLayout4 = QtGui.QVBoxLayout(self.fileGroupBox) self.fileHorizontalLayout = QtGui.QHBoxLayout(self.fileGroupBox)
self.verticalLayout4.setObjectName(u'verticalLayout4') self.fileHorizontalLayout.setSpacing(8)
self.horizontalLayout = QtGui.QHBoxLayout() self.fileHorizontalLayout.setContentsMargins(8, 8, 8, 8)
self.horizontalLayout.setObjectName(u'horizontalLayout') self.fileHorizontalLayout.setObjectName(u'fileHorizontalLayout')
self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox) self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox)
self.fileLineEdit.setObjectName(u'fileLineEdit') self.fileLineEdit.setObjectName(u'fileLineEdit')
self.fileLineEdit.setReadOnly(True) self.fileLineEdit.setReadOnly(True)
self.fileLineEdit.setEnabled(False) self.fileHorizontalLayout.addWidget(self.fileLineEdit)
self.horizontalLayout.addWidget(self.fileLineEdit)
self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox) self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox)
self.saveFilePushButton.setMaximumWidth(
self.saveFilePushButton.size().height())
self.saveFilePushButton.setIcon( self.saveFilePushButton.setIcon(
build_icon(u':/general/general_open.png')) build_icon(u':/general/general_open.png'))
self.saveFilePushButton.setObjectName(u'saveFilePushButton') self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.horizontalLayout.addWidget(self.saveFilePushButton) self.fileHorizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout4.addLayout(self.horizontalLayout) self.verticalLayout.addWidget(self.fileGroupBox)
self.verticalLayout2.addWidget(self.fileGroupBox)
self.verticalLayout.addWidget(self.dateRangeGroupBox)
self.buttonBox = create_accept_reject_button_box( self.buttonBox = create_accept_reject_button_box(
songUsageDetailDialog, True) songUsageDetailDialog, True)
self.verticalLayout.addWidget(self.buttonBox) self.verticalLayout.addWidget(self.buttonBox)

View File

@ -96,6 +96,7 @@ class SongUsagePlugin(Plugin):
self.songUsageActiveButton = QtGui.QToolButton( self.songUsageActiveButton = QtGui.QToolButton(
self.formparent.statusBar) self.formparent.statusBar)
self.songUsageActiveButton.setCheckable(True) self.songUsageActiveButton.setCheckable(True)
self.songUsageActiveButton.setAutoRaise(True)
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin', self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin',
'Toggle the tracking of song usage.')) 'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton') self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')