|
QGIS API Documentation
master-6164ace
|
#include <qgsattributetablefiltermodel.h>
Inheritance diagram for QgsAttributeTableFilterModel:
Collaboration diagram for QgsAttributeTableFilterModel: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. | |
| QModelIndex | fidToIndex (QgsFeatureId fid) |
| QModelIndexList | fidToIndexList (QgsFeatureId fid) |
| QgsVectorLayer * | layer () const |
| Returns the layer this filter acts on. | |
| QgsVectorLayerCache * | layerCache () const |
| Returns the layerCache this filter acts on. | |
| virtual QModelIndex | mapFromMaster (const QModelIndex &sourceIndex) const |
| virtual QModelIndex | mapToMaster (const QModelIndex &proxyIndex) const |
| 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. | |
| 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 |
| 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 | |
| QgsMapCanvas * | mCanvas |
| QgsFeatureIds | mFilteredFeatures |
| FilterMode | mFilterMode |
| QItemSelectionModel * | mMasterSelection |
| 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(), mMasterSelection, selectionChanged(), setSourceModel(), and QgsAttributeTableModel::SortRole.
| 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 197 of file qgsattributetablefiltermodel.cpp.
References generateListOfVisibleFeatures().
Referenced by setFilterMode().
| QModelIndex QgsAttributeTableFilterModel::fidToIndex | ( | QgsFeatureId | fid | ) | [virtual] |
Implements QgsFeatureModel.
Definition at line 295 of file qgsattributetablefiltermodel.cpp.
References mapFromMaster(), and masterModel().
| QModelIndexList QgsAttributeTableFilterModel::fidToIndexList | ( | QgsFeatureId | fid | ) |
Definition at line 300 of file qgsattributetablefiltermodel.cpp.
References mapFromMaster(), and masterModel().
| bool QgsAttributeTableFilterModel::filterAcceptsRow | ( | int | sourceRow, |
| const QModelIndex & | sourceParent | ||
| ) | const [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 154 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.
| 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 217 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().
| QgsVectorLayer* QgsAttributeTableFilterModel::layer | ( | ) | const [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().
| QgsVectorLayerCache* QgsAttributeTableFilterModel::layerCache | ( | ) | const [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().
| 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] |
Definition at line 317 of file qgsattributetablefiltermodel.cpp.
Referenced by QgsFeatureListModel::fidToIdx(), fidToIndex(), fidToIndexList(), and QgsFeatureListModel::mapFromMaster().
| QModelIndex QgsAttributeTableFilterModel::mapToMaster | ( | const QModelIndex & | proxyIndex | ) | const [virtual] |
Definition at line 311 of file qgsattributetablefiltermodel.cpp.
Referenced by QgsFeatureListModel::mapToMaster().
| QgsAttributeTableModel* QgsAttributeTableFilterModel::masterModel | ( | ) | const [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 290 of file qgsattributetablefiltermodel.cpp.
References masterModel(), and QgsAttributeTableModel::rowToId().
Referenced by filterAcceptsRow(), and lessThan().
Returns if selected features are currently shown on top.
Definition at line 118 of file qgsattributetablefiltermodel.cpp.
References mSelectedOnTop.
Referenced by setSelectedOnTop().
| void QgsAttributeTableFilterModel::selectionChanged | ( | ) | [private, slot] |
Definition at line 203 of file qgsattributetablefiltermodel.cpp.
References generateListOfVisibleFeatures(), mFilterMode, mSelectedOnTop, ShowSelected, and sort().
Referenced by QgsAttributeTableFilterModel().
| 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).
| ids | The list of feature ids which will be accepted by the filter |
Definition at line 123 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 130 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 95 of file qgsattributetablefiltermodel.cpp.
References mSelectedOnTop, selectedOnTop(), and sort().
Referenced by QgsDualView::setSelectedOnTop().
| void QgsAttributeTableFilterModel::setSourceModel | ( | QgsAttributeTableModel * | sourceModel | ) |
Definition at line 109 of file qgsattributetablefiltermodel.cpp.
References mMasterSelection, and mTableModel.
Referenced by QgsAttributeTableFilterModel().
| void QgsAttributeTableFilterModel::sort | ( | int | column, |
| Qt::SortOrder | order = Qt::AscendingOrder |
||
| ) | [protected, virtual] |
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 89 of file qgsattributetablefiltermodel.cpp.
References masterModel(), and QgsAttributeTableModel::prefetchColumnData().
Referenced by selectionChanged(), and setSelectedOnTop().
Definition at line 167 of file qgsattributetablefiltermodel.h.
Referenced by generateListOfVisibleFeatures(), and setFilterMode().
Definition at line 166 of file qgsattributetablefiltermodel.h.
Referenced by filterAcceptsRow(), generateListOfVisibleFeatures(), and setFilteredFeatures().
Definition at line 168 of file qgsattributetablefiltermodel.h.
Referenced by filterAcceptsRow(), selectionChanged(), and setFilterMode().
QItemSelectionModel* QgsAttributeTableFilterModel::mMasterSelection [private] |
Definition at line 170 of file qgsattributetablefiltermodel.h.
Referenced by QgsAttributeTableFilterModel(), and setSourceModel().
bool QgsAttributeTableFilterModel::mSelectedOnTop [private] |
Definition at line 169 of file qgsattributetablefiltermodel.h.
Referenced by lessThan(), selectedOnTop(), selectionChanged(), and setSelectedOnTop().
Definition at line 171 of file qgsattributetablefiltermodel.h.
Referenced by setSourceModel().