Class FeatureCheckListModel
ClassList > FeatureCheckListModel
#include <featurechecklistmodel.h>
Inherits the following classes: QSortFilterProxyModel
Public Properties
| Type | Name |
|---|---|
| property bool | addNull Set to TRUE if null values are allowed in the list. |
| property bool | allowMulti The attribute field to have information about type (JSON/HSTORE) etc. |
| property AppExpressionContextScopesGenerator * | appExpressionContextScopesGenerator The application expression context scope generator used when filtering by expression. |
| property QgsField | attributeField The attribute field to have information about type (JSON/HSTORE) etc. |
| property QVariant | attributeValue The attribute value to generate checklist. |
| property QgsFeature | currentFormFeature The current form feature, used to evaluate expressions such as current_value('attr1 )`. |
| property QgsVectorLayer * | currentLayer The vector layer to list. |
| property bool | displayGroupName Set to TRUE if the group name will be displayed in the list. |
| property QString | displayValueField The display value field. |
| property QString | filterExpression Expression to filter features with. Empty string if no filter is applied. |
| property QString | groupField The grouping key field. |
| property QString | keyField The primary key field. |
| property bool | orderByValue Set to TRUE if features should be ordered by value. |
| property QString | searchTerm The current search term used to filter items. |
| property bool | sortCheckedFirst The sorting method. |
Public Signals
| Type | Name |
|---|---|
| signal void | addNullChanged |
| signal void | allowMultiChanged |
| signal void | appExpressionContextScopesGeneratorChanged |
| signal void | attributeFieldChanged |
| signal void | attributeValueChanged |
| signal void | currentFormFeatureChanged |
| signal void | currentLayerChanged |
| signal void | displayGroupNameChanged |
| signal void | displayValueFieldChanged |
| signal void | filterExpressionChanged |
| signal void | groupFieldChanged |
| signal void | keyFieldChanged |
| signal void | listUpdated |
| signal void | orderByValueChanged |
| signal void | searchTermChanged |
| signal void | sortCheckedFirstChanged |
Public Functions
| Type | Name |
|---|---|
| FeatureCheckListModel (QObject * parent=nullptr) |
|
| bool | addNull () const |
| bool | allowMulti () const |
| AppExpressionContextScopesGenerator * | appExpressionContextScopesGenerator () const |
| QgsField | attributeField () const |
| QVariant | attributeValue () const |
| QgsFeature | currentFormFeature () const |
| QgsVectorLayer * | currentLayer () const |
| Q_INVOKABLE QVariant | dataFromRowIndex (int row, int role) |
| bool | displayGroupName () const |
| QString | displayValueField () const |
| QString | filterExpression () const |
| Q_INVOKABLE QList< int > | findDisplayValueMatches (const QString & filter) const |
| Q_INVOKABLE int | findKey (const QVariant & key) const |
| Q_INVOKABLE QgsFeature | getFeatureById (QgsFeatureId id) const |
| Q_INVOKABLE QgsFeature | getFeatureFromKeyValue (const QVariant & value) const |
| QString | groupField () const |
| QString | keyField () const |
| bool | orderByValue () const |
| QString | searchTerm () const |
| void | setAddNull (bool addNull) |
| void | setAllowMulti (bool allowMulti) |
| void | setAppExpressionContextScopesGenerator (AppExpressionContextScopesGenerator * generator) |
| void | setAttributeField (const QgsField & field) |
| void | setAttributeValue (const QVariant & attributeValue) |
| void | setCurrentFormFeature (const QgsFeature & feature) |
| void | setCurrentLayer (QgsVectorLayer * currentLayer) |
| void | setDisplayGroupName (bool displayGroupName) |
| void | setDisplayValueField (const QString & displayValueField) |
| void | setFilterExpression (const QString & filterExpression) |
| void | setGroupField (const QString & groupField) |
| void | setKeyField (const QString & keyField) |
| void | setOrderByValue (bool orderByValue) |
| void | setSearchTerm (const QString & searchTerm) |
| void | setSortCheckedFirst (bool enabled) |
| bool | sortCheckedFirst () const |
| Q_INVOKABLE void | toggleCheckAll (bool toggleChecked=true) |
Protected Functions
| Type | Name |
|---|---|
| bool | filterAcceptsRow (int sourceRow, const QModelIndex & sourceParent) override const |
| bool | lessThan (const QModelIndex & left, const QModelIndex & right) override const |
Detailed Description
A proxy model for filtering and sorting feature checklist items.
This model enhances a source model (typically a FeatureCheckListModel) by allowing: * Text-based filtering using a search term. * Optional sorting that prioritizes checked items. * Fuzzy and prefix-based matching for search refinement.
Used in UI contexts where users interact with large lists of features and need to quickly find and sort items by name or selection state.
Public Properties Documentation
property addNull [1/2]
Set to TRUE if null values are allowed in the list.
bool FeatureCheckListModel::addNull;
property allowMulti [1/2]
The attribute field to have information about type (JSON/HSTORE) etc.
bool FeatureCheckListModel::allowMulti;
property appExpressionContextScopesGenerator [1/2]
The application expression context scope generator used when filtering by expression.
AppExpressionContextScopesGenerator * FeatureCheckListModel::appExpressionContextScopesGenerator;
property attributeField [1/2]
The attribute field to have information about type (JSON/HSTORE) etc.
QgsField FeatureCheckListModel::attributeField;
property attributeValue [1/2]
The attribute value to generate checklist.
QVariant FeatureCheckListModel::attributeValue;
property currentFormFeature [1/2]
The current form feature, used to evaluate expressions such as current_value('attr1 )`.
QgsFeature FeatureCheckListModel::currentFormFeature;
property currentLayer [1/2]
The vector layer to list.
QgsVectorLayer * FeatureCheckListModel::currentLayer;
property displayGroupName [1/2]
Set to TRUE if the group name will be displayed in the list.
bool FeatureCheckListModel::displayGroupName;
property displayValueField [1/2]
The display value field.
QString FeatureCheckListModel::displayValueField;
property filterExpression [1/2]
Expression to filter features with. Empty string if no filter is applied.
QString FeatureCheckListModel::filterExpression;
property groupField [1/2]
The grouping key field.
QString FeatureCheckListModel::groupField;
property keyField [1/2]
The primary key field.
QString FeatureCheckListModel::keyField;
property orderByValue [1/2]
Set to TRUE if features should be ordered by value.
bool FeatureCheckListModel::orderByValue;
property searchTerm [1/2]
The current search term used to filter items.
QString FeatureCheckListModel::searchTerm;
property sortCheckedFirst [1/2]
The sorting method.
bool FeatureCheckListModel::sortCheckedFirst;
Public Signals Documentation
signal addNullChanged
void FeatureCheckListModel::addNullChanged;
signal allowMultiChanged
void FeatureCheckListModel::allowMultiChanged;
signal appExpressionContextScopesGeneratorChanged
void FeatureCheckListModel::appExpressionContextScopesGeneratorChanged;
signal attributeFieldChanged
void FeatureCheckListModel::attributeFieldChanged;
signal attributeValueChanged
void FeatureCheckListModel::attributeValueChanged;
signal currentFormFeatureChanged
void FeatureCheckListModel::currentFormFeatureChanged;
signal currentLayerChanged
void FeatureCheckListModel::currentLayerChanged;
signal displayGroupNameChanged
void FeatureCheckListModel::displayGroupNameChanged;
signal displayValueFieldChanged
void FeatureCheckListModel::displayValueFieldChanged;
signal filterExpressionChanged
void FeatureCheckListModel::filterExpressionChanged;
signal groupFieldChanged
void FeatureCheckListModel::groupFieldChanged;
signal keyFieldChanged
void FeatureCheckListModel::keyFieldChanged;
signal listUpdated
void FeatureCheckListModel::listUpdated;
signal orderByValueChanged
void FeatureCheckListModel::orderByValueChanged;
signal searchTermChanged
void FeatureCheckListModel::searchTermChanged;
signal sortCheckedFirstChanged
void FeatureCheckListModel::sortCheckedFirstChanged;
Public Functions Documentation
function FeatureCheckListModel
explicit FeatureCheckListModel::FeatureCheckListModel (
QObject * parent=nullptr
)
function addNull [2/2]
bool FeatureCheckListModel::addNull () const
Add a NULL value as the first entry.
function allowMulti [2/2]
bool FeatureCheckListModel::allowMulti () const
Whether multiple selected items are allowed
function appExpressionContextScopesGenerator [2/2]
AppExpressionContextScopesGenerator * FeatureCheckListModel::appExpressionContextScopesGenerator () const
Returns the application expression context scope generator used when filtering by expression
function attributeField [2/2]
QgsField FeatureCheckListModel::attributeField () const
the current attribute field
function attributeValue [2/2]
QVariant FeatureCheckListModel::attributeValue () const
the attribute value. A QVariantList or an hstore formatted string, depending on the field type.
function currentFormFeature [2/2]
QgsFeature FeatureCheckListModel::currentFormFeature () const
The current form feature, used to evaluate expressions such as current_value('attr1)`
function currentLayer [2/2]
QgsVectorLayer * FeatureCheckListModel::currentLayer () const
function dataFromRowIndex
inline Q_INVOKABLE QVariant FeatureCheckListModel::dataFromRowIndex (
int row,
int role
)
function displayGroupName [2/2]
bool FeatureCheckListModel::displayGroupName () const
function displayValueField [2/2]
QString FeatureCheckListModel::displayValueField () const
function filterExpression [2/2]
QString FeatureCheckListModel::filterExpression () const
Expression to filter features with. Empty string if no filter is applied.
function findDisplayValueMatches
Q_INVOKABLE QList< int > FeatureCheckListModel::findDisplayValueMatches (
const QString & filter
) const
Get rows for a given filter string used to match display values.
function findKey
Q_INVOKABLE int FeatureCheckListModel::findKey (
const QVariant & key
) const
Get the row for a given key value.
function getFeatureById
Q_INVOKABLE QgsFeature FeatureCheckListModel::getFeatureById (
QgsFeatureId id
) const
Returns the first feature matching the feature id.
function getFeatureFromKeyValue
Q_INVOKABLE QgsFeature FeatureCheckListModel::getFeatureFromKeyValue (
const QVariant & value
) const
Returns the first feature matching the key value.
function groupField [2/2]
QString FeatureCheckListModel::groupField () const
function keyField [2/2]
QString FeatureCheckListModel::keyField () const
function orderByValue [2/2]
bool FeatureCheckListModel::orderByValue () const
Orders all the values alphabethically by their displayString.
function searchTerm [2/2]
QString FeatureCheckListModel::searchTerm () const
Returns the current search term used to filter items.
function setAddNull
void FeatureCheckListModel::setAddNull (
bool addNull
)
Add a NULL value as the first entry.
function setAllowMulti
void FeatureCheckListModel::setAllowMulti (
bool allowMulti
)
Sets whether multiple selected items are allowed
function setAppExpressionContextScopesGenerator
void FeatureCheckListModel::setAppExpressionContextScopesGenerator (
AppExpressionContextScopesGenerator * generator
)
Sets the application expression context scope generator used when filtering by expression
function setAttributeField
void FeatureCheckListModel::setAttributeField (
const QgsField & field
)
the current attribute field
function setAttributeValue
void FeatureCheckListModel::setAttributeValue (
const QVariant & attributeValue
)
the attribute value. A QVariantList or an hstore formatted string, depending on the field type.
function setCurrentFormFeature
void FeatureCheckListModel::setCurrentFormFeature (
const QgsFeature & feature
)
Sets the current form feature, used to evaluate expressions such as current_value('attr1)`
function setCurrentLayer
void FeatureCheckListModel::setCurrentLayer (
QgsVectorLayer * currentLayer
)
function setDisplayGroupName
void FeatureCheckListModel::setDisplayGroupName (
bool displayGroupName
)
function setDisplayValueField
void FeatureCheckListModel::setDisplayValueField (
const QString & displayValueField
)
function setFilterExpression
void FeatureCheckListModel::setFilterExpression (
const QString & filterExpression
)
Sets an expression to filter features with. Empty string if no filter is applied.
function setGroupField
void FeatureCheckListModel::setGroupField (
const QString & groupField
)
function setKeyField
void FeatureCheckListModel::setKeyField (
const QString & keyField
)
function setOrderByValue
void FeatureCheckListModel::setOrderByValue (
bool orderByValue
)
Orders all the values alphabethically by their displayString.
function setSearchTerm
void FeatureCheckListModel::setSearchTerm (
const QString & searchTerm
)
Sets the search term for filtering and updates the filter.
function setSortCheckedFirst
void FeatureCheckListModel::setSortCheckedFirst (
bool enabled
)
Enables or disables sorting checked items first.
function sortCheckedFirst [2/2]
bool FeatureCheckListModel::sortCheckedFirst () const
Returns whether checked items are sorted to the top.
function toggleCheckAll
Q_INVOKABLE void FeatureCheckListModel::toggleCheckAll (
bool toggleChecked=true
)
Sets all element to either checked or unchecked state, depending on toggleChecked
Protected Functions Documentation
function filterAcceptsRow
bool FeatureCheckListModel::filterAcceptsRow (
int sourceRow,
const QModelIndex & sourceParent
) override const
Determines whether a row should be accepted based on the current filter settings. Checks if the data in the row matches the current search term.
function lessThan
bool FeatureCheckListModel::lessThan (
const QModelIndex & left,
const QModelIndex & right
) override const
Compares two items for sorting in the feature check list.
Sorting priority: * Null placeholder (if addNull() is enabled). * Grouping by groupField() (empty groups first, then alphabetically). * Checked-first (if mSortCheckedFirst is enabled and no search term). * Search relevance (startsWith + fuzzy score if search term is active). * Value-based alphabetical ordering (if orderByValue() is enabled). * Key-based fallback (empty keys first, then alphabetically by key).
Parameters:
leftThe model index of the left item.rightThe model index of the right item.
Returns:
True if the left item should appear before the right item.
The documentation for this class was generated from the following file src/core/featurechecklistmodel.h