QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Slots | Public Member Functions | Protected Member Functions | List of all members
QgsAttributeTableFilterModel Class Reference

#include <qgsattributetablefiltermodel.h>

Inheritance diagram for QgsAttributeTableFilterModel:
Inheritance graph
[legend]

Public Types

enum  FilterMode {
  ShowAll, ShowSelected, ShowVisible, ShowFilteredList,
  ShowEdited
}

Public Slots

void extentsChanged ()
 Is called upon every change of the visible extents on the map canvas.

Public Member Functions

 QgsAttributeTableFilterModel (QgsMapCanvas *canvas, QgsAttributeTableModel *sourceModel, QObject *parent=0)
 Make sure, the master model is already loaded, so the selection will get synchronized.
QModelIndex fidToIndex (QgsFeatureId fid) override
QModelIndexList fidToIndexList (QgsFeatureId fid)
QgsFeatureIds filteredFeatures ()
FilterMode filterMode ()
QgsVectorLayerlayer () const
 Returns the layer this filter acts on.
QgsVectorLayerCachelayerCache () const
 Returns the layerCache this filter acts on.
virtual QModelIndex mapFromMaster (const QModelIndex &sourceIndex) const
virtual QModelIndex mapToMaster (const QModelIndex &proxyIndex) const
QgsAttributeTableModelmasterModel () const
 Returns the table model this filter is using.
QgsFeatureId rowToId (const QModelIndex &row)
 Returns the feature id for a given model index.
bool selectedOnTop ()
 Returns if selected features are currently shown on top.
virtual void setFilteredFeatures (QgsFeatureIds ids)
 Specify a list of features, which the filter will accept.
void setFilterMode (FilterMode filterMode)
 Set the filter mode the filter will use.
void setSelectedOnTop (bool selectedOnTop)
 Changes the sort order of the features.
void setSourceModel (QgsAttributeTableModel *sourceModel)

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override
 Returns true if the source row will be accepted.
void generateListOfVisibleFeatures ()
 Updates the list of currently visible features on the map canvas.
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
 Used by the sorting algorithm.
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override
 Sort by the given column using the given order.

Detailed Description

Definition at line 31 of file qgsattributetablefiltermodel.h.

Member Enumeration Documentation

Enumerator:
ShowAll 
ShowSelected 
ShowVisible 
ShowFilteredList 
ShowEdited 

Definition at line 36 of file qgsattributetablefiltermodel.h.

Constructor & Destructor Documentation

QgsAttributeTableFilterModel::QgsAttributeTableFilterModel ( QgsMapCanvas canvas,
QgsAttributeTableModel sourceModel,
QObject *  parent = 0 
)

Make sure, the master model is already loaded, so the selection will get synchronized.

Parameters
parentparent object (owner)
sourceModelThe QgsAttributeTableModel to use as source (mostly referred to as master model)
canvasThe mapCanvas. Used to identify the currently visible features.

Definition at line 30 of file qgsattributetablefiltermodel.cpp.

Member Function Documentation

void QgsAttributeTableFilterModel::extentsChanged ( )
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 205 of file qgsattributetablefiltermodel.cpp.

QModelIndex QgsAttributeTableFilterModel::fidToIndex ( QgsFeatureId  fid)
overridevirtual

Implements QgsFeatureModel.

Definition at line 313 of file qgsattributetablefiltermodel.cpp.

QModelIndexList QgsAttributeTableFilterModel::fidToIndexList ( QgsFeatureId  fid)

Definition at line 318 of file qgsattributetablefiltermodel.cpp.

bool QgsAttributeTableFilterModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
overrideprotected

Returns true if the source row will be accepted.

Parameters
sourceRowrow from the source model
sourceParentparent index in the source model

Definition at line 168 of file qgsattributetablefiltermodel.cpp.

QgsFeatureIds QgsAttributeTableFilterModel::filteredFeatures ( )

Definition at line 133 of file qgsattributetablefiltermodel.cpp.

FilterMode QgsAttributeTableFilterModel::filterMode ( )
inline

Definition at line 89 of file qgsattributetablefiltermodel.h.

void QgsAttributeTableFilterModel::generateListOfVisibleFeatures ( )
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 225 of file qgsattributetablefiltermodel.cpp.

QgsVectorLayer* QgsAttributeTableFilterModel::layer ( ) const
inline

Returns the layer this filter acts on.

Returns
Abovementioned layer

Definition at line 96 of file qgsattributetablefiltermodel.h.

QgsVectorLayerCache* QgsAttributeTableFilterModel::layerCache ( ) const
inline

Returns the layerCache this filter acts on.

Returns
The layer cache

Definition at line 103 of file qgsattributetablefiltermodel.h.

bool QgsAttributeTableFilterModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
overrideprotected

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.

Definition at line 42 of file qgsattributetablefiltermodel.cpp.

QModelIndex QgsAttributeTableFilterModel::mapFromMaster ( const QModelIndex &  sourceIndex) const
virtual

Definition at line 335 of file qgsattributetablefiltermodel.cpp.

QModelIndex QgsAttributeTableFilterModel::mapToMaster ( const QModelIndex &  proxyIndex) const
virtual

Definition at line 329 of file qgsattributetablefiltermodel.cpp.

QgsAttributeTableModel* QgsAttributeTableFilterModel::masterModel ( ) const
inline

Returns the table model this filter is using.

Returns
the table model in quesion

Definition at line 110 of file qgsattributetablefiltermodel.h.

QgsFeatureId QgsAttributeTableFilterModel::rowToId ( const QModelIndex &  row)

Returns the feature id for a given model index.

Parameters
rowA model index of the row in question
Returns
The feature id of the feature visible in the provided row

Definition at line 308 of file qgsattributetablefiltermodel.cpp.

bool QgsAttributeTableFilterModel::selectedOnTop ( )

Returns if selected features are currently shown on top.

Returns
True if selected are shown on top

Definition at line 121 of file qgsattributetablefiltermodel.cpp.

void QgsAttributeTableFilterModel::setFilteredFeatures ( QgsFeatureIds  ids)
virtual

Specify a list of features, which the filter will accept.

The filter mode will automatically be adjusted to show only these features (ShowFilteredList).

Parameters
idsThe list of feature ids which will be accepted by the filter

Definition at line 126 of file qgsattributetablefiltermodel.cpp.

void QgsAttributeTableFilterModel::setFilterMode ( FilterMode  filterMode)

Set the filter mode the filter will use.

Parameters
filterModeSets the current mode of the filter

Definition at line 144 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

Parameters
selectedOnTopSpecify, if selected features should be sorted on top

Definition at line 100 of file qgsattributetablefiltermodel.cpp.

void QgsAttributeTableFilterModel::setSourceModel ( QgsAttributeTableModel sourceModel)

Definition at line 114 of file qgsattributetablefiltermodel.cpp.

void QgsAttributeTableFilterModel::sort ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)
overrideprotectedvirtual

Sort by the given column using the given order.

Prefetches all the data from the layer to speed up sorting.

Parameters
columnThe column which should be sorted
orderThe order ( Qt::AscendingOrder or Qt::DescendingOrder )

Definition at line 94 of file qgsattributetablefiltermodel.cpp.


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