Skip to content

Wire the RA sort into the object list's Sort marking menu #630

Description

@brickbots

SortOrder.RA exists in the object list and, once #622 lands, sort() actually
implements it. The user still cannot select it — there is no marking-menu entry
that reaches it, so the sort is dead code.

Why it is unreachable

UIObjectList.__init__ builds the Sort submenu with only two live slots:

callback=MarkingMenu(
    up=MarkingMenuOption(),
    left=MarkingMenuOption(label=_("Nearest"), callback=self.mm_change_sort),
    down=MarkingMenuOption(),                      # <- bare, label="", callback=None
    right=MarkingMenuOption(label=_("Standard"), callback=self.mm_change_sort),
),

Two pieces of code already assume the down slot is RA and are therefore both
dead:

  • __init__: if self.current_sort == SortOrder.RA: self.marking_menu.left.callback.down.selected = True
  • mm_change_sort: if menu_item.label == _("RA"): ...

MarkingMenuOption() defaults to label="" and callback=None, so the slot
renders empty and dispatches nothing.

Fix

Give the down slot its label and callback:

down=MarkingMenuOption(label=_("RA"), callback=self.mm_change_sort),

That is the whole wiring — mm_change_sort and the selected bookkeeping are
already written for it, and #622 supplies the sort() branch and the
_sort_order_label entry.

i18n

None needed. msgid "RA" is already present and translated in all four
catalogues (de, es, fr, zh) — it has been used by the "Sorting by
{sort_order}" toast for some time.

Depends on

#622, which adds the SortOrder.RA branch to sort(). Wiring the menu without
it would give the user a menu entry that changes the label and nothing else.

Acceptance

  • The Sort marking menu shows a third option, and choosing it orders the list by
    right ascension.
  • The header and the in-list "Sort: …" label both read "RA" — both already route
    through _sort_order_label.
  • Re-opening the list with RA active pre-selects the right marking-menu slot.
  • Covered in tests/test_ui_modules.py the way the other sorts are.

Worth deciding while implementing

RA sorting is a plain sorted(..., key=lambda x: x.ra), so it cuts the sky at
RA 0 rather than at the meridian. That is the conventional catalog behaviour and
almost certainly what is wanted, but it is the sort of thing better settled
deliberately than by default.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions