QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
QgsDualView Class Reference

This widget is used to show the attributes of a set of features of a QgsVectorLayer. More...

#include <qgsdualview.h>

Inheritance diagram for QgsDualView:
Inheritance graph
[legend]

Public Types

enum  FeatureListBrowsingAction { NoAction = 0 , PanToFeature , ZoomToFeature }
 Action on the map canvas when browsing the list of features. More...
 
enum  ViewMode { AttributeTable = 0 , AttributeEditor = 1 }
 The view modes, in which this widget can present information. More...
 

Public Slots

void cancelProgress ()
 Cancel the progress dialog (if any)
 
void copyCellContent () const
 Copy the content of the selected cell in the clipboard.
 
void openConditionalStyles ()
 
void parentFormValueChanged (const QString &attribute, const QVariant &value)
 Called in embedded forms when an attribute value in the parent form has changed.
 
bool saveEditChanges ()
 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.
 

Signals

void displayExpressionChanged (const QString &expression)
 Emitted whenever the display expression is successfully changed.
 
void filterChanged ()
 Emitted whenever the filter changes.
 
void filterExpressionSet (const QString &expression, QgsAttributeForm::FilterType type)
 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 Member Functions

 QgsDualView (QWidget *parent=nullptr)
 Constructor.
 
 ~QgsDualView () override
 
QgsAttributeTableConfig attributeTableConfig () const
 The config used for the attribute table.
 
int featureCount ()
 Returns the number of features on the layer.
 
int filteredFeatureCount ()
 Returns the number of features which are currently visible, according to the filter restrictions.
 
QgsFeatureIds filteredFeatures ()
 Gets a list of currently visible feature ids.
 
void filterFeatures (const QgsExpression &filterExpression, const QgsExpressionContext &context)
 Sets the expression and Updates the filtered features in the filter model.
 
QgsAttributeTableFilterModel::FilterMode filterMode ()
 Gets the filter mode.
 
void init (QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext(), bool loadFeatures=true, bool showFirstFeature=true)
 Has to be called to initialize the dual view.
 
QgsAttributeTableModelmasterModel () const
 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.
 
Q_DECL_DEPRECATED 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.
 
QString sortExpression () const
 Gets the expression used for sorting the table and feature list.
 
QgsAttributeTableViewtableView ()
 Returns the table view.
 
ViewMode view () const
 Returns the current view mode.
 

Static Public Member Functions

static QgsAttributeList requiredAttributes (const QgsVectorLayer *layer)
 Returns the list of required attributes according to the attribute table configuration of the layer, only visible attributes and virtual fields referenced fields are returned.
 

Protected Member Functions

void hideEvent (QHideEvent *event) override
 

Friends

class TestQgsAttributeTable
 
class TestQgsDualView
 

Detailed Description

This widget is used to show the attributes of a set of features of a QgsVectorLayer.

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.

Definition at line 44 of file qgsdualview.h.

Member Enumeration Documentation

◆ FeatureListBrowsingAction

Action on the map canvas when browsing the list of features.

Enumerator
NoAction 

No action is done.

PanToFeature 

The map is panned to the center of the feature bounding-box.

ZoomToFeature 

The map is zoomed to contained the feature bounding-box.

Definition at line 74 of file qgsdualview.h.

◆ ViewMode

The view modes, in which this widget can present information.

Relates to the QStackedWidget stacks.

Enumerator
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.

Definition at line 55 of file qgsdualview.h.

Constructor & Destructor Documentation

◆ QgsDualView()

QgsDualView::QgsDualView ( QWidget *  parent = nullptr)
explicit

Constructor.

Parameters
parentThe parent widget

Definition at line 52 of file qgsdualview.cpp.

◆ ~QgsDualView()

QgsDualView::~QgsDualView ( )
override

Definition at line 116 of file qgsdualview.cpp.

Member Function Documentation

◆ attributeTableConfig()

QgsAttributeTableConfig QgsDualView::attributeTableConfig ( ) const

The config used for the attribute table.

Returns
The config used for the attribute table.

Definition at line 1368 of file qgsdualview.cpp.

◆ cancelProgress

void QgsDualView::cancelProgress ( )
slot

Cancel the progress dialog (if any)

Definition at line 820 of file qgsdualview.cpp.

◆ copyCellContent

void QgsDualView::copyCellContent ( ) const
slot

Copy the content of the selected cell in the clipboard.

Definition at line 808 of file qgsdualview.cpp.

◆ displayExpressionChanged

void QgsDualView::displayExpressionChanged ( const QString &  expression)
signal

Emitted whenever the display expression is successfully changed.

Parameters
expressionThe expression that was applied

◆ featureCount()

int QgsDualView::featureCount ( )

Returns the number of features on the layer.

Returns
Number of features

Definition at line 798 of file qgsdualview.cpp.

◆ filterChanged

void QgsDualView::filterChanged ( )
signal

Emitted whenever the filter changes.

◆ filteredFeatureCount()

int QgsDualView::filteredFeatureCount ( )

Returns the number of features which are currently visible, according to the filter restrictions.

Returns
Number of features

Definition at line 803 of file qgsdualview.cpp.

◆ filteredFeatures()

QgsFeatureIds QgsDualView::filteredFeatures ( )
inline

Gets a list of currently visible feature ids.

Definition at line 178 of file qgsdualview.h.

◆ filterExpressionSet

void QgsDualView::filterExpressionSet ( const QString &  expression,
QgsAttributeForm::FilterType  type 
)
signal

Emitted when a filter expression is set using the view.

Parameters
expressionfilter expression
typefilter type

◆ filterFeatures()

void QgsDualView::filterFeatures ( const QgsExpression filterExpression,
const QgsExpressionContext context 
)

Sets the expression and Updates the filtered features in the filter model.

It is called when the filter expression changed.

Since
QGIS 3.10.3

Definition at line 1307 of file qgsdualview.cpp.

◆ filterMode()

QgsAttributeTableFilterModel::FilterMode QgsDualView::filterMode ( )
inline

Gets the filter mode.

Returns
the filter mode

Definition at line 133 of file qgsdualview.h.

◆ formModeChanged

void QgsDualView::formModeChanged ( QgsAttributeEditorContext::Mode  mode)
signal

Emitted when the form changes mode.

Parameters
modenew mode

◆ hideEvent()

void QgsDualView::hideEvent ( QHideEvent *  event)
overrideprotected

Definition at line 834 of file qgsdualview.cpp.

◆ init()

void QgsDualView::init ( QgsVectorLayer layer,
QgsMapCanvas mapCanvas,
const QgsFeatureRequest request = QgsFeatureRequest(),
const QgsAttributeEditorContext context = QgsAttributeEditorContext(),
bool  loadFeatures = true,
bool  showFirstFeature = true 
)

Has to be called to initialize the dual view.

Parameters
layerThe layer which should be used to fetch features
mapCanvasThe mapCanvas (used for the FilterMode QgsAttributeTableFilterModel::ShowVisible)
requestUse a modified request to limit the shown features
contextThe context in which this view is shown
loadFeatureswhether to initially load all features into the view. If set to false, limited features can later be loaded using setFilterMode()
showFirstFeaturewhether to initially show the first feature form upon initializing the dual view

Definition at line 122 of file qgsdualview.cpp.

◆ masterModel()

QgsAttributeTableModel * QgsDualView::masterModel ( ) const
inline

Returns the model which has the information about all features (not only filtered)

Returns
The master model

Definition at line 185 of file qgsdualview.h.

◆ openConditionalStyles

void QgsDualView::openConditionalStyles ( )
slot

Definition at line 717 of file qgsdualview.cpp.

◆ parentFormValueChanged

void QgsDualView::parentFormValueChanged ( const QString &  attribute,
const QVariant &  value 
)
slot

Called in embedded forms when an attribute value in the parent form has changed.

Notify the form widgets that something has changed in case they have filter expression that depend on the parent form scope.

Since
QGIS 3.14

Definition at line 826 of file qgsdualview.cpp.

◆ requiredAttributes()

QgsAttributeList QgsDualView::requiredAttributes ( const QgsVectorLayer layer)
static

Returns the list of required attributes according to the attribute table configuration of the layer, only visible attributes and virtual fields referenced fields are returned.

Since
QGIS 3.32

Definition at line 1149 of file qgsdualview.cpp.

◆ saveEditChanges

bool QgsDualView::saveEditChanges ( )
slot

