Skip to content

Commit

Permalink
[attribute form] Fix initial multi editing state of relation referenc…
Browse files Browse the repository at this point in the history
…e editor widgets
  • Loading branch information
nirvn committed May 2, 2024
1 parent 4abc205 commit 061936b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ The index at which the extra identifier value is available within the model.

void extraValueDoesNotExistChanged();
%Docstring
Flag indicating that the extraIdentifierValue does not exist in the data.
Notification that the model has found a feature tied to the extraIdentifierValue.
%End

void beginUpdate();
Expand Down
7 changes: 7 additions & 0 deletions python/PyQt6/gui/auto_generated/qgsfeaturelistcombobox.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ Determines if a NULL value should be available in the list.
Emitted when the current feature changes

.. versionadded:: 3.16.5
%End

void currentFeatureFoundChanged();
%Docstring
Emitted when the feature picker model changes its feature found state

.. versionadded:: 3.38
%End

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ The index at which the extra identifier value is available within the model.

void extraValueDoesNotExistChanged();
%Docstring
Flag indicating that the extraIdentifierValue does not exist in the data.
Notification that the model has found a feature tied to the extraIdentifierValue.
%End

void beginUpdate();
Expand Down
7 changes: 7 additions & 0 deletions python/gui/auto_generated/qgsfeaturelistcombobox.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ Determines if a NULL value should be available in the list.
Emitted when the current feature changes

.. versionadded:: 3.16.5
%End

void currentFeatureFoundChanged();
%Docstring
Emitted when the feature picker model changes its feature found state

.. versionadded:: 3.38
%End

};
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsfeaturepickermodelbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ QgsFeaturePickerModelBase::QgsFeaturePickerModelBase( QObject *parent )
// The fact that the feature changed is a combination of the 2 signals:
// If the extra value is set to a feature currently not fetched, it will go through an intermediate step while the extra value does not exist (as it call reloadFeature)
connect( this, &QgsFeaturePickerModelBase::extraIdentifierValueChanged, this, &QgsFeaturePickerModelBase::currentFeatureChanged );
connect( this, &QgsFeaturePickerModelBase::extraValueDoesNotExistChanged, this, &QgsFeaturePickerModelBase::currentFeatureChanged );
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeaturepickermodelbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class CORE_EXPORT QgsFeaturePickerModelBase : public QAbstractItemModel SIP_ABST
void extraIdentifierValueIndexChanged( int index );

/**
* Flag indicating that the extraIdentifierValue does not exist in the data.
* Notification that the model has found a feature tied to the extraIdentifierValue.
*/
void extraValueDoesNotExistChanged();

Expand Down
8 changes: 8 additions & 0 deletions src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ void QgsRelationReferenceWidget::init()

// Only connect after iterating, to have only one iterator on the referenced table at once
connect( mComboBox, &QgsFeatureListComboBox::currentFeatureChanged, this, &QgsRelationReferenceWidget::comboReferenceChanged );
connect( mComboBox, &QgsFeatureListComboBox::currentFeatureFoundChanged, this, &QgsRelationReferenceWidget::comboReferenceFoundChanged );

QApplication::restoreOverrideCursor();

Expand Down Expand Up @@ -626,6 +627,13 @@ void QgsRelationReferenceWidget::comboReferenceChanged()
emitForeignKeysChanged( mComboBox->identifierValues() );
}

void QgsRelationReferenceWidget::comboReferenceFoundChanged()
{
mReferencedLayer->getFeatures( mComboBox->currentFeatureRequest() ).nextFeature( mFeature );
highlightFeature( mFeature );
updateAttributeEditorFrame( mFeature );
}

void QgsRelationReferenceWidget::updateAttributeEditorFrame( const QgsFeature &feature )
{
mOpenFormButton->setEnabled( feature.isValid() );
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsrelationreferencewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
void highlightActionTriggered( QAction *action );
void deleteHighlight();
void comboReferenceChanged();
void comboReferenceFoundChanged();
void featureIdentified( const QgsFeature &feature );
void setMapTool( QgsMapTool *mapTool );
void unsetMapTool();
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsfeaturelistcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ QgsFeatureListComboBox::QgsFeatureListComboBox( QWidget *parent )
connect( mLineEdit, &QgsFilterLineEdit::cleared, this, &QgsFeatureListComboBox::onFilterLineEditCleared );

connect( mModel, &QgsFeatureFilterModel::currentFeatureChanged, this, &QgsFeatureListComboBox::currentFeatureChanged );
connect( mModel, &QgsFeatureFilterModel::extraValueDoesNotExistChanged, this, &QgsFeatureListComboBox::currentFeatureFoundChanged );

setToolTip( tr( "Just start typing what you are looking for." ) );
}
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsfeaturelistcombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
*/
void currentFeatureChanged();

/**
* Emitted when the feature picker model changes its feature found state
* \since QGIS 3.38
*/
void currentFeatureFoundChanged();

private slots:
void onCurrentTextChanged( const QString &text );
void onFilterLineEditCleared();
Expand Down

0 comments on commit 061936b

Please sign in to comment.