mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Merge pull request #869 from Arthur-Milchior/trip_new_field_name
New field name checks are more specific
This commit is contained in:
commit
904419b052
2 changed files with 10 additions and 1 deletions
|
@ -12,3 +12,5 @@ fields-reverse-text-direction-rtl = Reverse text direction (RTL)
|
||||||
fields-size = Size:
|
fields-size = Size:
|
||||||
fields-sort-by-this-field-in-the = Sort by this field in the browser
|
fields-sort-by-this-field-in-the = Sort by this field in the browser
|
||||||
fields-that-field-name-is-already-used = That field name is already used.
|
fields-that-field-name-is-already-used = That field name is already used.
|
||||||
|
fields-name-first-letter-not-valid = The field name should not start with #, ^ or /.
|
||||||
|
fields-name-invalid-letter = The field name should not contain :, ", { or }.
|
||||||
|
|
|
@ -82,9 +82,16 @@ class FieldDialog(QDialog):
|
||||||
self.loadField(idx)
|
self.loadField(idx)
|
||||||
|
|
||||||
def _uniqueName(self, prompt, ignoreOrd=None, old=""):
|
def _uniqueName(self, prompt, ignoreOrd=None, old=""):
|
||||||
txt = getOnlyText(prompt, default=old).replace('"', "")
|
txt = getOnlyText(prompt, default=old).replace('"', "").strip()
|
||||||
if not txt:
|
if not txt:
|
||||||
return
|
return
|
||||||
|
if txt[0] in "#^/":
|
||||||
|
showWarning(tr(TR.FIELDS_NAME_FIRST_LETTER_NOT_VALID))
|
||||||
|
return
|
||||||
|
for letter in """:{"}""":
|
||||||
|
if letter in txt:
|
||||||
|
showWarning(tr(TR.FIELDS_NAME_INVALID_LETTER))
|
||||||
|
return
|
||||||
for f in self.model["flds"]:
|
for f in self.model["flds"]:
|
||||||
if ignoreOrd is not None and f["ord"] == ignoreOrd:
|
if ignoreOrd is not None and f["ord"] == ignoreOrd:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue