gui.ui.tab_verse_selection_manager

File:

EuljiroBible/gui/ui/tab_verse_selection_manager.py

Author:

Benjamin Jaedon Choi - https://github.com/saintbenjamin

Affiliated Church:

The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]

Address:

The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea

Telephone:

+82-2-2266-3070

E-mail:

euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)

License:

MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.

Handles version selection and book/chapter dropdown synchronization in the TabVerse panel.

class gui.ui.tab_verse_selection_manager.TabVerseSelectionManager(bible_data, version_helper, tr_func)[source]

Bases: object

Selection and dropdown manager for the TabVerse UI.

This class manages version checkbox layout and selection state, the version summary label, and the book/chapter dropdown behavior for the verse tab. It coordinates with VerseVersionHelper to validate version selections and compute the set of common books available across selected versions.

bible_data

Bible data loader instance used to resolve standard book names and verse structures.

Type:

BibleDataLoader

version_helper

Helper used to read selected versions, validate selections, and compute common books.

Type:

VerseVersionHelper

tr

Translation function used for localized UI messages.

Type:

Callable[[str], str]

__init__(bible_data, version_helper, tr_func)[source]

Initialize the selection manager with Bible data and helper dependencies.

Parameters:
  • bible_data (BibleDataLoader) – Bible data loader instance.

  • version_helper (VerseVersionHelper) – Helper used to manage selected versions.

  • tr_func (Callable[[str], str]) – Translation function for localized UI strings.

create_version_checkbox(parent, version_name)[source]

Create a version selection checkbox for a given Bible version.

The checkbox label uses the GUI alias mapping when available, while the underlying version key is stored on the widget as version_key.

Parameters:
  • parent (QWidget) – Parent UI instance used to access bible_data and update callbacks.

  • version_name (str) – Full version identifier.

Returns:

Configured checkbox instance.

Return type:

QCheckBox

update_grid_layout(parent)[source]

Reflow the version checkbox grid layout based on the current viewport width.

This recomputes the number of columns from the available width and places checkboxes into the grid accordingly. Platform-specific width ratios are used to account for rendering/scrollbar differences.

Parameters:

parent (QWidget) – TabVerse instance containing the version scroll area and grid layout.

update_version_summary(parent)[source]

Update the selected-version summary label and refresh dependent dropdowns.

If no versions are selected, this clears book/chapter/verse inputs and shows a warning dialog. Otherwise, it updates the summary label (alias vs full name) and refreshes the book dropdown to reflect books common to all selected versions.

Parameters:

parent (QWidget) – TabVerse instance containing summary label and dropdown widgets.

populate_book_dropdown(parent, lang_code=None)[source]

Populate the book dropdown with the full standard book list.

This is used to initialize the book dropdown independent of version filtering.

Parameters:
  • parent (QWidget) – TabVerse instance containing the book combo box.

  • lang_code (str | None) – Language code used for display names (default: “ko”).

update_book_dropdown(parent, lang_code=None)[source]

Update the book dropdown to include only books common to all selected versions.

This validates the selected versions, computes the intersection of supported books, updates the dropdown entries accordingly, and attempts to restore any previous book/chapter/verse selections when possible.

Parameters:
  • parent (QWidget) – TabVerse instance containing book/chapter/verse input widgets.

  • lang_code (str | None) – Language code used for display names. If not provided, it is inferred from the current translation context.

update_chapter_dropdown(parent)[source]

Update the chapter dropdown for the currently selected book.

This resolves the internal book key, reads available chapter indices from the selected version’s verse structure, and fills the chapter combo box with a 1..max range.

Parameters:

parent (QWidget) – TabVerse instance containing the book and chapter widgets.