|
QGIS API Documentation
2.8.6-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. More... | |
| void | progress (int i, bool &cancel) |
Public Member Functions | |
| QgsAttributeTableModel (QgsVectorLayerCache *layerCache, QObject *parent=0) | |
| Constructor. More... | |
| int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| Returns the number of columns. More... | |
| virtual QVariant | data (const QModelIndex &index, int role) const override |
| Returns data on the given index. More... | |
| const QgsAttributeEditorContext & | editorContext () const |
| Returns the context in which this table is shown. More... | |
| void | executeAction (int action, const QModelIndex &idx) const |
| Execute an action. More... | |
| void | executeMapLayerAction (QgsMapLayerAction *action, const QModelIndex &idx) const |
| Execute a QgsMapLayerAction. More... | |
| QgsFeature | feature (const QModelIndex &idx) const |
| Return the feature attributes at given model index. More... | |
| int | fieldCol (int idx) const |
| get column from field index More... | |
| int | fieldIdx (int col) const |
| get field index from column More... | |
| Qt::ItemFlags | flags (const QModelIndex &index) const override |
| Returns item flags for the index. More... | |
| QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
| Returns header data. More... | |
| QModelIndex | idToIndex (QgsFeatureId id) const |
| QModelIndexList | idToIndexList (QgsFeatureId id) const |
| int | idToRow (QgsFeatureId id) const |
| Maps feature id to table row. More... | |
| QgsVectorLayer * | layer () const |
| Returns the layer this model uses as backend. More... | |
| QgsVectorLayerCache * | layerCache () const |
| Returns the layer cache this model uses as backend. More... | |
| virtual void | loadLayer () |
| Loads the layer into the model Preferably to be called, before basing any other models on this model. More... | |
| void | prefetchColumnData (int column) |
| Caches the entire data for one column. More... | |
| void | reload (const QModelIndex &index1, const QModelIndex &index2) |
| Reloads the model data between indices. More... | |
| bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
| Remove rows. More... | |
| const QgsFeatureRequest & | request () const |
| Get the the feature request. More... | |
| void | resetModel () |
| Resets the model. More... | |
| virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| Returns the number of rows. More... | |
| QgsFeatureId | rowToId (int row) const |
| Maps row to feature id. More... | |
| virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
| Updates data on given index. More... | |
| void | setEditorContext (const QgsAttributeEditorContext &context) |
| Sets the context in which this table is shown. More... | |
| void | setRequest (const QgsFeatureRequest &request) |
| Set a request that will be used to fill this attribute table model. More... | |
| void | swapRows (QgsFeatureId a, QgsFeatureId b) |
| Swaps two rows. More... | |
Protected Slots | |
| virtual void | attributeValueChanged (QgsFeatureId fid, int idx, const QVariant &value) |
| Launched when attribute value has been changed. More... | |
| virtual void | featureAdded (QgsFeatureId fid) |
| Launched when a feature has been added. More... | |
| virtual void | featureDeleted (QgsFeatureId fid) |
| Launched when a feature has been deleted. More... | |
| virtual void | layerDeleted () |
| Launched when layer has been deleted. More... | |
Protected Member Functions | |
| virtual void | loadAttributes () |
| Gets mFieldCount, mAttributes and mValueMaps. More... | |
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.
| Enumerator | |
|---|---|
| SortRole | |
| FeatureIdRole | |
| FieldIndexRole | |
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 36 of file qgsattributetablemodel.cpp.
|
protectedvirtualslot |
Launched when attribute value has been changed.
| fid | feature id |
| idx | attribute index |
| value | new value |
Definition at line 193 of file qgsattributetablemodel.cpp.
|
override |
Returns the number of columns.
| parent | parent index |
Definition at line 410 of file qgsattributetablemodel.cpp.
|
overridevirtual |
Returns data on the given index.
| index | model index |
| role | data role |
Definition at line 448 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 584 of file qgsattributetablemodel.cpp.
| void QgsAttributeTableModel::executeMapLayerAction | ( | QgsMapLayerAction * | action, |
| const QModelIndex & | idx | ||
| ) | const |
Execute a QgsMapLayerAction.
Definition at line 590 of file qgsattributetablemodel.cpp.
| QgsFeature QgsAttributeTableModel::feature | ( | const QModelIndex & | idx | ) | const |
Return the feature attributes at given model index.
Definition at line 596 of file qgsattributetablemodel.cpp.
|
protectedvirtualslot |
Launched when a feature has been added.
| fid | feature id |
Definition at line 132 of file qgsattributetablemodel.cpp.
|
protectedvirtualslot |
Launched when a feature has been deleted.
| fid | feature id |
Definition at line 77 of file qgsattributetablemodel.cpp.
| int QgsAttributeTableModel::fieldCol | ( | int | idx | ) | const |
get column from field index
Definition at line 399 of file qgsattributetablemodel.cpp.
| int QgsAttributeTableModel::fieldIdx | ( | int | col | ) | const |
get field index from column
Definition at line 394 of file qgsattributetablemodel.cpp.
|
signal |
|
override |
Returns item flags for the index.
| index | model index |
Definition at line 553 of file qgsattributetablemodel.cpp.
|
override |
Returns header data.
| section | required section |
| orientation | horizontal or vertical orientation |
| role | data role |
Definition at line 416 of file qgsattributetablemodel.cpp.
| QModelIndex QgsAttributeTableModel::idToIndex | ( | QgsFeatureId | id | ) | const |
Definition at line 364 of file qgsattributetablemodel.cpp.
| QModelIndexList QgsAttributeTableModel::idToIndexList | ( | QgsFeatureId | id | ) | const |
Definition at line 369 of file qgsattributetablemodel.cpp.
| int QgsAttributeTableModel::idToRow | ( | QgsFeatureId | id | ) | const |
Maps feature id to table row.
| id | feature id |
Definition at line 353 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 179 of file qgsattributetablemodel.cpp.
|
protectedvirtual |
Gets mFieldCount, mAttributes and mValueMaps.
Definition at line 235 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 289 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 609 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 572 of file qgsattributetablemodel.cpp.
|
override |
Remove rows.
Definition at line 92 of file qgsattributetablemodel.cpp.
| const QgsFeatureRequest & QgsAttributeTableModel::request | ( | ) | const |
Get the the feature request.
Definition at line 646 of file qgsattributetablemodel.cpp.
| void QgsAttributeTableModel::resetModel | ( | ) |
Resets the model.
Definition at line 578 of file qgsattributetablemodel.cpp.
|
overridevirtual |
Returns the number of rows.
| parent | parent index |
Definition at line 404 of file qgsattributetablemodel.cpp.
| QgsFeatureId QgsAttributeTableModel::rowToId | ( | int | row | ) | const |
Maps row to feature id.
| row | row number |
Definition at line 382 of file qgsattributetablemodel.cpp.
|
overridevirtual |
Updates data on given index.
| index | model index |
| value | new data value |
| role | data role |
Definition at line 516 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 639 of file qgsattributetablemodel.cpp.
| void QgsAttributeTableModel::swapRows | ( | QgsFeatureId | a, |
| QgsFeatureId | b | ||
| ) |
Swaps two rows.
| a | first row |
| b | second row |
Definition at line 330 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.
1.8.11