8 #include <QItemSelection>
11 : QAbstractProxyModel( parent )
24 QAbstractProxyModel::setSourceModel( sourceModel );
29 connect(
mFilterModel, SIGNAL( rowsAboutToBeRemoved(
const QModelIndex&,
int,
int ) ), SLOT(
onBeginRemoveRows(
const QModelIndex&,
int,
int ) ) );
30 connect(
mFilterModel, SIGNAL( rowsRemoved(
const QModelIndex&,
int,
int ) ), SLOT(
onEndRemoveRows(
const QModelIndex&,
int,
int ) ) );
31 connect(
mFilterModel, SIGNAL( rowsAboutToBeInserted(
const QModelIndex&,
int,
int ) ), SLOT(
onBeginInsertRows(
const QModelIndex&,
int,
int ) ) );
32 connect(
mFilterModel, SIGNAL( rowsInserted(
const QModelIndex&,
int,
int ) ), SLOT(
onEndInsertRows(
const QModelIndex&,
int,
int ) ) );
34 connect(
mFilterModel, SIGNAL( layoutAboutToBeChanged() ),
this, SIGNAL( layoutAboutToBeChanged() ) );
35 connect(
mFilterModel, SIGNAL( layoutChanged() ),
this, SIGNAL( layoutChanged() ) );
56 if ( role == Qt::DisplayRole || role == Qt::EditRole )
67 if ( role == Qt::UserRole )
79 const QList<QgsFeatureId> addedFeatures = editBuffer->
addedFeatures().keys();
82 if ( addedFeatures.contains( feat.
id() ) )
84 featInfo.
isNew =
true;
86 if ( changedFeatures.contains( feat.
id() ) )
92 return QVariant::fromValue( featInfo );
95 return sourceModel()->data(
mapToSource( index ), role );
100 return sourceModel()->flags(
mapToSource( index ) ) & ~Qt::ItemIsEditable;
147 beginRemoveRows( parent, first, last );
160 beginInsertRows( parent, first, last );
173 if ( !proxyIndex.isValid() )
174 return QModelIndex();
181 if ( !sourceIndex.isValid() )
182 return QModelIndex();
189 return mapSelectionFromSource(
mFilterModel->mapSelectionFromSource( selection ) ) ;
194 return mFilterModel->mapSelectionToSource( mapSelectionToSource( selection ) ) ;
201 if ( !proxyIndex.isValid() )
202 return QModelIndex();
204 return sourceModel()->index( proxyIndex.row(), proxyIndex.column() );
209 if ( !sourceIndex.isValid() )
210 return QModelIndex();
212 return createIndex( sourceIndex.row(), 0 );
218 return createIndex( row, column );
224 return QModelIndex();
236 return sourceModel()->rowCount();
246 return QModelIndexList() <<
fidToIndex( fid );
QgsFeatureId id() const
Get the feature id for this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
QgsFeatureListModel(QgsAttributeTableFilterModel *sourceModel, QObject *parent=NULL)
virtual QVariant data(const QModelIndex &index, int role) const
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QgsAttributeTableFilterModel * mFilterModel
const QString expression() const
Alias for dump()
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
virtual QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
QgsExpression * mExpression
const QgsChangedAttributesMap & changedAttributeValues()
Changed attributes values which are not commited.
void onEndInsertRows(const QModelIndex &parent, int first, int last)
QModelIndex idToIndex(QgsFeatureId id) const
bool featureByIndex(const QModelIndex &index, QgsFeature &feat)
Container of fields for a vector layer.
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
virtual QItemSelection mapSelectionToMaster(const QItemSelection &selection) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) 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...
QString parserErrorString()
Returns a detailed message about errors while parsing a QgsExpression.
virtual void setSourceModel(QgsAttributeTableFilterModel *sourceModel)
void onBeginInsertRows(const QModelIndex &parent, int first, int last)
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...
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
QgsVectorLayerCache * layerCache() const
Returns the layerCache this filter acts on.
bool setDisplayExpression(const QString expression)
virtual QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
QModelIndexList fidToIndexList(QgsFeatureId fid)
virtual QModelIndex parent(const QModelIndex &child) const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
QString mParserErrorString
QgsAttributeTableModel * masterModel()
void onBeginRemoveRows(const QModelIndex &parent, int first, int last)
This class caches features of a given QgsVectorLayer.
const QgsFeatureMap & addedFeatures()
New features which are not commited.
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
virtual const QgsFields & fields() const =0
Return a map of indexes with field names for this layer.
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
bool featureAtId(QgsFeatureId featureId, QgsFeature &feature, bool skipCache=false)
Gets the feature at the given feature id.
QModelIndex fidToIndex(QgsFeatureId fid)
virtual ~QgsFeatureListModel()
QgsFeatureId idxToFid(const QModelIndex &index) const
void onEndRemoveRows(const QModelIndex &parent, int first, int last)
QgsVectorLayerCache * layerCache()
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
QgsFeatureId rowToId(int row) const
Maps row to feature id.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsVectorDataProvider * dataProvider()
Returns the data provider.
QModelIndex fidToIdx(const QgsFeatureId fid) const
QString parserErrorString() const
Returns parser error.
virtual QItemSelection mapSelectionFromMaster(const QItemSelection &selection) const
QString displayExpression() const
virtual Qt::ItemFlags flags(const QModelIndex &index) const