29#include "moc_qgsattributedialog.cpp"
31using namespace Qt::StringLiterals;
35 , mOwnedFeature( featureOwner ? thepFeature : nullptr )
37 init( vl, thepFeature, context, showDialogButtons );
53void QgsAttributeDialog::saveGeometry()
60void QgsAttributeDialog::restoreGeometry()
64 QDialog::restoreGeometry( QgsSettings().value( u
"Windows/AttributeDialog/geometry"_s ).toByteArray() );
77 const bool didSave = mAttributeForm->saveWithDetails( &error );
84 if ( error.isEmpty() )
85 error = tr(
"An unknown error was encountered saving attributes" );
101 QDialog::showEvent(
event );
115 mTrackedVectorLayerTools.rollback();
123 setWindowTitle( tr(
"%1 - Feature Attributes" ).arg( layer->
name() ) );
124 setLayout(
new QGridLayout() );
125 layout()->setContentsMargins( 0, 0, 0, 0 );
127 mMessageBar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
128 layout()->addWidget( mMessageBar );
130 setLayout( layout() );
134 if ( showDialogButtons )
139 layout()->addWidget( mAttributeForm );
140 QDialogButtonBox *buttonBox = mAttributeForm->findChild<QDialogButtonBox *>();
143 connect( layer, &QObject::destroyed,
this, &QWidget::close );
149 mMenuBar =
new QMenuBar(
this );
150 mMenuBar->addMenu( mMenu );
151 layout()->setMenuBar( mMenuBar );
158 mAttributeForm->setMode( mode );
159 mMenu->setMode( mode );
161 if ( !mMenu->isEmpty() && !mMenuBar )
163 mMenuBar =
new QMenuBar(
this );
164 mMenuBar->addMenu( mMenu );
165 layout()->setMenuBar( mMenuBar );
167 else if ( mMenu->isEmpty() && mMenuBar )
169 layout()->setMenuBar(
nullptr );
177 if ( e->type() == QEvent::WindowActivate && mHighlight )
179 else if ( e->type() == QEvent::WindowDeactivate && mHighlight )
182 return QDialog::event( e );
187 mAttributeForm->setExtraContextScope( extraScope );
@ Critical
Critical/error message.
void setMode(QgsAttributeEditorContext::Mode mode)
Toggles the form mode.
const QgsFeature * feature() const
Returns the current feature of the attribute form.
~QgsAttributeDialog() override
bool event(QEvent *e) override
Intercept window activate/deactivate events to show/hide the highlighted feature.
void showEvent(QShowEvent *event) override
QgsMapLayerActionContext createActionContext() override
Creates a QgsMapLayerActionContext.
void show()
Show the dialog non-blocking. Reparents this dialog to be a child of the dialog form.
void setExtraContextScope(QgsExpressionContextScope *extraScope)
Sets extraScope as an additional expression context scope to be used for calculations in this form.
void setHighlight(QgsHighlight *h)
setHighlight
QgsAttributeDialog(QgsVectorLayer *vl, QgsFeature *thepFeature, bool featureOwner, QWidget *parent=nullptr, bool showDialogButtons=true, const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
Create an attribute dialog for a given layer and feature.
Contains context information for attribute editor widgets.
const QgsVectorLayerTools * vectorLayerTools() const
Returns the associated vector layer tools.
@ StandaloneDialog
A form was opened as a new dialog.
void setFormMode(FormMode mode)
Sets the form mode.
void setVectorLayerTools(QgsVectorLayerTools *vlTools)
Sets the associated vector layer tools.
Single scope for storing variables and functions for use within a QgsExpressionContext.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Highlights features on the map.
Encapsulates the context in which a QgsMapLayerAction action is executed.
void setAttributeDialog(QgsAttributeDialog *dialog)
Sets the attribute dialog associated with the action's execution.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the action's execution.
A bar for displaying non-blocking messages to the user.
Stores settings for use within QGIS.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Represents a vector layer which manages a vector based dataset.