adsfolio.gui.models
Qt models for the paged PDF library table.
- class adsfolio.gui.models.FileTableModel(registry, query, columns=(Column(key='title', header='Title', width=380, getter=<function _title>, sortable=True), Column(key='author', header='First author', width=160, getter=<function _author>, sortable=True), Column(key='author_count', header='N_author', width=70, getter=<function <lambda>>, sortable=True), Column(key='year', header='Year', width=60, getter=<function <lambda>>, sortable=True), Column(key='pub', header='Journal', width=120, getter=<function _pub>, sortable=True), Column(key='citation_count', header='Citations', width=75, getter=<function <lambda>>, sortable=True), Column(key='bibcode', header='Bibcode', width=190, getter=<function <lambda>>, sortable=True), Column(key='arxiv', header='arXiv', width=120, getter=<function arxiv_id>, sortable=True), Column(key='status', header='', width=22, getter=<function <lambda>>, sortable=True), Column(key='filename', header='Filename', width=260, getter=<function _filename>, sortable=True), Column(key='size_bytes', header='Size', width=80, getter=<function _size>, sortable=True), Column(key='first_seen_at', header='Added', width=140, getter=<function <lambda>>, sortable=True), Column(key='mtime_ns', header='Modified', width=140, getter=<function _mtime>, sortable=True), Column(key='duplicate_kind', header='Duplicate', width=110, getter=<function _duplicate>, sortable=True)), parent=None)[source]
Bases:
PySide6.QtCore.QAbstractTableModelTable model that pages one sorted snapshot of a
PdfRegistryquery.- canFetchMore(parent=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)[source]
Return whether the snapshot holds rows not yet shown.
- Parameters:
parent (PySide6.QtCore.QModelIndex)
- Return type:
- columnCount(parent=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)[source]
Return the number of visible columns.
- Parameters:
parent (PySide6.QtCore.QModelIndex)
- Return type:
- property columns: tuple[adsfolio.gui.library.Column, ...][source]
Return the active table column definitions.
- data(index, role=ItemDataRole.DisplayRole)[source]
Return display and presentation data for index.
- Parameters:
index (PySide6.QtCore.QModelIndex)
role (int)
- Return type:
- fetchMore(parent=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)[source]
Show the next
PAGE_SIZEsnapshot rows without querying.- Parameters:
parent (PySide6.QtCore.QModelIndex)
- Return type:
None
- headerData(section, orientation, role=ItemDataRole.DisplayRole)[source]
Return column headers.
- Parameters:
section (int)
orientation (PySide6.QtCore.Qt.Orientation)
role (int)
- Return type:
- property query: adsfolio.gui.library.FileQuery[source]
Return the active file query.
- query_failed
- property records: tuple[dict[str, Any], ...][source]
Return every record of the current query, loaded or not, in order.
- rowCount(parent=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)[source]
Return the number of rows currently loaded into the model.
- Parameters:
parent (PySide6.QtCore.QModelIndex)
- Return type:
- set_column_fonts(fonts, colors=None)[source]
Apply optional fixed-width fonts and text colors by column key.
- Parameters:
fonts (dict[str, PySide6.QtGui.QFont])
colors (dict[str, PySide6.QtGui.QColor] | None)
- Return type:
None
- set_columns(columns)[source]
Replace the active table columns and reload column layout.
- Parameters:
columns (Sequence[Column]) – New sequence of column definitions.
- Return type:
None
- set_query(query)[source]
Replace the query and reload the model.
- Parameters:
query (adsfolio.gui.library.FileQuery)
- Return type:
None
- set_registry(registry, query=None)[source]
Replace the registry, and optionally the query, with one reload.
- set_timestamp_format(timestamp_format)[source]
Apply an ISO 8601 or custom
strftimetimestamp format.- Parameters:
timestamp_format (str)
- Return type:
None
- sort(column, order=SortOrder.AscendingOrder)[source]
Re-query SQLite using the selected sortable column.
- Parameters:
column (int)
order (PySide6.QtCore.Qt.SortOrder)
- Return type:
None
- staticMetaObject = PySide6.QtCore.QMetaObject("FileTableModel" inherits "QAbstractTableModel": Methods: #76 type=Signal, signature=query_failed(QString), parameters=QString )
- class adsfolio.gui.models.FirstAuthorDelegate(parent=None)[source]
Bases:
adsfolio.gui.models.RowHeightDelegateDraw the first author’s surname in bold without changing the model text.
- Parameters:
parent (Any)
- paint(painter, option, index)[source]
Paint only the surname in bold while retaining native row styling.
- Parameters:
painter (Any)
index (PySide6.QtCore.QModelIndex)
- Return type:
None
- staticMetaObject = PySide6.QtCore.QMetaObject("FirstAuthorDelegate" inherits "RowHeightDelegate": )
- class adsfolio.gui.models.LibraryTableView(parent=None)[source]
Bases:
PySide6.QtWidgets.QTreeViewScroll horizontally in smaller steps for discrete wheels and while Shift is held.
- Parameters:
parent (Any)
- eventFilter(watched, event)[source]
Apply the same discrete horizontal speed over the header and scrollbars.
- Parameters:
watched (PySide6.QtCore.QObject)
event (PySide6.QtCore.QEvent)
- Return type:
- keyPressEvent(event)[source]
Move between rows without scrolling sideways.
- Parameters:
event (PySide6.QtGui.QKeyEvent)
- Return type:
None
- mousePressEvent(event)[source]
Select the clicked row without scrolling sideways.
- Parameters:
event (PySide6.QtGui.QMouseEvent)
- Return type:
None
- scrollTo(index, hint=ScrollHint.EnsureVisible)[source]
Scroll to an index, and keep the horizontal position for user row moves.
The view selects whole rows. After a click or key press, Qt’s default also scrolls sideways to show the current cell, so a click on a partly hidden column moved the table. A direct call still scrolls to the column.
- Parameters:
- Return type:
None
- staticMetaObject = PySide6.QtCore.QMetaObject("LibraryTableView" inherits "QTreeView": )
- timerEvent(event)[source]
Keep the horizontal position when Qt’s delayed click scroll runs.
After a mouse press, Qt waits for the double-click interval plus 100 ms and then scrolls to the clicked cell from this timer.
- Parameters:
event (PySide6.QtCore.QTimerEvent)
- Return type:
None
- wheelEvent(event)[source]
Use one tenth of a wheel page for discrete horizontal or Shift scrolling.
- Parameters:
event (PySide6.QtGui.QWheelEvent)
- Return type:
None
- class adsfolio.gui.models.LinkDelegate(brand, parent=None)[source]
Bases:
adsfolio.gui.models.RowHeightDelegateRender external links as text or compact branded badges.
- Parameters:
brand (str)
parent (Any)
- paint(painter, option, index)[source]
Paint a full link or a compact badge according to cell width.
- Parameters:
painter (Any)
index (PySide6.QtCore.QModelIndex)
- Return type:
None
- static requires_icon(text, available_width, font)[source]
Return whether the link text needs compact rendering.
- Parameters:
text (str)
available_width (int)
font (PySide6.QtGui.QFont)
- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("LinkDelegate" inherits "RowHeightDelegate": )
- class adsfolio.gui.models.ResolutionDelegate(parent=None)[source]
Bases:
adsfolio.gui.models.RowHeightDelegateDraw a compact marker for a record’s ADS link or local-metadata state.
- Parameters:
parent (Any)
- paint(painter, option, index)[source]
Preserve native item styling, then draw the resolved-state marker.
- Parameters:
painter (Any)
index (PySide6.QtCore.QModelIndex)
- Return type:
None
- staticMetaObject = PySide6.QtCore.QMetaObject("ResolutionDelegate" inherits "RowHeightDelegate": )
- class adsfolio.gui.models.RowHeightDelegate(parent=None)[source]
Bases:
PySide6.QtWidgets.QStyledItemDelegateApply an optional fixed height to table item geometry.
When highlight is set, the delegate also marks matched search text.
- Parameters:
parent (Any)
- highlight: adsfolio.gui.models.SearchHighlight | None
- initStyleOption(option, index)[source]
Move a file row in a folder tree left, under its folder icon.
A file row has no folding arrow, so its own indentation step is empty. The cell content starts there instead, so the file icon lines up with the folder icon above it. Folder rows keep their indentation.
- Parameters:
index (PySide6.QtCore.QModelIndex)
- Return type:
None
- paint(painter, option, index)[source]
Paint the native item, then mark matched search text.
- Parameters:
painter (Any)
index (PySide6.QtCore.QModelIndex)
- Return type:
None
- set_row_height(height)[source]
Set the fixed table-row height and refresh delegate geometry.
- Parameters:
height (int | None)
- Return type:
None
- sizeHint(option, index)[source]
Return the native size or the configured fixed row height.
- Parameters:
index (PySide6.QtCore.QModelIndex)
- Return type:
- staticMetaObject = PySide6.QtCore.QMetaObject("RowHeightDelegate" inherits "QStyledItemDelegate": )
- class adsfolio.gui.models.SearchHighlight[source]
Bases:
objectHold the active search for highlighting matched text in table cells.
A term with a field name highlights in the columns that display that field. A plain term highlights in the columns of the default fields, or in every text column when all fields are searched.
- adsfolio.gui.models.paint_highlights(painter, rect, spans, advance, visible, height)[source]
Draw translucent marks behind the visible part of matched text.
- Parameters:
painter (QPainter) – Painter of the cell.
rect (QRect) – Rectangle of the cell text. Marks are clipped to it.
spans (Sequence[tuple[int, int]]) – Character spans to mark.
advance (Callable[[int], int]) – Return the x offset of a character index from the text start.
visible (int) – Number of characters shown before an elision mark.
height (int) – Font line height.
- Return type:
None