29#include "moc_qgsattributedialog.cpp"
31using namespace Qt::StringLiterals;
35 , mOwnedFeature( featureOwner ? thepFeature : nullptr )
37 init( vl, thepFeature, context, showDialogButtons );
52void QgsAttributeDialog::saveGeometry()
59void QgsAttributeDialog::restoreGeometry()
63 QDialog::restoreGeometry( QgsSettings().value( u
"Windows/AttributeDialog/geometry"_s ).toByteArray() );
76 const bool didSave = mAttributeForm->saveWithDetails( &error );
83 if ( error.isEmpty() )
84 error = tr(
"An unknown error was encountered saving attributes" );
100 QDialog::showEvent(
event );
114 mTrackedVectorLayerTools.rollback();
122 setWindowTitle( tr(
"%1 - Feature Attributes" ).arg( layer->
name() ) );
123 setLayout(
new QGridLayout() );
124 layout()->setContentsMargins( 0, 0, 0, 0 );
126 mMessageBar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
127 layout()->addWidget( mMessageBar );
129 setLayout( layout() );
133 if ( showDialogButtons )
138 layout()->addWidget( mAttributeForm );
139 QDialogButtonBox *buttonBox = mAttributeForm->findChild<QDialogButtonBox *>();
142 connect( layer, &QObject::destroyed,
this, &QWidget::close );
148 mMenuBar =
new QMenuBar(
this );
149 mMenuBar->addMenu( mMenu );
150 layout()->setMenuBar( mMenuBar );
157 mAttributeForm->setMode( mode );
158 mMenu->setMode( mode );
160 if ( !mMenu->isEmpty() && !mMenuBar )
162 mMenuBar =
new QMenuBar(
this );
163 mMenuBar->addMenu( mMenu );
164 layout()->setMenuBar( mMenuBar );
166 else if ( mMenu->isEmpty() && mMenuBar )
168 layout()->setMenuBar(
nullptr );
176 if ( e->type() == QEvent::WindowActivate && mHighlight )
178 else if ( e->type() == QEvent::WindowDeactivate && mHighlight )
181 return QDialog::event( e );
186 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.