QGIS API Documentation
2.2.0-Valmiera
|
#include <qgsattributetablefiltermodel.h>
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. | |
QgsVectorLayer * | layer () const |
Returns the layer this filter acts on. | |
QgsVectorLayerCache * | layerCache () const |
Returns the layerCache this filter acts on. | |
QgsAttributeTableModel * | masterModel () 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 |
QgsMapCanvas * | mCanvas |
FilterMode | mFilterMode |
bool | mSelectedOnTop |
QgsAttributeTableModel * | mTableModel |
Definition at line 31 of file qgsattributetablefiltermodel.h.
Definition at line 36 of file qgsattributetablefiltermodel.h.
QgsAttributeTableFilterModel::QgsAttributeTableFilterModel | ( | QgsMapCanvas * | canvas, |
QgsAttributeTableModel * | sourceModel, | ||
QObject * | parent = NULL |
||
) |
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 30 of file qgsattributetablefiltermodel.cpp.
References layer(), selectionChanged(), setSourceModel(), and QgsAttributeTableModel::SortRole.
|
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 200 of file qgsattributetablefiltermodel.cpp.
References generateListOfVisibleFeatures().
Referenced by setFilterMode().
|
virtual |
Implements QgsFeatureModel.
Definition at line 298 of file qgsattributetablefiltermodel.cpp.
References mapFromMaster(), and masterModel().
QModelIndexList QgsAttributeTableFilterModel::fidToIndexList | ( | QgsFeatureId | fid | ) |
Definition at line 303 of file qgsattributetablefiltermodel.cpp.
References mapFromMaster(), and masterModel().
|
protected |
Returns true if the source row will be accepted.
sourceRow | row from the source model |
sourceParent | parent index in the source model |
Definition at line 157 of file qgsattributetablefiltermodel.cpp.
References QgsVectorLayerEditBuffer::addedFeatures(), QgsVectorLayerEditBuffer::changedAttributeValues(), QgsVectorLayer::editBuffer(), layer(), masterModel(), mFilteredFeatures, mFilterMode, rowToId(), QgsAttributeTableModel::rowToId(), QgsVectorLayer::selectedFeaturesIds(), ShowAll, ShowEdited, ShowFilteredList, ShowSelected, and ShowVisible.
|
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 220 of file qgsattributetablefiltermodel.cpp.
References QgsFeatureRendererV2::capabilities(), QgsFeatureIterator::close(), QgsRenderContext::extent(), QgsMapCanvas::extent(), QgsFeatureRendererV2::Filter, QgsVectorLayerCache::getFeatures(), QgsFeature::id(), layer(), QgsAttributeTableModel::layerCache(), QgsMapCanvas::mapRenderer(), QgsMapRenderer::mapToLayerCoordinates(), QgsRenderContext::mapToPixel(), masterModel(), QgsMapLayer::maximumScale(), mCanvas, mFilteredFeatures, QgsFeatureIterator::nextFeature(), QgsFeatureRequest::NoGeometry, QgsDebugMsg, QgsMapRenderer::rendererContext(), QgsVectorLayer::rendererV2(), QgsMapRenderer::scale(), QgsFeatureRendererV2::ScaleDependent, QgsRenderContext::setExtent(), QgsRenderContext::setMapToPixel(), QgsRenderContext::setRendererScale(), QgsFeatureRendererV2::startRender(), QgsFeatureRendererV2::stopRender(), and QgsFeatureRendererV2::willRenderFeature().
Referenced by extentsChanged(), selectionChanged(), and setFilterMode().
|
inline |
Returns the layer this filter acts on.
Definition at line 92 of file qgsattributetablefiltermodel.h.
Referenced by QgsAttributeTableView::contextMenuEvent(), QgsFeatureListModel::data(), filterAcceptsRow(), generateListOfVisibleFeatures(), QgsAttributeTableDelegate::layer(), lessThan(), QgsAttributeTableFilterModel(), QgsFeatureListModel::setDisplayExpression(), and QgsAttributeTableView::setModel().
|
inline |
Returns the layerCache this filter acts on.
Definition at line 99 of file qgsattributetablefiltermodel.h.
Referenced by QgsFeatureListModel::data(), QgsFeatureListModel::featureByIndex(), and QgsFeatureListModel::layerCache().
|
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 42 of file qgsattributetablefiltermodel.cpp.
References layer(), masterModel(), mSelectedOnTop, rowToId(), QgsVectorLayer::selectedFeaturesIds(), and QgsAttributeTableModel::SortRole.
|
virtual |
Definition at line 320 of file qgsattributetablefiltermodel.cpp.
Referenced by QgsFeatureListModel::fidToIdx(), fidToIndex(), fidToIndexList(), and QgsFeatureListModel::mapFromMaster().
|
virtual |
Definition at line 314 of file qgsattributetablefiltermodel.cpp.
Referenced by QgsFeatureListModel::mapToMaster().
|
inline |
Returns the table model this filter is using.
Definition at line 106 of file qgsattributetablefiltermodel.h.
Referenced by QgsFeatureListModel::fidToIdx(), fidToIndex(), fidToIndexList(), filterAcceptsRow(), generateListOfVisibleFeatures(), QgsFeatureListModel::idxToFid(), lessThan(), QgsFeatureListModel::masterModel(), rowToId(), and sort().
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 293 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.
Definition at line 121 of file qgsattributetablefiltermodel.cpp.
References mSelectedOnTop.
Referenced by setSelectedOnTop().
|
privateslot |
Definition at line 206 of file qgsattributetablefiltermodel.cpp.
References generateListOfVisibleFeatures(), mFilterMode, mSelectedOnTop, ShowSelected, and sort().
Referenced by QgsAttributeTableFilterModel().
|
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 126 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.
filterMode | Sets the current mode of the filter |
Definition at line 133 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
selectedOnTop | Specify, if selected features should be sorted on top |
Definition at line 100 of file qgsattributetablefiltermodel.cpp.
References mSelectedOnTop, selectedOnTop(), and sort().
Referenced by QgsDualView::setSelectedOnTop().
void QgsAttributeTableFilterModel::setSourceModel | ( | QgsAttributeTableModel * | sourceModel | ) |
Definition at line 114 of file qgsattributetablefiltermodel.cpp.
References mTableModel.
Referenced by QgsAttributeTableFilterModel().
|
protectedvirtual |
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 ) |
Definition at line 94 of file qgsattributetablefiltermodel.cpp.
References masterModel(), and QgsAttributeTableModel::prefetchColumnData().
Referenced by selectionChanged(), and setSelectedOnTop().
|
private |
Definition at line 167 of file qgsattributetablefiltermodel.h.
Referenced by generateListOfVisibleFeatures(), and setFilterMode().
|
private |
Definition at line 166 of file qgsattributetablefiltermodel.h.
Referenced by filterAcceptsRow(), generateListOfVisibleFeatures(), and setFilteredFeatures().
|
private |
Definition at line 168 of file qgsattributetablefiltermodel.h.
Referenced by filterAcceptsRow(), selectionChanged(), and setFilterMode().
|
private |
Definition at line 169 of file qgsattributetablefiltermodel.h.
Referenced by lessThan(), selectedOnTop(), selectionChanged(), and setSelectedOnTop().
|
private |
Definition at line 170 of file qgsattributetablefiltermodel.h.
Referenced by setSourceModel().