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 );
305 switch ( filterMode )
308 setBrowsingAutoPanScaleAllowed(
false );
315 setBrowsingAutoPanScaleAllowed(
true );
329 void QgsDualView::initLayerCache(
bool cacheGeometry )
333 int cacheSize = settings.
value( QStringLiteral(
"qgis/attributeTableRowCache" ),
"10000" ).toInt();
339 rebuildFullLayerCache();
345 delete mFeatureListModel;
366 connect( mMasterModel, &QgsAttributeTableModel::rowsRemoved, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
367 connect( mMasterModel, &QgsAttributeTableModel::rowsInserted, mFilterModel, &QgsAttributeTableFilterModel::invalidate );
375 void QgsDualView::restoreRecentDisplayExpressions()
377 const QVariantList previewExpressions = mLayer->customProperty( QStringLiteral(
"dualview/previewExpressions" ) ).toList();
379 for (
const QVariant &previewExpression : previewExpressions )
380 insertRecentlyUsedDisplayExpression( previewExpression.toString() );
383 void QgsDualView::saveRecentDisplayExpressions()
const 389 QList<QAction *> actions = mFeatureListPreviewButton->actions();
392 int index = actions.indexOf( mLastDisplayExpressionAction );
395 QVariantList previewExpressions;
396 for ( ; index < actions.length(); ++index )
398 QAction *action = actions.at( index );
399 previewExpressions << action->property(
"previewExpression" );
402 mLayer->setCustomProperty( QStringLiteral(
"dualview/previewExpressions" ), previewExpressions );
406 void QgsDualView::setDisplayExpression(
const QString &expression )
408 mDisplayExpression = expression;
409 insertRecentlyUsedDisplayExpression( expression );
412 void QgsDualView::insertRecentlyUsedDisplayExpression(
const QString &expression )
414 QList<QAction *> actions = mFeatureListPreviewButton->actions();
417 int index = actions.indexOf( mLastDisplayExpressionAction );
420 for (
int i = 0; index + i < actions.length(); ++i )
422 QAction *action = actions.at( index );
423 if ( action->text() == expression || i >= 9 )
425 if ( action == mLastDisplayExpressionAction )
426 mLastDisplayExpressionAction =
nullptr;
427 mFeatureListPreviewButton->removeAction( action );
431 if ( !mLastDisplayExpressionAction )
432 mLastDisplayExpressionAction = action;
437 QString name = expression;
439 if ( expression.startsWith( QLatin1String(
"COALESCE( \"" ) ) && expression.endsWith( QLatin1String(
", '<NULL>' )" ) ) )
441 name = expression.mid( 11, expression.length() - 24 );
443 int fieldIndex = mLayer->fields().indexOf( name );
444 if ( fieldIndex != -1 )
446 name = mLayer->attributeDisplayName( fieldIndex );
447 icon = mLayer->fields().iconForField( fieldIndex );
455 QAction *previewAction =
new QAction( icon, name, mFeatureListPreviewButton );
456 previewAction->setProperty(
"previewExpression", expression );
457 connect( previewAction, &QAction::triggered,
this, [expression,
this](
bool )
459 setDisplayExpression( expression );
460 mFeatureListPreviewButton->setText( expression );
464 mFeatureListPreviewButton->insertAction( mLastDisplayExpressionAction, previewAction );
465 mLastDisplayExpressionAction = previewAction;
468 void QgsDualView::updateEditSelectionProgress(
int progress,
int count )
470 mProgressCount->setText( QStringLiteral(
"%1 / %2" ).arg( progress + 1 ).arg( count ) );
471 mPreviousFeatureButton->setEnabled( progress > 0 );
472 mNextFeatureButton->setEnabled( progress + 1 < count );
473 mFirstFeatureButton->setEnabled( progress > 0 );
474 mLastFeatureButton->setEnabled( progress + 1 < count );
477 void QgsDualView::panOrZoomToFeature(
const QgsFeatureIds &featureset )
482 if ( mBrowsingAutoPanScaleAllowed )
484 if ( mAutoPanButton->isChecked() )
485 QTimer::singleShot( 0,
this, [ = ]()
489 else if ( mAutoZoomButton->isChecked() )
490 QTimer::singleShot( 0,
this, [ = ]()
495 if ( mFlashButton->isChecked() )
496 QTimer::singleShot( 0,
this, [ = ]()
500 mLastFeatureSet = featureset;
504 void QgsDualView::setBrowsingAutoPanScaleAllowed(
bool allowed )
506 if ( mBrowsingAutoPanScaleAllowed == allowed )
509 mBrowsingAutoPanScaleAllowed = allowed;
511 mAutoPanButton->setEnabled( allowed );
512 mAutoZoomButton->setEnabled( allowed );
514 QString disabledHint = tr(
"(disabled when attribute table only shows features visible in the current map canvas extent)" );
516 mAutoPanButton->setToolTip( tr(
"Automatically pan to the current feature" ) + ( allowed ? QString() : QString(
' ' ) + disabledHint ) );
517 mAutoZoomButton->setToolTip( tr(
"Automatically zoom to the current feature" ) + ( allowed ? QString() : QString(
' ' ) + disabledHint ) );
520 void QgsDualView::panZoomGroupButtonToggled( QAbstractButton *button,
bool checked )
522 if ( button == mAutoPanButton && checked )
525 mAutoZoomButton->setChecked(
false );
527 else if ( button == mAutoZoomButton && checked )
530 mAutoPanButton->setChecked(
false );
538 panOrZoomToFeature( mFeatureListView->currentEditSelection() );
541 void QgsDualView::flashButtonClicked(
bool clicked )
543 QgsSettings().
setValue( QStringLiteral(
"/qgis/attributeTable/featureListHighlightFeature" ), clicked );
550 canvas->
flashFeatureIds( mLayer, mFeatureListView->currentEditSelection() );
553 void QgsDualView::featureListAboutToChangeEditSelection(
bool &ok )
555 if ( mLayer->isEditable() && !mAttributeForm->
save() )
559 void QgsDualView::featureListCurrentEditSelectionChanged(
const QgsFeature &feat )
561 if ( !mAttributeForm )
563 mTempAttributeFormFeature = feat;
565 else if ( !mLayer->isEditable() || mAttributeForm->
save() )
569 featureset << feat.
id();
572 panOrZoomToFeature( featureset );
583 mFeatureListView->setCurrentFeatureEdited(
false );
584 mFeatureListView->setEditSelection( fids );
589 return mAttributeForm->
save();
594 mConditionalFormatWidgetStack->setVisible( !mConditionalFormatWidgetStack->isVisible() );
618 void QgsDualView::previewExpressionBuilder()
624 dlg.setWindowTitle( tr(
"Expression Based Preview" ) );
627 if ( dlg.exec() == QDialog::Accepted )
629 mFeatureListView->setDisplayExpression( dlg.expressionText() );
630 mFeatureListPreviewButton->setDefaultAction( mActionExpressionPreview );
631 mFeatureListPreviewButton->setPopupMode( QToolButton::MenuButtonPopup );
634 setDisplayExpression( mFeatureListView->displayExpression() );
637 void QgsDualView::previewColumnChanged( QAction *previewAction,
const QString &expression )
639 if ( !mFeatureListView->setDisplayExpression( QStringLiteral(
"COALESCE( \"%1\", '<NULL>' )" ).arg( expression ) ) )
641 QMessageBox::warning(
this,
642 tr(
"Column Preview" ),
643 tr(
"Could not set column '%1' as preview column.\nParser error:\n%2" )
644 .arg( previewAction->text(), mFeatureListView->parserErrorString() )
649 mFeatureListPreviewButton->setText( previewAction->text() );
650 mFeatureListPreviewButton->setIcon( previewAction->icon() );
651 mFeatureListPreviewButton->setPopupMode( QToolButton::InstantPopup );
654 setDisplayExpression( mFeatureListView->displayExpression() );
664 return mFilterModel->rowCount();
669 QAction *action = qobject_cast<QAction *>( sender() );
671 if ( action && action->data().isValid() && action->data().canConvert<QModelIndex>() )
673 QModelIndex index = action->data().toModelIndex();
675 QApplication::clipboard()->setText( var.toString() );
682 mProgressDlg->cancel();
688 saveRecentDisplayExpressions();
691 void QgsDualView::viewWillShowContextMenu( QMenu *menu,
const QModelIndex &atIndex )
698 QModelIndex sourceIndex = mFilterModel->
mapToSource( atIndex );
700 QAction *copyContentAction =
new QAction( tr(
"Copy Cell Content" ),
this );
701 copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
702 menu->addAction( copyContentAction );
709 menu->addAction( tr(
"Zoom to Feature" ),
this, SLOT( zoomToCurrentFeature() ) );
710 menu->addAction( tr(
"Pan to Feature" ),
this, SLOT( panToCurrentFeature() ) );
711 menu->addAction( tr(
"Flash Feature" ),
this, SLOT( flashCurrentFeature() ) );
715 QList<QgsAction> actions = mLayer->actions()->actions( QStringLiteral(
"Field" ) );
716 if ( !actions.isEmpty() )
718 QAction *a = menu->addAction( tr(
"Run Layer Action" ) );
719 a->setEnabled(
false );
721 const auto constActions = actions;
722 for (
const QgsAction &action : constActions )
724 if ( !action.runable() )
727 if ( vl && !vl->
isEditable() && action.isEnabledOnlyWhenEditable() )
734 QModelIndex rowSourceIndex = mFilterModel->
fidToIndex( mFilterModel->
rowToId( atIndex ) );
735 if ( ! rowSourceIndex.isValid() )
741 if ( !registeredActions.isEmpty() )
744 menu->addSeparator();
746 const auto constRegisteredActions = registeredActions;
757 if ( mLayer->selectedFeatureCount() > 1 && mLayer->selectedFeatureIds().contains( currentFid ) )
760 if ( !constRegisteredActions.isEmpty() )
762 menu->addSeparator();
763 QAction *action = menu->addAction( tr(
"Actions on Selection (%1)" ).arg( mLayer->selectedFeatureCount() ) );
764 action->setEnabled(
false );
768 menu->addAction( action->text(), action, [ = ]() {action->triggerForFeatures( mLayer, mLayer->selectedFeatures() );} );
773 menu->addSeparator();
779 void QgsDualView::widgetWillShowContextMenu(
QgsActionMenu *menu,
const QModelIndex &atIndex )
785 void QgsDualView::showViewHeaderMenu( QPoint point )
787 int col = mTableView->columnAt( point.x() );
789 delete mHorizontalHeaderMenu;
790 mHorizontalHeaderMenu =
new QMenu(
this );
792 QAction *hide =
new QAction( tr(
"&Hide Column" ), mHorizontalHeaderMenu );
793 connect( hide, &QAction::triggered,
this, &QgsDualView::hideColumn );
794 hide->setData( col );
795 mHorizontalHeaderMenu->addAction( hide );
796 QAction *setWidth =
new QAction( tr(
"&Set Width…" ), mHorizontalHeaderMenu );
797 connect( setWidth, &QAction::triggered,
this, &QgsDualView::resizeColumn );
798 setWidth->setData( col );
799 mHorizontalHeaderMenu->addAction( setWidth );
800 QAction *optimizeWidth =
new QAction( tr(
"&Autosize" ), mHorizontalHeaderMenu );
801 connect( optimizeWidth, &QAction::triggered,
this, &QgsDualView::autosizeColumn );
802 optimizeWidth->setData( col );
803 mHorizontalHeaderMenu->addAction( optimizeWidth );
805 mHorizontalHeaderMenu->addSeparator();
806 QAction *organize =
new QAction( tr(
"&Organize Columns…" ), mHorizontalHeaderMenu );
807 connect( organize, &QAction::triggered,
this, &QgsDualView::organizeColumns );
808 mHorizontalHeaderMenu->addAction( organize );
809 QAction *sort =
new QAction( tr(
"&Sort…" ), mHorizontalHeaderMenu );
810 connect( sort, &QAction::triggered,
this, &QgsDualView::modifySort );
811 mHorizontalHeaderMenu->addAction( sort );
813 mHorizontalHeaderMenu->popup( mTableView->horizontalHeader()->mapToGlobal( point ) );
816 void QgsDualView::organizeColumns()
824 if ( dialog.exec() == QDialog::Accepted )
831 void QgsDualView::tableColumnResized(
int column,
int width )
835 if ( sourceCol >= 0 && config.
columnWidth( sourceCol ) != width )
842 void QgsDualView::hideColumn()
844 QAction *action = qobject_cast<QAction *>( sender() );
845 int col = action->data().toInt();
848 if ( sourceCol >= 0 )
855 void QgsDualView::resizeColumn()
857 QAction *action = qobject_cast<QAction *>( sender() );
858 int col = action->data().toInt();
864 if ( sourceCol >= 0 )
867 int width = QInputDialog::getInt(
this, tr(
"Set column width" ), tr(
"Enter column width" ),
868 mTableView->columnWidth( col ),
878 void QgsDualView::autosizeColumn()
880 QAction *action = qobject_cast<QAction *>( sender() );
881 int col = action->data().toInt();
882 mTableView->resizeColumnToContents( col );
885 void QgsDualView::modifySort()
893 orderByDlg.setWindowTitle( tr(
"Configure Attribute Table Sort Order" ) );
894 QDialogButtonBox *dialogButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
895 QGridLayout *layout =
new QGridLayout();
896 connect( dialogButtonBox, &QDialogButtonBox::accepted, &orderByDlg, &QDialog::accept );
897 connect( dialogButtonBox, &QDialogButtonBox::rejected, &orderByDlg, &QDialog::reject );
898 orderByDlg.setLayout( layout );
900 QGroupBox *sortingGroupBox =
new QGroupBox();
901 sortingGroupBox->setTitle( tr(
"Defined sort order in attribute table" ) );
902 sortingGroupBox->setCheckable(
true );
904 layout->addWidget( sortingGroupBox );
905 sortingGroupBox->setLayout(
new QGridLayout() );
910 expressionBuilder->
setLayer( mLayer );
912 expressionBuilder->
loadRecent( QStringLiteral(
"generic" ) );
916 sortingGroupBox->layout()->addWidget( expressionBuilder );
918 QCheckBox *cbxSortAscending =
new QCheckBox( tr(
"Sort ascending" ) );
919 cbxSortAscending->setChecked( config.
sortOrder() == Qt::AscendingOrder );
920 sortingGroupBox->layout()->addWidget( cbxSortAscending );
922 layout->addWidget( dialogButtonBox );
923 if ( orderByDlg.exec() )
925 Qt::SortOrder sortOrder = cbxSortAscending->isChecked() ? Qt::AscendingOrder : Qt::DescendingOrder;
926 if ( sortingGroupBox->isChecked() )
942 void QgsDualView::zoomToCurrentFeature()
944 QModelIndex currentIndex = mTableView->currentIndex();
945 if ( !currentIndex.isValid() )
951 ids.insert( mFilterModel->
rowToId( currentIndex ) );
959 void QgsDualView::panToCurrentFeature()
961 QModelIndex currentIndex = mTableView->currentIndex();
962 if ( !currentIndex.isValid() )
968 ids.insert( mFilterModel->
rowToId( currentIndex ) );
976 void QgsDualView::flashCurrentFeature()
978 QModelIndex currentIndex = mTableView->currentIndex();
979 if ( !currentIndex.isValid() )
985 ids.insert( mFilterModel->
rowToId( currentIndex ) );
993 void QgsDualView::rebuildFullLayerCache()
1001 void QgsDualView::previewExpressionChanged(
const QString &expression )
1003 mLayer->setDisplayExpression( expression );
1006 void QgsDualView::onSortColumnChanged()
1010 cfg.
sortOrder() != mFilterModel->sortOrder() )
1018 void QgsDualView::sortByPreviewExpression()
1020 Qt::SortOrder sortOrder = Qt::AscendingOrder;
1023 sortOrder = mConfig.
sortOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder;
1028 void QgsDualView::updateSelectedFeatures()
1040 void QgsDualView::extentChanged()
1053 void QgsDualView::featureFormAttributeChanged(
const QString &attribute,
const QVariant &value,
bool attributeChanged )
1055 Q_UNUSED( attribute )
1057 if ( attributeChanged )
1058 mFeatureListView->setCurrentFeatureEdited(
true );
1073 mTableView->setFeatureSelectionManager( featureSelectionManager );
1074 mFeatureListView->setFeatureSelectionManager( featureSelectionManager );
1076 if ( mFeatureSelectionManager && mFeatureSelectionManager->parent() == this )
1077 delete mFeatureSelectionManager;
1079 mFeatureSelectionManager = featureSelectionManager;
1085 mConfig.
update( mLayer->fields() );
1086 mLayer->setAttributeTableConfig( mConfig );
1088 mTableView->setAttributeTableConfig( mConfig );
1093 if ( sortExpression.isNull() )
1094 mFilterModel->
sort( -1 );
1096 mFilterModel->
sort( sortExpression, sortOrder );
1113 void QgsDualView::progress(
int i,
bool &cancel )
1115 if ( !mProgressDlg )
1117 mProgressDlg =
new QProgressDialog( tr(
"Loading features…" ), tr(
"Abort" ), 0, 0,
this );
1118 mProgressDlg->setWindowTitle( tr(
"Attribute Table" ) );
1119 mProgressDlg->setWindowModality( Qt::WindowModal );
1120 mProgressDlg->show();
1123 mProgressDlg->setLabelText( tr(
"%1 features loaded." ).arg( i ) );
1124 QCoreApplication::processEvents();
1126 cancel = mProgressDlg && mProgressDlg->wasCanceled();
1129 void QgsDualView::finished()
1131 delete mProgressDlg;
1132 mProgressDlg =
nullptr;
1141 mDualView->masterModel()->executeAction( mAction, mFieldIdx );
1147 editedIds << mDualView->masterModel()->rowToId( mFieldIdx.row() );
1148 mDualView->setCurrentEditSelection( editedIds );
1158 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.
Q_INVOKABLE 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.
QgsFeatureId rowToId(int row) const
Maps row to feature id.
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.
QModelIndex fidToIndex(QgsFeatureId fid) override
The map is panned to the center of the feature bounding-box.