QGIS API Documentation  3.21.0-Master (5b68dc587e)
qgsattributetableview.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  QgsAttributeTableView.cpp
3  --------------------------------------
4  Date : Feb 2009
5  Copyright : (C) 2009 Vita Cizek
6  Email : weetya (at) gmail.com
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 <QDesktopServices>
17 #include <QKeyEvent>
18 #include <QHeaderView>
19 #include <QMenu>
20 #include <QToolButton>
21 #include <QHBoxLayout>
22 
23 #include "qgssettings.h"
24 #include "qgsactionmanager.h"
25 #include "qgsattributetableview.h"
26 #include "qgsattributetablemodel.h"
29 #include "qgsvectorlayer.h"
30 #include "qgsvectorlayercache.h"
32 #include "qgsvectordataprovider.h"
33 #include "qgslogger.h"
34 #include "qgsmapcanvas.h"
37 #include "qgsfeatureiterator.h"
38 #include "qgsstringutils.h"
39 #include "qgsgui.h"
40 
42  : QTableView( parent )
43 {
44  const QgsSettings settings;
45  restoreGeometry( settings.value( QStringLiteral( "BetterAttributeTable/geometry" ) ).toByteArray() );
46 
47  //verticalHeader()->setDefaultSectionSize( 20 );
48  horizontalHeader()->setHighlightSections( false );
49 
50  // We need mouse move events to create the action button on hover
51  mTableDelegate = new QgsAttributeTableDelegate( this );
52  setItemDelegate( mTableDelegate );
53 
54  setEditTriggers( QAbstractItemView::AllEditTriggers );
55 
56  setSelectionBehavior( QAbstractItemView::SelectRows );
57  setSelectionMode( QAbstractItemView::ExtendedSelection );
58  setSortingEnabled( true ); // At this point no data is in the model yet, so actually nothing is sorted.
59  horizontalHeader()->setSortIndicatorShown( false ); // So hide the indicator to avoid confusion.
60 
61  setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );
62 
63  verticalHeader()->viewport()->installEventFilter( this );
64 
65  connect( verticalHeader(), &QHeaderView::sectionPressed, this, [ = ]( int row ) { selectRow( row, true ); } );
66  connect( verticalHeader(), &QHeaderView::sectionEntered, this, &QgsAttributeTableView::_q_selectRow );
67  connect( horizontalHeader(), &QHeaderView::sectionResized, this, &QgsAttributeTableView::columnSizeChanged );
68  connect( horizontalHeader(), &QHeaderView::sortIndicatorChanged, this, &QgsAttributeTableView::showHorizontalSortIndicator );
69  connect( QgsGui::mapLayerActionRegistry(), &QgsMapLayerActionRegistry::changed, this, &QgsAttributeTableView::recreateActionWidgets );
70 }
71 
72 bool QgsAttributeTableView::eventFilter( QObject *object, QEvent *event )
73 {
74  if ( object == verticalHeader()->viewport() )
75  {
76  switch ( event->type() )
77  {
78  case QEvent::MouseButtonPress:
79  mFeatureSelectionModel->enableSync( false );
80  break;
81 
82  case QEvent::MouseButtonRelease:
83  mFeatureSelectionModel->enableSync( true );
84  break;
85 
86  default:
87  break;
88  }
89  }
90  return QTableView::eventFilter( object, event );
91 }
92 
94 {
95  int i = 0;
96  const auto constColumns = config.columns();
97  for ( const QgsAttributeTableConfig::ColumnConfig &columnConfig : constColumns )
98  {
99  if ( columnConfig.hidden )
100  continue;
101 
102  if ( columnConfig.width >= 0 )
103  {
104  setColumnWidth( i, columnConfig.width );
105  }
106  else
107  {
108  setColumnWidth( i, horizontalHeader()->defaultSectionSize() );
109  }
110  i++;
111  }
112  mConfig = config;
113  if ( config.sortExpression().isEmpty() )
114  horizontalHeader()->setSortIndicatorShown( false );
115 }
116 
118 {
119  // In order to get the ids in the right sorted order based on the view we have to get the feature ids first
120  // from the selection manager which is in the order the user selected them when clicking
121  // then get the model index, sort that, and finally return the new sorted features ids.
122  const QgsFeatureIds featureIds = mFeatureSelectionManager->selectedFeatureIds();
123  QModelIndexList indexList;
124  for ( const QgsFeatureId &id : featureIds )
125  {
126  const QModelIndex index = mFilterModel->fidToIndex( id );
127  indexList << index;
128  }
129 
130  std::sort( indexList.begin(), indexList.end() );
131  QList<QgsFeatureId> ids;
132  for ( const QModelIndex &index : indexList )
133  {
134  const QgsFeatureId id = mFilterModel->data( index, QgsAttributeTableModel::FeatureIdRole ).toLongLong();
135  ids.append( id );
136  }
137  return ids;
138 }
139 
141 {
142  mFilterModel = filterModel;
143  QTableView::setModel( mFilterModel );
144 
145  if ( mFilterModel )
146  {
147  connect( mFilterModel, &QObject::destroyed, this, &QgsAttributeTableView::modelDeleted );
148  connect( mTableDelegate, &QgsAttributeTableDelegate::actionColumnItemPainted, this, &QgsAttributeTableView::onActionColumnItemPainted );
149  }
150 
151  delete mFeatureSelectionModel;
152  mFeatureSelectionModel = nullptr;
153 
154  if ( mFilterModel )
155  {
156  if ( !mFeatureSelectionManager )
157  {
158  mOwnedFeatureSelectionManager = new QgsVectorLayerSelectionManager( mFilterModel->layer(), this );
159  mFeatureSelectionManager = mOwnedFeatureSelectionManager;
160  }
161 
162  mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFeatureSelectionManager, mFilterModel );
163  setSelectionModel( mFeatureSelectionModel );
164  mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel );
165  connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )( const QModelIndexList &indexes )>( &QgsFeatureSelectionModel::requestRepaint ),
166  this, static_cast<void ( QgsAttributeTableView::* )( const QModelIndexList &indexes )>( &QgsAttributeTableView::repaintRequested ) );
167  connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )()>( &QgsFeatureSelectionModel::requestRepaint ),
168  this, static_cast<void ( QgsAttributeTableView::* )()>( &QgsAttributeTableView::repaintRequested ) );
169 
170  connect( mFilterModel->layer(), &QgsVectorLayer::editingStarted, this, &QgsAttributeTableView::recreateActionWidgets );
171  connect( mFilterModel->layer(), &QgsVectorLayer::editingStopped, this, &QgsAttributeTableView::recreateActionWidgets );
172  connect( mFilterModel->layer(), &QgsVectorLayer::readOnlyChanged, this, &QgsAttributeTableView::recreateActionWidgets );
173  }
174 }
175 
177 {
178  mFeatureSelectionManager = featureSelectionManager;
179 
180  if ( mFeatureSelectionModel )
181  mFeatureSelectionModel->setFeatureSelectionManager( mFeatureSelectionManager );
182 
183  // only delete the owner selection manager and not one created from outside
184  if ( mOwnedFeatureSelectionManager )
185  {
186  mOwnedFeatureSelectionManager->deleteLater();
187  mOwnedFeatureSelectionManager = nullptr;
188  }
189 }
190 
191 QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
192 {
193  const QgsAttributeTableConfig attributeTableConfig = mConfig;
194 
195  QToolButton *toolButton = nullptr;
196  QWidget *container = nullptr;
197 
198  if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
199  {
200  toolButton = new QToolButton();
201  toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
202  toolButton->setPopupMode( QToolButton::MenuButtonPopup );
203  container = toolButton;
204  }
205  else
206  {
207  container = new QWidget();
208  container->setLayout( new QHBoxLayout() );
209  container->layout()->setContentsMargins( 0, 0, 0, 0 );
210  }
211 
212  QList< QAction * > actionList;
213  QAction *defaultAction = nullptr;
214 
215  // first add user created layer actions
216  const QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) );
217  const auto constActions = actions;
218  for ( const QgsAction &action : constActions )
219  {
220  if ( !mFilterModel->layer()->isEditable() && action.isEnabledOnlyWhenEditable() )
221  continue;
222 
223  const QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QString();
224  QAction *act = new QAction( action.icon(), actionTitle, container );
225  act->setToolTip( action.name() );
226  act->setData( "user_action" );
227  act->setProperty( "fid", fid );
228  act->setProperty( "action_id", action.id() );
229  connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
230  actionList << act;
231 
232  if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "Feature" ) ).id() == action.id() )
233  defaultAction = act;
234  }
235 
236  const auto mapLayerActions {QgsGui::mapLayerActionRegistry()->mapLayerActions( mFilterModel->layer(), QgsMapLayerAction::SingleFeature ) };
237  // next add any registered actions for this layer
238  for ( QgsMapLayerAction *mapLayerAction : mapLayerActions )
239  {
240  QAction *action = new QAction( mapLayerAction->icon(), mapLayerAction->text(), container );
241  action->setData( "map_layer_action" );
242  action->setToolTip( mapLayerAction->text() );
243  action->setProperty( "fid", fid );
244  action->setProperty( "action", QVariant::fromValue( qobject_cast<QObject *>( mapLayerAction ) ) );
245  connect( action, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
246  actionList << action;
247 
248  if ( !defaultAction &&
249  QgsGui::mapLayerActionRegistry()->defaultActionForLayer( mFilterModel->layer() ) == mapLayerAction )
250  defaultAction = action;
251  }
252 
253  if ( !defaultAction && !actionList.isEmpty() )
254  defaultAction = actionList.at( 0 );
255 
256  const auto constActionList = actionList;
257  for ( QAction *act : constActionList )
258  {
259  if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
260  {
261  toolButton->addAction( act );
262 
263  if ( act == defaultAction )
264  toolButton->setDefaultAction( act );
265 
266  container = toolButton;
267  }
268  else
269  {
270  QToolButton *btn = new QToolButton;
271  btn->setDefaultAction( act );
272  container->layout()->addWidget( btn );
273  }
274  }
275 
276  if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::ButtonList )
277  {
278  static_cast< QHBoxLayout * >( container->layout() )->addStretch();
279  }
280 
281  // TODO: Rethink default actions
282 #if 0
283  if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
284  toolButton->setDefaultAction( toolButton->actions().at( 0 ) );
285 #endif
286 
287  return container;
288 }
289 
290 void QgsAttributeTableView::closeEvent( QCloseEvent *e )
291 {
292  Q_UNUSED( e )
293  QgsSettings settings;
294  settings.setValue( QStringLiteral( "BetterAttributeTable/geometry" ), QVariant( saveGeometry() ) );
295 }
296 
297 void QgsAttributeTableView::mousePressEvent( QMouseEvent *event )
298 {
299  setSelectionMode( QAbstractItemView::NoSelection );
300  QTableView::mousePressEvent( event );
301  setSelectionMode( QAbstractItemView::ExtendedSelection );
302 }
303 
305 {
306  setSelectionMode( QAbstractItemView::NoSelection );
307  QTableView::mouseReleaseEvent( event );
308  setSelectionMode( QAbstractItemView::ExtendedSelection );
309  if ( event->modifiers() == Qt::ControlModifier )
310  {
311  const QModelIndex index = indexAt( event->pos() );
312  const QVariant data = model()->data( index, Qt::DisplayRole );
313  if ( data.type() == QVariant::String )
314  {
315  const QString textVal = data.toString();
316  if ( QgsStringUtils::isUrl( textVal ) )
317  {
318  QDesktopServices::openUrl( QUrl( textVal ) );
319  }
320  }
321  }
322 }
323 
324 void QgsAttributeTableView::mouseMoveEvent( QMouseEvent *event )
325 {
326  setSelectionMode( QAbstractItemView::NoSelection );
327  QTableView::mouseMoveEvent( event );
328  setSelectionMode( QAbstractItemView::ExtendedSelection );
329 }
330 
331 void QgsAttributeTableView::keyPressEvent( QKeyEvent *event )
332 {
333  switch ( event->key() )
334  {
335 
336  // Default Qt behavior would be to change the selection.
337  // We don't make it that easy for the user to trash his selection.
338  case Qt::Key_Up:
339  case Qt::Key_Down:
340  case Qt::Key_Left:
341  case Qt::Key_Right:
342  setSelectionMode( QAbstractItemView::NoSelection );
343  QTableView::keyPressEvent( event );
344  setSelectionMode( QAbstractItemView::ExtendedSelection );
345  break;
346 
347  default:
348  QTableView::keyPressEvent( event );
349  break;
350  }
351 }
352 
353 void QgsAttributeTableView::repaintRequested( const QModelIndexList &indexes )
354 {
355  const auto constIndexes = indexes;
356  for ( const QModelIndex &index : constIndexes )
357  {
358  update( index );
359  }
360 }
361 
363 {
364  setDirtyRegion( viewport()->rect() );
365 }
366 
368 {
369  QItemSelection selection;
370  selection.append( QItemSelectionRange( mFilterModel->index( 0, 0 ), mFilterModel->index( mFilterModel->rowCount() - 1, 0 ) ) );
371  mFeatureSelectionModel->selectFeatures( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
372 }
373 
374 void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event )
375 {
376  delete mActionPopup;
377  mActionPopup = nullptr;
378 
379  const QModelIndex idx = mFilterModel->mapToMaster( indexAt( event->pos() ) );
380  if ( !idx.isValid() )
381  {
382  return;
383  }
384 
385  QgsVectorLayer *vlayer = mFilterModel->layer();
386  if ( !vlayer )
387  return;
388 
389  mActionPopup = new QMenu( this );
390 
391  QAction *selectAllAction = mActionPopup->addAction( tr( "Select All" ) );
392  selectAllAction->setShortcut( QKeySequence::SelectAll );
393  connect( selectAllAction, &QAction::triggered, this, &QgsAttributeTableView::selectAll );
394 
395  // let some other parts of the application add some actions
396  emit willShowContextMenu( mActionPopup, idx );
397 
398  if ( !mActionPopup->actions().isEmpty() )
399  {
400  mActionPopup->popup( event->globalPos() );
401  }
402 }
403 
405 {
406  selectRow( row, true );
407 }
408 
410 {
411  selectRow( row, false );
412 }
413 
414 void QgsAttributeTableView::modelDeleted()
415 {
416  mFilterModel = nullptr;
417  mFeatureSelectionManager = nullptr;
418  mFeatureSelectionModel = nullptr;
419 }
420 
421 void QgsAttributeTableView::selectRow( int row, bool anchor )
422 {
423  if ( selectionBehavior() == QTableView::SelectColumns
424  || ( selectionMode() == QTableView::SingleSelection
425  && selectionBehavior() == QTableView::SelectItems ) )
426  return;
427 
428  if ( row >= 0 && row < model()->rowCount() )
429  {
430  const int column = horizontalHeader()->logicalIndexAt( isRightToLeft() ? viewport()->width() : 0 );
431  const QModelIndex index = model()->index( row, column );
432  QItemSelectionModel::SelectionFlags command = selectionCommand( index );
433  selectionModel()->setCurrentIndex( index, QItemSelectionModel::NoUpdate );
434  if ( ( anchor && !( command & QItemSelectionModel::Current ) )
435  || ( selectionMode() == QTableView::SingleSelection ) )
436  mRowSectionAnchor = row;
437 
438  if ( selectionMode() != QTableView::SingleSelection
439  && command.testFlag( QItemSelectionModel::Toggle ) )
440  {
441  if ( anchor )
442  mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index )
443  ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
444  command &= ~QItemSelectionModel::Toggle;
445  command |= mCtrlDragSelectionFlag;
446  if ( !anchor )
447  command |= QItemSelectionModel::Current;
448  }
449 
450  const QModelIndex tl = model()->index( std::min( mRowSectionAnchor, row ), 0 );
451  const QModelIndex br = model()->index( std::max( mRowSectionAnchor, row ), model()->columnCount() - 1 );
452  if ( verticalHeader()->sectionsMoved() && tl.row() != br.row() )
453  setSelection( visualRect( tl ) | visualRect( br ), command );
454  else
455  mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
456  }
457 }
458 
459 void QgsAttributeTableView::showHorizontalSortIndicator()
460 {
461  horizontalHeader()->setSortIndicatorShown( true );
462 }
463 
464 void QgsAttributeTableView::actionTriggered()
465 {
466  QAction *action = qobject_cast<QAction *>( sender() );
467  const QgsFeatureId fid = action->property( "fid" ).toLongLong();
468 
469  QgsFeature f;
470  mFilterModel->layerCache()->getFeatures( QgsFeatureRequest( fid ) ).nextFeature( f );
471 
472  if ( action->data().toString() == QLatin1String( "user_action" ) )
473  {
474  mFilterModel->layer()->actions()->doAction( action->property( "action_id" ).toUuid(), f );
475  }
476  else if ( action->data().toString() == QLatin1String( "map_layer_action" ) )
477  {
478  QObject *object = action->property( "action" ).value<QObject *>();
479  QgsMapLayerAction *layerAction = qobject_cast<QgsMapLayerAction *>( object );
480  if ( layerAction )
481  {
482  layerAction->triggerForFeature( mFilterModel->layer(), f );
483  }
484  }
485 }
486 
487 void QgsAttributeTableView::columnSizeChanged( int index, int oldWidth, int newWidth )
488 {
489  Q_UNUSED( oldWidth )
490  emit columnResized( index, newWidth );
491 }
492 
493 void QgsAttributeTableView::onActionColumnItemPainted( const QModelIndex &index )
494 {
495  if ( !indexWidget( index ) )
496  {
497  QWidget *widget = createActionWidget( mFilterModel->data( index, QgsAttributeTableModel::FeatureIdRole ).toLongLong() );
498  mActionWidgets.insert( index, widget );
499  setIndexWidget( index, widget );
500  }
501 }
502 
503 void QgsAttributeTableView::recreateActionWidgets()
504 {
505  QMap< QModelIndex, QWidget * >::const_iterator it = mActionWidgets.constBegin();
506  for ( ; it != mActionWidgets.constEnd(); ++it )
507  {
508  // ownership of widget was transferred by initial call to setIndexWidget - clearing
509  // the index widget will delete the old widget safely
510  // they should then be recreated by onActionColumnItemPainted
511  setIndexWidget( it.key(), nullptr );
512  }
513  mActionWidgets.clear();
514 }
515 
517 {
518  const QModelIndex index = mFilterModel->fidToIndex( fid );
519 
520  if ( !index.isValid() )
521  return;
522 
523  scrollTo( index );
524 
525  const QModelIndex selectionIndex = index.sibling( index.row(), col );
526 
527  if ( !selectionIndex.isValid() )
528  return;
529 
530  selectionModel()->setCurrentIndex( index, QItemSelectionModel::SelectCurrent );
531 }
QList< QgsAction > actions(const QString &actionScope=QString()) const
Returns a list of actions that are available in the given action scope.
void doAction(QUuid actionId, const QgsFeature &feature, int defaultValueIndex=0, const QgsExpressionContextScope &scope=QgsExpressionContextScope())
Does the given action.
QgsAction defaultAction(const QString &actionScope)
Each scope can have a default action.
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:35
QUuid id() const
Returns a unique id for this action.
Definition: qgsaction.h:135
This is a container for configuration of the attribute table.
QVector< QgsAttributeTableConfig::ColumnConfig > columns() const
Gets the list with all columns and their configuration.
@ DropDown
A tool button with a drop-down to select the current action.
@ ButtonList
A list of buttons.
ActionWidgetStyle actionWidgetStyle() const
Gets the style of the action widget.
QString sortExpression() const
Gets the expression used for sorting.
A delegate item class for QgsAttributeTable (see Qt documentation for QItemDelegate).
void actionColumnItemPainted(const QModelIndex &index) const
Emitted when an action column item is painted.
void setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel)
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
QModelIndex fidToIndex(QgsFeatureId fid) override
QVariant data(const QModelIndex &index, int role) const override
QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
QgsVectorLayerCache * layerCache() const
Returns the layerCache this filter acts on.
@ FeatureIdRole
Get the feature id of the feature in this row.
Provides a table view of features of a QgsVectorLayer.
void willShowContextMenu(QMenu *menu, const QModelIndex &atIndex)
Emitted in order to provide a hook to add additional* menu entries to the context menu.
QList< QgsFeatureId > selectedFeaturesIds() const
Returns the selected features in the attribute table in table sorted order.
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
setFeatureSelectionManager
void mouseMoveEvent(QMouseEvent *event) override
Called for mouse move events on a table cell.
virtual void selectRow(int row)
QgsAttributeTableView(QWidget *parent=nullptr)
Constructor for QgsAttributeTableView.
void scrollToFeature(const QgsFeatureId &fid, int column=-1)
Scroll to a feature with a given fid.
void mouseReleaseEvent(QMouseEvent *event) override
Called for mouse release events on a table cell.
void contextMenuEvent(QContextMenuEvent *event) override
Is called when the context menu will be shown.
virtual void _q_selectRow(int row)
void closeEvent(QCloseEvent *event) override
Saves geometry to the settings on close.
void mousePressEvent(QMouseEvent *event) override
Called for mouse press events on a table cell.
void keyPressEvent(QKeyEvent *event) override
Called for key press events Disables selection change by only pressing an arrow key.
void setAttributeTableConfig(const QgsAttributeTableConfig &config)
Set the attribute table config which should be used to control the appearance of the attribute table.
void columnResized(int column, int width)
Emitted when a column in the view has been resized.
bool eventFilter(QObject *object, QEvent *event) override
This event filter is installed on the verticalHeader to intercept mouse press and release events.
virtual void setModel(QgsAttributeTableFilterModel *filterModel)
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
void enableSync(bool enable)
Enables or disables synchronisation to the QgsVectorLayer When synchronisation is disabled,...
virtual void selectFeatures(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
Select features on this table.
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
virtual void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
void requestRepaint()
Request a repaint of the visible items of connected views.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
Definition: qgsgui.cpp:118
Is an interface class to abstract feature selection handling.
virtual const QgsFeatureIds & selectedFeatureIds() const =0
Returns reference to identifiers of selected features.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
void changed()
Triggered when an action is added or removed from the registry.
An action which can run on map layers The class can be used in two manners:
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
void editingStarted()
Emitted when editing on this layer has started.
static bool isUrl(const QString &string)
Returns whether the string is a URL (http,https,ftp,file)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &featureRequest=QgsFeatureRequest())
Query this VectorLayerCache for features.
Represents a vector layer which manages a vector based data sets.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QgsActionManager * actions()
Returns all layer actions defined on this layer.
void readOnlyChanged()
Emitted when the read only state of this layer is changed.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
Defines the configuration of a column in the attribute table.