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