QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
#include <qgsattributetablefiltermodel.h>
Public Types | |
enum | ColumnType { ColumnTypeField, ColumnTypeActionButton } |
The type of a column. More... | |
enum | FilterMode { ShowAll, ShowSelected, ShowVisible, ShowFilteredList, ShowEdited } |
The filter mode defines how the rows should be filtered. More... | |
enum | Role { TypeRole = QgsAttributeTableModel::UserRole } |
The additional roles defined by this filter model. More... | |
Public Slots | |
void | extentsChanged () |
Is called upon every change of the visible extents on the map canvas. More... | |
Signals | |
void | sortColumnChanged (int column, Qt::SortOrder order) |
Is emitted whenever the sort column is changed. More... | |
Public Member Functions | |
QgsAttributeTableFilterModel (QgsMapCanvas *canvas, QgsAttributeTableModel *sourceModel, QObject *parent=nullptr) | |
Make sure, the master model is already loaded, so the selection will get synchronized. More... | |
int | actionColumnIndex () const |
Get the index of the first column that contains an action widget. More... | |
int | columnCount (const QModelIndex &parent) const override |
virtual QVariant | data (const QModelIndex &index, int role) const override |
QModelIndex | fidToIndex (QgsFeatureId fid) override |
QModelIndexList | fidToIndexList (QgsFeatureId fid) |
QgsFeatureIds | filteredFeatures () |
Get a list of currently filtered feature ids. More... | |
FilterMode | filterMode () |
The current filterModel. More... | |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const override |
QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
QgsVectorLayer * | layer () const |
Returns the layer this filter acts on. More... | |
QgsVectorLayerCache * | layerCache () const |
Returns the layerCache this filter acts on. More... | |
QgsMapCanvas * | mapCanvas () const |
Returns the map canvas. More... | |
QModelIndex | mapFromMaster (const QModelIndex &sourceIndex) const |
virtual QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const override |
QModelIndex | mapToMaster (const QModelIndex &proxyIndex) const |
virtual QModelIndex | mapToSource (const QModelIndex &proxyIndex) const override |
QgsAttributeTableModel * | masterModel () const |
Returns the table model this filter is using. More... | |
QgsFeatureId | rowToId (const QModelIndex &row) |
Returns the feature id for a given model index. More... | |
bool | selectedOnTop () |
Returns if selected features are currently shown on top. More... | |
void | setAttributeTableConfig (const QgsAttributeTableConfig &config) |
Set the attribute table configuration to control which fields are shown, in which order they are shown as well as if and where an action column is shown. More... | |
virtual void | setFilteredFeatures (const QgsFeatureIds &ids) |
Specify a list of features, which the filter will accept. More... | |
void | setFilterMode (FilterMode filterMode) |
Set the filter mode the filter will use. More... | |
void | setSelectedOnTop (bool selectedOnTop) |
Changes the sort order of the features. More... | |
void | setSourceModel (QgsAttributeTableModel *sourceModel) |
Set the attribute table model that backs this model. More... | |
virtual void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override |
Sort by the given column using the given order. More... | |
void | sort (QString expression, Qt::SortOrder order=Qt::AscendingOrder) |
Sort by the given expression using the given order. More... | |
QString | sortExpression () const |
The expression which is used to sort the attribute table. More... | |
Public Member Functions inherited from QSortFilterProxyModel | |
QSortFilterProxyModel (QObject *parent) | |
~QSortFilterProxyModel () | |
virtual QModelIndex | buddy (const QModelIndex &index) const |
virtual bool | canFetchMore (const QModelIndex &parent) const |
void | clear () |
virtual bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
bool | dynamicSortFilter () const |
virtual void | fetchMore (const QModelIndex &parent) |
Qt::CaseSensitivity | filterCaseSensitivity () const |
int | filterKeyColumn () const |
QRegExp | filterRegExp () const |
int | filterRole () const |
virtual bool | hasChildren (const QModelIndex &parent) const |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent) const |
virtual bool | insertColumns (int column, int count, const QModelIndex &parent) |
virtual bool | insertRows (int row, int count, const QModelIndex &parent) |
void | invalidate () |
bool | isSortLocaleAware () const |
virtual QItemSelection | mapSelectionFromSource (const QItemSelection &sourceSelection) const |
virtual QItemSelection | mapSelectionToSource (const QItemSelection &proxySelection) const |
virtual QModelIndexList | match (const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const |
virtual QMimeData * | mimeData (const QModelIndexList &indexes) const |
virtual QStringList | mimeTypes () const |
virtual QModelIndex | parent (const QModelIndex &child) const |
virtual bool | removeColumns (int column, int count, const QModelIndex &parent) |
virtual bool | removeRows (int row, int count, const QModelIndex &parent) |
virtual int | rowCount (const QModelIndex &parent) const |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) |
void | setDynamicSortFilter (bool enable) |
void | setFilterCaseSensitivity (Qt::CaseSensitivity cs) |
void | setFilterFixedString (const QString &pattern) |
void | setFilterKeyColumn (int column) |
void | setFilterRegExp (const QRegExp ®Exp) |
void | setFilterRegExp (const QString &pattern) |
void | setFilterRole (int role) |
void | setFilterWildcard (const QString &pattern) |
virtual bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role) |
void | setSortCaseSensitivity (Qt::CaseSensitivity cs) |
void | setSortLocaleAware (bool on) |
void | setSortRole (int role) |
virtual void | setSourceModel (QAbstractItemModel *sourceModel) |
Qt::CaseSensitivity | sortCaseSensitivity () const |
int | sortColumn () const |
Qt::SortOrder | sortOrder () const |
int | sortRole () const |
virtual QSize | span (const QModelIndex &index) const |
virtual Qt::DropActions | supportedDropActions () const |
Public Member Functions inherited from QAbstractProxyModel | |
QAbstractProxyModel (QObject *parent) | |
~QAbstractProxyModel () | |
virtual QMap< int, QVariant > | itemData (const QModelIndex &proxyIndex) const |
virtual QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const=0 |
virtual QModelIndex | mapToSource (const QModelIndex &proxyIndex) const=0 |
virtual void | revert () |
virtual bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
QAbstractItemModel * | sourceModel () const |
virtual bool | submit () |
Public Member Functions inherited from QAbstractItemModel | |
QAbstractItemModel (QObject *parent) | |
virtual | ~QAbstractItemModel () |
virtual int | columnCount (const QModelIndex &parent) const=0 |
void | columnsAboutToBeInserted (const QModelIndex &parent, int start, int end) |
void | columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
void | columnsAboutToBeRemoved (const QModelIndex &parent, int start, int end) |
void | columnsInserted (const QModelIndex &parent, int start, int end) |
void | columnsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
void | columnsRemoved (const QModelIndex &parent, int start, int end) |
virtual QVariant | data (const QModelIndex &index, int role) const=0 |
void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
bool | hasIndex (int row, int column, const QModelIndex &parent) const |
void | headerDataChanged (Qt::Orientation orientation, int first, int last) |
virtual QModelIndex | index (int row, int column, const QModelIndex &parent) const=0 |
bool | insertColumn (int column, const QModelIndex &parent) |
bool | insertRow (int row, const QModelIndex &parent) |
void | layoutAboutToBeChanged () |
void | layoutChanged () |
void | modelAboutToBeReset () |
void | modelReset () |
virtual QModelIndex | parent (const QModelIndex &index) const=0 |
bool | removeColumn (int column, const QModelIndex &parent) |
bool | removeRow (int row, const QModelIndex &parent) |
const QHash< int, QByteArray > & | roleNames () const |
virtual int | rowCount (const QModelIndex &parent) const=0 |
void | rowsAboutToBeInserted (const QModelIndex &parent, int start, int end) |
void | rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
void | rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) |
void | rowsInserted (const QModelIndex &parent, int start, int end) |
void | rowsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
void | rowsRemoved (const QModelIndex &parent, int start, int end) |
void | setSupportedDragActions (QFlags< Qt::DropAction > actions) |
QModelIndex | sibling (int row, int column, const QModelIndex &index) const |
Qt::DropActions | supportedDragActions () const |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Public Member Functions inherited from QgsFeatureModel | |
virtual | ~QgsFeatureModel () |
Protected Member Functions | |
bool | filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override |
Returns true if the source row will be accepted. More... | |
void | generateListOfVisibleFeatures () |
Updates the list of currently visible features on the map canvas. More... | |
bool | lessThan (const QModelIndex &left, const QModelIndex &right) const override |
Used by the sorting algorithm. More... | |
Protected Member Functions inherited from QSortFilterProxyModel | |
virtual bool | filterAcceptsColumn (int source_column, const QModelIndex &source_parent) const |
void | filterChanged () |
void | invalidateFilter () |
Protected Member Functions inherited from QAbstractItemModel | |
void | beginInsertColumns (const QModelIndex &parent, int first, int last) |
void | beginInsertRows (const QModelIndex &parent, int first, int last) |
bool | beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) |
bool | beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) |
void | beginRemoveColumns (const QModelIndex &parent, int first, int last) |
void | beginRemoveRows (const QModelIndex &parent, int first, int last) |
void | beginResetModel () |
void | changePersistentIndex (const QModelIndex &from, const QModelIndex &to) |
void | changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to) |
QModelIndex | createIndex (int row, int column, void *ptr) const |
QModelIndex | createIndex (int row, int column, int id) const |
QModelIndex | createIndex (int row, int column, quint32 id) const |
void | endInsertColumns () |
void | endInsertRows () |
void | endMoveColumns () |
void | endMoveRows () |
void | endRemoveColumns () |
void | endRemoveRows () |
void | endResetModel () |
QModelIndexList | persistentIndexList () const |
void | reset () |
void | resetInternalData () |
void | setRoleNames (const QHash< int, QByteArray > &roleNames) |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Friends | |
class | TestQgsAttributeTable |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QSortFilterProxyModel | |
dynamicSortFilter | |
filterCaseSensitivity | |
filterKeyColumn | |
filterRegExp | |
filterRole | |
isSortLocaleAware | |
sortCaseSensitivity | |
sortRole | |
Properties inherited from QObject | |
objectName | |
Definition at line 34 of file qgsattributetablefiltermodel.h.
The type of a column.
Enumerator | |
---|---|
ColumnTypeField | This column shows a field. |
ColumnTypeActionButton | This column shows action buttons. |
Definition at line 54 of file qgsattributetablefiltermodel.h.
The filter mode defines how the rows should be filtered.
Enumerator | |
---|---|
ShowAll | Show all features. |
ShowSelected | Show only selected features. |
ShowVisible | Show only visible features (depends on the map canvas) |
ShowFilteredList | Show only features whose ids are on the filter list. {.
|
ShowEdited | Show only features which have unsaved changes. |
Definition at line 42 of file qgsattributetablefiltermodel.h.
The additional roles defined by this filter model.
The values of these roles start just after the roles defined by QgsAttributeTableModel so they do not conflict.
Enumerator | |
---|---|
TypeRole | The type of a given column. |
Definition at line 65 of file qgsattributetablefiltermodel.h.
QgsAttributeTableFilterModel::QgsAttributeTableFilterModel | ( | QgsMapCanvas * | canvas, |
QgsAttributeTableModel * | sourceModel, | ||
QObject * | parent = nullptr |
||
) |
Make sure, the master model is already loaded, so the selection will get synchronized.
parent | parent object (owner) |
sourceModel | The QgsAttributeTableModel to use as source (mostly referred to as master model) |
canvas | The mapCanvas. Used to identify the currently visible features. |
Definition at line 31 of file qgsattributetablefiltermodel.cpp.
int QgsAttributeTableFilterModel::actionColumnIndex | ( | ) | const |
Get the index of the first column that contains an action widget.
Returns -1 if none is defined.
Definition at line 120 of file qgsattributetablefiltermodel.cpp.
|
overridevirtual |
Reimplemented from QSortFilterProxyModel.
Definition at line 125 of file qgsattributetablefiltermodel.cpp.
|
overridevirtual |
Reimplemented from QSortFilterProxyModel.
Definition at line 81 of file qgsattributetablefiltermodel.cpp.
|
slot |
Is called upon every change of the visible extents on the map canvas.
When a change is signalled, the filter is updated and invalidated if needed.
Definition at line 358 of file qgsattributetablefiltermodel.cpp.
|
overridevirtual |
Implements QgsFeatureModel.
Definition at line 482 of file qgsattributetablefiltermodel.cpp.
QModelIndexList QgsAttributeTableFilterModel::fidToIndexList | ( | QgsFeatureId | fid | ) |
Definition at line 487 of file qgsattributetablefiltermodel.cpp.
|
overrideprotectedvirtual |
Returns true if the source row will be accepted.
sourceRow | row from the source model |
sourceParent | parent index in the source model |
Reimplemented from QSortFilterProxyModel.
Definition at line 320 of file qgsattributetablefiltermodel.cpp.
QgsFeatureIds QgsAttributeTableFilterModel::filteredFeatures | ( | ) |
Get a list of currently filtered feature ids.
Definition at line 290 of file qgsattributetablefiltermodel.cpp.
|
inline |
The current filterModel.
Definition at line 129 of file qgsattributetablefiltermodel.h.
|
overridevirtual |
Reimplemented from QSortFilterProxyModel.
Definition at line 527 of file qgsattributetablefiltermodel.cpp.
|
protected |
Updates the list of currently visible features on the map canvas.
Is called automatically when the filter mode is adjusted or the extents changed.
Definition at line 392 of file qgsattributetablefiltermodel.cpp.
|
overridevirtual |
Reimplemented from QSortFilterProxyModel.
Definition at line 99 of file qgsattributetablefiltermodel.cpp.
|
inline |
Returns the layer this filter acts on.
Definition at line 136 of file qgsattributetablefiltermodel.h.
|
inline |
Returns the layerCache this filter acts on.
Definition at line 143 of file qgsattributetablefiltermodel.h.
|
overrideprotectedvirtual |
Used by the sorting algorithm.
Compares the two model indices. Will also consider the selection state of the feature in case selected features are to be shown on top.
Reimplemented from QSortFilterProxyModel.
Definition at line 43 of file qgsattributetablefiltermodel.cpp.
|
inline |
Returns the map canvas.
Definition at line 199 of file qgsattributetablefiltermodel.h.
|
inline |
Definition at line 167 of file qgsattributetablefiltermodel.h.
|
overridevirtual |
Reimplemented from QSortFilterProxyModel.
Definition at line 513 of file qgsattributetablefiltermodel.cpp.
|
inline |
Definition at line 165 of file qgsattributetablefiltermodel.h.
|
overridevirtual |
Reimplemented from QSortFilterProxyModel.
Definition at line 498 of file qgsattributetablefiltermodel.cpp.
|
inline |
Returns the table model this filter is using.
Definition at line 150 of file qgsattributetablefiltermodel.h.
QgsFeatureId QgsAttributeTableFilterModel::rowToId | ( | const QModelIndex & | row | ) |
Returns the feature id for a given model index.
row | A model index of the row in question |
Definition at line 477 of file qgsattributetablefiltermodel.cpp.
bool QgsAttributeTableFilterModel::selectedOnTop | ( | ) |
Returns if selected features are currently shown on top.
Definition at line 278 of file qgsattributetablefiltermodel.cpp.
void QgsAttributeTableFilterModel::setAttributeTableConfig | ( | const QgsAttributeTableConfig & | config | ) |
Set the attribute table configuration to control which fields are shown, in which order they are shown as well as if and where an action column is shown.
Definition at line 131 of file qgsattributetablefiltermodel.cpp.
|
virtual |
Specify a list of features, which the filter will accept.
The filter mode will automatically be adjusted to show only these features (ShowFilteredList).
ids | The list of feature ids which will be accepted by the filter |
Definition at line 283 of file qgsattributetablefiltermodel.cpp.
void QgsAttributeTableFilterModel::setFilterMode | ( | FilterMode | filterMode | ) |
Set the filter mode the filter will use.
filterMode | Sets the current mode of the filter |
Definition at line 301 of file qgsattributetablefiltermodel.cpp.
void QgsAttributeTableFilterModel::setSelectedOnTop | ( | bool | selectedOnTop | ) |
Changes the sort order of the features.
If set to true, selected features will be sorted on top, regardless of the current sort column
selectedOnTop | Specify, if selected features should be sorted on top |
Definition at line 237 of file qgsattributetablefiltermodel.cpp.
void QgsAttributeTableFilterModel::setSourceModel | ( | QgsAttributeTableModel * | sourceModel | ) |
Set the attribute table model that backs this model.
sourceModel | The model |
Definition at line 257 of file qgsattributetablefiltermodel.cpp.
|
overridevirtual |
Sort by the given column using the given order.
Prefetches all the data from the layer to speed up sorting.
column | The column which should be sorted |
order | The order ( Qt::AscendingOrder or Qt::DescendingOrder ) |
Reimplemented from QSortFilterProxyModel.
Definition at line 70 of file qgsattributetablefiltermodel.cpp.
void QgsAttributeTableFilterModel::sort | ( | QString | expression, |
Qt::SortOrder | order = Qt::AscendingOrder |
||
) |
Sort by the given expression using the given order.
Prefetches all the data from the layer to speed up sorting.
expression | The expression which should be used for sorting |
order | The order ( Qt::AscendingOrder or Qt::DescendingOrder ) |
Definition at line 222 of file qgsattributetablefiltermodel.cpp.
|
signal |
Is emitted whenever the sort column is changed.
column | The sort column |
order | The sort order |
QString QgsAttributeTableFilterModel::sortExpression | ( | ) | const |
The expression which is used to sort the attribute table.
Definition at line 232 of file qgsattributetablefiltermodel.cpp.
|
friend |
Definition at line 271 of file qgsattributetablefiltermodel.h.