Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
SettingsSearchModel Class Reference

List model providing filtered, ranked search results. More...

#include <settings_search_model.h>

Inheritance diagram for SettingsSearchModel:
[legend]
Collaboration diagram for SettingsSearchModel:
[legend]

Public Types

enum  Roles { EntryRole = Qt::UserRole + 1 }
 Custom data role for accessing the full entry. More...

Public Member Functions

 SettingsSearchModel (QObject *parent=nullptr)
void setSourceEntries (const QList< SettingsSearchEntry > &entries)
 Replaces the source entries and rebuilds the filter.
void setFilterString (const QString &text)
 Sets the filter string and recalculates the results.
bool isFilterActive () const
 Whether a non-empty filter is currently active.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
SettingsSearchEntry entryForIndex (const QModelIndex &index) const
 Returns the full entry for a given model index.

Private Member Functions

void rebuildFilter ()
 Recalculates the filtered index list and ranking.

Private Attributes

QList< SettingsSearchEntrysourceEntries
 Complete unfiltered entry list.
QList< int > filteredIndices
 Indices into sourceEntries matching the filter.
QRegularExpression filterRegex
 Compiled regex for the current filter.
QString filterQuery
 Current filter query string.
bool filterActive = false
 Whether filtering is active.

Detailed Description

List model providing filtered, ranked search results.

Manages a list of SettingsSearchEntry items. When a filter string is set, entries are scored by relevance and sorted so the best matches appear first. Supports custom roles for accessing entry fields from views and delegates.

Member Enumeration Documentation

◆ Roles

Custom data role for accessing the full entry.

Enumerator
EntryRole 

Full SettingsSearchEntry object.

Constructor & Destructor Documentation

◆ SettingsSearchModel()

SettingsSearchModel::SettingsSearchModel ( QObject * parent = nullptr)
explicit

Member Function Documentation

◆ data()

QVariant SettingsSearchModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

◆ entryForIndex()

SettingsSearchEntry SettingsSearchModel::entryForIndex ( const QModelIndex & index) const

Returns the full entry for a given model index.

◆ isFilterActive()

bool SettingsSearchModel::isFilterActive ( ) const

Whether a non-empty filter is currently active.

◆ rebuildFilter()

void SettingsSearchModel::rebuildFilter ( )
private

Recalculates the filtered index list and ranking.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rowCount()

int SettingsSearchModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

◆ setFilterString()

void SettingsSearchModel::setFilterString ( const QString & text)

Sets the filter string and recalculates the results.

Here is the call graph for this function:

◆ setSourceEntries()

void SettingsSearchModel::setSourceEntries ( const QList< SettingsSearchEntry > & entries)

Replaces the source entries and rebuilds the filter.

Here is the call graph for this function:

Member Data Documentation

◆ filterActive

bool SettingsSearchModel::filterActive = false
private

Whether filtering is active.

◆ filteredIndices

QList<int> SettingsSearchModel::filteredIndices
private

Indices into sourceEntries matching the filter.

◆ filterQuery

QString SettingsSearchModel::filterQuery
private

Current filter query string.

◆ filterRegex

QRegularExpression SettingsSearchModel::filterRegex
private

Compiled regex for the current filter.

◆ sourceEntries

QList<SettingsSearchEntry> SettingsSearchModel::sourceEntries
private

Complete unfiltered entry list.


The documentation for this class was generated from the following files: