QGIS API Documentation
qgsdualview.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdualview.cpp
3  --------------------------------------
4  Date : 10.2.2013
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias at opengis dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsapplication.h"
17 #include "qgsactionmanager.h"
18 #include "qgsattributeform.h"
19 #include "qgsattributetablemodel.h"
20 #include "qgsdualview.h"
22 #include "qgsfeaturelistmodel.h"
24 #include "qgsmapcanvas.h"
26 #include "qgsmessagelog.h"
27 #include "qgsvectordataprovider.h"
28 #include "qgsvectorlayercache.h"
29 
30 #include <QDialog>
31 #include <QMenu>
32 #include <QMessageBox>
33 #include <QProgressDialog>
34 #include <QSettings>
35 
37  : QStackedWidget( parent )
38  , mEditorContext()
39  , mMasterModel( nullptr )
40  , mFilterModel( nullptr )
41  , mFeatureListModel( nullptr )
42  , mAttributeForm( nullptr )
43  , mLayerCache( nullptr )
44  , mProgressDlg( nullptr )
45  , mFeatureSelectionManager( nullptr )
46 {
47  setupUi( this );
48 
49  mConditionalFormatWidget->hide();
50 
51  mPreviewActionMapper = new QSignalMapper( this );
52 
53  mPreviewColumnsMenu = new QMenu( this );
54  mActionPreviewColumnsMenu->setMenu( mPreviewColumnsMenu );
55 
56  // Set preview icon
57  mActionExpressionPreview->setIcon( QgsApplication::getThemeIcon( "/mIconExpressionPreview.svg" ) );
58 
59  // Connect layer list preview signals
60  connect( mActionExpressionPreview, SIGNAL( triggered() ), SLOT( previewExpressionBuilder() ) );
61  connect( mPreviewActionMapper, SIGNAL( mapped( QObject* ) ), SLOT( previewColumnChanged( QObject* ) ) );
62  connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SLOT( previewExpressionChanged( QString ) ) );
63 }
64 
65 void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest &request, const QgsAttributeEditorContext &context )
66 {
67  mEditorContext = context;
68 
69  connect( mTableView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );
70 
71  initLayerCache( layer, !request.filterRect().isNull() );
72  initModels( mapCanvas, request );
73 
74  mConditionalFormatWidget->setLayer( layer );
75 
76  mTableView->setModel( mFilterModel );
77  mFeatureList->setModel( mFeatureListModel );
78  mAttributeForm = new QgsAttributeForm( layer, QgsFeature(), mEditorContext );
79  if ( !mAttributeEditorScrollArea->layout() )
80  mAttributeEditorScrollArea->setLayout( new QGridLayout() );
81  mAttributeEditorScrollArea->layout()->addWidget( mAttributeForm );
82  mAttributeEditorScrollArea->setWidget( mAttributeForm );
83 
84  mAttributeForm->hideButtonBox();
85 
86  connect( mAttributeForm, SIGNAL( attributeChanged( QString, QVariant ) ), this, SLOT( featureFormAttributeChanged() ) );
87  connect( mMasterModel, SIGNAL( modelChanged() ), mAttributeForm, SLOT( refreshFeature() ) );
88 
89  if ( mFeatureListPreviewButton->defaultAction() )
90  mFeatureList->setDisplayExpression( mDisplayExpression );
91  else
92  columnBoxInit();
93 
94  // This slows down load of the attribute table heaps and uses loads of memory.
95  //mTableView->resizeColumnsToContents();
96 
97  mFeatureList->setEditSelection( QgsFeatureIds() << mFeatureListModel->idxToFid( mFeatureListModel->index( 0, 0 ) ) );
98 }
99 
101 {
102  // load fields
103  QList<QgsField> fields = mLayerCache->layer()->fields().toList();
104 
105  QString defaultField;
106 
107  // default expression: saved value
108  QString displayExpression = mLayerCache->layer()->displayExpression();
109 
110  // if no display expression is saved: use display field instead
111  if ( displayExpression.isEmpty() )
112  {
113  if ( !mLayerCache->layer()->displayField().isEmpty() )
114  {
115  defaultField = mLayerCache->layer()->displayField();
116  displayExpression = QString( "COALESCE(\"%1\", '<NULL>')" ).arg( defaultField );
117  }
118  }
119 
120  // if neither display expression nor display field is saved...
121  if ( displayExpression.isEmpty() )
122  {
123  QgsAttributeList pkAttrs = mLayerCache->layer()->pkAttributeList();
124 
125  if ( !pkAttrs.isEmpty() )
126  {
127  if ( pkAttrs.size() == 1 )
128  defaultField = pkAttrs.at( 0 );
129 
130  // ... If there are primary key(s) defined
131  QStringList pkFields;
132 
133  Q_FOREACH ( int attr, pkAttrs )
134  {
135  pkFields.append( "COALESCE(\"" + fields[attr].name() + "\", '<NULL>')" );
136  }
137 
138  displayExpression = pkFields.join( "||', '||" );
139  }
140  else if ( !fields.isEmpty() )
141  {
142  if ( fields.size() == 1 )
143  defaultField = fields.at( 0 ).name();
144 
145  // ... concat all fields
146  QStringList fieldNames;
147  Q_FOREACH ( const QgsField& field, fields )
148  {
149  fieldNames.append( "COALESCE(\"" + field.name() + "\", '<NULL>')" );
150  }
151 
152  displayExpression = fieldNames.join( "||', '||" );
153  }
154  else
155  {
156  // ... there isn't really much to display
157  displayExpression = "'[Please define preview text]'";
158  }
159  }
160 
161  mFeatureListPreviewButton->addAction( mActionExpressionPreview );
162  mFeatureListPreviewButton->addAction( mActionPreviewColumnsMenu );
163 
164  Q_FOREACH ( const QgsField& field, fields )
165  {
166  int fieldIndex = mLayerCache->layer()->fieldNameIndex( field.name() );
167  if ( fieldIndex == -1 )
168  continue;
169 
170  if ( mLayerCache->layer()->editFormConfig()->widgetType( fieldIndex ) != "Hidden" )
171  {
172  QIcon icon = mLayerCache->layer()->fields().iconForField( fieldIndex );
173  QString text = field.name();
174 
175  // Generate action for the preview popup button of the feature list
176  QAction* previewAction = new QAction( icon, text, mFeatureListPreviewButton );
177  mPreviewActionMapper->setMapping( previewAction, previewAction );
178  connect( previewAction, SIGNAL( triggered() ), mPreviewActionMapper, SLOT( map() ) );
179  mPreviewColumnsMenu->addAction( previewAction );
180 
181  if ( text == defaultField )
182  {
183  mFeatureListPreviewButton->setDefaultAction( previewAction );
184  }
185  }
186  }
187 
188  // If there is no single field found as preview
189  if ( !mFeatureListPreviewButton->defaultAction() )
190  {
191  mFeatureList->setDisplayExpression( displayExpression );
192  mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
193  mDisplayExpression = mFeatureList->displayExpression();
194  }
195  else
196  {
197  mFeatureListPreviewButton->defaultAction()->trigger();
198  }
199 }
200 
202 {
203  setCurrentIndex( view );
204 }
205 
207 {
208  return static_cast< QgsDualView::ViewMode >( currentIndex() );
209 }
210 
212 {
213  mFilterModel->setFilterMode( filterMode );
214  emit filterChanged();
215 }
216 
217 void QgsDualView::setSelectedOnTop( bool selectedOnTop )
218 {
219  mFilterModel->setSelectedOnTop( selectedOnTop );
220 }
221 
222 void QgsDualView::initLayerCache( QgsVectorLayer* layer, bool cacheGeometry )
223 {
224  // Initialize the cache
225  QSettings settings;
226  int cacheSize = settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt();
227  mLayerCache = new QgsVectorLayerCache( layer, cacheSize, this );
228  mLayerCache->setCacheGeometry( cacheGeometry );
229  if ( 0 == cacheSize || 0 == ( QgsVectorDataProvider::SelectAtId & mLayerCache->layer()->dataProvider()->capabilities() ) )
230  {
231  connect( mLayerCache, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
232  connect( mLayerCache, SIGNAL( finished() ), this, SLOT( finished() ) );
233 
234  mLayerCache->setFullCache( true );
235  }
236 }
237 
238 void QgsDualView::initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request )
239 {
240  delete mFeatureListModel;
241  delete mFilterModel;
242  delete mMasterModel;
243 
244  mMasterModel = new QgsAttributeTableModel( mLayerCache, this );
245  mMasterModel->setRequest( request );
246  mMasterModel->setEditorContext( mEditorContext );
247 
248  connect( mMasterModel, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
249  connect( mMasterModel, SIGNAL( finished() ), this, SLOT( finished() ) );
250 
251  connect( mConditionalFormatWidget, SIGNAL( rulesUpdated( QString ) ), mMasterModel, SLOT( fieldConditionalStyleChanged( QString ) ) );
252 
253  mMasterModel->loadLayer();
254 
255  mFilterModel = new QgsAttributeTableFilterModel( mapCanvas, mMasterModel, mMasterModel );
256 
257  connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SIGNAL( displayExpressionChanged( QString ) ) );
258 
259  mFeatureListModel = new QgsFeatureListModel( mFilterModel, mFilterModel );
260 }
261 
262 void QgsDualView::on_mFeatureList_aboutToChangeEditSelection( bool& ok )
263 {
264  if ( mLayerCache->layer()->isEditable() && !mAttributeForm->save() )
265  ok = false;
266 }
267 
268 void QgsDualView::on_mFeatureList_currentEditSelectionChanged( const QgsFeature &feat )
269 {
270  if ( !mLayerCache->layer()->isEditable() || mAttributeForm->save() )
271  {
272  mAttributeForm->setFeature( feat );
274  }
275  else
276  {
277  // Couldn't save feature
278  }
279 }
280 
282 {
283  mFeatureList->setCurrentFeatureEdited( false );
284  mFeatureList->setEditSelection( fids );
285 }
286 
288 {
289  return mAttributeForm->save();
290 }
291 
293 {
294  mConditionalFormatWidget->setVisible( !mConditionalFormatWidget->isVisible() );
295  mConditionalFormatWidget->viewRules();
296 }
297 
299 {
300  if ( enabled )
302 
304 }
305 
306 void QgsDualView::previewExpressionBuilder()
307 {
308  // Show expression builder
309  QgsExpressionContext context;
312  << QgsExpressionContextUtils::layerScope( mLayerCache->layer() );
313 
314  QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this, "generic", context );
315  dlg.setWindowTitle( tr( "Expression based preview" ) );
316  dlg.setExpressionText( mFeatureList->displayExpression() );
317 
318  if ( dlg.exec() == QDialog::Accepted )
319  {
320  mFeatureList->setDisplayExpression( dlg.expressionText() );
321  mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
322  mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
323  }
324 
325  mDisplayExpression = mFeatureList->displayExpression();
326 }
327 
328 void QgsDualView::previewColumnChanged( QObject* action )
329 {
330  QAction* previewAction = qobject_cast< QAction* >( action );
331 
332  if ( previewAction )
333  {
334  if ( !mFeatureList->setDisplayExpression( QString( "COALESCE( \"%1\", '<NULL>' )" ).arg( previewAction->text() ) ) )
335  {
336  QMessageBox::warning( this,
337  tr( "Could not set preview column" ),
338  tr( "Could not set column '%1' as preview column.\nParser error:\n%2" )
339  .arg( previewAction->text(), mFeatureList->parserErrorString() )
340  );
341  }
342  else
343  {
344  mFeatureListPreviewButton->setDefaultAction( previewAction );
345  mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
346  }
347  }
348 
349  mDisplayExpression = mFeatureList->displayExpression();
350 
351  Q_ASSERT( previewAction );
352 }
353 
355 {
356  return mMasterModel->rowCount();
357 }
358 
360 {
361  return mFilterModel->rowCount();
362 }
363 
364 void QgsDualView::viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex )
365 {
366  if ( !menu )
367  {
368  return;
369  }
370 
371  QgsVectorLayer* vl = mFilterModel->layer();
372  QgsMapCanvas* canvas = mFilterModel->mapCanvas();
373  if ( canvas && vl && vl->geometryType() != QGis::NoGeometry )
374  {
375  menu->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToCurrentFeature() ) );
376  }
377 
378  QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );
379 
380  //add user-defined actions to context menu
381  if ( mLayerCache->layer()->actions()->size() != 0 )
382  {
383 
384  QAction *a = menu->addAction( tr( "Run layer action" ) );
385  a->setEnabled( false );
386 
387  for ( int i = 0; i < mLayerCache->layer()->actions()->size(); i++ )
388  {
389  const QgsAction &action = mLayerCache->layer()->actions()->at( i );
390 
391  if ( !action.runable() )
392  continue;
393 
394  QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, i, sourceIndex );
395  menu->addAction( action.name(), a, SLOT( execute() ) );
396  }
397  }
398 
399  //add actions from QgsMapLayerActionRegistry to context menu
401  if ( !registeredActions.isEmpty() )
402  {
403  //add a separator between user defined and standard actions
404  menu->addSeparator();
405 
407  for ( actionIt = registeredActions.begin(); actionIt != registeredActions.end(); ++actionIt )
408  {
409  QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction(( *actionIt )->text(), this, ( *actionIt ), sourceIndex );
410  menu->addAction(( *actionIt )->text(), a, SLOT( execute() ) );
411  }
412  }
413 
414  menu->addSeparator();
415  QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ), this, -1, sourceIndex );
416  menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
417 }
418 
419 void QgsDualView::zoomToCurrentFeature()
420 {
421  QModelIndex currentIndex = mTableView->currentIndex();
422  if ( !currentIndex.isValid() )
423  {
424  return;
425  }
426 
427  QgsFeatureIds ids;
428  ids.insert( mFilterModel->rowToId( currentIndex ) );
429  QgsMapCanvas* canvas = mFilterModel->mapCanvas();
430  if ( canvas )
431  {
432  canvas->zoomToFeatureIds( mLayerCache->layer(), ids );
433  }
434 }
435 
436 void QgsDualView::previewExpressionChanged( const QString& expression )
437 {
438  mLayerCache->layer()->setDisplayExpression( expression );
439 }
440 
441 void QgsDualView::featureFormAttributeChanged()
442 {
443  mFeatureList->setCurrentFeatureEdited( true );
444 }
445 
447 {
448  mFilterModel->setFilteredFeatures( filteredFeatures );
449 }
450 
452 {
453  mMasterModel->setRequest( request );
454 }
455 
457 {
458  mTableView->setFeatureSelectionManager( featureSelectionManager );
459  mFeatureList->setFeatureSelectionManager( featureSelectionManager );
460 
461  if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
462  delete mFeatureSelectionManager;
463 
464  mFeatureSelectionManager = featureSelectionManager;
465 }
466 
468 {
469  mFilterModel->setAttributeTableConfig( config );
470 }
471 
472 void QgsDualView::progress( int i, bool& cancel )
473 {
474  if ( !mProgressDlg )
475  {
476  mProgressDlg = new QProgressDialog( tr( "Loading features..." ), tr( "Abort" ), 0, 0, this );
477  mProgressDlg->setWindowTitle( tr( "Attribute table" ) );
478  mProgressDlg->setWindowModality( Qt::WindowModal );
479  mProgressDlg->show();
480  }
481 
482  mProgressDlg->setValue( i );
483  mProgressDlg->setLabelText( tr( "%1 features loaded." ).arg( i ) );
484 
486 
487  cancel = mProgressDlg && mProgressDlg->wasCanceled();
488 }
489 
490 void QgsDualView::finished()
491 {
492  delete mProgressDlg;
493  mProgressDlg = nullptr;
494 }
495 
496 /*
497  * QgsAttributeTableAction
498  */
499 
501 {
502  mDualView->masterModel()->executeAction( mAction, mFieldIdx );
503 }
504 
506 {
507  QgsFeatureIds editedIds;
508  editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
509  mDualView->setCurrentEditSelection( editedIds );
510  mDualView->setView( QgsDualView::AttributeEditor );
511 }
512 
513 /*
514  * QgsAttributeTableMapLayerAction
515  */
516 
518 {
519  mDualView->masterModel()->executeMapLayerAction( mAction, mFieldIdx );
520 }
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
Definition: qgsfield.cpp:429
QgsFeatureId id() const
Get the feature ID for this feature.
Definition: qgsfeature.cpp:65
void setRequest(const QgsFeatureRequest &request)
Set a request that will be used to fill this attribute table model.
QgsActionManager * actions()
Get all layer actions defined on this layer.
QgsFeatureId rowToId(const QModelIndex &row)
Returns the feature id for a given model index.
void setFilterMode(QgsAttributeTableFilterModel::FilterMode filterMode)
Set the filter mode.
const QgsAction & at(int idx) const
Get the action at the specified index.
virtual void loadLayer()
Loads the layer into the model Preferably to be called, before using this model as source for any oth...
void setupUi(QWidget *widget)
void setAttributeTableConfig(const QgsAttributeTableConfig &config)
Set the attribute table configuration to control which fields are shown, in which order they are show...
QgsMapCanvas * mapCanvas() const
Returns the map canvas.
int size() const
Get the number of actions managed by this.
QIcon iconForField(int fieldIdx) const
Returns an icon corresponding to a field index, based on the field&#39;s type and source.
Definition: qgsfield.cpp:492
void setSelectedOnTop(bool selectedOnTop)
Changes the sort order of the features.
void setFilterMode(FilterMode filterMode)
Set the filter mode the filter will use.
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
Set the feature selection model.
void openConditionalStyles()
void hideButtonBox()
Hides the button box (Ok/Cancel) and enables auto-commit.
const QgsRectangle & filterRect() const
Get the rectangle from which features will be taken.
void setWindowModality(Qt::WindowModality windowModality)
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:433
QgsFields fields() const
Returns the list of fields of this layer.
This class contains context information for attribute editor widgets.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
void setLabelText(const QString &text)
bool save()
Save all the values from the editors to the layer.
ViewMode
The view modes, in which this widget can present information.
Definition: qgsdualview.h:53
const T & at(int i) const
void addAction(QAction *action)
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, const QgsMapLayerAction::Targets &targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
int filteredFeatureCount()
Returns the number of features which are currently visible, according to the filter restrictions...
const QPixmap * icon() const
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string.
QString join(const QString &separator) const
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
QString widgetType(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
void setCurrentEditSelection(const QgsFeatureIds &fids)
Set the current edit selection in the AttributeEditor mode.
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
const QString displayExpression()
Get the preview expression, used to create a human readable preview string.
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:108
virtual int rowCount(const QModelIndex &parent) const
void setView(ViewMode view)
Change the current view mode.
int size() const
virtual void setFilteredFeatures(const QgsFeatureIds &ids)
Specify a list of features, which the filter will accept.
void setAttributeTableConfig(const QgsAttributeTableConfig &config)
Set the attribute table config which should be used to control the appearance of the attribute table...
QgsDualView(QWidget *parent=nullptr)
Constructor.
Definition: qgsdualview.cpp:36
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition: qgsdualview.h:64
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
void setMode(Mode mode)
Sets the current mode of the form.
const char * name() const
void setValue(int progress)
bool isValid() const
void setMapping(QObject *sender, int id)
QString name() const
The name of the action. This may be a longer description.
Definition: qgsaction.h:97
void processEvents(QFlags< QEventLoop::ProcessEventsFlag > flags)
void append(const T &value)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
int toInt(bool *ok) const
void setFeature(const QgsFeature &feature)
Update all editors to correspond to a different feature.
FilterMode
The filter mode defines how the rows should be filtered.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
void setEditorContext(const QgsAttributeEditorContext &context)
Sets the context in which this table is shown.
QString name() const
Gets the name of the field.
Definition: qgsfield.cpp:84
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:25
bool isEmpty() const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isEmpty() const
ViewMode view() const
Returns the current view mode.
void setCurrentIndex(int index)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void init(QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
Has to be called to initialize the dual view.
Definition: qgsdualview.cpp:65
QgsFeatureIds filteredFeatures()
Get a list of currently visible feature ids.
Definition: qgsdualview.h:147
const QString displayField() const
Returns the primary display field name used in the identify results dialog.
void filterChanged()
Is emitted, whenever the filter changes.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QAction * addSeparator()
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
Fast access to features using their ID.
iterator end()
This class caches features of a given QgsVectorLayer.
bool saveEditChanges()
saveEditChanges
void setRequest(const QgsFeatureRequest &request)
Set the request.
QgsAttributeTableFilterModel::FilterMode filterMode()
Get the filter mode.
Definition: qgsdualview.h:111
QgsAttributeList pkAttributeList() const
Returns list of attributes making up the primary key.
void setSelectedOnTop(bool selectedOnTop)
Toggle the selectedOnTop flag.
QVariant value(const QString &key, const QVariant &defaultValue) const
void zoomToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Set canvas extent to the bounding box of a set of features.
static QgsMapLayerActionRegistry * instance()
Returns the instance pointer, creating the object on the first call.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows.
void setCacheGeometry(bool cacheGeometry)
Enable or disable the caching of geometries.
void setFullCache(bool fullCache)
This enables or disables full caching.
void setWindowTitle(const QString &)
void displayExpressionChanged(const QString &expression)
Is emitted, whenever the display expression is successfully changed.
QgsFeatureId idxToFid(const QModelIndex &index) const
bool runable() const
Checks if the action is runable on the current platform.
Definition: qgsaction.cpp:19
StandardButton warning(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
void show()
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
QgsVectorDataProvider * dataProvider()
Returns the data provider.
void setFilteredFeatures(const QgsFeatureIds &filteredFeatures)
Set a list of currently visible features.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
This is a container for configuration of the attribute table.
void setMultiEditEnabled(bool enabled)
Sets whether multi edit mode is enabled.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Is an interface class to abstract feature selection handling.
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
iterator begin()
A generic dialog for building expression strings.
void setEnabled(bool)
void columnBoxInit()
Initializes widgets which depend on the attributes of this layer.
int featureCount()
Returns the number of features on the layer.