16 #include <QItemSelectionModel>
31 : QSortFilterProxyModel( parent )
33 , mFilterMode( ShowAll )
34 , mSelectedOnTop( false )
38 setDynamicSortFilter(
true );
50 if ( leftSelected && !rightSelected )
54 else if ( rightSelected && !leftSelected )
64 if ( leftData.isNull() )
67 if ( rightData.isNull() )
70 switch ( leftData.type() )
74 case QVariant::LongLong:
75 case QVariant::ULongLong:
76 return leftData.toLongLong() < rightData.toLongLong();
78 case QVariant::Double:
79 return leftData.toDouble() < rightData.toDouble();
82 return leftData.toDate() < rightData.toDate();
84 case QVariant::DateTime:
85 return leftData.toDateTime() < rightData.toDateTime();
88 return leftData.toString().localeAwareCompare( rightData.toString() ) < 0;
98 QSortFilterProxyModel::sort( column, order );
107 if ( sortColumn() == -1 )
121 QSortFilterProxyModel::setSourceModel( sourceModel );
162 Q_UNUSED( sourceParent );
186 const QList<QgsFeatureId> addedFeatures = editBuffer->
addedFeatures().keys();
189 return addedFeatures.contains( fid ) || changedFeatures.contains( fid );
218 sort( sortColumn(), sortOrder() );
241 if (
layer()->hasScaleBasedVisibility() &&
276 if ( t.elapsed() > 5000 )
279 emit progress( i, cancel );
308 QModelIndexList indexes;
309 foreach ( QModelIndex idx,
masterModel()->idToIndexList( fid ) )
320 return mapToSource( proxyIndex );
326 return mapFromSource( sourceIndex );
QgsFeatureId id() const
Get the feature id for this feature.
void generateListOfVisibleFeatures()
Updates the list of currently visible features on the map canvas.
QgsFeatureId rowToId(const QModelIndex &row)
Returns the feature id for a given model index.
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsAttributeTableFilterModel(QgsMapCanvas *canvas, QgsAttributeTableModel *sourceModel, QObject *parent=NULL)
Make sure, the master model is already loaded, so the selection will get synchronized.
virtual bool willRenderFeature(QgsFeature &feat)
return whether the renderer will render a feature or not.
A rectangle specified with double values.
QModelIndex fidToIndex(QgsFeatureId fid)
bool selectedOnTop()
Returns if selected features are currently shown on top.
QgsRenderContext * rendererContext()
Accessor for render context.
void setSelectedOnTop(bool selectedOnTop)
Changes the sort order of the features.
void setFilterMode(FilterMode filterMode)
Set the filter mode the filter will use.
QSet< QgsFeatureId > QgsFeatureIds
bool lessThan(const QModelIndex &left, const QModelIndex &right) const
Used by the sorting algorithm.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
Returns true if the source row will be accepted.
void setRendererScale(double scale)
const QgsChangedAttributesMap & changedAttributeValues()
Changed attributes values which are not commited.
const QgsRectangle & extent() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
QgsPoint mapToLayerCoordinates(QgsMapLayer *theLayer, QgsPoint point)
transform point coordinates from output CRS to layer's CRS
void setExtent(const QgsRectangle &extent)
Map canvas is a class for displaying all GIS data types on a canvas.
virtual void stopRender(QgsRenderContext &context)=0
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
virtual QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
QgsFeatureIds mFilteredFeatures
double scale() const
Scale denominator.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &featureRequest)
Query this VectorLayerCache for features.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QItemSelectionModel * mMasterSelection
QgsVectorLayerCache * layerCache() const
Returns the layer cache this model uses as backend.
void setSourceModel(QgsAttributeTableModel *sourceModel)
void extentsChanged()
Is called upon every change of the visible extents on the map canvas.
const QgsFeatureMap & addedFeatures()
New features which are not commited.
Contains information about the context of a rendering operation.
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
QgsMapRenderer * mapRenderer()
void setMapToPixel(const QgsMapToPixel &mtp)
const QgsMapToPixel & mapToPixel() const
virtual void startRender(QgsRenderContext &context, const QgsVectorLayer *vlayer)=0
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
QgsFeatureId rowToId(int row) const
Maps row to feature id.
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
QgsAttributeTableModel * mTableModel
QModelIndexList fidToIndexList(QgsFeatureId fid)
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
Sort by the given column using the given order.
virtual void setFilteredFeatures(QgsFeatureIds ids)
Specify a list of features, which the filter will accept.
void prefetchColumnData(int column)
Caches the entire data for one column.