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