controller.utils.keyword_result_model_light
- File:
EuljiroWorship/controller/utils/keyword_result_model_light.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.
Lightweight QAbstractTableModel for displaying Bible keyword search results.
This module defines a minimal table model optimized for keyword search output:
Two-column layout: Bible reference and verse text
Designed for read-only display in QTableView
Supports tooltip display of highlighted (HTML-formatted) verse text
Uses standard book name mapping for localized display
The model is intentionally lightweight and stateless, suitable for frequent replacement when running new keyword searches.
- class controller.utils.keyword_result_model_light.KeywordResultTableModelLight(*args, **kwargs)[source]
Bases:
QAbstractTableModelLightweight table model for Bible keyword search results.
This model presents search results in exactly two columns:
Column 0: Bible reference (localized book name + chapter:verse)
Column 1: Verse text
Design notes:
Read-only model (no editing or mutation support)
Optimized for rapid recreation on each search
Tooltip role is used to expose highlighted (HTML) text for delegates
- results
List of search result dictionaries.
Each entry is expected to contain:
bookchapterversetexthighlighted(optional)
- Type:
list[dict]
- book_names
Mapping from internal book IDs to localized (Korean) book names.
- Type:
dict[str, str]
- __init__(results)[source]
Initialize the model with keyword search results.
- Parameters:
results (list[dict]) –
List of search result entries. Each dictionary should include at least the following keys:
book
chapter
verse
text
An optional
highlightedfield may be provided for tooltip display.- Returns:
None
- load_book_names()[source]
Load localized Bible book names from the standard book definition file.
Reads the JSON file defined by
core.config.paths.STANDARD_BOOK_FILEand extracts Korean book names for display in the reference column.- Returns:
Mapping from internal book ID to Korean book name. Returns an empty dictionary if loading fails.
- Return type:
dict[str, str]
- rowCount(parent=PySide6.QtCore.QModelIndex)[source]
Return the number of rows in the model.
- Parameters:
parent (QModelIndex) – Unused parent index (required by Qt interface).
- Returns:
Number of search result entries.
- Return type:
int
- columnCount(parent=PySide6.QtCore.QModelIndex)[source]
Return the number of columns in the model.
This model always exposes exactly two columns:
Reference
Verse text
- Parameters:
parent (QModelIndex) – Unused parent index (required by Qt interface).
- Returns:
Number of columns (always 2).
- Return type:
int
- data(index, role=PySide6.QtCore.Qt.DisplayRole)[source]
Return data for the given index and role.
Supported roles are:
Qt.DisplayRole
Column 0 returns the formatted Bible reference (book_chapter:verse).
Column 1 returns the verse text.
Qt.ToolTipRole
Column 1 returns highlighted HTML text if available; otherwise, the plain verse text is returned.
- Parameters:
index (QModelIndex) – Model index identifying the row and column.
role (Qt.ItemDataRole) – Requested data role.
- Returns:
Data for the given role, or None if not applicable.
- Return type:
str | None
- headerData(section, orientation, role=PySide6.QtCore.Qt.DisplayRole)[source]
Return header labels for the table view.
Provides Korean column headers for horizontal orientation.
- Parameters:
section (int) – Column index.
orientation (Qt.Orientation) – Header orientation (horizontal or vertical).
role (Qt.ItemDataRole) – Requested data role.
- Returns:
Column header label if applicable, otherwise None.
- Return type:
str | None