QGIS API Documentation 3.39.0-Master (47f7b3a4989)
Loading...
Searching...
No Matches
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 else
128 {
129 horizontalHeader()->setSortIndicatorShown( false );
130 }
131 }
132 }
133 mSortExpression = config.sortExpression();
134}
135
137{
138 // In order to get the ids in the right sorted order based on the view we have to get the feature ids first
139 // from the selection manager which is in the order the user selected them when clicking
140 // then get the model index, sort that, and finally return the new sorted features ids.
141 const QgsFeatureIds featureIds = mFeatureSelectionManager->selectedFeatureIds();
142 QModelIndexList indexList;
143 for ( const QgsFeatureId &id : featureIds )
144 {
145 const QModelIndex index = mFilterModel->fidToIndex( id );
146 indexList << index;
147 }
148
149 std::sort( indexList.begin(), indexList.end() );
150 QList<QgsFeatureId> ids;
151 for ( const QModelIndex &index : indexList )
152 {
153 const QgsFeatureId id = mFilterModel->data( index, static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ).toLongLong();
154 ids.append( id );
155 }
156 return ids;
157}
158
160{
161 mFilterModel = filterModel;
162 QTableView::setModel( mFilterModel );
163
164 if ( mFilterModel )
165 {
166 connect( mFilterModel, &QObject::destroyed, this, &QgsAttributeTableView::modelDeleted );
167 connect( mTableDelegate, &QgsAttributeTableDelegate::actionColumnItemPainted, this, &QgsAttributeTableView::onActionColumnItemPainted );
168 }
169
170 delete mFeatureSelectionModel;
171 mFeatureSelectionModel = nullptr;
172
173 if ( mFilterModel )
174 {
175 if ( !mFeatureSelectionManager )
176 {
177 mOwnedFeatureSelectionManager = new QgsVectorLayerSelectionManager( mFilterModel->layer(), this );
178 mFeatureSelectionManager = mOwnedFeatureSelectionManager;
179 }
180
181 mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFeatureSelectionManager, mFilterModel );
182 setSelectionModel( mFeatureSelectionModel );
183 mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel );
184 connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )( const QModelIndexList &indexes )>( &QgsFeatureSelectionModel::requestRepaint ),
185 this, static_cast<void ( QgsAttributeTableView::* )( const QModelIndexList &indexes )>( &QgsAttributeTableView::repaintRequested ) );
186 connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )()>( &QgsFeatureSelectionModel::requestRepaint ),
187 this, static_cast<void ( QgsAttributeTableView::* )()>( &QgsAttributeTableView::repaintRequested ) );
188
189 connect( mFilterModel->layer(), &QgsVectorLayer::editingStarted, this, &QgsAttributeTableView::recreateActionWidgets );
190 connect( mFilterModel->layer(), &QgsVectorLayer::editingStopped, this, &QgsAttributeTableView::recreateActionWidgets );
191 connect( mFilterModel->layer(), &QgsVectorLayer::readOnlyChanged, this, &QgsAttributeTableView::recreateActionWidgets );
192 }
193}
194
196{
197 mFeatureSelectionManager = featureSelectionManager;
198
199 if ( mFeatureSelectionModel )
200 mFeatureSelectionModel->setFeatureSelectionManager( mFeatureSelectionManager );
201
202 // only delete the owner selection manager and not one created from outside
203 if ( mOwnedFeatureSelectionManager )
204 {
205 mOwnedFeatureSelectionManager->deleteLater();
206 mOwnedFeatureSelectionManager = nullptr;
207 }
208}
209
210QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
211{
212 const QgsAttributeTableConfig attributeTableConfig = mConfig;
213
214 QToolButton *toolButton = nullptr;
215 QWidget *container = nullptr;
216
217 if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
218 {
219 toolButton = new QToolButton();
220 toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
221 toolButton->setPopupMode( QToolButton::MenuButtonPopup );
222 container = toolButton;
223 }
224 else
225 {
226 container = new QWidget();
227 container->setLayout( new QHBoxLayout() );
228 container->layout()->setContentsMargins( 0, 0, 0, 0 );
229 }
230
231 QList< QAction * > actionList;
232 QAction *defaultAction = nullptr;
233
234 // first add user created layer actions
235 const QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) );
236 const auto constActions = actions;
237 for ( const QgsAction &action : constActions )
238 {
239 if ( !mFilterModel->layer()->isEditable() && action.isEnabledOnlyWhenEditable() )
240 continue;
241
242 const QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QString();
243 QAction *act = new QAction( action.icon(), actionTitle, container );
244 act->setToolTip( action.name() );
245 act->setData( "user_action" );
246 act->setProperty( "fid", fid );
247 act->setProperty( "action_id", action.id() );
248 connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
249 actionList << act;
250
251 if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "Feature" ) ).id() == action.id() )
252 defaultAction = act;
253 }
254
256 const QList< QgsMapLayerAction * > mapLayerActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( mFilterModel->layer(), Qgis::MapLayerActionTarget::SingleFeature, context );
257 // next add any registered actions for this layer
258 for ( QgsMapLayerAction *mapLayerAction : mapLayerActions )
259 {
260 QAction *action = new QAction( mapLayerAction->icon(), mapLayerAction->text(), container );
261 action->setData( "map_layer_action" );
262 action->setToolTip( mapLayerAction->text() );
263 action->setProperty( "fid", fid );
264 action->setProperty( "action", QVariant::fromValue( qobject_cast<QObject *>( mapLayerAction ) ) );
265 connect( action, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
266 actionList << action;
267
268 if ( !defaultAction &&
269 QgsGui::mapLayerActionRegistry()->defaultActionForLayer( mFilterModel->layer() ) == mapLayerAction )
270 defaultAction = action;
271 }
272
273 if ( !defaultAction && !actionList.isEmpty() )
274 defaultAction = actionList.at( 0 );
275
276 const auto constActionList = actionList;
277 for ( QAction *act : constActionList )
278 {
279 if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
280 {
281 toolButton->addAction( act );
282
283 if ( act == defaultAction )
284 toolButton->setDefaultAction( act );
285
286 container = toolButton;
287 }
288 else
289 {
290 QToolButton *btn = new QToolButton;
291 btn->setDefaultAction( act );
292 container->layout()->addWidget( btn );
293 }
294 }
295
296 if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::ButtonList )
297 {
298 static_cast< QHBoxLayout * >( container->layout() )->addStretch();
299 }
300
301 // TODO: Rethink default actions
302#if 0
303 if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
304 toolButton->setDefaultAction( toolButton->actions().at( 0 ) );
305#endif
306
307 return container;
308}
309
311{
312 Q_UNUSED( e )
313 QgsSettings settings;
314 settings.setValue( QStringLiteral( "BetterAttributeTable/geometry" ), QVariant( saveGeometry() ) );
315}
316
318{
319 setSelectionMode( QAbstractItemView::NoSelection );
320 QTableView::mousePressEvent( event );
321 setSelectionMode( QAbstractItemView::ExtendedSelection );
322}
323
325{
326 setSelectionMode( QAbstractItemView::NoSelection );
327 QTableView::mouseReleaseEvent( event );
328 setSelectionMode( QAbstractItemView::ExtendedSelection );
329 if ( event->modifiers() == Qt::ControlModifier )
330 {
331 const QModelIndex index = indexAt( event->pos() );
332 const QVariant data = model()->data( index, Qt::DisplayRole );
333 if ( data.userType() == QMetaType::Type::QString )
334 {
335 const QString textVal = data.toString();
336 if ( QgsStringUtils::isUrl( textVal ) )
337 {
338 QDesktopServices::openUrl( QUrl( textVal ) );
339 }
340 }
341 }
342}
343
345{
346 setSelectionMode( QAbstractItemView::NoSelection );
347 QTableView::mouseMoveEvent( event );
348 setSelectionMode( QAbstractItemView::ExtendedSelection );
349}
350
352{
353 switch ( event->key() )
354 {
355
356 // Default Qt behavior would be to change the selection.
357 // We don't make it that easy for the user to trash his selection.
358 case Qt::Key_Up:
359 case Qt::Key_Down:
360 case Qt::Key_Left:
361 case Qt::Key_Right:
362 setSelectionMode( QAbstractItemView::NoSelection );
363 QTableView::keyPressEvent( event );
364 setSelectionMode( QAbstractItemView::ExtendedSelection );
365 break;
366
367 default:
368 QTableView::keyPressEvent( event );
369 break;
370 }
371}
372
373void QgsAttributeTableView::repaintRequested( const QModelIndexList &indexes )
374{
375 const auto constIndexes = indexes;
376 for ( const QModelIndex &index : constIndexes )
377 {
378 update( index );
379 }
380}
381
383{
384 setDirtyRegion( viewport()->rect() );
385}
386
388{
389 QItemSelection selection;
390 selection.append( QItemSelectionRange( mFilterModel->index( 0, 0 ), mFilterModel->index( mFilterModel->rowCount() - 1, 0 ) ) );
391 mFeatureSelectionModel->selectFeatures( selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
392}
393
394void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event )
395{
396 delete mActionPopup;
397 mActionPopup = nullptr;
398
399 const QModelIndex idx = mFilterModel->mapToMaster( indexAt( event->pos() ) );
400 if ( !idx.isValid() )
401 {
402 return;
403 }
404
405 QgsVectorLayer *vlayer = mFilterModel->layer();
406 if ( !vlayer )
407 return;
408
409 mActionPopup = new QMenu( this );
410
411 QAction *selectAllAction = mActionPopup->addAction( tr( "Select All" ) );
412 selectAllAction->setShortcut( QKeySequence::SelectAll );
413 connect( selectAllAction, &QAction::triggered, this, &QgsAttributeTableView::selectAll );
414
415 // let some other parts of the application add some actions
416 emit willShowContextMenu( mActionPopup, idx );
417
418 if ( !mActionPopup->actions().isEmpty() )
419 {
420 mActionPopup->popup( event->globalPos() );
421 }
422}
423
425{
426 selectRow( row, true );
427}
428
430{
431 selectRow( row, false );
432}
433
434void QgsAttributeTableView::modelDeleted()
435{
436 mFilterModel = nullptr;
437 mFeatureSelectionManager = nullptr;
438 mFeatureSelectionModel = nullptr;
439}
440
441void QgsAttributeTableView::selectRow( int row, bool anchor )
442{
443 if ( selectionBehavior() == QTableView::SelectColumns
444 || ( selectionMode() == QTableView::SingleSelection
445 && selectionBehavior() == QTableView::SelectItems ) )
446 return;
447
448 if ( row >= 0 && row < model()->rowCount() )
449 {
450 const int column = horizontalHeader()->logicalIndexAt( isRightToLeft() ? viewport()->width() : 0 );
451 const QModelIndex index = model()->index( row, column );
452 QItemSelectionModel::SelectionFlags command = selectionCommand( index );
453 selectionModel()->setCurrentIndex( index, QItemSelectionModel::NoUpdate );
454 if ( ( anchor && !( command & QItemSelectionModel::Current ) )
455 || ( selectionMode() == QTableView::SingleSelection ) )
456 mRowSectionAnchor = row;
457
458 if ( selectionMode() != QTableView::SingleSelection
459 && command.testFlag( QItemSelectionModel::Toggle ) )
460 {
461 if ( anchor )
462 mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index )
463 ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
464 command &= ~QItemSelectionModel::Toggle;
465 command |= mCtrlDragSelectionFlag;
466 if ( !anchor )
467 command |= QItemSelectionModel::Current;
468 }
469
470 const QModelIndex tl = model()->index( std::min( mRowSectionAnchor, row ), 0 );
471 const QModelIndex br = model()->index( std::max( mRowSectionAnchor, row ), model()->columnCount() - 1 );
472 if ( verticalHeader()->sectionsMoved() && tl.row() != br.row() )
473 setSelection( visualRect( tl ) | visualRect( br ), command );
474 else
475 mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
476 }
477}
478
479void QgsAttributeTableView::showHorizontalSortIndicator()
480{
481 horizontalHeader()->setSortIndicatorShown( true );
482}
483
484void QgsAttributeTableView::actionTriggered()
485{
486 QAction *action = qobject_cast<QAction *>( sender() );
487 const QgsFeatureId fid = action->property( "fid" ).toLongLong();
488
489 QgsFeature f;
490 mFilterModel->layerCache()->getFeatures( QgsFeatureRequest( fid ) ).nextFeature( f );
491
492 if ( action->data().toString() == QLatin1String( "user_action" ) )
493 {
494 mFilterModel->layer()->actions()->doAction( action->property( "action_id" ).toUuid(), f );
495 }
496 else if ( action->data().toString() == QLatin1String( "map_layer_action" ) )
497 {
498 QObject *object = action->property( "action" ).value<QObject *>();
499 QgsMapLayerAction *layerAction = qobject_cast<QgsMapLayerAction *>( object );
500 if ( layerAction )
501 {
504 layerAction->triggerForFeature( mFilterModel->layer(), f );
506 layerAction->triggerForFeature( mFilterModel->layer(), f, context );
507 }
508 }
509}
510
511void QgsAttributeTableView::columnSizeChanged( int index, int oldWidth, int newWidth )
512{
513 Q_UNUSED( oldWidth )
514 emit columnResized( index, newWidth );
515}
516
517void QgsAttributeTableView::onActionColumnItemPainted( const QModelIndex &index )
518{
519 if ( !indexWidget( index ) )
520 {
521 QWidget *widget = createActionWidget( mFilterModel->data( index, static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ).toLongLong() );
522 mActionWidgets.insert( index, widget );
523 setIndexWidget( index, widget );
524 }
525}
526
527void QgsAttributeTableView::recreateActionWidgets()
528{
529 QMap< QModelIndex, QWidget * >::const_iterator it = mActionWidgets.constBegin();
530 for ( ; it != mActionWidgets.constEnd(); ++it )
531 {
532 // ownership of widget was transferred by initial call to setIndexWidget - clearing
533 // the index widget will delete the old widget safely
534 // they should then be recreated by onActionColumnItemPainted
535 setIndexWidget( it.key(), nullptr );
536 }
537 mActionWidgets.clear();
538}
539
541{
542 const QModelIndex index = mFilterModel->fidToIndex( fid );
543
544 if ( !index.isValid() )
545 return;
546
547 scrollTo( index );
548
549 const QModelIndex selectionIndex = index.sibling( index.row(), col );
550
551 if ( !selectionIndex.isValid() )
552 return;
553
554 selectionModel()->setCurrentIndex( index, QItemSelectionModel::SelectCurrent );
555}
556
558{
559 QWidget *editor = indexWidget( currentIndex() );
560 commitData( editor );
561 closeEditor( editor, QAbstractItemDelegate::NoHint );
562}
@ 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.
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:58
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.
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.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:6042
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6041
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Defines the configuration of a column in the attribute table.