Confirm delete of Custom item

This commit is contained in:
Stevan Pettit 2011-06-07 21:37:07 -04:00
parent c6166453bb
commit 4213dad51c
2 changed files with 44 additions and 3 deletions

View File

@ -47,17 +47,32 @@ class CustomTab(SettingsTab):
self.displayFooterCheckBox.setObjectName(u'displayFooterCheckBox')
self.customModeLayout.addRow(self.displayFooterCheckBox)
self.leftLayout.addWidget(self.customModeGroupBox)
self.leftLayout.addStretch()
self.rightLayout.addStretch()
QtCore.QObject.connect(self.displayFooterCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onDisplayFooterCheckBoxChanged)
self.customUIGroupBox = QtGui.QGroupBox(self.leftColumn)
self.customUIGroupBox.setObjectName(u'customUIGroupBox')
self.customUILayout = QtGui.QFormLayout(self.customUIGroupBox)
self.customUILayout.setObjectName(u'customUILayout')
self.confirmDeleteCheckBox = QtGui.QCheckBox(self.customUIGroupBox)
self.confirmDeleteCheckBox.setObjectName(u'confirmDeleteCheckBox')
self.customUILayout.addRow(self.confirmDeleteCheckBox)
self.leftLayout.addWidget(self.customUIGroupBox)
QtCore.QObject.connect(self.confirmDeleteCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onConfirmDeleteCheckBoxChanged)
self.leftLayout.addStretch()
self.rightLayout.addStretch()
def retranslateUi(self):
self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab',
'Custom Display'))
self.displayFooterCheckBox.setText(
translate('CustomPlugin.CustomTab', 'Display footer'))
self.customUIGroupBox.setTitle(translate('CustomPlugin.CustomTab',
'UI Settings'))
self.confirmDeleteCheckBox.setText(
translate('CustomPlugin.CustomTab', 'Confirm delete'))
def onDisplayFooterCheckBoxChanged(self, check_state):
self.displayFooter = False
@ -65,12 +80,24 @@ class CustomTab(SettingsTab):
if check_state == QtCore.Qt.Checked:
self.displayFooter = True
def onConfirmDeleteCheckBoxChanged(self, check_state):
self.confirmDelete = False
# we have a set value convert to True/False
if check_state == QtCore.Qt.Checked:
self.confirmDelete = True
def load(self):
self.displayFooter = QtCore.QSettings().value(
self.settingsSection + u'/display footer',
QtCore.QVariant(True)).toBool()
self.displayFooterCheckBox.setChecked(self.displayFooter)
self.confirmDelete = QtCore.QSettings().value(
self.settingsSection + u'/confirm delete',
QtCore.QVariant(True)).toBool()
self.confirmDeleteCheckBox.setChecked(self.confirmDelete)
def save(self):
QtCore.QSettings().setValue(self.settingsSection + u'/display footer',
QtCore.QVariant(self.displayFooter))
QtCore.QSettings().setValue(self.settingsSection + u'/confirm delete',
QtCore.QVariant(self.confirmDelete))

View File

@ -200,6 +200,20 @@ class CustomMediaItem(MediaManagerItem):
Remove a custom item from the list and database
"""
if check_item_selected(self.listView, UiStrings().SelectDelete):
self.confirmDelete = QtCore.QSettings().value(
self.settingsSection + u'/confirm delete',
QtCore.QVariant(u'False')).toBool()
items = self.listView.selectedIndexes()
if self.confirmDelete:
if QtGui.QMessageBox.question(self,
translate('CustomPlugin.MediaItem', 'Delete Custom(s)?'),
translate('CustomPlugin.MediaItem',
'Are you sure you want to delete the %n selected custom(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok |
QtGui.QMessageBox.Cancel),
QtGui.QMessageBox.Ok) == QtGui.QMessageBox.Cancel:
return
row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True)
id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0]