saveEditChanges

Returns
true if the saving was OK. false is possible due to connected validation logic.

Definition at line 712 of file qgsdualview.cpp.

◆ setAttributeTableConfig()

void QgsDualView::setAttributeTableConfig ( const QgsAttributeTableConfig config)

Set the attribute table config which should be used to control the appearance of the attribute table.

Definition at line 1330 of file qgsdualview.cpp.

◆ setCurrentEditSelection

void QgsDualView::setCurrentEditSelection ( const QgsFeatureIds fids)
slot

Set the current edit selection in the AttributeEditor mode.

Parameters
fidsA list of edited features (Currently only one at a time is supported)

Definition at line 706 of file qgsdualview.cpp.

◆ setFeatureSelectionManager()

void QgsDualView::setFeatureSelectionManager ( QgsIFeatureSelectionManager featureSelectionManager)

Set the feature selection model.

Parameters
featureSelectionManagerthe feature selection model

Definition at line 1319 of file qgsdualview.cpp.

◆ setFilteredFeatures()

void QgsDualView::setFilteredFeatures ( const QgsFeatureIds filteredFeatures)

Set a list of currently visible features.

Parameters
filteredFeaturesA list of feature ids
Deprecated:
QGIS 3.40. Since filterFeatures is handled in the attribute filter model itself.

Definition at line 1302 of file qgsdualview.cpp.

◆ setFilterMode()

void QgsDualView::setFilterMode ( QgsAttributeTableFilterModel::FilterMode  filterMode)

Set the filter mode.

Parameters
filterMode

Definition at line 309 of file qgsdualview.cpp.

◆ setMultiEditEnabled

void QgsDualView::setMultiEditEnabled ( bool  enabled)
slot

Sets whether multi edit mode is enabled.

Definition at line 722 of file qgsdualview.cpp.

◆ setRequest()

void QgsDualView::setRequest ( const QgsFeatureRequest request)

Set the request.

Parameters
requestThe request

Definition at line 1314 of file qgsdualview.cpp.

◆ setSelectedOnTop()

void QgsDualView::setSelectedOnTop ( bool  selectedOnTop)

Toggle the selectedOnTop flag.

If enabled, selected features will be moved to top.

Parameters
selectedOnToptrue: Show selected features on top. false: Use defined sorting column.

Definition at line 433 of file qgsdualview.cpp.

◆ setSortExpression()

void QgsDualView::setSortExpression ( const QString &  sortExpression,
Qt::SortOrder  sortOrder = Qt::AscendingOrder 
)

Set the expression used for sorting the table and feature list.

Definition at line 1350 of file qgsdualview.cpp.

◆ setView()

void QgsDualView::setView ( QgsDualView::ViewMode  view)

Change the current view mode.

Parameters
viewThe view mode to set
See also
view()

Definition at line 299 of file qgsdualview.cpp.

◆ showContextMenuExternally

void QgsDualView::showContextMenuExternally ( QgsActionMenu menu,
QgsFeatureId  fid 
)
signal

Emitted when selecting context menu on the feature list to create the context menu individually.

Parameters
menucontext menu
fidfeature id of the selected feature

◆ sortExpression()

QString QgsDualView::sortExpression ( ) const

Gets the expression used for sorting the table and feature list.

Definition at line 1363 of file qgsdualview.cpp.

◆ tableView()

QgsAttributeTableView * QgsDualView::tableView ( )
inline

Returns the table view.

Returns
The table view

Definition at line 206 of file qgsdualview.h.

◆ toggleSearchMode

void QgsDualView::toggleSearchMode ( bool  enabled)
slot

Toggles whether search mode should be enabled in the form.

Parameters
enabledset to true to switch on search mode

Definition at line 740 of file qgsdualview.cpp.

◆ view()

QgsDualView::ViewMode QgsDualView::view ( ) const

Returns the current view mode.

See also
setView()

Definition at line 304 of file qgsdualview.cpp.

Friends And Related Symbol Documentation

◆ TestQgsAttributeTable

friend class TestQgsAttributeTable
friend

Definition at line 452 of file qgsdualview.h.

◆ TestQgsDualView

friend class TestQgsDualView
friend

Definition at line 451 of file qgsdualview.h.


The documentation for this class was generated from the following files: