Skip to content

Add sub-events: let events belong to one or more super-events#2456

Open
dsblank wants to merge 2 commits into
gramps-project:masterfrom
dsblank:feature/sub-events
Open

Add sub-events: let events belong to one or more super-events#2456
dsblank wants to merge 2 commits into
gramps-project:masterfrom
dsblank:feature/sub-events

Conversation

@dsblank

@dsblank dsblank commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Implements the community-requested sub-events feature (events can belong to one or more "super-events", browsable as a hierarchy) discussed in:

Design mirrors the existing Place hierarchy (placeref_list): a plain super_event_list: list[EventHandle] on Event, no new secondary-object class, no new database tables.

  • Data modelEvent.super_event_list, with serialize/schema, handle-reference methods, merge() union with a self-reference guard, and accessors.
  • Migration — schema version bumped to (23, 0, 0) with gramps_upgrade_23(). Sub-event lookups reuse the existing indexed backlink table via find_backlink_handles() — no full-table scan.
  • Merge handling — fixes a MergeError that would otherwise fire as soon as an event gains an Event-class backlink (merging a super-event that other events point to).
  • Editor UI — a new "Part of" tab on the event editor (add/remove/reorder super-events), with a cycle guard using the same find_backlink_handles pattern the place editor already uses.
  • Tree view — a new "Event Tree" view alongside the existing flat Events view, following the same List/Tree split Places already has. Built without a new DB schema (in-memory BFS ordering).
  • XML<partof hlink="..."/> added to exportxml.py/importxml.py, grampsxml.dtd, grampsxml.rng, with the XML version bumped so the relationship survives export/import instead of being silently dropped.

Deferred (not in this PR, by design): an optional merge-dialog warning when merging events with sub-event relationships, and gramplet/report support for showing sub-event structure (existing reports are unaffected — every event still appears in flat listings).

Test plan

  • New unit/integration tests added for every phase (data model, migration, merge, cycle detection, XML round-trip) — 10,734 tests pass together via python3 -m unittest.
  • mypy clean on the full project.
  • black --check clean on all changed files.
  • Verified EventTreeModel's tree-building logic against a real SQLite-backed database (multi-level nesting, multiple children, unrelated roots, and a cycle-safety case) since a full interactive GTK session wasn't renderable in the sandbox this was built in.
  • Manual GUI smoke test in a real desktop session (editor "Part of" tab, Event Tree view) — not yet done by a human; recommended before merge.

🤖 Generated with Claude Code

dsblank added 2 commits July 3, 2026 13:03
Events can now reference zero or more super-events via a new
super_event_list field (Event.get_super_event_list/set_super_event_list/
add_super_event), mirroring how Place.placeref_list already lets a place
belong to more than one enclosing place. This lets researchers group
related events (e.g. individual legs of a multi-day emigration journey)
under a containing event, and browse them hierarchically.

Database changes:
- Event gains super_event_list; handle-reference methods, merge(), and
  get_referenced_handles() are updated so deleting or merging a
  super-event keeps every sub-event's list consistent.
- Schema version bumped to (23, 0, 0) with a matching upgrade step.
- Sub-event lookups reuse the existing indexed backlink table via
  find_backlink_handles(), so no full-table scan is needed.
- Merging an event that others reference as their super-event no longer
  raises MergeError; a self-reference guard prevents a merged event from
  becoming its own super-event.

UI changes:
- The event editor gains a "Part of" tab to add, remove, and reorder an
  event's super-events, with a cycle guard reusing the same
  find_backlink_handles pattern already used by the place editor.
- A new "Event Tree" view shows events nested under their primary
  super-event, alongside the existing flat Events view, following the
  same List/Tree split already used for Places.

Gramps XML changes:
- Events can now write and read a <partof hlink="..."/> element per
  super-event; the DTD, RelaxNG schema, and XML version are updated
  accordingly so the relationship survives export/import.

Issue #10672.
supereventembedlist.py and eventtreeview.py contain translatable
strings and are added to POTFILES.in. The new test files and the
plain supereventmodel.py have none and are added to POTFILES.skip.

Issue #10672.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant