29#include "moc_qgsfeatureselectiondlg.cpp"
32 : QDialog( parent, Qt::Window )
41 mDualView->setFeatureSelectionManager( mFeatureSelection );
46 mFeatureFilterWidget->init( vl, context, mDualView, mMessageBar, 5 );
47 mFeatureFilterWidget->filterVisible();
49 connect( mActionExpressionSelect, &QAction::triggered,
this, &QgsFeatureSelectionDlg::mActionExpressionSelect_triggered );
50 connect( mActionSelectAll, &QAction::triggered,
this, &QgsFeatureSelectionDlg::mActionSelectAll_triggered );
51 connect( mActionInvertSelection, &QAction::triggered,
this, &QgsFeatureSelectionDlg::mActionInvertSelection_triggered );
52 connect( mActionRemoveSelection, &QAction::triggered,
this, &QgsFeatureSelectionDlg::mActionRemoveSelection_triggered );
54 connect( mActionSelectedToTop, &QAction::toggled,
this, [
this](
bool checked ) { mDualView->setSelectedOnTop( checked ); } );
55 connect( mActionZoomMapToSelectedRows, &QAction::triggered,
this, &QgsFeatureSelectionDlg::mActionZoomMapToSelectedRows_triggered );
56 connect( mActionPanMapToSelectedRows, &QAction::triggered,
this, &QgsFeatureSelectionDlg::mActionPanMapToSelectedRows_triggered );
65 if ( evt->key() == Qt::Key_Enter || evt->key() == Qt::Key_Return )
67 QDialog::keyPressEvent( evt );
72 return mFeatureSelection->selectedFeatureIds();
77 mFeatureSelection->setSelectedFeatures( ids );
82 QWindow *mainWindow =
nullptr;
83 for (
const auto &w : QgsApplication::topLevelWindows() )
85 if ( w->objectName() == QLatin1String(
"QgisAppWindow" ) )
94 const QSize margins( size() - scrollAreaWidgetContents->size() );
95 const QSize innerWinSize( mainWindow->width(), mainWindow->height() );
96 setMaximumSize( innerWinSize );
97 const QSize minSize( scrollAreaWidgetContents->sizeHint() );
98 setMinimumSize( std::min( minSize.width() + margins.width(), innerWinSize.width() ), std::min( minSize.height() + margins.width(), innerWinSize.height() ) );
101 QDialog::showEvent( event );
104void QgsFeatureSelectionDlg::mActionExpressionSelect_triggered()
108 dlg->setAttribute( Qt::WA_DeleteOnClose );
112void QgsFeatureSelectionDlg::mActionInvertSelection_triggered()
114 mVectorLayer->invertSelection();
117void QgsFeatureSelectionDlg::mActionRemoveSelection_triggered()
119 mVectorLayer->removeSelection();
122void QgsFeatureSelectionDlg::mActionSelectAll_triggered()
124 mVectorLayer->selectAll();
127void QgsFeatureSelectionDlg::mActionZoomMapToSelectedRows_triggered()
129 mContext.mapCanvas()->zoomToSelected( mVectorLayer );
132void QgsFeatureSelectionDlg::mActionPanMapToSelectedRows_triggered()
134 mContext.mapCanvas()->panToSelected( mVectorLayer );
139 mFeatureFilterWidget->setFilterExpression( filter, type,
true );
Contains context information for attribute editor widgets.
QgsMapCanvas * mapCanvas() const
Returns the associated map canvas (e.g.
@ SearchMode
Form values are used for searching/filtering the layer.
@ AttributeEditor
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
void formModeChanged(QgsAttributeEditorContext::Mode mode)
Emitted when the form changes mode.
void filterExpressionSet(const QString &expression, QgsAttributeForm::FilterType type)
Emitted when a filter expression is set using the view.
void toggleSearchMode(bool enabled)
Toggles whether search mode should be enabled in the form.
A dialog for selecting features by expression.
void setMessageBar(QgsMessageBar *messageBar)
Sets the message bar to display feedback from the dialog.
Wraps a request for features to a vector layer (or directly its vector data provider).
void setSelectedFeatures(const QgsFeatureIds &ids)
Set the selected features.
const QgsFeatureIds & selectedFeatures()
Gets the selected features.
QgsFeatureSelectionDlg(QgsVectorLayer *vl, const QgsAttributeEditorContext &context, QWidget *parent=nullptr)
Constructor for QgsFeatureSelectionDlg.
void setFilterExpression(const QString &filter, QgsAttributeForm::FilterType type)
Set form filter expression.
void showEvent(QShowEvent *event) override
Make sure the dialog does not grow too much.
void keyPressEvent(QKeyEvent *evt) override
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Manages vector layer selections.
Represents a vector layer which manages a vector based dataset.
QSet< QgsFeatureId > QgsFeatureIds