QGIS API Documentation  2.6.0-Brighton
 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=NULL)
 Make sure, the master model is already loaded, so the selection will get synchronized.
void setSourceModel (QgsAttributeTableModel *sourceModel)
void setSelectedOnTop (bool selectedOnTop)
 Changes the sort order of the features.
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.
QgsFeatureIds filteredFeatures ()
void setFilterMode (FilterMode filterMode)
 Set the filter mode the filter will use.
FilterMode filterMode ()
QgsVectorLayerlayer () const
 Returns the layer this filter acts on.
QgsVectorLayerCachelayerCache () const
 Returns the layerCache this filter acts on.
QgsAttributeTableModelmasterModel () const
 Returns the table model this filter is using.
QgsFeatureId rowToId (const QModelIndex &row)
 Returns the feature id for a given model index.
QModelIndex fidToIndex (QgsFeatureId fid)
QModelIndexList fidToIndexList (QgsFeatureId fid)
virtual QModelIndex mapToMaster (const QModelIndex &proxyIndex) const
virtual QModelIndex mapFromMaster (const QModelIndex &sourceIndex) const

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const
 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
 Used by the sorting algorithm.
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 Sort by the given column using the given order.

Member Enumeration Documentation

Enumerator:
ShowAll 
ShowSelected 
ShowVisible 
ShowFilteredList 
ShowEdited 

Constructor & Destructor Documentation

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

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.

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.

QModelIndex QgsAttributeTableFilterModel::fidToIndex ( QgsFeatureId  fid)
virtual

Implements QgsFeatureModel.

QModelIndexList QgsAttributeTableFilterModel::fidToIndexList ( QgsFeatureId  fid)
bool QgsAttributeTableFilterModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
protected

Returns true if the source row will be accepted.

Parameters
sourceRowrow from the source model
sourceParentparent index in the source model
QgsFeatureIds QgsAttributeTableFilterModel::filteredFeatures ( )
FilterMode QgsAttributeTableFilterModel::filterMode ( )
inline
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.

QgsVectorLayer* QgsAttributeTableFilterModel::layer ( ) const
inline

Returns the layer this filter acts on.

Returns
Abovementioned layer
QgsVectorLayerCache* QgsAttributeTableFilterModel::layerCache ( ) const
inline

Returns the layerCache this filter acts on.

Returns
The layer cache
bool QgsAttributeTableFilterModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
protected

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.

QModelIndex QgsAttributeTableFilterModel::mapFromMaster ( const QModelIndex &  sourceIndex) const
virtual
QModelIndex QgsAttributeTableFilterModel::mapToMaster ( const QModelIndex &  proxyIndex) const
virtual
QgsAttributeTableModel* QgsAttributeTableFilterModel::masterModel ( ) const
inline

Returns the table model this filter is using.

Returns
the table model in quesion
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
bool QgsAttributeTableFilterModel::selectedOnTop ( )

Returns if selected features are currently shown on top.

Returns
True if selected are shown on top
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
void QgsAttributeTableFilterModel::setFilterMode ( FilterMode  filterMode)

Set the filter mode the filter will use.

Parameters
filterModeSets the current mode of the filter
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
void QgsAttributeTableFilterModel::setSourceModel ( QgsAttributeTableModel sourceModel)
void QgsAttributeTableFilterModel::sort ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)
protectedvirtual

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 )

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