19 #include <QMessageBox> 20 #include <QProgressDialog> 22 #include <QInputDialog> 49 : QStackedWidget( parent )
56 mConditionalFormatWidgetStack->hide();
58 mConditionalFormatWidgetStack->setMainPanel( mConditionalFormatWidget );
62 mConditionalSplitter->restoreState( settings.
value( QStringLiteral(
"/qgis/attributeTable/splitterState" ), QByteArray() ).toByteArray() );
64 mPreviewColumnsMenu =
new QMenu(
this );
65 mActionPreviewColumnsMenu->setMenu( mPreviewColumnsMenu );
71 connect( mActionExpressionPreview, &QAction::triggered,
this, &QgsDualView::previewExpressionBuilder );
80 auto createShortcuts = [ = ](
const QString & objectName, void (
QgsFeatureListView::* slot )() )
86 connect( sc, &QShortcut::activated, mFeatureListView, slot );
93 QButtonGroup *buttonGroup =
new QButtonGroup(
this );
94 buttonGroup->setExclusive(
false );
98 QAbstractButton *bt = buttonGroup->button( static_cast<int>( action ) );
100 bt->setChecked(
true );
101 connect( buttonGroup, qgis::overload< QAbstractButton *, bool >::of( &QButtonGroup::buttonToggled ),
this, &QgsDualView::panZoomGroupButtonToggled );
102 mFlashButton->setChecked(
QgsSettings().value( QStringLiteral(
"/qgis/attributeTable/featureListHighlightFeature" ),
true ).toBool() );
103 connect( mFlashButton, &QToolButton::clicked,
this, &QgsDualView::flashButtonClicked );
109 settings.
setValue( QStringLiteral(
"/qgis/attributeTable/splitterState" ), mConditionalSplitter->saveState() );
119 mEditorContext = context;
122 mTableView->horizontalHeader()->setContextMenuPolicy( Qt::CustomContextMenu );
123 connect( mTableView->horizontalHeader(), &QHeaderView::customContextMenuRequested,
this, &QgsDualView::showViewHeaderMenu );
128 initModels( mapCanvas, request, loadFeatures );
130 mConditionalFormatWidget->
setLayer( mLayer );
132 mTableView->setModel( mFilterModel );
133 mFeatureListView->setModel( mFeatureListModel );
134 delete mAttributeForm;
135 mAttributeForm =
new QgsAttributeForm( mLayer, mTempAttributeFormFeature, mEditorContext );
140 mAttributeEditorScrollArea->setWidgetResizable(
true );
141 mAttributeEditor->layout()->addWidget( mAttributeEditorScrollArea );
142 mAttributeEditorScrollArea->setWidget( mAttributeForm );
146 mAttributeEditor->layout()->addWidget( mAttributeForm );
155 if ( mFeatureListPreviewButton->defaultAction() )
156 mFeatureListView->setDisplayExpression( mDisplayExpression );
164 void QgsDualView::columnBoxInit()
167 QList<QgsField> fields = mLayer->fields().toList();
169 QString defaultField;
172 QString displayExpression = mLayer->displayExpression();
174 if ( displayExpression.isEmpty() )
177 displayExpression = QStringLiteral(
"'[Please define preview text]'" );
180 mFeatureListPreviewButton->addAction( mActionExpressionPreview );
181 mFeatureListPreviewButton->addAction( mActionPreviewColumnsMenu );
183 const auto constFields = fields;
184 for (
const QgsField &field : constFields )
186 int fieldIndex = mLayer->fields().lookupField( field.name() );
187 if ( fieldIndex == -1 )
190 QString fieldName = field.name();
193 QIcon icon = mLayer->fields().iconForField( fieldIndex );
194 QString text = mLayer->attributeDisplayName( fieldIndex );
197 QAction *previewAction =
new QAction( icon, text, mFeatureListPreviewButton );
198 connect( previewAction, &QAction::triggered,
this, [ = ] { previewColumnChanged( previewAction, fieldName ); } );
199 mPreviewColumnsMenu->addAction( previewAction );
201 if ( text == defaultField )
203 mFeatureListPreviewButton->setDefaultAction( previewAction );
208 QAction *sortByPreviewExpression =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"sort.svg" ) ), tr(
"Sort by preview expression" ),
this );
209 connect( sortByPreviewExpression, &QAction::triggered,
this, &QgsDualView::sortByPreviewExpression );
210 mFeatureListPreviewButton->addAction( sortByPreviewExpression );
212 QAction *separator =
new QAction( mFeatureListPreviewButton );
213 separator->setSeparator(
true );
214 mFeatureListPreviewButton->addAction( separator );
215 restoreRecentDisplayExpressions();
218 if ( !mFeatureListPreviewButton->defaultAction() )
220 mFeatureListView->setDisplayExpression( displayExpression );
221 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
222 setDisplayExpression( mFeatureListView->displayExpression() );
226 mFeatureListPreviewButton->defaultAction()->trigger();
232 setCurrentIndex( view );
264 || ( mMasterModel->
rowCount() == 0 );
266 if ( !needsGeometry )
275 switch ( filterMode )
297 if ( requiresTableReload )
300 whileBlocking( mLayerCache )->setCacheGeometry( needsGeometry );
314 void QgsDualView::initLayerCache(
bool cacheGeometry )
318 int cacheSize = settings.
value( QStringLiteral(
"qgis/attributeTableRowCache" ),
"10000" ).toInt();
324 rebuildFullLayerCache();
330 delete mFeatureListModel;
351 connect( mMasterModel, &QgsAttributeTableModel::rowsRemoved, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
352 connect( mMasterModel, &QgsAttributeTableModel::rowsInserted, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
360 void QgsDualView::restoreRecentDisplayExpressions()
362 const QVariantList previewExpressions = mLayer->customProperty( QStringLiteral(
"dualview/previewExpressions" ) ).toList();
364 for (
const QVariant &previewExpression : previewExpressions )
365 insertRecentlyUsedDisplayExpression( previewExpression.toString() );
368 void QgsDualView::saveRecentDisplayExpressions()
const 374 QList<QAction *> actions = mFeatureListPreviewButton->actions();
377 int index = actions.indexOf( mLastDisplayExpressionAction );
380 QVariantList previewExpressions;
381 for ( ; index < actions.length(); ++index )
383 QAction *action = actions.at( index );
384 previewExpressions << action->property(
"previewExpression" );
387 mLayer->setCustomProperty( QStringLiteral(
"dualview/previewExpressions" ), previewExpressions );
391 void QgsDualView::setDisplayExpression(
const QString &expression )
393 mDisplayExpression = expression;
394 insertRecentlyUsedDisplayExpression( expression );
397 void QgsDualView::insertRecentlyUsedDisplayExpression(
const QString &expression )
399 QList<QAction *> actions = mFeatureListPreviewButton->actions();
402 int index = actions.indexOf( mLastDisplayExpressionAction );
405 for (
int i = 0; index + i < actions.length(); ++i )
407 QAction *action = actions.at( index );
408 if ( action->text() == expression || i >= 9 )
410 if ( action == mLastDisplayExpressionAction )
411 mLastDisplayExpressionAction =
nullptr;
412 mFeatureListPreviewButton->removeAction( action );
416 if ( !mLastDisplayExpressionAction )
417 mLastDisplayExpressionAction = action;
422 QString name = expression;
424 if ( expression.startsWith( QLatin1String(
"COALESCE( \"" ) ) && expression.endsWith( QLatin1String(
", '<NULL>' )" ) ) )
426 name = expression.mid( 11, expression.length() - 24 );
428 int fieldIndex = mLayer->fields().indexOf( name );
429 if ( fieldIndex != -1 )
431 name = mLayer->attributeDisplayName( fieldIndex );
432 icon = mLayer->fields().iconForField( fieldIndex );
440 QAction *previewAction =
new QAction( icon, name, mFeatureListPreviewButton );
441 previewAction->setProperty(
"previewExpression", expression );
442 connect( previewAction, &QAction::triggered,
this, [expression,
this](
bool )
444 setDisplayExpression( expression );
445 mFeatureListPreviewButton->setText( expression );
449 mFeatureListPreviewButton->insertAction( mLastDisplayExpressionAction, previewAction );
450 mLastDisplayExpressionAction = previewAction;
453 void QgsDualView::updateEditSelectionProgress(
int progress,
int count )
455 mProgressCount->setText( QStringLiteral(
"%1 / %2" ).arg( progress + 1 ).arg( count ) );
456 mPreviousFeatureButton->setEnabled( progress > 0 );
457 mNextFeatureButton->setEnabled( progress + 1 < count );
458 mFirstFeatureButton->setEnabled( progress > 0 );
459 mLastFeatureButton->setEnabled( progress + 1 < count );
462 void QgsDualView::panOrZoomToFeature(
const QgsFeatureIds &featureset )
469 if ( mAutoPanButton->isChecked() )
470 QTimer::singleShot( 0,
this, [ = ]()
474 else if ( mAutoZoomButton->isChecked() )
475 QTimer::singleShot( 0,
this, [ = ]()
480 if ( mFlashButton->isChecked() )
481 QTimer::singleShot( 0,
this, [ = ]()
485 mLastFeatureSet = featureset;
489 void QgsDualView::panZoomGroupButtonToggled( QAbstractButton *button,
bool checked )
491 if ( button == mAutoPanButton && checked )
494 mAutoZoomButton->setChecked(
false );
496 else if ( button == mAutoZoomButton && checked )
499 mAutoPanButton->setChecked(
false );
507 panOrZoomToFeature( mFeatureListView->currentEditSelection() );
510 void QgsDualView::flashButtonClicked(
bool clicked )
512 QgsSettings().
setValue( QStringLiteral(
"/qgis/attributeTable/featureListHighlightFeature" ), clicked );
519 canvas->
flashFeatureIds( mLayer, mFeatureListView->currentEditSelection() );
522 void QgsDualView::featureListAboutToChangeEditSelection(
bool &ok )
524 if ( mLayer->isEditable() && !mAttributeForm->
save() )
528 void QgsDualView::featureListCurrentEditSelectionChanged(
const QgsFeature &feat )
530 if ( !mAttributeForm )
532 mTempAttributeFormFeature = feat;
534 else if ( !mLayer->isEditable() || mAttributeForm->
save() )
538 featureset << feat.
id();
541 panOrZoomToFeature( featureset );
552 mFeatureListView->setCurrentFeatureEdited(
false );
553 mFeatureListView->setEditSelection( fids );
558 return mAttributeForm->
save();
563 mConditionalFormatWidgetStack->setVisible( !mConditionalFormatWidgetStack->isVisible() );
587 void QgsDualView::previewExpressionBuilder()
593 dlg.setWindowTitle( tr(
"Expression Based Preview" ) );
596 if ( dlg.exec() == QDialog::Accepted )
598 mFeatureListView->setDisplayExpression( dlg.expressionText() );
599 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
600 mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
603 setDisplayExpression( mFeatureListView->displayExpression() );
606 void QgsDualView::previewColumnChanged( QAction *previewAction,
const QString &expression )
608 if ( !mFeatureListView->setDisplayExpression( QStringLiteral(
"COALESCE( \"%1\", '<NULL>' )" ).arg( expression ) ) )
610 QMessageBox::warning(
this,
611 tr(
"Column Preview" ),
612 tr(
"Could not set column '%1' as preview column.\nParser error:\n%2" )
613 .arg( previewAction->text(), mFeatureListView->parserErrorString() )
618 mFeatureListPreviewButton->setText( previewAction->text() );
619 mFeatureListPreviewButton->setIcon( previewAction->icon() );
620 mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
623 setDisplayExpression( mFeatureListView->displayExpression() );
633 return mFilterModel->rowCount();
638 QAction *action = qobject_cast<QAction *>( sender() );
640 if ( action && action->data().isValid() && action->data().canConvert<QModelIndex>() )
642 QModelIndex index = action->data().toModelIndex();
644 QApplication::clipboard()->setText( var.toString() );
651 mProgressDlg->cancel();
657 saveRecentDisplayExpressions();
660 void QgsDualView::viewWillShowContextMenu( QMenu *menu,
const QModelIndex &atIndex )
667 QModelIndex sourceIndex = mFilterModel->
mapToSource( atIndex );
669 QAction *copyContentAction =
new QAction( tr(
"Copy Cell Content" ),
this );
670 copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
671 menu->addAction( copyContentAction );
678 menu->addAction( tr(
"Zoom to Feature" ),
this, SLOT( zoomToCurrentFeature() ) );
679 menu->addAction( tr(
"Pan to Feature" ),
this, SLOT( panToCurrentFeature() ) );
680 menu->addAction( tr(
"Flash Feature" ),
this, SLOT( flashCurrentFeature() ) );
684 QList<QgsAction> actions = mLayer->actions()->actions( QStringLiteral(
"Field" ) );
685 if ( !actions.isEmpty() )
687 QAction *a = menu->addAction( tr(
"Run Layer Action" ) );
688 a->setEnabled(
false );
690 const auto constActions = actions;
691 for (
const QgsAction &action : constActions )
693 if ( !action.runable() )
696 if ( vl && !vl->
isEditable() && action.isEnabledOnlyWhenEditable() )
706 if ( !registeredActions.isEmpty() )
709 menu->addSeparator();
711 const auto constRegisteredActions = registeredActions;
719 menu->addSeparator();
725 void QgsDualView::widgetWillShowContextMenu(
QgsActionMenu *menu,
const QModelIndex &atIndex )
731 void QgsDualView::showViewHeaderMenu( QPoint point )
733 int col = mTableView->columnAt( point.x() );
735 delete mHorizontalHeaderMenu;
736 mHorizontalHeaderMenu =
new QMenu(
this );
738 QAction *hide =
new QAction( tr(
"&Hide Column" ), mHorizontalHeaderMenu );
739 connect( hide, &QAction::triggered,
this, &QgsDualView::hideColumn );
740 hide->setData( col );
741 mHorizontalHeaderMenu->addAction( hide );
742 QAction *setWidth =
new QAction( tr(
"&Set Width…" ), mHorizontalHeaderMenu );
743 connect( setWidth, &QAction::triggered,
this, &QgsDualView::resizeColumn );
744 setWidth->setData( col );
745 mHorizontalHeaderMenu->addAction( setWidth );
746 QAction *optimizeWidth =
new QAction( tr(
"&Autosize" ), mHorizontalHeaderMenu );
747 connect( optimizeWidth, &QAction::triggered,
this, &QgsDualView::autosizeColumn );
748 optimizeWidth->setData( col );
749 mHorizontalHeaderMenu->addAction( optimizeWidth );
751 mHorizontalHeaderMenu->addSeparator();
752 QAction *organize =
new QAction( tr(
"&Organize Columns…" ), mHorizontalHeaderMenu );
753 connect( organize, &QAction::triggered,
this, &QgsDualView::organizeColumns );
754 mHorizontalHeaderMenu->addAction( organize );
755 QAction *sort =
new QAction( tr(
"&Sort…" ), mHorizontalHeaderMenu );
756 connect( sort, &QAction::triggered,
this, &QgsDualView::modifySort );
757 mHorizontalHeaderMenu->addAction( sort );
759 mHorizontalHeaderMenu->popup( mTableView->horizontalHeader()->mapToGlobal( point ) );
762 void QgsDualView::organizeColumns()
770 if ( dialog.exec() == QDialog::Accepted )
777 void QgsDualView::tableColumnResized(
int column,
int width )
781 if ( sourceCol >= 0 && config.
columnWidth( sourceCol ) != width )
788 void QgsDualView::hideColumn()
790 QAction *action = qobject_cast<QAction *>( sender() );
791 int col = action->data().toInt();
794 if ( sourceCol >= 0 )
801 void QgsDualView::resizeColumn()
803 QAction *action = qobject_cast<QAction *>( sender() );
804 int col = action->data().toInt();
810 if ( sourceCol >= 0 )
813 int width = QInputDialog::getInt(
this, tr(
"Set column width" ), tr(
"Enter column width" ),
814 mTableView->columnWidth( col ),
824 void QgsDualView::autosizeColumn()
826 QAction *action = qobject_cast<QAction *>( sender() );
827 int col = action->data().toInt();
828 mTableView->resizeColumnToContents( col );
831 void QgsDualView::modifySort()
839 orderByDlg.setWindowTitle( tr(
"Configure Attribute Table Sort Order" ) );
840 QDialogButtonBox *dialogButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
841 QGridLayout *layout =
new QGridLayout();
842 connect( dialogButtonBox, &QDialogButtonBox::accepted, &orderByDlg, &QDialog::accept );
843 connect( dialogButtonBox, &QDialogButtonBox::rejected, &orderByDlg, &QDialog::reject );
844 orderByDlg.setLayout( layout );
846 QGroupBox *sortingGroupBox =
new QGroupBox();
847 sortingGroupBox->setTitle( tr(
"Defined sort order in attribute table" ) );
848 sortingGroupBox->setCheckable(
true );
850 layout->addWidget( sortingGroupBox );
851 sortingGroupBox->setLayout(
new QGridLayout() );
856 expressionBuilder->
setLayer( mLayer );
858 expressionBuilder->
loadRecent( QStringLiteral(
"generic" ) );
861 sortingGroupBox->layout()->addWidget( expressionBuilder );
863 QCheckBox *cbxSortAscending =
new QCheckBox( tr(
"Sort ascending" ) );
864 cbxSortAscending->setChecked( config.
sortOrder() == Qt::AscendingOrder );
865 sortingGroupBox->layout()->addWidget( cbxSortAscending );
867 layout->addWidget( dialogButtonBox );
868 if ( orderByDlg.exec() )
870 Qt::SortOrder sortOrder = cbxSortAscending->isChecked() ? Qt::AscendingOrder : Qt::DescendingOrder;
871 if ( sortingGroupBox->isChecked() )
887 void QgsDualView::zoomToCurrentFeature()
889 QModelIndex currentIndex = mTableView->currentIndex();
890 if ( !currentIndex.isValid() )
896 ids.insert( mFilterModel->
rowToId( currentIndex ) );
904 void QgsDualView::panToCurrentFeature()
906 QModelIndex currentIndex = mTableView->currentIndex();
907 if ( !currentIndex.isValid() )
913 ids.insert( mFilterModel->
rowToId( currentIndex ) );
921 void QgsDualView::flashCurrentFeature()
923 QModelIndex currentIndex = mTableView->currentIndex();
924 if ( !currentIndex.isValid() )
930 ids.insert( mFilterModel->
rowToId( currentIndex ) );
938 void QgsDualView::rebuildFullLayerCache()
946 void QgsDualView::previewExpressionChanged(
const QString &expression )
948 mLayer->setDisplayExpression( expression );
951 void QgsDualView::onSortColumnChanged()
955 cfg.
sortOrder() != mFilterModel->sortOrder() )
963 void QgsDualView::sortByPreviewExpression()
965 Qt::SortOrder sortOrder = Qt::AscendingOrder;
968 sortOrder = mConfig.
sortOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder;
973 void QgsDualView::updateSelectedFeatures()
985 void QgsDualView::extentChanged()
998 void QgsDualView::featureFormAttributeChanged(
const QString &attribute,
const QVariant &value,
bool attributeChanged )
1000 Q_UNUSED( attribute )
1002 if ( attributeChanged )
1003 mFeatureListView->setCurrentFeatureEdited(
true );
1018 mTableView->setFeatureSelectionManager( featureSelectionManager );
1019 mFeatureListView->setFeatureSelectionManager( featureSelectionManager );
1021 if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
1022 delete mFeatureSelectionManager;
1024 mFeatureSelectionManager = featureSelectionManager;
1030 mConfig.
update( mLayer->fields() );
1031 mLayer->setAttributeTableConfig( mConfig );
1033 mTableView->setAttributeTableConfig( mConfig );
1038 if ( sortExpression.isNull() )
1039 mFilterModel->
sort( -1 );
1041 mFilterModel->
sort( sortExpression, sortOrder );
1058 void QgsDualView::progress(
int i,
bool &cancel )
1060 if ( !mProgressDlg )
1062 mProgressDlg =
new QProgressDialog( tr(
"Loading features…" ), tr(
"Abort" ), 0, 0,
this );
1063 mProgressDlg->setWindowTitle( tr(
"Attribute Table" ) );
1064 mProgressDlg->setWindowModality( Qt::WindowModal );
1065 mProgressDlg->show();
1068 mProgressDlg->setLabelText( tr(
"%1 features loaded." ).arg( i ) );
1069 QCoreApplication::processEvents();
1071 cancel = mProgressDlg && mProgressDlg->wasCanceled();
1074 void QgsDualView::finished()
1076 delete mProgressDlg;
1077 mProgressDlg =
nullptr;
1086 mDualView->masterModel()->executeAction( mAction, mFieldIdx );
1092 editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
1093 mDualView->setCurrentEditSelection( editedIds );
1103 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)
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...
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.