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)
if filter_clause is not None:
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.all()

View File

@ -34,26 +34,33 @@ class Ui_SongUsageDeleteDialog(object):
def setupUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setObjectName(u'songUsageDeleteDialog')
songUsageDeleteDialog.resize(291, 243)
self.layoutWidget = QtGui.QWidget(songUsageDeleteDialog)
self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 247, 181))
self.layoutWidget.setObjectName(u'layoutWidget')
self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget)
self.verticalLayout = QtGui.QVBoxLayout(songUsageDeleteDialog)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setContentsMargins(8, 8, 8, 8)
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.setGridVisible(True)
self.deleteCalendar.setVerticalHeaderFormat(
QtGui.QCalendarWidget.NoVerticalHeader)
self.deleteCalendar.setObjectName(u'deleteCalendar')
self.verticalLayout.addWidget(self.deleteCalendar)
self.buttonBox = create_accept_reject_button_box(
songUsageDeleteDialog, True)
self.buttonBox.setGeometry(QtCore.QRect(30, 210, 245, 25))
self.buttonBox = QtGui.QDialogButtonBox(songUsageDeleteDialog)
self.buttonBox.setStandardButtons(
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
self.buttonBox.setObjectName(u'buttonBox')
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(songUsageDeleteDialog)
QtCore.QMetaObject.connectSlotsByName(songUsageDeleteDialog)
def retranslateUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setWindowTitle(
translate('SongUsagePlugin.SongUsageDeleteForm',
'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 #
###############################################################################
from PyQt4 import QtGui
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, Receiver
from openlp.plugins.songusage.lib.db import SongUsageItem
@ -42,23 +42,32 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
self.manager = manager
QtGui.QDialog.__init__(self, parent)
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,
translate('SongUsagePlugin.SongUsageDeleteForm',
'Delete Selected Song Usage Events?'),
translate('SongUsagePlugin.SongUsageDeleteForm',
'Are you sure you want to delete selected Song Usage data?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok |
QtGui.QMessageBox.Cancel),
QtGui.QMessageBox.Cancel)
if ret == QtGui.QMessageBox.Ok:
'Are you sure you want to delete selected Song Usage '
'data?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
if ret == QtGui.QMessageBox.Yes:
deleteDate = self.deleteCalendar.selectedDate().toPyDate()
self.manager.delete_all_objects(SongUsageItem,
SongUsageItem.usagedate <= deleteDate)
Receiver.send_message(u'openlp_information_message', {
u'title': translate('SongUsagePlugin.SongUsageDeleteForm',
'Deletion Successful'),
u'message': translate('SongUsagePlugin.SongUsageDeleteForm',
'All requested data has been deleted successfully. ')})
self.close()
u'message': translate(
'SongUsagePlugin.SongUsageDeleteForm',
'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.resize(609, 413)
self.verticalLayout = QtGui.QVBoxLayout(songUsageDetailDialog)
self.verticalLayout.setSpacing(8)
self.verticalLayout.setContentsMargins(8, 8, 8, 8)
self.verticalLayout.setObjectName(u'verticalLayout')
self.dateRangeGroupBox = QtGui.QGroupBox(songUsageDetailDialog)
self.dateRangeGroupBox.setObjectName(u'dateRangeGroupBox')
self.verticalLayout2 = QtGui.QVBoxLayout(self.dateRangeGroupBox)
self.verticalLayout2.setObjectName(u'verticalLayout2')
self.dateHorizontalLayout = QtGui.QHBoxLayout()
self.dateHorizontalLayout = QtGui.QHBoxLayout(self.dateRangeGroupBox)
self.dateHorizontalLayout.setSpacing(8)
self.dateHorizontalLayout.setContentsMargins(8, 8, 8, 8)
self.dateHorizontalLayout.setObjectName(u'dateHorizontalLayout')
self.fromDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.fromDate.setObjectName(u'fromDate')
@ -53,26 +55,25 @@ class Ui_SongUsageDetailDialog(object):
self.toDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.toDate.setObjectName(u'toDate')
self.dateHorizontalLayout.addWidget(self.toDate)
self.verticalLayout2.addLayout(self.dateHorizontalLayout)
self.verticalLayout.addWidget(self.dateRangeGroupBox)
self.fileGroupBox = QtGui.QGroupBox(self.dateRangeGroupBox)
self.fileGroupBox.setObjectName(u'fileGroupBox')
self.verticalLayout4 = QtGui.QVBoxLayout(self.fileGroupBox)
self.verticalLayout4.setObjectName(u'verticalLayout4')
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(u'horizontalLayout')
self.fileHorizontalLayout = QtGui.QHBoxLayout(self.fileGroupBox)
self.fileHorizontalLayout.setSpacing(8)
self.fileHorizontalLayout.setContentsMargins(8, 8, 8, 8)
self.fileHorizontalLayout.setObjectName(u'fileHorizontalLayout')
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.fileHorizontalLayout.addWidget(self.fileLineEdit)
self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox)
self.saveFilePushButton.setMaximumWidth(
self.saveFilePushButton.size().height())
self.saveFilePushButton.setIcon(
build_icon(u':/general/general_open.png'))
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.horizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout4.addLayout(self.horizontalLayout)
self.verticalLayout2.addWidget(self.fileGroupBox)
self.verticalLayout.addWidget(self.dateRangeGroupBox)
self.fileHorizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout.addWidget(self.fileGroupBox)
self.buttonBox = create_accept_reject_button_box(
songUsageDetailDialog, True)
self.verticalLayout.addWidget(self.buttonBox)

View File

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