QgsDualView class
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
Contents
The attributes can be edited. It supports two different layouts: the table layout, in which the attributes for the features are shown in a table and the editor layout, where the features are shown as a selectable list and the attributes for the currently selected feature are shown in a form.
Public types
- enum ViewMode { AttributeTable = 0, AttributeEditor = 1 }
- The view modes, in which this widget can present information.
Constructors, destructors, conversion operators
- QgsDualView(QWidget* parent = nullptr) explicit
- Constructor.
Public functions
- auto attributeTableConfig() const -> QgsAttributeTableConfig
- The config used for the attribute table.
- auto featureCount() -> int
- Returns the number of features on the layer.
- auto filteredFeatureCount() -> int
- Returns the number of features which are currently visible, according to the filter restrictions.
- auto filteredFeatures() -> QgsFeatureIds
- Gets a list of currently visible feature ids.
-
auto filterMode() -> QgsAttributeTableFilterModel::
FilterMode - Gets the filter mode.
- void init(QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request = QgsFeatureRequest(), const QgsAttributeEditorContext& context = QgsAttributeEditorContext(), bool loadFeatures = true)
- Has to be called to initialize the dual view.
- auto masterModel() const -> QgsAttributeTableModel*
- Returns the model which has the information about all features (not only filtered)
- void setAttributeTableConfig(const QgsAttributeTableConfig& config)
- Set the attribute table config which should be used to control the appearance of the attribute table.
- void setFeatureSelectionManager(QgsIFeatureSelectionManager* featureSelectionManager)
- Set the feature selection model.
- void setFilteredFeatures(const QgsFeatureIds& filteredFeatures)
- Set a list of currently visible features.
-
void setFilterMode(QgsAttributeTableFilterModel::
FilterMode filterMode) - Set the filter mode.
- void setRequest(const QgsFeatureRequest& request)
- Set the request.
- void setSelectedOnTop(bool selectedOnTop)
- Toggle the selectedOnTop flag.
- void setSortExpression(const QString& sortExpression, Qt::SortOrder sortOrder = Qt::AscendingOrder)
- Set the expression used for sorting the table and feature list.
- void setView(ViewMode view)
- Change the current view mode.
- auto sortExpression() const -> QString
- Gets the expression used for sorting the table and feature list.
- auto tableView() -> QgsAttributeTableView*
- Returns the table view.
- auto view() const -> ViewMode
- Returns the current view mode.
Signals
- void displayExpressionChanged(const QString& expression)
- Is emitted, whenever the display expression is successfully changed.
- void filterChanged()
- Is emitted, whenever the filter changes.
-
void filterExpressionSet(const QString& expression,
QgsAttributeForm::
FilterType type) - Is emitted when a filter expression is set using the view.
-
void formModeChanged(QgsAttributeEditorContext::
Mode mode) - Emitted when the form changes mode.
- void showContextMenuExternally(QgsActionMenu* menu, QgsFeatureId fid)
- Emitted when selecting context menu on the feature list to create the context menu individually.
Public slots
- void cancelProgress()
- Cancel the progress dialog (if any)
- void copyCellContent() const
- Copy the content of the selected cell in the clipboard.
- auto saveEditChanges() -> bool
- saveEditChanges
- void setCurrentEditSelection(const QgsFeatureIds& fids)
- Set the current edit selection in the AttributeEditor mode.
- void setMultiEditEnabled(bool enabled)
- Sets whether multi edit mode is enabled.
- void toggleSearchMode(bool enabled)
- Toggles whether search mode should be enabled in the form.
Private slots
Enum documentation
enum QgsDualView:: ViewMode
The view modes, in which this widget can present information.
Relates to the QStackedWidget stacks.
| Enumerators | |
|---|---|
| AttributeTable |
Shows the features and attributes in a table layout. |
| AttributeEditor |
Show a list of the features, where one can be chosen and the according attribute dialog will be presented in the neighbouring frame. |
Function documentation
QgsDualView:: QgsDualView(QWidget* parent = nullptr) explicit
Constructor.
| Parameters | |
|---|---|
| parent | The parent widget |
QgsAttributeTableConfig QgsDualView:: attributeTableConfig() const
The config used for the attribute table.
| Returns | The config used for the attribute table. |
|---|
int QgsDualView:: featureCount()
Returns the number of features on the layer.
| Returns | Number of features |
|---|
int QgsDualView:: filteredFeatureCount()
Returns the number of features which are currently visible, according to the filter restrictions.
| Returns | Number of features |
|---|
QgsAttributeTableFilterModel:: FilterMode QgsDualView:: filterMode()
Gets the filter mode.
| Returns | the filter mode |
|---|
void QgsDualView:: init(QgsVectorLayer* layer,
QgsMapCanvas* mapCanvas,
const QgsFeatureRequest& request = QgsFeatureRequest(),
const QgsAttributeEditorContext& context = QgsAttributeEditorContext(),
bool loadFeatures = true)
Has to be called to initialize the dual view.
| Parameters | |
|---|---|
| layer | The layer which should be used to fetch features |
| mapCanvas | The mapCanvas (used for the FilterMode QgsAttributeTableFilterModel:: |
| request | Use a modified request to limit the shown features |
| context | The context in which this view is shown |
| loadFeatures | whether to initially load all features into the view. If set to false, limited features can later be loaded using setFilterMode() |
QgsAttributeTableModel* QgsDualView:: masterModel() const
Returns the model which has the information about all features (not only filtered)
| Returns | The master model |
|---|
void QgsDualView:: setFeatureSelectionManager(QgsIFeatureSelectionManager* featureSelectionManager)
Set the feature selection model.
| Parameters | |
|---|---|
| featureSelectionManager | the feature selection model |
void QgsDualView:: setFilteredFeatures(const QgsFeatureIds& filteredFeatures)
Set a list of currently visible features.
| Parameters | |
|---|---|
| filteredFeatures | A list of feature ids |
void QgsDualView:: setFilterMode(QgsAttributeTableFilterModel:: FilterMode filterMode)
Set the filter mode.
| Parameters | |
|---|---|
| filterMode | |
void QgsDualView:: setRequest(const QgsFeatureRequest& request)
Set the request.
| Parameters | |
|---|---|
| request | The request |
void QgsDualView:: setSelectedOnTop(bool selectedOnTop)
Toggle the selectedOnTop flag.
| Parameters | |
|---|---|
| selectedOnTop | True: Show selected features on top. False: Use defined sorting column. |
If enabled, selected features will be moved to top.
void QgsDualView:: displayExpressionChanged(const QString& expression) signal
Is emitted, whenever the display expression is successfully changed.
| Parameters | |
|---|---|
| expression | The expression that was applied |
void QgsDualView:: filterExpressionSet(const QString& expression,
QgsAttributeForm:: FilterType type) signal
Is emitted when a filter expression is set using the view.
| Parameters | |
|---|---|
| expression | filter expression |
| type | filter type |
void QgsDualView:: formModeChanged(QgsAttributeEditorContext:: Mode mode) signal
Emitted when the form changes mode.
| Parameters | |
|---|---|
| mode | new mode |
void QgsDualView:: showContextMenuExternally(QgsActionMenu* menu,
QgsFeatureId fid) signal
Emitted when selecting context menu on the feature list to create the context menu individually.
| Parameters | |
|---|---|
| menu | context menu |
| fid | feature id of the selected feature |
void QgsDualView:: cancelProgress() public slot
Cancel the progress dialog (if any)
void QgsDualView:: copyCellContent() const public slot
Copy the content of the selected cell in the clipboard.
bool QgsDualView:: saveEditChanges() public slot
saveEditChanges
| Returns | true if the saving was OK. false is possible due to connected validation logic. |
|---|
void QgsDualView:: setCurrentEditSelection(const QgsFeatureIds& fids) public slot
Set the current edit selection in the AttributeEditor mode.
| Parameters | |
|---|---|
| fids | A list of edited features (Currently only one at a time is supported) |
void QgsDualView:: setMultiEditEnabled(bool enabled) public slot
Sets whether multi edit mode is enabled.
void QgsDualView:: toggleSearchMode(bool enabled) public slot
Toggles whether search mode should be enabled in the form.
| Parameters | |
|---|---|
| enabled | set to true to switch on search mode |
void QgsDualView:: finished() virtual private slot
Will be called, once all the features are loaded.
Use e.g. to close a dialog created from progress( int i, bool &cancel )
void QgsDualView:: progress(int i,
bool& cancel) virtual private slot
Will be called periodically, when loading layers from slow data providers.
| Parameters | |
|---|---|
| i | The number of features already loaded |
| cancel | Set to true to cancel |