QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 "qgsactionmanager.h"
28#include "qgsvectorlayer.h"
29#include "qgsvectorlayercache.h"
33#include "qgsfeatureiterator.h"
34#include "qgsstringutils.h"
35#include "qgsgui.h"
36#include "qgsmaplayeraction.h"
37
39 : QgsTableView( parent )
40{
41 const QgsSettings settings;
42 restoreGeometry( settings.value( QStringLiteral( "BetterAttributeTable/geometry" ) ).toByteArray() );
43
44 //verticalHeader()->setDefaultSectionSize( 20 );
45 horizontalHeader()->setHighlightSections( false );
46
47 // We need mouse move events to create the action button on hover
48 mTableDelegate = new QgsAttributeTableDelegate( this );
49 setItemDelegate( mTableDelegate );
50
51 setEditTriggers( QAbstractItemView::AllEditTriggers );
52
53 setSelectionBehavior( QAbstractItemView::SelectRows );
54 setSelectionMode( QAbstractItemView::ExtendedSelection );
55 setSortingEnabled( true ); // At this point no data is in the model yet, so actually nothing is sorted.
56 horizontalHeader()->setSortIndicatorShown( false ); // So hide the indicator to avoid confusion.
57
58 setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );
59
60 verticalHeader()->viewport()->installEventFilter( this );
61
62 connect( verticalHeader(), &QHeaderView::sectionPressed, this, [ = ]( int row ) { selectRow( row, true ); } );
63 connect( verticalHeader(), &QHeaderView::sectionEntered, this, &QgsAttributeTableView::_q_selectRow );
64 connect( horizontalHeader(), &QHeaderView::sectionResized, this, &QgsAttributeTableView::columnSizeChanged );
65 connect( horizontalHeader(), &QHeaderView::sortIndicatorChanged, this, &QgsAttributeTableView::showHorizontalSortIndicator );
66 connect( QgsGui::mapLayerActionRegistry(), &QgsMapLayerActionRegistry::changed, this, &QgsAttributeTableView::recreateActionWidgets );
67}
68
69bool QgsAttributeTableView::eventFilter( QObject *object, QEvent *event )
70{
71 if ( object == verticalHeader()->viewport() )
72 {
73 switch ( event->type() )
74 {
75 case QEvent::MouseButtonPress:
76 mFeatureSelectionModel->enableSync( false );
77 break;
78
79 case QEvent::MouseButtonRelease:
80 mFeatureSelectionModel->enableSync( true );
81 break;
82
83 default:
84 break;
85 }
86 }
87 return QTableView::eventFilter( object, event );
88}
89
91{
92 int i = 0;
93 const auto constColumns = config.columns();
94 QMap<QString, int> columns;
95 for ( const QgsAttributeTableConfig::ColumnConfig &columnConfig : constColumns )
96 {
97 if ( columnConfig.hidden )
98 continue;
99
100 if ( columnConfig.width >= 0 )
101 {
102 setColumnWidth( i, columnConfig.width );
103 }
104 else
105 {
106 setColumnWidth( i, horizontalHeader()->defaultSectionSize() );
107 }
108 columns.insert( columnConfig.name, i );
109 i++;
110 }
111 mConfig = config;
112 if ( config.sortExpression().isEmpty() )
113 {
114 horizontalHeader()->setSortIndicatorShown( false );
115 }
116 else
117 {
118 if ( mSortExpression != config.sortExpression() )
119 {
120 const QgsExpression sortExp { config.sortExpression() };
121 if ( sortExp.isField() )
122 {
123 const QStringList refCols { sortExp.referencedColumns().values() };
124 horizontalHeader()->setSortIndicatorShown( true );
125 horizontalHeader()->setSortIndicator( columns.value( refCols.constFirst() ), config.sortOrder() );
126 }
127 }
128 }
129 mSortExpression = config.sortExpression();
130}
131
133{
134 // In order to get the ids in the right sorted order based on the view we have to get the feature ids first
135 // from the selection manager which is in the order the user selected them when clicking
136 // then get the model index, sort that, and finally return the new sorted features ids.
137 const QgsFeatureIds featureIds = mFeatureSelectionManager->selectedFeatureIds();
138 QModelIndexList indexList;
139 for ( const QgsFeatureId &id : featureIds )
140 {
141 const QModelIndex index = mFilterModel->fidToIndex( id );
142 indexList << index;
143 }
144
145 std::sort( indexList.begin(), indexList.end() );
146 QList<QgsFeatureId> ids;
147 for ( const QModelIndex &index : indexList )
148 {
149 const QgsFeatureId id = mFilterModel->data( index, static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ).toLongLong();
150 ids.append( id );
151 }
152 return ids;
153}
154
156{
157 mFilterModel = filterModel;
158 QTableView::setModel( mFilterModel );
159
160 if ( mFilterModel )
161 {
162 connect( mFilterModel, &QObject::destroyed, this, &QgsAttributeTableView::modelDeleted );
163 connect( mTableDelegate, &QgsAttributeTableDelegate::actionColumnItemPainted, this, &QgsAttributeTableView::onActionColumnItemPainted );
164 }
165
166 delete mFeatureSelectionModel;
167 mFeatureSelectionModel = nullptr;
168
169 if ( mFilterModel )
170 {
171 if ( !mFeatureSelectionManager )
172 {
173 mOwnedFeatureSelectionManager = new QgsVectorLayerSelectionManager( mFilterModel->layer(), this );
174 mFeatureSelectionManager = mOwnedFeatureSelectionManager;
175 }
176
177 mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFeatureSelectionManager, mFilterModel );
178 setSelectionModel( mFeatureSelectionModel );
179 mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel );
180 connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )( const QModelIndexList &indexes )>( &QgsFeatureSelectionModel::requestRepaint ),
181 this, static_cast<void ( QgsAttributeTableView::* )( const QModelIndexList &indexes )>( &QgsAttributeTableView::repaintRequested ) );
182 connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )()>( &QgsFeatureSelectionModel::requestRepaint ),
183 this, static_cast<void ( QgsAttributeTableView::* )()>( &QgsAttributeTableView::repaintRequested ) );
184
185 connect( mFilterModel->layer(), &QgsVectorLayer::editingStarted, this, &QgsAttributeTableView::recreateActionWidgets );
186 connect( mFilterModel->layer(), &QgsVectorLayer::editingStopped, this, &QgsAttributeTableView::recreateActionWidgets );
187 connect( mFilterModel->layer(), &QgsVectorLayer::readOnlyChanged, this, &QgsAttributeTableView::recreateActionWidgets );
188 }
189}
190
192{
193 mFeatureSelectionManager = featureSelectionManager;
194
195 if ( mFeatureSelectionModel )
196 mFeatureSelectionModel->setFeatureSelectionManager( mFeatureSelectionManager );
197
198 // only delete the owner selection manager and not one created from outside
199 if ( mOwnedFeatureSelectionManager )
200 {
201 mOwnedFeatureSelectionManager->deleteLater();
202 mOwnedFeatureSelectionManager = nullptr;
203 }
204}
205
206QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
207{
208 const QgsAttributeTableConfig attributeTableConfig = mConfig;
209
210 QToolButton *toolButton = nullptr;
211 QWidget *container = nullptr;
212
213 if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
214 {
215 toolButton = new QToolButton();
216 toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
217 toolButton->setPopupMode( QToolButton::MenuButtonPopup );
218 container = toolButton;
219 }
220 else
221 {
222 container = new QWidget();
223 container->setLayout( new QHBoxLayout() );
224 container->layout()->setContentsMargins( 0, 0, 0, 0 );
225 }
226
227 QList< QAction * > actionList;
228 QAction *defaultAction = nullptr;
229
230 // first add user created layer actions
231 const QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) );
232 const auto constActions = actions;
233 for ( const QgsAction &action : constActions )
234 {
235 if ( !mFilterModel->layer()->isEditable() && action.isEnabledOnlyWhenEditable() )
236 continue;
237
238 const QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QString();
239 QAction *act = new QAction( action.icon(), actionTitle, container );
240 act->setToolTip( action.name() );
241 act->setData( "user_action" );
242 act->setProperty( "fid", fid );
243 act->setProperty( "action_id", action.id() );
244 connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
245 actionList << act;
246
247 if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "Feature" ) ).id() == action.id() )
248 defaultAction = act;
249 }
250
252 const QList< QgsMapLayerAction * > mapLayerActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( mFilterModel->layer(), Qgis::MapLayerActionTarget::SingleFeature, context );
253 // next add any registered actions for this layer
254 for ( QgsMapLayerAction *mapLayerAction : mapLayerActions )
255 {
256 QAction *action = new QAction( mapLayerAction->icon(), mapLayerAction->text(), container );
257 action->setData( "map_layer_action" );
258 action->setToolTip( mapLayerAction->text() );
259 action->setProperty( "fid", fid );
260 action->setProperty( "action", QVariant::fromValue( qobject_cast<QObject *>( mapLayerAction ) ) );
261 connect( action, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
262 actionList << action;
263
264 if ( !defaultAction &&
265 QgsGui::mapLayerActionRegistry()->defaultActionForLayer( mFilterModel->layer() ) == mapLayerAction )
266 defaultAction = action;
267 }
268
269 if ( !defaultAction && !actionList.isEmpty() )
270 defaultAction = actionList.at( 0 );
271
272 const auto constActionList = actionList;
273 for ( QAction *act : constActionList )
274 {
275 if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
276 {
277 toolButton->addAction( act );
278
279 if ( act == defaultAction )
280 toolButton->setDefaultAction( act );
281
282 container = toolButton;
283 }
284 else
285 {
286 QToolButton *btn = new QToolButton;
287 btn->setDefaultAction( act );
288 container->layout()->addWidget( btn );
289 }
290 }
291
292 if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::ButtonList )
293 {
294 static_cast< QHBoxLayout * >( container->layout() )->addStretch();
295 }
296
297 // TODO: Rethink default actions
298#if 0
299 if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
300 toolButton->setDefaultAction( toolButton->actions().at( 0 ) );
301#endif
302
303 return container;
304}
305
307{
308 Q_UNUSED( e )
309 QgsSettings settings;
310 settings.setValue( QStringLiteral( "BetterAttributeTable/geometry" ), QVariant( saveGeometry() ) );
311}
312
314{
315 setSelectionMode( QAbstractItemView::NoSelection );
316 QTableView::mousePressEvent( event );
317 setSelectionMode( QAbstractItemView::ExtendedSelection );
318}
319
321{
322 setSelectionMode( QAbstractItemView::NoSelection );
323 QTableView::mouseReleaseEvent( event );
324 setSelectionMode( QAbstractItemView::ExtendedSelection );
325 if ( event->modifiers() == Qt::ControlModifier )
326 {
327 const QModelIndex index = indexAt( event->pos() );
328 const QVariant data = model()->data( index, Qt::DisplayRole );
329 if ( data.type() == QVariant::String )
330 {
331 const QString textVal = data.toString();
332 if ( QgsStringUtils::isUrl( textVal ) )
333 {
334 QDesktopServices::openUrl( QUrl( textVal ) );
335 }
336 }
337 }
338}
339
341{
342 setSelectionMode( QAbstractItemView::NoSelection );
343 QTableView::mouseMoveEvent( event );
344 setSelectionMode( QAbstractItemView::ExtendedSelection );
345}
346
348{
349 switch ( event->key() )
350 {
351
352 // Default Qt behavior would be to change the selection.
353 // We don't make it that easy for the user to trash his selection.
354 case Qt::Key_Up:
355 case Qt::Key_Down:
356 case Qt::Key_Left:
357 case Qt::Key_Right:
358 setSelectionMode( QAbstractItemView::NoSelection );
359 QTableView::keyPressEvent( event );
360 setSelectionMode( QAbstractItemView::ExtendedSelection );
361 break;
362
363 default:
364 QTableView::keyPressEvent( event );
365 break;
366 }
367}
368
369void QgsAttributeTableView::repaintRequested( const QModelIndexList &indexes )
370{
371 const auto constIndexes = indexes;
372 for ( const QModelIndex &index : constIndexes )
373 {
374 update( index );
375 }
376}
377
379{
380 setDirtyRegion( viewport()->rect() );
381}
382
384{
385 QItemSelection selection;
386 selection.append( QItemSelectionRange( mFilterModel->index( 0, 0 ), mFilterModel->index( mFilterModel->rowCount() - 1, 0 ) ) );
387 mFeatureSelectionModel->selectFeatures( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
388}
389
390void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event )
391{
392 delete mActionPopup;
393 mActionPopup = nullptr;
394
395 const QModelIndex idx = mFilterModel->mapToMaster( indexAt( event->pos() ) );
396 if ( !idx.isValid() )
397 {
398 return;
399 }
400
401 QgsVectorLayer *vlayer = mFilterModel->layer();
402 if ( !vlayer )
403 return;
404
405 mActionPopup = new QMenu( this );
406
407 QAction *selectAllAction = mActionPopup->addAction( tr( "Select All" ) );
408 selectAllAction->setShortcut( QKeySequence::SelectAll );
409 connect( selectAllAction, &QAction::triggered, this, &QgsAttributeTableView::selectAll );
410
411 // let some other parts of the application add some actions
412 emit willShowContextMenu( mActionPopup, idx );
413
414 if ( !mActionPopup->actions().isEmpty() )
415 {
416 mActionPopup->popup( event->globalPos() );
417 }
418}
419
421{
422 selectRow( row, true );
423}
424
426{
427 selectRow( row, false );
428}
429
430void QgsAttributeTableView::modelDeleted()
431{
432 mFilterModel = nullptr;
433 mFeatureSelectionManager = nullptr;
434 mFeatureSelectionModel = nullptr;
435}
436
437void QgsAttributeTableView::selectRow( int row, bool anchor )
438{
439 if ( selectionBehavior() == QTableView::SelectColumns
440 || ( selectionMode() == QTableView::SingleSelection
441 && selectionBehavior() == QTableView::SelectItems ) )
442 return;
443
444 if ( row >= 0 && row < model()->rowCount() )
445 {
446 const int column = horizontalHeader()->logicalIndexAt( isRightToLeft() ? viewport()->width() : 0 );
447 const QModelIndex index = model()->index( row, column );
448 QItemSelectionModel::SelectionFlags command = selectionCommand( index );
449 selectionModel()->setCurrentIndex( index, QItemSelectionModel::NoUpdate );
450 if ( ( anchor && !( command & QItemSelectionModel::Current ) )
451 || ( selectionMode() == QTableView::SingleSelection ) )
452 mRowSectionAnchor = row;
453
454 if ( selectionMode() != QTableView::SingleSelection
455 && command.testFlag( QItemSelectionModel::Toggle ) )
456 {
457 if ( anchor )
458 mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index )
459 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
460 command &= ~QItemSelectionModel::Toggle;
461 command |= mCtrlDragSelectionFlag;
462 if ( !anchor )
463 command |= QItemSelectionModel::Current;
464 }
465
466 const QModelIndex tl = model()->index( std::min( mRowSectionAnchor, row ), 0 );
467 const QModelIndex br = model()->index( std::max( mRowSectionAnchor, row ), model()->columnCount() - 1 );
468 if ( verticalHeader()->sectionsMoved() && tl.row() != br.row() )
469 setSelection( visualRect( tl ) | visualRect( br ), command );
470 else
471 mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
472 }
473}
474
475void QgsAttributeTableView::showHorizontalSortIndicator()
476{
477 horizontalHeader()->setSortIndicatorShown( true );
478}
479
480void QgsAttributeTableView::actionTriggered()
481{
482 QAction *action = qobject_cast<QAction *>( sender() );
483 const QgsFeatureId fid = action->property( "fid" ).toLongLong();
484
485 QgsFeature f;
486 mFilterModel->layerCache()->getFeatures( QgsFeatureRequest( fid ) ).nextFeature( f );
487
488 if ( action->data().toString() == QLatin1String( "user_action" ) )
489 {
490 mFilterModel->layer()->actions()->doAction( action->property( "action_id" ).toUuid(), f );
491 }
492 else if ( action->data().toString() == QLatin1String( "map_layer_action" ) )
493 {
494 QObject *object = action->property( "action" ).value<QObject *>();
495 QgsMapLayerAction *layerAction = qobject_cast<QgsMapLayerAction *>( object );
496 if ( layerAction )
497 {
500 layerAction->triggerForFeature( mFilterModel->layer(), f );
502 layerAction->triggerForFeature( mFilterModel->layer(), f, context );
503 }
504 }
505}
506
507void QgsAttributeTableView::columnSizeChanged( int index, int oldWidth, int newWidth )
508{
509 Q_UNUSED( oldWidth )
510 emit columnResized( index, newWidth );
511}
512
513void QgsAttributeTableView::onActionColumnItemPainted( const QModelIndex &index )
514{
515 if ( !indexWidget( index ) )
516 {
517 QWidget *widget = createActionWidget( mFilterModel->data( index, static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ).toLongLong() );
518 mActionWidgets.insert( index, widget );
519 setIndexWidget( index, widget );
520 }
521}
522
523void QgsAttributeTableView::recreateActionWidgets()
524{
525 QMap< QModelIndex, QWidget * >::const_iterator it = mActionWidgets.constBegin();
526 for ( ; it != mActionWidgets.constEnd(); ++it )
527 {
528 // ownership of widget was transferred by initial call to setIndexWidget - clearing
529 // the index widget will delete the old widget safely
530 // they should then be recreated by onActionColumnItemPainted
531 setIndexWidget( it.key(), nullptr );
532 }
533 mActionWidgets.clear();
534}
535
537{
538 const QModelIndex index = mFilterModel->fidToIndex( fid );
539
540 if ( !index.isValid() )
541 return;
542
543 scrollTo( index );
544
545 const QModelIndex selectionIndex = index.sibling( index.row(), col );
546
547 if ( !selectionIndex.isValid() )
548 return;
549
550 selectionModel()->setCurrentIndex( index, QItemSelectionModel::SelectCurrent );
551}
552
554{
555 QWidget *editor = indexWidget( currentIndex() );
556 commitData( editor );
557 closeEditor( editor, QAbstractItemDelegate::NoHint );
558}
@ SingleFeature
Action targets a single feature from a layer.
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:37
QUuid id() const
Returns a unique id for this action.
Definition: qgsaction.h:127
This is a container for configuration of the attribute table.
Qt::SortOrder sortOrder() const
Gets the sort order.
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)
QgsVectorLayerCache * layerCache() const
Returns the layerCache this filter acts on.
QModelIndex fidToIndex(QgsFeatureId fid) override
QVariant data(const QModelIndex &index, int role) const override
QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
@ FeatureId
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 closeCurrentEditor()
Closes the editor delegate for the current item, committing its changes to the model.
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)
Class for parsing and evaluation of expressions (formerly called "search strings").
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
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:129
Is an interface class to abstract feature selection handling.
virtual const QgsFeatureIds & selectedFeatureIds() const =0
Returns reference to identifiers of selected features.
Encapsulates the context in which a QgsMapLayerAction action is executed.
void changed()
Triggered when an action is added or removed from the registry.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, Qgis::MapLayerActionTargets targets=Qgis::MapLayerActionTarget::AllActions, const QgsMapLayerActionContext &context=QgsMapLayerActionContext())
Returns the map layer actions which can run on the specified layer.
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.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:64
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static bool isUrl(const QString &string)
Returns whether the string is a URL (http,https,ftp,file)
A QTableView subclass with QGIS specific tweaks and improvements.
Definition: qgstableview.h:36
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.
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:5776
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:5775
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.