19 #include <QMessageBox> 20 #include <QProgressDialog> 22 #include <QInputDialog> 48 : QStackedWidget( parent )
55 mConditionalFormatWidget->hide();
57 mPreviewColumnsMenu =
new QMenu(
this );
58 mActionPreviewColumnsMenu->setMenu( mPreviewColumnsMenu );
64 connect( mActionExpressionPreview, &QAction::triggered,
this, &QgsDualView::previewExpressionBuilder );
73 auto createShortcuts = [ = ](
const QString & objectName, void (
QgsFeatureListView::* slot )() )
77 connect( sc, &QShortcut::activated, mFeatureListView, slot );
84 QButtonGroup *buttonGroup =
new QButtonGroup(
this );
85 buttonGroup->setExclusive(
false );
89 QAbstractButton *bt = buttonGroup->button( static_cast<int>( action ) );
91 bt->setChecked(
true );
92 connect( buttonGroup, qgis::overload< QAbstractButton *, bool >::of( &QButtonGroup::buttonToggled ),
this, &QgsDualView::panZoomGroupButtonToggled );
93 mFlashButton->setChecked(
QgsSettings().value( QStringLiteral(
"/qgis/attributeTable/featureListHighlightFeature" ),
true ).toBool() );
94 connect( mFlashButton, &QToolButton::clicked,
this, &QgsDualView::flashButtonClicked );
104 mEditorContext = context;
107 mTableView->horizontalHeader()->setContextMenuPolicy( Qt::CustomContextMenu );
108 connect( mTableView->horizontalHeader(), &QHeaderView::customContextMenuRequested,
this, &QgsDualView::showViewHeaderMenu );
113 initModels( mapCanvas, request, loadFeatures );
115 mConditionalFormatWidget->setLayer( mLayer );
117 mTableView->setModel( mFilterModel );
118 mFeatureListView->setModel( mFeatureListModel );
119 delete mAttributeForm;
120 mAttributeForm =
new QgsAttributeForm( mLayer, mTempAttributeFormFeature, mEditorContext );
125 mAttributeEditorScrollArea->setWidgetResizable(
true );
126 mAttributeEditor->layout()->addWidget( mAttributeEditorScrollArea );
127 mAttributeEditorScrollArea->setWidget( mAttributeForm );
131 mAttributeEditor->layout()->addWidget( mAttributeForm );
140 if ( mFeatureListPreviewButton->defaultAction() )
141 mFeatureListView->setDisplayExpression( mDisplayExpression );
149 void QgsDualView::columnBoxInit()
152 QList<QgsField> fields = mLayer->fields().toList();
154 QString defaultField;
157 QString displayExpression = mLayer->displayExpression();
159 if ( displayExpression.isEmpty() )
162 displayExpression = QStringLiteral(
"'[Please define preview text]'" );
165 mFeatureListPreviewButton->addAction( mActionExpressionPreview );
166 mFeatureListPreviewButton->addAction( mActionPreviewColumnsMenu );
168 const auto constFields = fields;
169 for (
const QgsField &field : constFields )
171 int fieldIndex = mLayer->fields().lookupField( field.name() );
172 if ( fieldIndex == -1 )
175 QString fieldName = field.name();
178 QIcon icon = mLayer->fields().iconForField( fieldIndex );
179 QString text = mLayer->attributeDisplayName( fieldIndex );
182 QAction *previewAction =
new QAction( icon, text, mFeatureListPreviewButton );
183 connect( previewAction, &QAction::triggered,
this, [ = ] { previewColumnChanged( previewAction, fieldName ); } );
184 mPreviewColumnsMenu->addAction( previewAction );
186 if ( text == defaultField )
188 mFeatureListPreviewButton->setDefaultAction( previewAction );
193 QAction *sortByPreviewExpression =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"sort.svg" ) ), tr(
"Sort by preview expression" ),
this );
194 connect( sortByPreviewExpression, &QAction::triggered,
this, &QgsDualView::sortByPreviewExpression );
195 mFeatureListPreviewButton->addAction( sortByPreviewExpression );
197 QAction *separator =
new QAction( mFeatureListPreviewButton );
198 separator->setSeparator(
true );
199 mFeatureListPreviewButton->addAction( separator );
200 restoreRecentDisplayExpressions();
203 if ( !mFeatureListPreviewButton->defaultAction() )
205 mFeatureListView->setDisplayExpression( displayExpression );
206 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
207 setDisplayExpression( mFeatureListView->displayExpression() );
211 mFeatureListPreviewButton->defaultAction()->trigger();
217 setCurrentIndex( view );
249 || ( mMasterModel->
rowCount() == 0 );
251 if ( !needsGeometry )
260 switch ( filterMode )
282 if ( requiresTableReload )
285 whileBlocking( mLayerCache )->setCacheGeometry( needsGeometry );
299 void QgsDualView::initLayerCache(
bool cacheGeometry )
303 int cacheSize = settings.
value( QStringLiteral(
"qgis/attributeTableRowCache" ),
"10000" ).toInt();
309 rebuildFullLayerCache();
315 delete mFeatureListModel;
336 connect( mMasterModel, &QgsAttributeTableModel::rowsRemoved, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
337 connect( mMasterModel, &QgsAttributeTableModel::rowsInserted, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
345 void QgsDualView::restoreRecentDisplayExpressions()
347 const QVariantList previewExpressions = mLayer->customProperty( QStringLiteral(
"dualview/previewExpressions" ) ).toList();
349 for (
const QVariant &previewExpression : previewExpressions )
350 insertRecentlyUsedDisplayExpression( previewExpression.toString() );
353 void QgsDualView::saveRecentDisplayExpressions()
const 359 QList<QAction *> actions = mFeatureListPreviewButton->actions();
362 int index = actions.indexOf( mLastDisplayExpressionAction );
365 QVariantList previewExpressions;
366 for ( ; index < actions.length(); ++index )
368 QAction *action = actions.at( index );
369 previewExpressions << action->property(
"previewExpression" );
372 mLayer->setCustomProperty( QStringLiteral(
"dualview/previewExpressions" ), previewExpressions );
376 void QgsDualView::setDisplayExpression(
const QString &expression )
378 mDisplayExpression = expression;
379 insertRecentlyUsedDisplayExpression( expression );
382 void QgsDualView::insertRecentlyUsedDisplayExpression(
const QString &expression )
384 QList<QAction *> actions = mFeatureListPreviewButton->actions();
387 int index = actions.indexOf( mLastDisplayExpressionAction );
390 for (
int i = 0; index + i < actions.length(); ++i )
392 QAction *action = actions.at( index );
393 if ( action->text() == expression || i >= 9 )
395 if ( action == mLastDisplayExpressionAction )
396 mLastDisplayExpressionAction =
nullptr;
397 mFeatureListPreviewButton->removeAction( action );
401 if ( !mLastDisplayExpressionAction )
402 mLastDisplayExpressionAction = action;
407 QString name = expression;
409 if ( expression.startsWith( QLatin1String(
"COALESCE( \"" ) ) && expression.endsWith( QLatin1String(
", '<NULL>' )" ) ) )
411 name = expression.mid( 11, expression.length() - 24 );
413 int fieldIndex = mLayer->fields().indexOf( name );
414 if ( fieldIndex != -1 )
416 name = mLayer->attributeDisplayName( fieldIndex );
417 icon = mLayer->fields().iconForField( fieldIndex );
425 QAction *previewAction =
new QAction( icon, name, mFeatureListPreviewButton );
426 previewAction->setProperty(
"previewExpression", expression );
427 connect( previewAction, &QAction::triggered,
this, [expression,
this](
bool )
429 setDisplayExpression( expression );
430 mFeatureListPreviewButton->setText( expression );
434 mFeatureListPreviewButton->insertAction( mLastDisplayExpressionAction, previewAction );
435 mLastDisplayExpressionAction = previewAction;
438 void QgsDualView::updateEditSelectionProgress(
int progress,
int count )
440 mProgressCount->setText( QStringLiteral(
"%1 / %2" ).arg( progress + 1 ).arg( count ) );
441 mPreviousFeatureButton->setEnabled( progress > 0 );
442 mNextFeatureButton->setEnabled( progress + 1 < count );
443 mFirstFeatureButton->setEnabled( progress > 0 );
444 mLastFeatureButton->setEnabled( progress + 1 < count );
447 void QgsDualView::panOrZoomToFeature(
const QgsFeatureIds &featureset )
452 if ( mAutoPanButton->isChecked() )
453 QTimer::singleShot( 0,
this, [ = ]()
457 else if ( mAutoZoomButton->isChecked() )
458 QTimer::singleShot( 0,
this, [ = ]()
463 if ( mFlashButton->isChecked() )
464 QTimer::singleShot( 0,
this, [ = ]()
471 void QgsDualView::panZoomGroupButtonToggled( QAbstractButton *button,
bool checked )
473 if ( button == mAutoPanButton && checked )
476 mAutoZoomButton->setChecked(
false );
478 else if ( button == mAutoZoomButton && checked )
481 mAutoPanButton->setChecked(
false );
489 panOrZoomToFeature( mFeatureListView->currentEditSelection() );
492 void QgsDualView::flashButtonClicked(
bool clicked )
494 QgsSettings().
setValue( QStringLiteral(
"/qgis/attributeTable/featureListHighlightFeature" ), clicked );
501 canvas->
flashFeatureIds( mLayer, mFeatureListView->currentEditSelection() );
504 void QgsDualView::featureListAboutToChangeEditSelection(
bool &ok )
506 if ( mLayer->isEditable() && !mAttributeForm->
save() )
510 void QgsDualView::featureListCurrentEditSelectionChanged(
const QgsFeature &feat )
512 if ( !mAttributeForm )
514 mTempAttributeFormFeature = feat;
516 else if ( !mLayer->isEditable() || mAttributeForm->
save() )
520 featureset << feat.
id();
523 panOrZoomToFeature( featureset );
534 mFeatureListView->setCurrentFeatureEdited(
false );
535 mFeatureListView->setEditSelection( fids );
540 return mAttributeForm->
save();
545 mConditionalFormatWidget->setVisible( !mConditionalFormatWidget->isVisible() );
546 mConditionalFormatWidget->viewRules();
570 void QgsDualView::previewExpressionBuilder()
576 dlg.setWindowTitle( tr(
"Expression Based Preview" ) );
579 if ( dlg.exec() == QDialog::Accepted )
581 mFeatureListView->setDisplayExpression( dlg.expressionText() );
582 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
583 mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
586 setDisplayExpression( mFeatureListView->displayExpression() );
589 void QgsDualView::previewColumnChanged( QAction *previewAction,
const QString &expression )
591 if ( !mFeatureListView->setDisplayExpression( QStringLiteral(
"COALESCE( \"%1\", '<NULL>' )" ).arg( expression ) ) )
593 QMessageBox::warning(
this,
594 tr(
"Column Preview" ),
595 tr(
"Could not set column '%1' as preview column.\nParser error:\n%2" )
596 .arg( previewAction->text(), mFeatureListView->parserErrorString() )
601 mFeatureListPreviewButton->setText( previewAction->text() );
602 mFeatureListPreviewButton->setIcon( previewAction->icon() );
603 mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
606 setDisplayExpression( mFeatureListView->displayExpression() );
616 return mFilterModel->rowCount();
621 QAction *action = qobject_cast<QAction *>( sender() );
623 if ( action && action->data().isValid() && action->data().canConvert<QModelIndex>() )
625 QModelIndex index = action->data().toModelIndex();
627 QApplication::clipboard()->setText( var.toString() );
634 mProgressDlg->cancel();
640 saveRecentDisplayExpressions();
643 void QgsDualView::viewWillShowContextMenu( QMenu *menu,
const QModelIndex &atIndex )
650 QModelIndex sourceIndex = mFilterModel->
mapToSource( atIndex );
652 QAction *copyContentAction =
new QAction( tr(
"Copy Cell Content" ),
this );
653 copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
654 menu->addAction( copyContentAction );
661 menu->addAction( tr(
"Zoom to Feature" ),
this, SLOT( zoomToCurrentFeature() ) );
662 menu->addAction( tr(
"Pan to Feature" ),
this, SLOT( panToCurrentFeature() ) );
663 menu->addAction( tr(
"Flash Feature" ),
this, SLOT( flashCurrentFeature() ) );
667 QList<QgsAction> actions = mLayer->actions()->actions( QStringLiteral(
"Field" ) );
668 if ( !actions.isEmpty() )
670 QAction *a = menu->addAction( tr(
"Run Layer Action" ) );
671 a->setEnabled(
false );
673 const auto constActions = actions;
674 for (
const QgsAction &action : constActions )
676 if ( !action.runable() )
679 if ( vl && !vl->
isEditable() && action.isEnabledOnlyWhenEditable() )
689 if ( !registeredActions.isEmpty() )
692 menu->addSeparator();
694 const auto constRegisteredActions = registeredActions;
702 menu->addSeparator();
708 void QgsDualView::widgetWillShowContextMenu(
QgsActionMenu *menu,
const QModelIndex &atIndex )
714 void QgsDualView::showViewHeaderMenu( QPoint point )
716 int col = mTableView->columnAt( point.x() );
718 delete mHorizontalHeaderMenu;
719 mHorizontalHeaderMenu =
new QMenu(
this );
721 QAction *hide =
new QAction( tr(
"&Hide Column" ), mHorizontalHeaderMenu );
722 connect( hide, &QAction::triggered,
this, &QgsDualView::hideColumn );
723 hide->setData( col );
724 mHorizontalHeaderMenu->addAction( hide );
725 QAction *setWidth =
new QAction( tr(
"&Set Width…" ), mHorizontalHeaderMenu );
726 connect( setWidth, &QAction::triggered,
this, &QgsDualView::resizeColumn );
727 setWidth->setData( col );
728 mHorizontalHeaderMenu->addAction( setWidth );
729 QAction *optimizeWidth =
new QAction( tr(
"&Autosize" ), mHorizontalHeaderMenu );
730 connect( optimizeWidth, &QAction::triggered,
this, &QgsDualView::autosizeColumn );
731 optimizeWidth->setData( col );
732 mHorizontalHeaderMenu->addAction( optimizeWidth );
734 mHorizontalHeaderMenu->addSeparator();
735 QAction *organize =
new QAction( tr(
"&Organize Columns…" ), mHorizontalHeaderMenu );
736 connect( organize, &QAction::triggered,
this, &QgsDualView::organizeColumns );
737 mHorizontalHeaderMenu->addAction( organize );
738 QAction *sort =
new QAction( tr(
"&Sort…" ), mHorizontalHeaderMenu );
739 connect( sort, &QAction::triggered,
this, &QgsDualView::modifySort );
740 mHorizontalHeaderMenu->addAction( sort );
742 mHorizontalHeaderMenu->popup( mTableView->horizontalHeader()->mapToGlobal( point ) );
745 void QgsDualView::organizeColumns()
753 if ( dialog.exec() == QDialog::Accepted )
760 void QgsDualView::tableColumnResized(
int column,
int width )
764 if ( sourceCol >= 0 && config.
columnWidth( sourceCol ) != width )
771 void QgsDualView::hideColumn()
773 QAction *action = qobject_cast<QAction *>( sender() );
774 int col = action->data().toInt();
777 if ( sourceCol >= 0 )
784 void QgsDualView::resizeColumn()
786 QAction *action = qobject_cast<QAction *>( sender() );
787 int col = action->data().toInt();
793 if ( sourceCol >= 0 )
796 int width = QInputDialog::getInt(
this, tr(
"Set column width" ), tr(
"Enter column width" ),
797 mTableView->columnWidth( col ),
807 void QgsDualView::autosizeColumn()
809 QAction *action = qobject_cast<QAction *>( sender() );
810 int col = action->data().toInt();
811 mTableView->resizeColumnToContents( col );
814 void QgsDualView::modifySort()
822 orderByDlg.setWindowTitle( tr(
"Configure Attribute Table Sort Order" ) );
823 QDialogButtonBox *dialogButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
824 QGridLayout *layout =
new QGridLayout();
825 connect( dialogButtonBox, &QDialogButtonBox::accepted, &orderByDlg, &QDialog::accept );
826 connect( dialogButtonBox, &QDialogButtonBox::rejected, &orderByDlg, &QDialog::reject );
827 orderByDlg.setLayout( layout );
829 QGroupBox *sortingGroupBox =
new QGroupBox();
830 sortingGroupBox->setTitle( tr(
"Defined sort order in attribute table" ) );
831 sortingGroupBox->setCheckable(
true );
833 layout->addWidget( sortingGroupBox );
834 sortingGroupBox->setLayout(
new QGridLayout() );
839 expressionBuilder->
setLayer( mLayer );
841 expressionBuilder->
loadRecent( QStringLiteral(
"generic" ) );
844 sortingGroupBox->layout()->addWidget( expressionBuilder );
846 QCheckBox *cbxSortAscending =
new QCheckBox( tr(
"Sort ascending" ) );
847 cbxSortAscending->setChecked( config.
sortOrder() == Qt::AscendingOrder );
848 sortingGroupBox->layout()->addWidget( cbxSortAscending );
850 layout->addWidget( dialogButtonBox );
851 if ( orderByDlg.exec() )
853 Qt::SortOrder sortOrder = cbxSortAscending->isChecked() ? Qt::AscendingOrder : Qt::DescendingOrder;
854 if ( sortingGroupBox->isChecked() )
870 void QgsDualView::zoomToCurrentFeature()
872 QModelIndex currentIndex = mTableView->currentIndex();
873 if ( !currentIndex.isValid() )
879 ids.insert( mFilterModel->
rowToId( currentIndex ) );
887 void QgsDualView::panToCurrentFeature()
889 QModelIndex currentIndex = mTableView->currentIndex();
890 if ( !currentIndex.isValid() )
896 ids.insert( mFilterModel->
rowToId( currentIndex ) );
904 void QgsDualView::flashCurrentFeature()
906 QModelIndex currentIndex = mTableView->currentIndex();
907 if ( !currentIndex.isValid() )
913 ids.insert( mFilterModel->
rowToId( currentIndex ) );
921 void QgsDualView::rebuildFullLayerCache()
929 void QgsDualView::previewExpressionChanged(
const QString &expression )
931 mLayer->setDisplayExpression( expression );
934 void QgsDualView::onSortColumnChanged()
938 cfg.
sortOrder() != mFilterModel->sortOrder() )
946 void QgsDualView::sortByPreviewExpression()
948 Qt::SortOrder sortOrder = Qt::AscendingOrder;
951 sortOrder = mConfig.
sortOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder;
956 void QgsDualView::updateSelectedFeatures()
968 void QgsDualView::extentChanged()
981 void QgsDualView::featureFormAttributeChanged(
const QString &attribute,
const QVariant &value,
bool attributeChanged )
983 Q_UNUSED( attribute )
985 if ( attributeChanged )
986 mFeatureListView->setCurrentFeatureEdited(
true );
1001 mTableView->setFeatureSelectionManager( featureSelectionManager );
1002 mFeatureListView->setFeatureSelectionManager( featureSelectionManager );
1004 if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
1005 delete mFeatureSelectionManager;
1007 mFeatureSelectionManager = featureSelectionManager;
1013 mConfig.
update( mLayer->fields() );
1014 mLayer->setAttributeTableConfig( mConfig );
1016 mTableView->setAttributeTableConfig( mConfig );
1021 if ( sortExpression.isNull() )
1022 mFilterModel->
sort( -1 );
1024 mFilterModel->
sort( sortExpression, sortOrder );
1041 void QgsDualView::progress(
int i,
bool &cancel )
1043 if ( !mProgressDlg )
1045 mProgressDlg =
new QProgressDialog( tr(
"Loading features…" ), tr(
"Abort" ), 0, 0,
this );
1046 mProgressDlg->setWindowTitle( tr(
"Attribute Table" ) );
1047 mProgressDlg->setWindowModality( Qt::WindowModal );
1048 mProgressDlg->show();
1051 mProgressDlg->setLabelText( tr(
"%1 features loaded." ).arg( i ) );
1052 QCoreApplication::processEvents();
1054 cancel = mProgressDlg && mProgressDlg->wasCanceled();
1057 void QgsDualView::finished()
1059 delete mProgressDlg;
1060 mProgressDlg =
nullptr;
1069 mDualView->masterModel()->executeAction( mAction, mFieldIdx );
1075 editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
1076 mDualView->setCurrentEditSelection( editedIds );
1086 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.
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
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.
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)
QgsAttributeTableConfig config() const
Gets the updated configuration.
void willShowContextMenu(QMenu *menu, const QModelIndex &atIndex)
Emitted in order to provide a hook to add additional* menu entries to the context menu...
const Flags & flags() const
void setSelectedOnTop(bool selectedOnTop)
Changes the sort order of the features.
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
void filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
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()
void currentEditSelectionProgressChanged(int progress, int count)
Emitted whenever the current edit selection has been changed.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QString sortExpression() const
Gets the expression used for sorting the table and feature list.
This class contains context information for attribute editor widgets.
ViewMode
The view modes, in which this widget can present information.
void willShowContextMenu(QgsActionMenu *menu, const QModelIndex &atIndex)
Emitted when the context menu is created to add the specific actions to it.
FilterType filterType() const
Returns the filter type which is currently set on this request.
int columnWidth(int column) const
Returns the width of a column, or -1 if column should use default width.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
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.
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.
The map is zoomed to contained the feature bounding-box.
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.
int mapVisibleColumnToIndex(int visibleColumn) const
Maps a visible column index to its original column index.
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
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.
static QgsShortcutsManager * shortcutsManager()
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
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...
QgsDualView(QWidget *parent=nullptr)
Constructor.
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Shows a list of features and renders a edit button next to each feature.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
void editFirstFeature()
editFirstFeature will try to edit the first feature of the list
void setColumnWidth(int column, int width)
Sets the width of a column.
void copyCellContent() const
Copy the content of the selected cell in the clipboard.
void setSortExpression(const QString &sortExpression, Qt::SortOrder sortOrder=Qt::AscendingOrder)
Set the expression used for sorting the table and feature list.
Show only selected features.
FilterMode filterMode()
The current filterModel.
void editNextFeature()
editNextFeature will try to edit next feature of the list
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...
ViewMode view() const
Returns the current view mode.
QgsAttributeTableConfig attributeTableConfig() const
The config used for the attribute table.
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 ...
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
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)
Emitted whenever the display expression is successfully changed.
void filterChanged()
Emitted whenever the filter changes.
void editPreviousFeature()
editPreviousFeature will try to edit previous feature of the list
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
Show only features which have unsaved changes.
const QgsFeatureRequest & request() const
Gets the the feature request.
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)
FeatureListBrowsingAction
Action on the map canvas when browsing the list of features.
QShortcut * shortcutByName(const QString &name) const
Returns a shortcut by its name, or nullptr if nothing found.
QString sortExpression() const
The expression which is used to sort the attribute table.
This class caches features of a given QgsVectorLayer.
const QgsAttributeEditorContext * parentContext() const
bool saveEditChanges()
saveEditChanges
Show only features whose ids are on the filter list. {.
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum.
void progress(int i, bool &cancel)
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
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.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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.
void setColumnHidden(int column, bool hidden)
Sets whether the specified column should be hidden.
Single edit mode, for editing a single feature.
void panToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids, bool alwaysRecenter=true)
Centers canvas extent to feature ids.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QgsMapCanvas * mapCanvas() const
Returns the map canvas.
void displayExpressionChanged(const QString &expression)
Emitted whenever the display expression is successfully changed.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
void setSortByDisplayExpression(bool sortByDisplayExpression)
Sort this model by its display expression.
void setFilteredFeatures(const QgsFeatureIds &filteredFeatures)
Set a list of currently visible features.
void editLastFeature()
editLastFeature will try to edit the last feature of the list
This is a container for configuration of the attribute table.
Qt::SortOrder sortOrder() const
Gets the sort order.
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 currentEditSelectionChanged(QgsFeature &feat)
Emitted whenever the current edit selection has been changed.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
Represents a vector layer which manages a vector based data sets.
QString sortExpression() const
Gets the expression used for sorting.
void sortColumnChanged(int column, Qt::SortOrder order)
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.
An action which can run on map layers.
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.
The map is panned to the center of the feature bounding-box.