better warning about setting templates to nothing

This commit is contained in:
Damien Elmes 2010-02-06 02:01:26 +09:00
parent fb6d5a8556
commit 7d74be890b

View file

@ -1383,18 +1383,16 @@ class ChangeModelDialog(QDialog):
# check maps # check maps
fmap = self.getFieldMap() fmap = self.getFieldMap()
cmap = self.getTemplateMap() cmap = self.getTemplateMap()
def any(l):
for x in l:
if x:
return True
return False
if not cmap or (self.targetModel != self.oldModel and if not cmap or (self.targetModel != self.oldModel and
not fmap): not fmap):
return ui.utils.showInfo( return ui.utils.showInfo(
_("Targets must be unique."), parent=self) _("Targets must be unique."), parent=self)
if not any(cmap.values()): if [c for c in cmap.values() if not c]:
return ui.utils.showInfo( if not ui.utils.askUser(_("""\
_("Must map at least one template."), parent=self) Any cards with templates mapped to nothing will be deleted.
If a fact has no remaining cards, it will be lost.
Are you sure you want to continue?"""), parent=self):
return
if self.targetModel == self.oldModel: if self.targetModel == self.oldModel:
self.ret = (self.targetModel, None, cmap) self.ret = (self.targetModel, None, cmap)
return QDialog.accept(self) return QDialog.accept(self)