Quantum GIS API Documentation  master-ce49b66
QgsAttributeTableFilterModel Class Reference

#include <qgsattributetablefiltermodel.h>

+ Inheritance diagram for QgsAttributeTableFilterModel:
+ Collaboration diagram for QgsAttributeTableFilterModel:

List of all members.

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)
QgsVectorLayerlayer () const
 Returns the layer this filter acts on.
QgsVectorLayerCachelayerCache () const
 Returns the layerCache this filter acts on.
virtual QModelIndex mapFromMaster (const QModelIndex &sourceIndex) const
virtual QModelIndex mapToMaster (const QModelIndex &proxyIndex) const
QgsAttributeTableModelmasterModel () 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

QgsMapCanvasmCanvas
QgsFeatureIds mFilteredFeatures
FilterMode mFilterMode
QItemSelectionModel * mMasterSelection
bool mSelectedOnTop
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

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().

Implements QgsFeatureModel.

Definition at line 295 of file qgsattributetablefiltermodel.cpp.

References mapFromMaster(), and masterModel().

bool QgsAttributeTableFilterModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const [protected]

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

Referenced by QgsFeatureListModel::mapToMaster().

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

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

Referenced by filterAcceptsRow(), and lessThan().

Returns if selected features are currently shown on top.

Returns:
True if selected are shown on top

Definition at line 118 of file qgsattributetablefiltermodel.cpp.

References mSelectedOnTop.

Referenced by setSelectedOnTop().

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

References mFilteredFeatures, setFilterMode(), and ShowFilteredList.

Referenced by QgsDualView::setFilteredFeatures().

Set the filter mode the filter will use.

Parameters:
filterModeSets 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

Parameters:
selectedOnTopSpecify, 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::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.

Parameters:
columnThe column which should be sorted
orderThe order ( Qt::AscendingOrder or Qt::DescendingOrder )

Definition at line 89 of file qgsattributetablefiltermodel.cpp.

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

Referenced by selectionChanged(), and setSelectedOnTop().


Member Data Documentation

QItemSelectionModel* QgsAttributeTableFilterModel::mMasterSelection [private]

Definition at line 170 of file qgsattributetablefiltermodel.h.

Referenced by QgsAttributeTableFilterModel(), and setSourceModel().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines