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.QAbstractTableModel

Table model that pages one sorted snapshot of a PdfRegistry query.

Parameters:
  • registry (Any | None)

  • query (FileQuery)

  • columns (Sequence[Column] | Any)

  • parent (Any)

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:

bool

columnCount(parent=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)[source]

Return the number of visible columns.

Parameters:

parent (PySide6.QtCore.QModelIndex)

Return type:

int

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:
Return type:

Any

fetchMore(parent=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)[source]

Show the next PAGE_SIZE snapshot rows without querying.

Parameters:

parent (PySide6.QtCore.QModelIndex)

Return type:

None

headerData(section, orientation, role=ItemDataRole.DisplayRole)[source]

Return column headers.

Parameters:
Return type:

Any

property query: adsfolio.gui.library.FileQuery[source]

Return the active file query.

query_failed
record_at(row)[source]

Return the loaded record at row, or None when unavailable.

Parameters:

row (int)

Return type:

dict[str, Any] | None

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:

int

set_column_alignments(alignments)[source]

Apply horizontal alignment overrides by column key.

Parameters:

alignments (dict[str, str])

Return type:

None

set_column_fonts(fonts, colors=None)[source]

Apply optional fixed-width fonts and text colors by column key.

Parameters:
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.

Parameters:
  • registry (object or None) – New registry, or None to empty the model.

  • query (FileQuery, optional) – New query. If omitted, the current query is kept.

Return type:

None

set_timestamp_format(timestamp_format)[source]

Apply an ISO 8601 or custom strftime timestamp format.

Parameters:

timestamp_format (str)

Return type:

None

sort(column, order=SortOrder.AscendingOrder)[source]

Re-query SQLite using the selected sortable column.

Parameters:
Return type:

None

staticMetaObject = PySide6.QtCore.QMetaObject("FileTableModel" inherits "QAbstractTableModel": Methods:   #76 type=Signal, signature=query_failed(QString), parameters=QString )
property total: int[source]

Return the total number of rows matching the current query.

class adsfolio.gui.models.FirstAuthorDelegate(parent=None)[source]

Bases: adsfolio.gui.models.RowHeightDelegate

Draw 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:
Return type:

None

static split_author(value)[source]

Split an ADS-style author name into surname and remaining text.

Parameters:

value (str)

Return type:

tuple[str, str]

staticMetaObject = PySide6.QtCore.QMetaObject("FirstAuthorDelegate" inherits "RowHeightDelegate": )
class adsfolio.gui.models.LibraryTableView(parent=None)[source]

Bases: PySide6.QtWidgets.QTreeView

Scroll 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:
Return type:

bool

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.RowHeightDelegate

Render 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:
Return type:

None

static requires_icon(text, available_width, font)[source]

Return whether the link text needs compact rendering.

Parameters:
Return type:

bool

staticMetaObject = PySide6.QtCore.QMetaObject("LinkDelegate" inherits "RowHeightDelegate": )
class adsfolio.gui.models.ResolutionDelegate(parent=None)[source]

Bases: adsfolio.gui.models.RowHeightDelegate

Draw 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:
Return type:

None

staticMetaObject = PySide6.QtCore.QMetaObject("ResolutionDelegate" inherits "RowHeightDelegate": )
class adsfolio.gui.models.RowHeightDelegate(parent=None)[source]

Bases: PySide6.QtWidgets.QStyledItemDelegate

Apply 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:
Return type:

None

paint(painter, option, index)[source]

Paint the native item, then mark matched search text.

Parameters:
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:
Return type:

PySide6.QtCore.QSize

staticMetaObject = PySide6.QtCore.QMetaObject("RowHeightDelegate" inherits "QStyledItemDelegate": )
class adsfolio.gui.models.SearchHighlight[source]

Bases: object

Hold 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.

column_key(column)[source]

Return the key of a model column, or "" when it is unknown.

Parameters:

column (int)

Return type:

str

column_keys: tuple[str, ...]
default_fields: tuple[str, ...]
spans(column_key, text)[source]

Return sorted, merged (start, end) spans to mark in text.

Parameters:
Return type:

list[tuple[int, int]]

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

adsfolio.gui.models.resolution_tooltip(record)[source]

Return the status-marker description for one record.

Parameters:

record (dict[str, Any])

Return type:

str