Fix #7548: Edit bulk m'data won't edit all if one instance is already specified. The None value was ambiguous, meaning both None and No Change. Added a 'Do not change' option to eliminate the ambiguity.

This commit is contained in:
Charles Haley 2010-11-27 12:09:12 +00:00
parent a5cadce603
commit 9e756e0a96

View File

@ -437,7 +437,7 @@ class BulkBool(BulkBase, Bool):
if tweaks['bool_custom_columns_are_tristate'] == 'no' and val is None: if tweaks['bool_custom_columns_are_tristate'] == 'no' and val is None:
val = False val = False
if value is not None and value != val: if value is not None and value != val:
return None return 'nochange'
value = val value = val
return value return value
@ -445,19 +445,23 @@ class BulkBool(BulkBase, Bool):
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
QComboBox(parent)] QComboBox(parent)]
w = self.widgets[1] w = self.widgets[1]
items = [_('Yes'), _('No'), _('Undefined')] items = [_('Yes'), _('No'), _('Undefined'), _('Do not change')]
icons = [I('ok.png'), I('list_remove.png'), I('blank.png')] icons = [I('ok.png'), I('list_remove.png'), I('blank.png'), I('blank.png')]
for icon, text in zip(icons, items): for icon, text in zip(icons, items):
w.addItem(QIcon(icon), text) w.addItem(QIcon(icon), text)
def getter(self):
val = self.widgets[1].currentIndex()
return {3: 'nochange', 2: None, 1: False, 0: True}[val]
def setter(self, val): def setter(self, val):
val = {None: 2, False: 1, True: 0}[val] val = {'nochange': 3, None: 2, False: 1, True: 0}[val]
self.widgets[1].setCurrentIndex(val) self.widgets[1].setCurrentIndex(val)
def commit(self, book_ids, notify=False): def commit(self, book_ids, notify=False):
val = self.gui_val val = self.gui_val
val = self.normalize_ui_val(val) val = self.normalize_ui_val(val)
if val != self.initial_val: if val != self.initial_val and val != 'nochange':
if tweaks['bool_custom_columns_are_tristate'] == 'no' and val is None: if tweaks['bool_custom_columns_are_tristate'] == 'no' and val is None:
val = False val = False
self.db.set_custom_bulk(book_ids, val, num=self.col_id, notify=notify) self.db.set_custom_bulk(book_ids, val, num=self.col_id, notify=notify)