37 #include <QMessageBox> 38 #include <QProgressDialog> 40 #include <QInputDialog> 43 : QStackedWidget( parent )
49 mConditionalFormatWidget->hide();
51 mPreviewColumnsMenu =
new QMenu(
this );
52 mActionPreviewColumnsMenu->setMenu( mPreviewColumnsMenu );
58 connect( mActionExpressionPreview, &QAction::triggered,
this, &QgsDualView::previewExpressionBuilder );
69 mEditorContext = context;
72 mTableView->horizontalHeader()->setContextMenuPolicy( Qt::CustomContextMenu );
73 connect( mTableView->horizontalHeader(), &QHeaderView::customContextMenuRequested,
this, &QgsDualView::showViewHeaderMenu );
78 initModels( mapCanvas, request, loadFeatures );
80 mConditionalFormatWidget->setLayer( mLayer );
82 mTableView->setModel( mFilterModel );
83 mFeatureList->setModel( mFeatureListModel );
84 delete mAttributeForm;
85 mAttributeForm =
new QgsAttributeForm( mLayer, mTempAttributeFormFeature, mEditorContext );
90 mAttributeEditorScrollArea->setWidgetResizable(
true );
91 mAttributeEditor->layout()->addWidget( mAttributeEditorScrollArea );
92 mAttributeEditorScrollArea->setWidget( mAttributeForm );
96 mAttributeEditor->layout()->addWidget( mAttributeForm );
105 if ( mFeatureListPreviewButton->defaultAction() )
106 mFeatureList->setDisplayExpression( mDisplayExpression );
114 void QgsDualView::columnBoxInit()
117 QList<QgsField> fields = mLayer->fields().toList();
119 QString defaultField;
122 QString displayExpression = mLayer->displayExpression();
124 if ( displayExpression.isEmpty() )
127 displayExpression = QStringLiteral(
"'[Please define preview text]'" );
130 mFeatureListPreviewButton->addAction( mActionExpressionPreview );
131 mFeatureListPreviewButton->addAction( mActionPreviewColumnsMenu );
133 Q_FOREACH (
const QgsField &field, fields )
135 int fieldIndex = mLayer->fields().lookupField( field.
name() );
136 if ( fieldIndex == -1 )
139 QString fieldName = field.
name();
142 QIcon icon = mLayer->fields().iconForField( fieldIndex );
143 QString text = mLayer->attributeDisplayName( fieldIndex );
146 QAction *previewAction =
new QAction( icon, text, mFeatureListPreviewButton );
147 connect( previewAction, &QAction::triggered,
this, [ = ] { previewColumnChanged( previewAction, fieldName ); } );
148 mPreviewColumnsMenu->addAction( previewAction );
150 if ( text == defaultField )
152 mFeatureListPreviewButton->setDefaultAction( previewAction );
157 QAction *sortByPreviewExpression =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"sort.svg" ) ), tr(
"Sort by preview expression" ),
this );
158 connect( sortByPreviewExpression, &QAction::triggered,
this, &QgsDualView::sortByPreviewExpression );
159 mFeatureListPreviewButton->addAction( sortByPreviewExpression );
161 QAction *separator =
new QAction( mFeatureListPreviewButton );
162 separator->setSeparator(
true );
163 mFeatureListPreviewButton->addAction( separator );
164 restoreRecentDisplayExpressions();
167 if ( !mFeatureListPreviewButton->defaultAction() )
169 mFeatureList->setDisplayExpression( displayExpression );
170 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
171 setDisplayExpression( mFeatureList->displayExpression() );
175 mFeatureListPreviewButton->defaultAction()->trigger();
181 setCurrentIndex( view );
213 || ( mMasterModel->
rowCount() == 0 );
215 if ( !needsGeometry )
224 switch ( filterMode )
246 if ( requiresTableReload )
249 whileBlocking( mLayerCache )->setCacheGeometry( needsGeometry );
263 void QgsDualView::initLayerCache(
bool cacheGeometry )
267 int cacheSize = settings.
value( QStringLiteral(
"qgis/attributeTableRowCache" ),
"10000" ).toInt();
273 rebuildFullLayerCache();
279 delete mFeatureListModel;
300 connect( mMasterModel, &QgsAttributeTableModel::rowsRemoved, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
301 connect( mMasterModel, &QgsAttributeTableModel::rowsInserted, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
309 void QgsDualView::restoreRecentDisplayExpressions()
311 const QVariantList previewExpressions = mLayer->customProperty( QStringLiteral(
"dualview/previewExpressions" ) ).toList();
313 for (
const QVariant &previewExpression : previewExpressions )
314 insertRecentlyUsedDisplayExpression( previewExpression.toString() );
317 void QgsDualView::saveRecentDisplayExpressions()
const 323 QList<QAction *> actions = mFeatureListPreviewButton->actions();
326 int index = actions.indexOf( mLastDisplayExpressionAction );
329 QVariantList previewExpressions;
330 for ( ; index < actions.length(); ++index )
332 QAction *action = actions.at( index );
333 previewExpressions << action->property(
"previewExpression" );
336 mLayer->setCustomProperty( QStringLiteral(
"dualview/previewExpressions" ), previewExpressions );
340 void QgsDualView::setDisplayExpression(
const QString &expression )
342 mDisplayExpression = expression;
343 insertRecentlyUsedDisplayExpression( expression );
346 void QgsDualView::insertRecentlyUsedDisplayExpression(
const QString &expression )
348 QList<QAction *> actions = mFeatureListPreviewButton->actions();
351 int index = actions.indexOf( mLastDisplayExpressionAction );
354 for (
int i = 0; index + i < actions.length(); ++i )
356 QAction *action = actions.at( index );
357 if ( action->text() == expression || i >= 9 )
359 if ( action == mLastDisplayExpressionAction )
360 mLastDisplayExpressionAction =
nullptr;
361 mFeatureListPreviewButton->removeAction( action );
365 if ( !mLastDisplayExpressionAction )
366 mLastDisplayExpressionAction = action;
371 QString name = expression;
373 if ( expression.startsWith( QLatin1String(
"COALESCE( \"" ) ) && expression.endsWith( QLatin1String(
", '<NULL>' )" ) ) )
375 name = expression.mid( 11, expression.length() - 24 );
377 int fieldIndex = mLayer->fields().indexOf( name );
378 if ( fieldIndex != -1 )
380 name = mLayer->attributeDisplayName( fieldIndex );
381 icon = mLayer->fields().iconForField( fieldIndex );
389 QAction *previewAction =
new QAction( icon, name, mFeatureListPreviewButton );
390 previewAction->setProperty(
"previewExpression", expression );
391 connect( previewAction, &QAction::triggered,
this, [expression,
this](
bool )
393 setDisplayExpression( expression );
394 mFeatureListPreviewButton->setText( expression );
398 mFeatureListPreviewButton->insertAction( mLastDisplayExpressionAction, previewAction );
399 mLastDisplayExpressionAction = previewAction;
402 void QgsDualView::mFeatureList_aboutToChangeEditSelection(
bool &ok )
404 if ( mLayer->isEditable() && !mAttributeForm->
save() )
408 void QgsDualView::mFeatureList_currentEditSelectionChanged(
const QgsFeature &feat )
410 if ( !mAttributeForm )
412 mTempAttributeFormFeature = feat;
414 else if ( !mLayer->isEditable() || mAttributeForm->
save() )
427 mFeatureList->setCurrentFeatureEdited(
false );
428 mFeatureList->setEditSelection( fids );
433 return mAttributeForm->
save();
438 mConditionalFormatWidget->setVisible( !mConditionalFormatWidget->isVisible() );
439 mConditionalFormatWidget->viewRules();
463 void QgsDualView::previewExpressionBuilder()
469 dlg.setWindowTitle( tr(
"Expression Based Preview" ) );
472 if ( dlg.exec() == QDialog::Accepted )
474 mFeatureList->setDisplayExpression( dlg.expressionText() );
475 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
476 mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
479 setDisplayExpression( mFeatureList->displayExpression() );
482 void QgsDualView::previewColumnChanged( QAction *previewAction,
const QString &expression )
484 if ( !mFeatureList->setDisplayExpression( QStringLiteral(
"COALESCE( \"%1\", '<NULL>' )" ).arg( expression ) ) )
486 QMessageBox::warning(
this,
487 tr(
"Column Preview" ),
488 tr(
"Could not set column '%1' as preview column.\nParser error:\n%2" )
489 .arg( previewAction->text(), mFeatureList->parserErrorString() )
494 mFeatureListPreviewButton->setText( previewAction->text() );
495 mFeatureListPreviewButton->setIcon( previewAction->icon() );
496 mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
499 setDisplayExpression( mFeatureList->displayExpression() );
509 return mFilterModel->rowCount();
514 QAction *action = qobject_cast<QAction *>( sender() );
516 if ( action && action->data().isValid() && action->data().canConvert<QModelIndex>() )
518 QModelIndex index = action->data().toModelIndex();
520 QApplication::clipboard()->setText( var.toString() );
527 mProgressDlg->cancel();
533 saveRecentDisplayExpressions();
536 void QgsDualView::viewWillShowContextMenu( QMenu *menu,
const QModelIndex &atIndex )
543 QModelIndex sourceIndex = mFilterModel->
mapToSource( atIndex );
545 QAction *copyContentAction =
new QAction( tr(
"Copy Cell Content" ),
this );
546 copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
547 menu->addAction( copyContentAction );
554 menu->addAction( tr(
"Zoom to Feature" ),
this, SLOT( zoomToCurrentFeature() ) );
555 menu->addAction( tr(
"Pan to Feature" ),
this, SLOT( panToCurrentFeature() ) );
556 menu->addAction( tr(
"Flash Feature" ),
this, SLOT( flashCurrentFeature() ) );
560 QList<QgsAction> actions = mLayer->actions()->actions( QStringLiteral(
"Field" ) );
561 if ( !actions.isEmpty() )
563 QAction *a = menu->addAction( tr(
"Run Layer Action" ) );
564 a->setEnabled(
false );
566 Q_FOREACH (
const QgsAction &action, actions )
575 #if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) 576 menu->addAction( action.
name(), a, SLOT( execute() ) );
585 if ( !registeredActions.isEmpty() )
588 menu->addSeparator();
593 #if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) 594 menu->addAction( action->text(), a, SLOT( execut() ) );
601 menu->addSeparator();
603 #if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) 604 menu->addAction( tr(
"Open Form" ), a, SLOT( featureForm() ) );
611 void QgsDualView::widgetWillShowContextMenu(
QgsActionMenu *menu,
const QModelIndex &atIndex )
617 void QgsDualView::showViewHeaderMenu( QPoint point )
619 int col = mTableView->columnAt( point.x() );
621 delete mHorizontalHeaderMenu;
622 mHorizontalHeaderMenu =
new QMenu(
this );
624 QAction *hide =
new QAction( tr(
"&Hide Column" ), mHorizontalHeaderMenu );
625 connect( hide, &QAction::triggered,
this, &QgsDualView::hideColumn );
626 hide->setData( col );
627 mHorizontalHeaderMenu->addAction( hide );
628 QAction *setWidth =
new QAction( tr(
"&Set Width…" ), mHorizontalHeaderMenu );
629 connect( setWidth, &QAction::triggered,
this, &QgsDualView::resizeColumn );
630 setWidth->setData( col );
631 mHorizontalHeaderMenu->addAction( setWidth );
632 QAction *optimizeWidth =
new QAction( tr(
"&Autosize" ), mHorizontalHeaderMenu );
633 connect( optimizeWidth, &QAction::triggered,
this, &QgsDualView::autosizeColumn );
634 optimizeWidth->setData( col );
635 mHorizontalHeaderMenu->addAction( optimizeWidth );
637 mHorizontalHeaderMenu->addSeparator();
638 QAction *organize =
new QAction( tr(
"&Organize Columns…" ), mHorizontalHeaderMenu );
639 connect( organize, &QAction::triggered,
this, &QgsDualView::organizeColumns );
640 mHorizontalHeaderMenu->addAction( organize );
641 QAction *sort =
new QAction( tr(
"&Sort…" ), mHorizontalHeaderMenu );
642 connect( sort, &QAction::triggered,
this, &QgsDualView::modifySort );
643 mHorizontalHeaderMenu->addAction( sort );
645 mHorizontalHeaderMenu->popup( mTableView->horizontalHeader()->mapToGlobal( point ) );
648 void QgsDualView::organizeColumns()
656 if ( dialog.exec() == QDialog::Accepted )
663 void QgsDualView::tableColumnResized(
int column,
int width )
667 if ( sourceCol >= 0 && config.
columnWidth( sourceCol ) != width )
674 void QgsDualView::hideColumn()
676 QAction *action = qobject_cast<QAction *>( sender() );
677 int col = action->data().toInt();
680 if ( sourceCol >= 0 )
687 void QgsDualView::resizeColumn()
689 QAction *action = qobject_cast<QAction *>( sender() );
690 int col = action->data().toInt();
696 if ( sourceCol >= 0 )
699 int width = QInputDialog::getInt(
this, tr(
"Set column width" ), tr(
"Enter column width" ),
700 mTableView->columnWidth( col ),
710 void QgsDualView::autosizeColumn()
712 QAction *action = qobject_cast<QAction *>( sender() );
713 int col = action->data().toInt();
714 mTableView->resizeColumnToContents( col );
717 void QgsDualView::modifySort()
725 orderByDlg.setWindowTitle( tr(
"Configure Attribute Table Sort Order" ) );
726 QDialogButtonBox *dialogButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
727 QGridLayout *layout =
new QGridLayout();
728 connect( dialogButtonBox, &QDialogButtonBox::accepted, &orderByDlg, &QDialog::accept );
729 connect( dialogButtonBox, &QDialogButtonBox::rejected, &orderByDlg, &QDialog::reject );
730 orderByDlg.setLayout( layout );
732 QGroupBox *sortingGroupBox =
new QGroupBox();
733 sortingGroupBox->setTitle( tr(
"Defined sort order in attribute table" ) );
734 sortingGroupBox->setCheckable(
true );
736 layout->addWidget( sortingGroupBox );
737 sortingGroupBox->setLayout(
new QGridLayout() );
742 expressionBuilder->
setLayer( mLayer );
744 expressionBuilder->
loadRecent( QStringLiteral(
"generic" ) );
747 sortingGroupBox->layout()->addWidget( expressionBuilder );
749 QCheckBox *cbxSortAscending =
new QCheckBox( tr(
"Sort ascending" ) );
750 cbxSortAscending->setChecked( config.
sortOrder() == Qt::AscendingOrder );
751 sortingGroupBox->layout()->addWidget( cbxSortAscending );
753 layout->addWidget( dialogButtonBox );
754 if ( orderByDlg.exec() )
756 Qt::SortOrder sortOrder = cbxSortAscending->isChecked() ? Qt::AscendingOrder : Qt::DescendingOrder;
757 if ( sortingGroupBox->isChecked() )
773 void QgsDualView::zoomToCurrentFeature()
775 QModelIndex currentIndex = mTableView->currentIndex();
776 if ( !currentIndex.isValid() )
782 ids.insert( mFilterModel->
rowToId( currentIndex ) );
790 void QgsDualView::panToCurrentFeature()
792 QModelIndex currentIndex = mTableView->currentIndex();
793 if ( !currentIndex.isValid() )
799 ids.insert( mFilterModel->
rowToId( currentIndex ) );
807 void QgsDualView::flashCurrentFeature()
809 QModelIndex currentIndex = mTableView->currentIndex();
810 if ( !currentIndex.isValid() )
816 ids.insert( mFilterModel->
rowToId( currentIndex ) );
824 void QgsDualView::rebuildFullLayerCache()
832 void QgsDualView::previewExpressionChanged(
const QString &expression )
834 mLayer->setDisplayExpression( expression );
837 void QgsDualView::onSortColumnChanged()
841 cfg.
sortOrder() != mFilterModel->sortOrder() )
849 void QgsDualView::sortByPreviewExpression()
851 Qt::SortOrder sortOrder = Qt::AscendingOrder;
854 sortOrder = mConfig.
sortOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder;
859 void QgsDualView::updateSelectedFeatures()
871 void QgsDualView::extentChanged()
884 void QgsDualView::featureFormAttributeChanged(
const QString &attribute,
const QVariant &value,
bool attributeChanged )
886 Q_UNUSED( attribute );
888 if ( attributeChanged )
889 mFeatureList->setCurrentFeatureEdited(
true );
904 mTableView->setFeatureSelectionManager( featureSelectionManager );
905 mFeatureList->setFeatureSelectionManager( featureSelectionManager );
907 if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
908 delete mFeatureSelectionManager;
910 mFeatureSelectionManager = featureSelectionManager;
916 mConfig.
update( mLayer->fields() );
917 mLayer->setAttributeTableConfig( mConfig );
919 mTableView->setAttributeTableConfig( mConfig );
924 if ( sortExpression.isNull() )
925 mFilterModel->
sort( -1 );
927 mFilterModel->
sort( sortExpression, sortOrder );
944 void QgsDualView::progress(
int i,
bool &cancel )
948 mProgressDlg =
new QProgressDialog( tr(
"Loading features…" ), tr(
"Abort" ), 0, 0,
this );
949 mProgressDlg->setWindowTitle( tr(
"Attribute Table" ) );
950 mProgressDlg->setWindowModality( Qt::WindowModal );
951 mProgressDlg->show();
954 mProgressDlg->setLabelText( tr(
"%1 features loaded." ).arg( i ) );
955 QCoreApplication::processEvents();
957 cancel = mProgressDlg && mProgressDlg->wasCanceled();
960 void QgsDualView::finished()
963 mProgressDlg =
nullptr;
972 mDualView->masterModel()->executeAction( mAction, mFieldIdx );
978 editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
979 mDualView->setCurrentEditSelection( editedIds );
989 mDualView->masterModel()->executeMapLayerAction( mAction, mFieldIdx );
void setRequest(const QgsFeatureRequest &request)
Set a request that will be used to fill this attribute table model.
QgsFeatureId rowToId(const QModelIndex &row)
Returns the feature id for a given model index.
void setFilterMode(QgsAttributeTableFilterModel::FilterMode filterMode)
Set the filter mode.
A rectangle specified with double values.
void setSortExpression(const QString &sortExpression)
Set the sort expression used for sorting.
const Flags & flags() const
virtual void loadLayer()
Loads the layer into the model Preferably to be called, before using this model as source for any oth...
void update(const QgsFields &fields)
Update the configuration with the given fields.
QSet< QgsFeatureId > QgsFeatureIds
void setAttributeTableConfig(const QgsAttributeTableConfig &config)
Set the attribute table configuration to control which fields are shown, in which order they are show...
void init(QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext(), bool loadFeatures=true)
Has to be called to initialize the dual view.
void setExpressionText(const QString &text)
void willShowContextMenu(QMenu *menu, const QModelIndex &atIndex)
Is emitted, in order to provide a hook to add additional* menu entries to the context menu...
QgsMapCanvas * mapCanvas() const
Returns the map canvas.
QgsAttributeTableConfig config() const
Gets the updated configuration.
void setSelectedOnTop(bool selectedOnTop)
Changes the sort order of the features.
void filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
Is emitted when a filter expression is set using the view.
void setSortOrder(Qt::SortOrder sortOrder)
Set the sort order.
void setFilterMode(FilterMode filterMode)
Set the filter mode the filter will use.
void toggleSearchMode(bool enabled)
Toggles whether search mode should be enabled in the form.
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
Set the feature selection model.
This class is a composition of two QSettings instances:
void invalidated()
The cache has been invalidated and cleared.
void openConditionalStyles()
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
This class contains context information for attribute editor widgets.
int mapVisibleColumnToIndex(int visibleColumn) const
Maps a visible column index to its original column index.
ViewMode
The view modes, in which this widget can present information.
void willShowContextMenu(QgsActionMenu *menu, const QModelIndex &atIndex)
Is emitted, when the context menu is created to add the specific actions to it.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void fieldConditionalStyleChanged(const QString &fieldName)
Handles updating the model when the conditional style for a field changes.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
int filteredFeatureCount()
Returns the number of features which are currently visible, according to the filter restrictions...
void columnResized(int column, int width)
Emitted when a column in the view has been resized.
const QgsFeatureRequest & request() const
Gets the the feature request.
Multi edit mode, for editing fields of multiple features at once.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Show only visible features (depends on the map canvas)
void setCurrentEditSelection(const QgsFeatureIds &fids)
Set the current edit selection in the AttributeEditor mode.
Map canvas is a class for displaying all GIS data types on a canvas.
void hideEvent(QHideEvent *event) override
void setView(ViewMode view)
Change the current view mode.
virtual void setFilteredFeatures(const QgsFeatureIds &ids)
Specify a list of features, which the filter will accept.
QVariant data(const QModelIndex &index, int role) const override
Returns data on the given index.
void setAttributeTableConfig(const QgsAttributeTableConfig &config)
Set the attribute table config which should be used to control the appearance of the attribute table...
QString sortExpression() const
Gets the expression used for sorting.
QgsDualView(QWidget *parent=nullptr)
Constructor.
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
void setColumnWidth(int column, int width)
Sets the width of a column.
void setSortExpression(const QString &sortExpression, Qt::SortOrder sortOrder=Qt::AscendingOrder)
Set the expression used for sorting the table and feature list.
QString name() const
The name of the action. This may be a longer description.
Qt::SortOrder sortOrder() const
Gets the sort order.
Show only selected features.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
FilterMode filterMode()
The current filterModel.
void setExtraColumns(int extraColumns)
Empty extra columns to announce from this model.
FilterMode
The filter mode defines how the rows should be filtered.
void flashFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids, const QColor &startColor=QColor(255, 0, 0, 255), const QColor &endColor=QColor(255, 0, 0, 0), int flashes=3, int duration=500)
Causes a set of features with matching ids from a vector layer to flash within the canvas...
Dialog for organising (hiding and reordering) columns in the attributes table.
void aboutToChangeEditSelection(bool &ok)
void setEditorContext(const QgsAttributeEditorContext &context)
Sets the context in which this table is shown.
QgsFeatureRequest & disableFilter()
Disables filter conditions.
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories...
Utility class that encapsulates an action based on vector attributes.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void progress(int i, bool &cancel)
When filling the cache, this signal gets emitted periodically to notify about the progress and to be ...
ViewMode view() const
Returns the current view mode.
void panToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Centers canvas extent to feature ids.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QgsFeatureIds filteredFeatures()
Gets a list of currently visible feature ids.
void displayExpressionChanged(const QString &expression)
Is emitted, whenever the display expression is successfully changed.
void filterChanged()
Is emitted, whenever the filter changes.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
This signal is emitted when selection was changed.
FilterType filterType() const
Returns the filter type which is currently set on this request.
Show only features which have unsaved changes.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Encapsulate a field in an attribute table or data source.
Fast access to features using their ID.
void cancelProgress()
Cancel the progress dialog (if any)
QgsAttributeTableConfig attributeTableConfig() const
The config used for the attribute table.
QUuid id() const
Returns a unique id for this action.
This class caches features of a given QgsVectorLayer.
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
bool saveEditChanges()
saveEditChanges
Show only features whose ids are on the filter list. {.
void progress(int i, bool &cancel)
void setRequest(const QgsFeatureRequest &request)
Set the request.
QgsAttributeTableFilterModel::FilterMode filterMode()
Gets the filter mode.
void modelChanged()
Model has been changed.
void setSelectedOnTop(bool selectedOnTop)
Toggle the selectedOnTop flag.
void showContextMenuExternally(QgsActionMenu *menu, QgsFeatureId fid)
Emitted when selecting context menu on the feature list to create the context menu individually...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
void zoomToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Set canvas extent to the bounding box of a set of features.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows.
void setCacheGeometry(bool cacheGeometry)
Enable or disable the caching of geometries.
void setFullCache(bool fullCache)
This enables or disables full caching.
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Sort by the given column using the given order.
QString sortExpression() const
The expression which is used to sort the attribute table.
void setColumnHidden(int column, bool hidden)
Sets whether the specified column should be hidden.
Single edit mode, for editing a single feature.
void displayExpressionChanged(const QString &expression)
Is emitted, whenever the display expression is successfully changed.
QString sortExpression() const
Gets the expression used for sorting the table and feature list.
const QgsAttributeEditorContext * parentContext() const
bool runable() const
Checks if the action is runable on the current platform.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
void setSortByDisplayExpression(bool sortByDisplayExpression)
Sort this model by its display expression.
void setFilteredFeatures(const QgsFeatureIds &filteredFeatures)
Set a list of currently visible features.
This is a container for configuration of the attribute table.
Form values are used for searching/filtering the layer.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
void setMultiEditEnabled(bool enabled)
Sets whether multi edit mode is enabled.
Is an interface class to abstract feature selection handling.
void copyCellContent() const
Copy the content of the selected cell in the clipboard.
void currentEditSelectionChanged(QgsFeature &feat)
Is emitted, whenever the current edit selection has been changed.
Represents a vector layer which manages a vector based data sets.
void sortColumnChanged(int column, Qt::SortOrder order)
Is emitted whenever the sort column is changed.
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
void finished()
When filling the cache, this signal gets emitted once the cache is fully initialized.
void extentsChanged()
Emitted when the extents of the map change.
A generic dialog for building expression strings.
bool isEnabledOnlyWhenEditable() const
Returns whether only enabled in editable mode.
An action which can run on map layers.
int columnWidth(int column) const
Returns the width of a column, or -1 if column should use default width.
int featureCount()
Returns the number of features on the layer.
void formModeChanged(QgsAttributeEditorContext::Mode mode)
Emitted when the form changes mode.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.