|
|
@ -32,19 +32,14 @@ class PageAddOperator(AgeOperator, bpy.types.Operator): |
|
|
|
page = age.pages.add() |
|
|
|
page = age.pages.add() |
|
|
|
|
|
|
|
|
|
|
|
# Find the first non-zero ID and suggest that. |
|
|
|
# Find the first non-zero ID and suggest that. |
|
|
|
suffixes = [] |
|
|
|
suffixes = {p.seq_suffix for p in age.pages} |
|
|
|
for p in age.pages: |
|
|
|
if suffixes: |
|
|
|
# Filter out pages with no-id or |
|
|
|
test = set(range(min(suffixes), max(suffixes))) |
|
|
|
if p.seq_suffix: |
|
|
|
|
|
|
|
suffixes.append(p.seq_suffix) |
|
|
|
|
|
|
|
if len(suffixes): |
|
|
|
|
|
|
|
suffixes.sort() |
|
|
|
|
|
|
|
test = set(range(suffixes[0], suffixes[-1])) |
|
|
|
|
|
|
|
missing = test - set(suffixes) |
|
|
|
missing = test - set(suffixes) |
|
|
|
try: |
|
|
|
try: |
|
|
|
suffix = missing.pop() |
|
|
|
suffix = missing.pop() |
|
|
|
except KeyError: |
|
|
|
except KeyError: |
|
|
|
suffix = suffixes[-1] + 1 |
|
|
|
suffix = max(suffixes) + 1 |
|
|
|
page.make_default_name(suffix) |
|
|
|
page.make_default_name(suffix) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# Page 0 is a magic "catch-all" page. The user *may* define it |
|
|
|
# Page 0 is a magic "catch-all" page. The user *may* define it |
|
|
|