23 #include "qgssettings.h"
28 , mOwnedFeature( featureOwner ? thepFeature : nullptr )
30 init( vl, thepFeature, context, showDialogButtons );
46 void QgsAttributeDialog::saveGeometry()
50 QgsSettings().setValue( QStringLiteral(
"Windows/AttributeDialog/geometry" ),
QDialog::saveGeometry() );
53 void QgsAttributeDialog::restoreGeometry()
57 QDialog::restoreGeometry( QgsSettings().value( QStringLiteral(
"Windows/AttributeDialog/geometry" ) ).toByteArray() );
77 if ( error.isEmpty() )
78 error = tr(
"An unknown error was encountered saving attributes" );
82 Qgis::MessageLevel::Critical );
105 setWindowTitle( tr(
"%1 - Feature Attributes" ).arg( layer->
name() ) );
106 setLayout(
new QGridLayout() );
107 layout()->setContentsMargins( 0, 0, 0, 0 );
109 mMessageBar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
110 layout()->addWidget( mMessageBar );
112 setLayout( layout() );
116 if ( showDialogButtons )
121 layout()->addWidget( mAttributeForm );
122 QDialogButtonBox *buttonBox = mAttributeForm->findChild<QDialogButtonBox *>();
125 connect( layer, &QObject::destroyed,
this, &QWidget::close );
127 mMenu =
new QgsActionMenu( layer, mAttributeForm->
feature(), QStringLiteral(
"Feature" ),
this );
130 QMenuBar *menuBar =
new QMenuBar(
this );
131 menuBar->addMenu( mMenu );
132 layout()->setMenuBar( menuBar );
141 mAttributeForm->
setMode( mode );
147 if ( e->type() == QEvent::WindowActivate && mHighlight )
149 else if ( e->type() == QEvent::WindowDeactivate && mHighlight )
152 return QDialog::event( e );
void setMode(QgsAttributeEditorContext::Mode mode)
Toggles the form mode.
~QgsAttributeDialog() override
bool event(QEvent *e) override
Intercept window activate/deactivate events to show/hide the highlighted feature.
const QgsFeature * feature()
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.
This class contains context information for attribute editor widgets.
@ 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.
const QgsVectorLayerTools * vectorLayerTools() const
Returns 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...
A class for highlight features on the map.
A bar for displaying non-blocking messages to the user.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
Represents a vector layer which manages a vector based data sets.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.