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