QGIS API Documentation  2.15.0-Master (af20121)
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 "qgsattributetablemodel.h"
19 #include "qgsdualview.h"
21 #include "qgsfeaturelistmodel.h"
23 #include "qgsmapcanvas.h"
25 #include "qgsmessagelog.h"
26 #include "qgsvectordataprovider.h"
27 #include "qgsvectorlayercache.h"
28 
29 #include <QDialog>
30 #include <QMenu>
31 #include <QMessageBox>
32 #include <QProgressDialog>
33 #include <QSettings>
34 
36  : QStackedWidget( parent )
37  , mEditorContext()
38  , mMasterModel( nullptr )
39  , mFilterModel( nullptr )
40  , mFeatureListModel( nullptr )
41  , mAttributeForm( nullptr )
42  , mLayerCache( nullptr )
43  , mProgressDlg( nullptr )
44  , mFeatureSelectionManager( nullptr )
45 {
46  setupUi( this );
47 
48  mConditionalFormatWidget->hide();
49 
50  mPreviewActionMapper = new QSignalMapper( this );
51 
52  mPreviewColumnsMenu = new QMenu( this );
53  mActionPreviewColumnsMenu->setMenu( mPreviewColumnsMenu );
54 
55  // Set preview icon
56  mActionExpressionPreview->setIcon( QgsApplication::getThemeIcon( "/mIconExpressionPreview.svg" ) );
57 
58  // Connect layer list preview signals
59  connect( mActionExpressionPreview, SIGNAL( triggered() ), SLOT( previewExpressionBuilder() ) );
60  connect( mPreviewActionMapper, SIGNAL( mapped( QObject* ) ), SLOT( previewColumnChanged( QObject* ) ) );
61  connect( mFeatureList, SIGNAL( displayExpressionChanged( QString ) ), this, SLOT( previewExpressionChanged( QString ) ) );
62 }
63 
64 void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest &request, const QgsAttributeEditorContext &context )
65 {
66  mEditorContext = context;
67 
68  connect( mTableView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );
69 
70  initLayerCache( layer, !request.filterRect().isNull() );
71  initModels( mapCanvas, request );
72 
73  mConditionalFormatWidget->setLayer( layer );
74 
75  mTableView->setModel( mFilterModel );
76  mFeatureList->setModel( mFeatureListModel );
77  mAttributeForm = new QgsAttributeForm( layer, QgsFeature(), mEditorContext );
78  if ( !mAttributeEditorScrollArea->layout() )
79  mAttributeEditorScrollArea->setLayout( new QGridLayout() );
80  mAttributeEditorScrollArea->layout()->addWidget( mAttributeForm );
81  mAttributeEditorScrollArea->setWidget( mAttributeForm );
82 
83  mAttributeForm->hideButtonBox();
84 
85  connect( mAttributeForm, SIGNAL( attributeChanged( QString, QVariant ) ), this, SLOT( featureFormAttributeChanged() ) );
86  connect( mAttributeForm, SIGNAL( modeChanged( QgsAttributeForm::Mode ) ), this, SIGNAL( formModeChanged( QgsAttributeForm::Mode ) ) );
87  connect( mMasterModel, SIGNAL( modelChanged() ), mAttributeForm, SLOT( refreshFeature() ) );
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 
312 {
313  if ( enabled )
314  {
316  mAttributeForm->setMode( QgsAttributeForm::SearchMode );
317  }
318  else
319  {
320  mAttributeForm->setMode( QgsAttributeForm::SingleEditMode );
321  }
322 }
323 
324 void QgsDualView::previewExpressionBuilder()
325 {
326  // Show expression builder
327  QgsExpressionContext context;
330  << QgsExpressionContextUtils::layerScope( mLayerCache->layer() );
331 
332  QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this, "generic", context );
333  dlg.setWindowTitle( tr( "Expression based preview" ) );
334  dlg.setExpressionText( mFeatureList->displayExpression() );
335 
336  if ( dlg.exec() == QDialog::Accepted )
337  {
338  mFeatureList->setDisplayExpression( dlg.expressionText() );
339  mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
340  mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
341  }
342 
343  mDisplayExpression = mFeatureList->displayExpression();
344 }
345 
346 void QgsDualView::previewColumnChanged( QObject* action )
347 {
348  QAction* previewAction = qobject_cast< QAction* >( action );
349 
350  if ( previewAction )
351  {
352  if ( !mFeatureList->setDisplayExpression( QString( "COALESCE( \"%1\", '<NULL>' )" ).arg( previewAction->text() ) ) )
353  {
354  QMessageBox::warning( this,
355  tr( "Could not set preview column" ),
356  tr( "Could not set column '%1' as preview column.\nParser error:\n%2" )
357  .arg( previewAction->text(), mFeatureList->parserErrorString() )
358  );
359  }
360  else
361  {
362  mFeatureListPreviewButton->setDefaultAction( previewAction );
363  mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
364  }
365  }
366 
367  mDisplayExpression = mFeatureList->displayExpression();
368 
369  Q_ASSERT( previewAction );
370 }
371 
373 {
374  return mMasterModel->rowCount();
375 }
376 
378 {
379  return mFilterModel->rowCount();
380 }
381 
382 void QgsDualView::viewWillShowContextMenu( QMenu* menu, const QModelIndex& atIndex )
383 {
384  if ( !menu )
385  {
386  return;
387  }
388 
389  QgsVectorLayer* vl = mFilterModel->layer();
390  QgsMapCanvas* canvas = mFilterModel->mapCanvas();
391  if ( canvas && vl && vl->geometryType() != QGis::NoGeometry )
392  {
393  menu->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToCurrentFeature() ) );
394  }
395 
396  QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );
397 
398  //add user-defined actions to context menu
399  if ( mLayerCache->layer()->actions()->size() != 0 )
400  {
401 
402  QAction *a = menu->addAction( tr( "Run layer action" ) );
403  a->setEnabled( false );
404 
405  for ( int i = 0; i < mLayerCache->layer()->actions()->size(); i++ )
406  {
407  const QgsAction &action = mLayerCache->layer()->actions()->at( i );
408 
409  if ( !action.runable() )
410  continue;
411 
412  QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, i, sourceIndex );
413  menu->addAction( action.name(), a, SLOT( execute() ) );
414  }
415  }
416 
417  //add actions from QgsMapLayerActionRegistry to context menu
419  if ( !registeredActions.isEmpty() )
420  {
421  //add a separator between user defined and standard actions
422  menu->addSeparator();
423 
425  for ( actionIt = registeredActions.begin(); actionIt != registeredActions.end(); ++actionIt )
426  {
427  QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction(( *actionIt )->text(), this, ( *actionIt ), sourceIndex );
428  menu->addAction(( *actionIt )->text(), a, SLOT( execute() ) );
429  }
430  }
431 
432  menu->addSeparator();
433  QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ), this, -1, sourceIndex );
434  menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
435 }
436 
437 void QgsDualView::zoomToCurrentFeature()
438 {
439  QModelIndex currentIndex = mTableView->currentIndex();
440  if ( !currentIndex.isValid() )
441  {
442  return;
443  }
444 
445  QgsFeatureIds ids;
446  ids.insert( mFilterModel->rowToId( currentIndex ) );
447  QgsMapCanvas* canvas = mFilterModel->mapCanvas();
448  if ( canvas )
449  {
450  canvas->zoomToFeatureIds( mLayerCache->layer(), ids );
451  }
452 }
453 
454 void QgsDualView::previewExpressionChanged( const QString& expression )
455 {
456  mLayerCache->layer()->setDisplayExpression( expression );
457 }
458 
459 void QgsDualView::sortByPreviewExpression()
460 {
461  setSortExpression( mFeatureList->displayExpression() );
462 }
463 
464 void QgsDualView::featureFormAttributeChanged()
465 {
466  mFeatureList->setCurrentFeatureEdited( true );
467 }
468 
470 {
471  mFilterModel->setFilteredFeatures( filteredFeatures );
472 }
473 
475 {
476  mMasterModel->setRequest( request );
477 }
478 
480 {
481  mTableView->setFeatureSelectionManager( featureSelectionManager );
482  mFeatureList->setFeatureSelectionManager( featureSelectionManager );
483 
484  if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
485  delete mFeatureSelectionManager;
486 
487  mFeatureSelectionManager = featureSelectionManager;
488 }
489 
491 {
492  mFilterModel->setAttributeTableConfig( config );
493 }
494 
496 {
497  if ( sortExpression.isNull() )
498  mFilterModel->sort( -1 );
499  else
500  mFilterModel->sort( sortExpression );
501 }
502 
504 {
505  return mFilterModel->sortExpression();
506 }
507 
508 void QgsDualView::progress( int i, bool& cancel )
509 {
510  if ( !mProgressDlg )
511  {
512  mProgressDlg = new QProgressDialog( tr( "Loading features..." ), tr( "Abort" ), 0, 0, this );
513  mProgressDlg->setWindowTitle( tr( "Attribute table" ) );
514  mProgressDlg->setWindowModality( Qt::WindowModal );
515  mProgressDlg->show();
516  }
517 
518  mProgressDlg->setValue( i );
519  mProgressDlg->setLabelText( tr( "%1 features loaded." ).arg( i ) );
520 
522 
523  cancel = mProgressDlg && mProgressDlg->wasCanceled();
524 }
525 
526 void QgsDualView::finished()
527 {
528  delete mProgressDlg;
529  mProgressDlg = nullptr;
530 }
531 
532 /*
533  * QgsAttributeTableAction
534  */
535 
537 {
538  mDualView->masterModel()->executeAction( mAction, mFieldIdx );
539 }
540 
542 {
543  QgsFeatureIds editedIds;
544  editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
545  mDualView->setCurrentEditSelection( editedIds );
546  mDualView->setView( QgsDualView::AttributeEditor );
547 }
548 
549 /*
550  * QgsAttributeTableMapLayerAction
551  */
552 
554 {
555  mDualView->masterModel()->executeMapLayerAction( mAction, mFieldIdx );
556 }
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 filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
Is emitted when a filter expression is set using the view.
void setFilterMode(FilterMode filterMode)
Set the filter mode the filter will use.
void toggleSearchMode(bool enabled)
Toggles whether search mode should be enabled in the form.
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:54
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:35
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition: qgsdualview.h:65
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
FilterType
Filter types.
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:64
QgsFeatureIds filteredFeatures()
Get a list of currently visible feature ids.
Definition: qgsdualview.h:148
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:112
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
void formModeChanged(QgsAttributeForm::Mode mode)
Emitted when the form changes mode.
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.