QGIS API Documentation
2.8.2-Wien
|
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a QAbstractItemView. More...
#include <qgsattributetablemodel.h>
Public Types | |
enum | Role { SortRole = Qt::UserRole + 1, FeatureIdRole = Qt::UserRole + 2, FieldIndexRole = Qt::UserRole + 3 } |
Signals | |
void | finished () |
void | modelChanged () |
Model has been changed. | |
void | progress (int i, bool &cancel) |
Public Member Functions | |
QgsAttributeTableModel (QgsVectorLayerCache *layerCache, QObject *parent=0) | |
Constructor. | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
Returns the number of columns. | |
virtual QVariant | data (const QModelIndex &index, int role) const override |
Returns data on the given index. | |
const QgsAttributeEditorContext & | editorContext () const |
Returns the context in which this table is shown. | |
void | executeAction (int action, const QModelIndex &idx) const |
Execute an action. | |
void | executeMapLayerAction (QgsMapLayerAction *action, const QModelIndex &idx) const |
Execute a QgsMapLayerAction. | |
QgsFeature | feature (const QModelIndex &idx) const |
Return the feature attributes at given model index. | |
int | fieldCol (int idx) const |
get column from field index | |
int | fieldIdx (int col) const |
get field index from column | |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
Returns item flags for the index. | |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
Returns header data. | |
QModelIndex | idToIndex (QgsFeatureId id) const |
QModelIndexList | idToIndexList (QgsFeatureId id) const |
int | idToRow (QgsFeatureId id) const |
Maps feature id to table row. | |
QgsVectorLayer * | layer () const |
Returns the layer this model uses as backend. | |
QgsVectorLayerCache * | layerCache () const |
Returns the layer cache this model uses as backend. | |
virtual void | loadLayer () |
Loads the layer into the model Preferably to be called, before basing any other models on this model. | |
void | prefetchColumnData (int column) |
Caches the entire data for one column. | |
void | reload (const QModelIndex &index1, const QModelIndex &index2) |
Reloads the model data between indices. | |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
Remove rows. | |
const QgsFeatureRequest & | request () const |
Get the the feature request. | |
void | resetModel () |
Resets the model. | |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
Returns the number of rows. | |
QgsFeatureId | rowToId (int row) const |
Maps row to feature id. | |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
Updates data on given index. | |
void | setEditorContext (const QgsAttributeEditorContext &context) |
Sets the context in which this table is shown. | |
void | setRequest (const QgsFeatureRequest &request) |
Set a request that will be used to fill this attribute table model. | |
void | swapRows (QgsFeatureId a, QgsFeatureId b) |
Swaps two rows. |
Protected Slots | |
virtual void | attributeValueChanged (QgsFeatureId fid, int idx, const QVariant &value) |
Launched when attribute value has been changed. | |
virtual void | featureAdded (QgsFeatureId fid) |
Launched when a feature has been added. | |
virtual void | featureDeleted (QgsFeatureId fid) |
Launched when a feature has been deleted. | |
virtual void | layerDeleted () |
Launched when layer has been deleted. |
Protected Member Functions | |
virtual void | loadAttributes () |
Gets mFieldCount, mAttributes and mValueMaps. |
Protected Attributes | |
QgsAttributeList | mAttributes |
QVector< QVariant > | mAttributeWidgetCaches |
QgsFeature | mFeat |
int | mFieldCount |
QHash< QgsFeatureId, int > | mIdRowMap |
QgsVectorLayerCache * | mLayerCache |
QHash< int, QgsFeatureId > | mRowIdMap |
QVector< QgsEditorWidgetConfig > | mWidgetConfigs |
QVector< QgsEditorWidgetFactory * > | mWidgetFactories |
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a QAbstractItemView.
Is able to generate editor widgets for its QModelIndexes as well. Is mostly referred to as "master model" within this doc and the source.
Definition at line 45 of file qgsattributetablemodel.h.
Definition at line 50 of file qgsattributetablemodel.h.
QgsAttributeTableModel::QgsAttributeTableModel | ( | QgsVectorLayerCache * | layerCache, |
QObject * | parent = 0 |
||
) |
Constructor.
layerCache | A layer cache to use as backend |
parent | The parent QObject (owner) |
Definition at line 35 of file qgsattributetablemodel.cpp.
|
protectedvirtualslot |
Launched when attribute value has been changed.
fid | feature id |
idx | attribute index |
value | new value |
Definition at line 192 of file qgsattributetablemodel.cpp.
|
override |
Returns the number of columns.
parent | parent index |
Definition at line 409 of file qgsattributetablemodel.cpp.
|
overridevirtual |
Returns data on the given index.
index | model index |
role | data role |
Definition at line 447 of file qgsattributetablemodel.cpp.
|
inline |
Returns the context in which this table is shown.
Will be forwarded to any editor widget created when editing data on this model.
Definition at line 225 of file qgsattributetablemodel.h.
void QgsAttributeTableModel::executeAction | ( | int | action, |
const QModelIndex & | idx | ||
) | const |
Execute an action.
Definition at line 581 of file qgsattributetablemodel.cpp.
void QgsAttributeTableModel::executeMapLayerAction | ( | QgsMapLayerAction * | action, |
const QModelIndex & | idx | ||
) | const |
Execute a QgsMapLayerAction.
Definition at line 587 of file qgsattributetablemodel.cpp.
QgsFeature QgsAttributeTableModel::feature | ( | const QModelIndex & | idx | ) | const |
Return the feature attributes at given model index.
Definition at line 593 of file qgsattributetablemodel.cpp.
|
protectedvirtualslot |
Launched when a feature has been added.
fid | feature id |
Definition at line 131 of file qgsattributetablemodel.cpp.
|
protectedvirtualslot |
Launched when a feature has been deleted.
fid | feature id |
Definition at line 76 of file qgsattributetablemodel.cpp.
int QgsAttributeTableModel::fieldCol | ( | int | idx | ) | const |
get column from field index
Definition at line 398 of file qgsattributetablemodel.cpp.
int QgsAttributeTableModel::fieldIdx | ( | int | col | ) | const |
get field index from column
Definition at line 393 of file qgsattributetablemodel.cpp.
|
signal |
|
override |
Returns item flags for the index.
index | model index |
Definition at line 552 of file qgsattributetablemodel.cpp.
|
override |
Returns header data.
section | required section |
orientation | horizontal or vertical orientation |
role | data role |
Definition at line 415 of file qgsattributetablemodel.cpp.
QModelIndex QgsAttributeTableModel::idToIndex | ( | QgsFeatureId | id | ) | const |
Definition at line 363 of file qgsattributetablemodel.cpp.
QModelIndexList QgsAttributeTableModel::idToIndexList | ( | QgsFeatureId | id | ) | const |
Definition at line 368 of file qgsattributetablemodel.cpp.
int QgsAttributeTableModel::idToRow | ( | QgsFeatureId | id | ) | const |
Maps feature id to table row.
id | feature id |
Definition at line 352 of file qgsattributetablemodel.cpp.
|
inline |
Returns the layer this model uses as backend.
Retrieved from the layer cache.
Definition at line 165 of file qgsattributetablemodel.h.
|
inline |
Returns the layer cache this model uses as backend.
Definition at line 170 of file qgsattributetablemodel.h.
|
protectedvirtualslot |
Launched when layer has been deleted.
Definition at line 178 of file qgsattributetablemodel.cpp.
|
protectedvirtual |
Gets mFieldCount, mAttributes and mValueMaps.
Definition at line 234 of file qgsattributetablemodel.cpp.
|
virtual |
Loads the layer into the model Preferably to be called, before basing any other models on this model.
Definition at line 288 of file qgsattributetablemodel.cpp.
|
signal |
Model has been changed.
void QgsAttributeTableModel::prefetchColumnData | ( | int | column | ) |
Caches the entire data for one column.
This should be called prior to sorting, so the data does not have to be fetched for every single comparison. Specify -1 as column to invalidate the cache
column | The column index of the field to catch |
Definition at line 606 of file qgsattributetablemodel.cpp.
|
signal |
void QgsAttributeTableModel::reload | ( | const QModelIndex & | index1, |
const QModelIndex & | index2 | ||
) |
Reloads the model data between indices.
index1 | start index |
index2 | end index |
Definition at line 569 of file qgsattributetablemodel.cpp.
|
override |
Remove rows.
Definition at line 91 of file qgsattributetablemodel.cpp.
const QgsFeatureRequest & QgsAttributeTableModel::request | ( | ) | const |
Get the the feature request.
Definition at line 643 of file qgsattributetablemodel.cpp.
void QgsAttributeTableModel::resetModel | ( | ) |
Resets the model.
Definition at line 575 of file qgsattributetablemodel.cpp.
|
overridevirtual |
Returns the number of rows.
parent | parent index |
Definition at line 403 of file qgsattributetablemodel.cpp.
QgsFeatureId QgsAttributeTableModel::rowToId | ( | int | row | ) | const |
Maps row to feature id.
row | row number |
Definition at line 381 of file qgsattributetablemodel.cpp.
|
overridevirtual |
Updates data on given index.
index | model index |
value | new data value |
role | data role |
Definition at line 515 of file qgsattributetablemodel.cpp.
|
inline |
Sets the context in which this table is shown.
Will be forwarded to any editor widget created when editing data on this model.
context | The context |
Definition at line 217 of file qgsattributetablemodel.h.
void QgsAttributeTableModel::setRequest | ( | const QgsFeatureRequest & | request | ) |
Set a request that will be used to fill this attribute table model.
In contrast to a filter, the request will constrain the data shown without the possibility to dynamically adjust it.
request | The request to use to fill this table model. |
Definition at line 636 of file qgsattributetablemodel.cpp.
void QgsAttributeTableModel::swapRows | ( | QgsFeatureId | a, |
QgsFeatureId | b | ||
) |
Swaps two rows.
a | first row |
b | second row |
Definition at line 329 of file qgsattributetablemodel.cpp.
|
protected |
Definition at line 285 of file qgsattributetablemodel.h.
|
protected |
Definition at line 287 of file qgsattributetablemodel.h.
|
mutableprotected |
Definition at line 283 of file qgsattributetablemodel.h.
|
protected |
Definition at line 281 of file qgsattributetablemodel.h.
|
protected |
Definition at line 290 of file qgsattributetablemodel.h.
|
protected |
Definition at line 280 of file qgsattributetablemodel.h.
|
protected |
Definition at line 291 of file qgsattributetablemodel.h.
|
protected |
Definition at line 288 of file qgsattributetablemodel.h.
|
protected |
Definition at line 286 of file qgsattributetablemodel.h.