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

#include <qgsattributetablefiltermodel.h>

Inheritance diagram for QgsAttributeTableFilterModel:
Inheritance graph
[legend]
Collaboration diagram for QgsAttributeTableFilterModel:
Collaboration 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.
void setFilterMode (FilterMode filterMode)
 Set the filter mode the filter will use.
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.

Private Slots

void selectionChanged ()

Private Attributes

QgsFeatureIds mFilteredFeatures
QgsMapCanvasmCanvas
FilterMode mFilterMode
bool mSelectedOnTop
QItemSelectionModel * mMasterSelection
QgsAttributeTableModelmTableModel

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 = 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.

Definition at line 30 of file qgsattributetablefiltermodel.cpp.

References layer(), mMasterSelection, selectionChanged(), setSourceModel(), and QgsAttributeTableModel::SortRole.

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 203 of file qgsattributetablefiltermodel.cpp.

References generateListOfVisibleFeatures().

Referenced by setFilterMode().

QModelIndex QgsAttributeTableFilterModel::fidToIndex ( QgsFeatureId  fid)
virtual

Implements QgsFeatureModel.

Definition at line 301 of file qgsattributetablefiltermodel.cpp.

References mapFromMaster(), and masterModel().

QModelIndexList QgsAttributeTableFilterModel::fidToIndexList ( QgsFeatureId  fid)

Definition at line 306 of file qgsattributetablefiltermodel.cpp.

References mapFromMaster(), and masterModel().

bool QgsAttributeTableFilterModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
protected
void QgsAttributeTableFilterModel::generateListOfVisibleFeatures ( )
protected
QgsVectorLayer* QgsAttributeTableFilterModel::layer ( ) const
inline
QgsVectorLayerCache* QgsAttributeTableFilterModel::layerCache ( ) const
inline

Returns the layerCache this filter acts on.

Returns
The layer cache

Definition at line 99 of file qgsattributetablefiltermodel.h.

Referenced by QgsFeatureListModel::data(), QgsFeatureListModel::featureByIndex(), and QgsFeatureListModel::layerCache().

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.

Definition at line 43 of file qgsattributetablefiltermodel.cpp.

References layer(), masterModel(), mSelectedOnTop, rowToId(), QgsVectorLayer::selectedFeaturesIds(), and QgsAttributeTableModel::SortRole.

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

Definition at line 317 of file qgsattributetablefiltermodel.cpp.

Referenced by QgsFeatureListModel::mapToMaster().

QgsAttributeTableModel* QgsAttributeTableFilterModel::masterModel ( ) const
inline
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 296 of file qgsattributetablefiltermodel.cpp.

References masterModel(), and QgsAttributeTableModel::rowToId().

Referenced by filterAcceptsRow(), and lessThan().

bool QgsAttributeTableFilterModel::selectedOnTop ( )

Returns if selected features are currently shown on top.

Returns
True if selected are shown on top

Definition at line 124 of file qgsattributetablefiltermodel.cpp.

References mSelectedOnTop.

Referenced by setSelectedOnTop().

void QgsAttributeTableFilterModel::selectionChanged ( )
privateslot
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 129 of file qgsattributetablefiltermodel.cpp.

References mFilteredFeatures, setFilterMode(), and ShowFilteredList.

Referenced by QgsDualView::setFilteredFeatures().

void QgsAttributeTableFilterModel::setFilterMode ( FilterMode  filterMode)

Set the filter mode the filter will use.

Parameters
filterModeSets the current mode of the filter

Definition at line 136 of file qgsattributetablefiltermodel.cpp.

References extentsChanged(), generateListOfVisibleFeatures(), mCanvas, mFilterMode, ShowSelected, and ShowVisible.

Referenced by setFilteredFeatures(), and QgsDualView::setFilterMode().

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 101 of file qgsattributetablefiltermodel.cpp.

References mSelectedOnTop, selectedOnTop(), and sort().

Referenced by QgsDualView::setSelectedOnTop().

void QgsAttributeTableFilterModel::setSourceModel ( QgsAttributeTableModel sourceModel)

Definition at line 115 of file qgsattributetablefiltermodel.cpp.

References mMasterSelection, and mTableModel.

Referenced by QgsAttributeTableFilterModel().

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 )

Definition at line 95 of file qgsattributetablefiltermodel.cpp.

References masterModel(), and QgsAttributeTableModel::prefetchColumnData().

Referenced by selectionChanged(), and setSelectedOnTop().

Member Data Documentation

QgsMapCanvas* QgsAttributeTableFilterModel::mCanvas
private

Definition at line 167 of file qgsattributetablefiltermodel.h.

Referenced by generateListOfVisibleFeatures(), and setFilterMode().

QgsFeatureIds QgsAttributeTableFilterModel::mFilteredFeatures
private
FilterMode QgsAttributeTableFilterModel::mFilterMode
private
QItemSelectionModel* QgsAttributeTableFilterModel::mMasterSelection
private

Definition at line 170 of file qgsattributetablefiltermodel.h.

Referenced by QgsAttributeTableFilterModel(), and setSourceModel().

bool QgsAttributeTableFilterModel::mSelectedOnTop
private
QgsAttributeTableModel* QgsAttributeTableFilterModel::mTableModel
private

Definition at line 171 of file qgsattributetablefiltermodel.h.

Referenced by setSourceModel().


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