28 #include <QHBoxLayout>
37 , mInitialized( false )
49 mToggleEditingButton->
setText(
tr(
"Toggle editing" ) );
52 buttonLayout->
addWidget( mToggleEditingButton );
56 mSaveEditsButton->
setText(
tr(
"Save layer edits" ) );
58 buttonLayout->
addWidget( mSaveEditsButton );
62 mAddFeatureButton->
setText(
tr(
"Add feature" ) );
63 buttonLayout->
addWidget( mAddFeatureButton );
67 mDeleteFeatureButton->
setText(
tr(
"Delete feature" ) );
68 buttonLayout->
addWidget( mDeleteFeatureButton );
72 mLinkFeatureButton->
setText(
tr(
"Link feature" ) );
73 buttonLayout->
addWidget( mLinkFeatureButton );
77 mUnlinkFeatureButton->
setText(
tr(
"Unlink feature" ) );
78 buttonLayout->
addWidget( mUnlinkFeatureButton );
83 mFormViewButton->
setText(
tr(
"Form view" ) );
87 buttonLayout->
addWidget( mFormViewButton );
90 mTableViewButton->
setText(
tr(
"Table view" ) );
94 buttonLayout->
addWidget( mTableViewButton );
104 referencingLayerEditingToggled();
111 mDualView->
setView( mViewMode );
118 connect( mViewModeButtonGroup, SIGNAL( buttonClicked(
int ) ),
this, SLOT(
setViewMode(
int ) ) );
119 connect( mToggleEditingButton, SIGNAL(
clicked(
bool ) ),
this, SLOT( toggleEditing(
bool ) ) );
120 connect( mSaveEditsButton, SIGNAL(
clicked() ),
this, SLOT( saveEdits() ) );
121 connect( mAddFeatureButton, SIGNAL(
clicked() ),
this, SLOT( addFeature() ) );
122 connect( mDeleteFeatureButton, SIGNAL(
clicked() ),
this, SLOT( deleteFeature() ) );
123 connect( mLinkFeatureButton, SIGNAL(
clicked() ),
this, SLOT( linkFeature() ) );
124 connect( mUnlinkFeatureButton, SIGNAL(
clicked() ),
this, SLOT( unlinkFeature() ) );
135 mRelation = relation;
138 connect( mRelation.
referencingLayer(), SIGNAL( editingStarted() ),
this, SLOT( referencingLayerEditingToggled() ) );
139 connect( mRelation.
referencingLayer(), SIGNAL( editingStopped() ),
this, SLOT( referencingLayerEditingToggled() ) );
146 if ( canChangeAttributes && !lyr->isReadOnly() )
149 referencingLayerEditingToggled();
173 mEditorContext = context;
184 mRelationId = qgisRelationId;
190 void QgsRelationEditorWidget::referencingLayerEditingToggled()
192 bool editable =
false;
206 void QgsRelationEditorWidget::addFeature()
220 void QgsRelationEditorWidget::linkFeature()
224 if ( selectionDlg.exec() )
234 Q_FOREACH (
QgsFeatureId fid, selectionDlg.selectedFeatures() )
237 while ( it.hasNext() )
246 void QgsRelationEditorWidget::deleteFeature()
254 void QgsRelationEditorWidget::unlinkFeature()
266 keyFields.
insert( idx, fld );
272 while ( it.hasNext() )
280 void QgsRelationEditorWidget::toggleEditing(
bool state )
292 void QgsRelationEditorWidget::saveEdits()
297 void QgsRelationEditorWidget::onCollapsedStateChanged(
bool collapsed )
299 if ( !mInitialized && !collapsed && mRelation.
isValid() )
bool isValid() const
Returns the validity of this relation.
const QString name() const
void setContentsMargins(int left, int top, int right, int bottom)
void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
void clicked(bool checked)
bool deleteFeature(QgsFeatureId fid)
delete a feature from the layer (but does not commit it)
This class contains context information for attribute editor widgets.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
ViewMode
The view modes, in which this widget can present information.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
Container of fields for a vector layer.
virtual const QgsFeatureIds & selectedFeaturesIds() const override
Return reference to identifiers of selected features.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setView(ViewMode view)
Change the current view mode.
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Defines a relation between matchin fields of the two involved tables of a relation.
Shows the features and attributes in a table layout.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
QgsVectorLayer * referencingLayer() const
Access the referencing (child) layer This is the layer which has the field(s) which point to another ...
virtual void addItem(QLayoutItem *item)
void setObjectName(const QString &name)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void init(QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request=QgsFeatureRequest(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
Has to be called to initialize the dual view.
Q_DECL_DEPRECATED bool changeAttributeValue(QgsFeatureId fid, int field, QVariant value, bool emitSignal)
Changes an attribute value (but does not commit it)
Encapsulate a field in an attribute table or data source.
QgsFeatureRequest getRelatedFeaturesRequest(const QgsFeature &feature) const
Creates a request to return all the features on the referencing (child) layer which have a foreign ke...
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
This selection manager synchronizes a local set of selected features with an attribute table...
QgsAttributeTableModel * masterModel() const
Returns the model which has the information about all features (not only filtered) ...
const QString & referencingField() const
Get the name of the referencing field.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
void setTitle(const QString &title)
QgsVectorLayer * layer() const
Returns the layer this model uses as backend.
const QgsVectorLayerTools * vectorLayerTools() const
void loadState()
Will load the collapsed and checked state.
QList< FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names f...
void setText(const QString &text)
iterator insert(const Key &key, const T &value)
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsVectorDataProvider * dataProvider()
Returns the data provider.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
allows modification of attribute values
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
const QString & referencedField() const
Get the name of the referenced field.
void addLayout(QLayout *layout, int stretch)