QGIS API Documentation  2.15.0-Master (13f053b)
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  QAction* sortByPreviewExpression = new QAction( QgsApplication::getThemeIcon( "sort.svg" ), tr( "Sort by preview expression" ), this );
201  connect( sortByPreviewExpression, SIGNAL( triggered( bool ) ), this, SLOT( sortByPreviewExpression() ) );
202  mFeatureListPreviewButton->addAction( sortByPreviewExpression );
203 }
204 
206 {
207  setCurrentIndex( view );
208 }
209 
211 {
212  return static_cast< QgsDualView::ViewMode >( currentIndex() );
213 }
214 
216 {
217  mFilterModel->setFilterMode( filterMode );
218  emit filterChanged();
219 }
220 
221 void QgsDualView::setSelectedOnTop( bool selectedOnTop )
222 {
223  mFilterModel->setSelectedOnTop( selectedOnTop );
224 }
225 
226 void QgsDualView::initLayerCache( QgsVectorLayer* layer, bool cacheGeometry )
227 {
228  // Initialize the cache
229  QSettings settings;
230  int cacheSize = settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt();
231  mLayerCache = new QgsVectorLayerCache( layer, cacheSize, this );
232  mLayerCache->setCacheGeometry( cacheGeometry );
233  if ( 0 == cacheSize || 0 == ( QgsVectorDataProvider::SelectAtId & mLayerCache->layer()->dataProvider()->capabilities() ) )
234  {
235  connect( mLayerCache, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
236  connect( mLayerCache, SIGNAL( finished() ), this, SLOT( finished() ) );
237 
238  mLayerCache->setFullCache( true );
239  }
240 }
241 
242 void QgsDualView::initModels( QgsMapCanvas* mapCanvas, const QgsFeatureRequest& request )
243 {
244  delete mFeatureListModel;
245  delete mFilterModel;
246  delete mMasterModel;
247 
248  mMasterModel = new QgsAttributeTableModel( mLayerCache, this );
249  mMasterModel->setRequest( request );
250  mMasterModel->setEditorContext( mEditorContext );
251  mMasterModel->setExtraColumns( 1 ); // Add one extra column which we can "abuse" as an action column
252 
253  connect( mMasterModel, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
254  connect( mMasterModel, SIGNAL( finished() ), this, SLOT( finished() ) );
255 
256  connect( mConditionalFormatWidget, SIGNAL( rulesUpdated( QString ) ), mMasterModel, SLOT( fieldConditionalStyleChanged( QString ) ) );
257 
258  mMasterModel->loadLayer();
259 
260  mFilterModel = new QgsAttributeTableFilterModel( mapCanvas, mMasterModel, mMasterModel );
261 
262  connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SIGNAL( displayExpressionChanged( QString ) ) );
263 
264  mFeatureListModel = new QgsFeatureListModel( mFilterModel, mFilterModel );
265 }
266 
267 void QgsDualView::on_mFeatureList_aboutToChangeEditSelection( bool& ok )
268 {
269  if ( mLayerCache->layer()->isEditable() && !mAttributeForm->save() )
270  ok = false;
271 }
272 
273 void QgsDualView::on_mFeatureList_currentEditSelectionChanged( const QgsFeature &feat )
274 {
275  if ( !mLayerCache->layer()->isEditable() || mAttributeForm->save() )
276  {
277  mAttributeForm->setFeature( feat );
279  }
280  else
281  {
282  // Couldn't save feature
283  }
284 }
285 
287 {
288  mFeatureList->setCurrentFeatureEdited( false );
289  mFeatureList->setEditSelection( fids );
290 }
291 
293 {
294  return mAttributeForm->save();
295 }
296 
298 {
299  mConditionalFormatWidget->setVisible( !mConditionalFormatWidget->isVisible() );
300  mConditionalFormatWidget->viewRules();
301 }
302 
304 {
305  if ( enabled )
307 
309 }
310 
311 void QgsDualView::previewExpressionBuilder()
312 {
313  // Show expression builder
314  QgsExpressionContext context;
317  << QgsExpressionContextUtils::layerScope( mLayerCache->layer() );
318 
319  QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this, "generic", context );
320  dlg.setWindowTitle( tr( "Expression based preview" ) );
321  dlg.setExpressionText( mFeatureList->displayExpression() );
322 
323  if ( dlg.exec() == QDialog::Accepted )
324  {
325  mFeatureList->setDisplayExpression( dlg.expressionText() );
326  mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
327  mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
328  }
329 
330  mDisplayExpression = mFeatureList->displayExpression();
331 }
332 
333 void QgsDualView::previewColumnChanged( QObject* action )
334 {
335  QAction* previewAction = qobject_cast< QAction* >( action );
336 
337  if ( previewAction )
338  {
339  if ( !mFeatureList->setDisplayExpression( QString( "COALESCE( \"%1\", '<NULL>' )" ).arg( previewAction->text() ) ) )
340  {
341  QMessageBox::warning( this,
342  tr( "Could not set preview column" ),
343  tr( "Could not set column '%1' as preview column.\nParser error:\n%2" )
344  .arg( previewAction->text(), mFeatureList->parserErrorString() )
345  );
346  }
347  else
348  {
349  mFeatureListPreviewButton->setDefaultAction( previewAction );
350  mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
351  }
352  }
353 
354  mDisplayExpression = mFeatureList->displayExpression();
355 
356  Q_ASSERT( previewAction );
357 }
358 
360 {
361  return mMasterModel->rowCount();
362 }
363 
365 {
366  return mFilterModel->rowCount();
367 }
368 
369 void QgsDualView::viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex )
370 {
371  if ( !menu )
372  {
373  return;
374  }
375 
376  QgsVectorLayer* vl = mFilterModel->layer();
377  QgsMapCanvas* canvas = mFilterModel->mapCanvas();
378  if ( canvas && vl && vl->geometryType() != QGis::NoGeometry )
379  {
380  menu->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToCurrentFeature() ) );
381  }
382 
383  QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );
384 
385  //add user-defined actions to context menu
386  if ( mLayerCache->layer()->actions()->size() != 0 )
387  {
388 
389  QAction *a = menu->addAction( tr( "Run layer action" ) );
390  a->setEnabled( false );
391 
392  for ( int i = 0; i < mLayerCache->layer()->actions()->size(); i++ )
393  {
394  const QgsAction &action = mLayerCache->layer()->actions()->at( i );
395 
396  if ( !action.runable() )
397  continue;
398 
399  QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, i, sourceIndex );
400  menu->addAction( action.name(), a, SLOT( execute() ) );
401  }
402  }
403 
404  //add actions from QgsMapLayerActionRegistry to context menu
406  if ( !registeredActions.isEmpty() )
407  {
408  //add a separator between user defined and standard actions
409  menu->addSeparator();
410 
412  for ( actionIt = registeredActions.begin(); actionIt != registeredActions.end(); ++actionIt )
413  {
414  QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction(( *actionIt )->text(), this, ( *actionIt ), sourceIndex );
415  menu->addAction(( *actionIt )->text(), a, SLOT( execute() ) );
416  }
417  }
418 
419  menu->addSeparator();
420  QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ), this, -1, sourceIndex );
421  menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
422 }
423 
424 void QgsDualView::zoomToCurrentFeature()
425 {
426  QModelIndex currentIndex = mTableView->currentIndex();
427  if ( !currentIndex.isValid() )
428  {
429  return;
430  }
431 
432  QgsFeatureIds ids;
433  ids.insert( mFilterModel->rowToId( currentIndex ) );
434  QgsMapCanvas* canvas = mFilterModel->mapCanvas();
435  if ( canvas )
436  {
437  canvas->zoomToFeatureIds( mLayerCache->layer(), ids );
438  }
439 }
440 
441 void QgsDualView::previewExpressionChanged( const QString& expression )
442 {
443  mLayerCache->layer()->setDisplayExpression( expression );
444 }
445 
446 void QgsDualView::sortByPreviewExpression()
447 {
448  setSortExpression( mFeatureList->displayExpression() );
449 }
450 
451 void QgsDualView::featureFormAttributeChanged()
452 {
453  mFeatureList->setCurrentFeatureEdited( true );
454 }
455 
457 {
458  mFilterModel->setFilteredFeatures( filteredFeatures );
459 }
460 
462 {
463  mMasterModel->setRequest( request );
464 }
465 
467 {
468  mTableView->setFeatureSelectionManager( featureSelectionManager );
469  mFeatureList->setFeatureSelectionManager( featureSelectionManager );
470 
471  if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
472  delete mFeatureSelectionManager;
473 
474  mFeatureSelectionManager = featureSelectionManager;
475 }
476 
478 {
479  mFilterModel->setAttributeTableConfig( config );
480 }
481 
483 {
484  if ( sortExpression.isNull() )
485  mFilterModel->sort( -1 );
486  else
487  mFilterModel->sort( sortExpression );
488 }
489 
491 {
492  return mFilterModel->sortExpression();
493 }
494 
495 void QgsDualView::progress( int i, bool& cancel )
496 {
497  if ( !mProgressDlg )
498  {
499  mProgressDlg = new QProgressDialog( tr( "Loading features..." ), tr( "Abort" ), 0, 0, this );
500  mProgressDlg->setWindowTitle( tr( "Attribute table" ) );
501  mProgressDlg->setWindowModality( Qt::WindowModal );
502  mProgressDlg->show();
503  }
504 
505  mProgressDlg->setValue( i );
506  mProgressDlg->setLabelText( tr( "%1 features loaded." ).arg( i ) );
507 
509 
510  cancel = mProgressDlg && mProgressDlg->wasCanceled();
511 }
512 
513 void QgsDualView::finished()
514 {
515  delete mProgressDlg;
516  mProgressDlg = nullptr;
517 }
518 
519 /*
520  * QgsAttributeTableAction
521  */
522 
524 {
525  mDualView->masterModel()->executeAction( mAction, mFieldIdx );
526 }
527 
529 {
530  QgsFeatureIds editedIds;
531  editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
532  mDualView->setCurrentEditSelection( editedIds );
533  mDualView->setView( QgsDualView::AttributeEditor );
534 }
535 
536 /*
537  * QgsAttributeTableMapLayerAction
538  */
539 
541 {
542  mDualView->masterModel()->executeMapLayerAction( mAction, mFieldIdx );
543 }
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:439
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
bool isNull() 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 setExtraColumns(int extraColumns)
Empty extra columns to announce from this model.
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.
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Sort by the given column using the given order.
QString sortExpression() const
The expression which is used to sort the attribute table.
void setWindowTitle(const QString &)
void displayExpressionChanged(const QString &expression)
Is emitted, whenever the display expression is successfully changed.
QgsFeatureId idxToFid(const QModelIndex &index) const
QString sortExpression() const
Get the expression used for sorting the table and feature list.
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.
void setSortExpression(const QString &sortExpression)
Set the expression used for sorting the table and feature list.