[Identify tool] Change to single setting for referenced and referencing relations

This commit is contained in:
Even Rouault 2024-06-24 23:21:58 +02:00 committed by Nyall Dawson
parent d911ea04dd
commit fb65578f81
3 changed files with 13 additions and 37 deletions

View File

@ -108,9 +108,7 @@ constexpr int REPRESENTED_VALUE_ROLE = Qt::UserRole + 2;
const QgsSettingsEntryBool *QgsIdentifyResultsDialog::settingHideNullValues = new QgsSettingsEntryBool( QStringLiteral( "hide-null-values" ), QgsSettingsTree::sTreeMap, false, QStringLiteral( "Whether to hide attributes with NULL values in the identify feature result" ) );
const QgsSettingsEntryBool *QgsIdentifyResultsDialog::settingShowReferencingRelations = new QgsSettingsEntryBool( QStringLiteral( "show-referencing-relations" ), QgsSettingsTree::sTreeMap, true, QStringLiteral( "Whether to show referencing relations in the identify feature result" ) );
const QgsSettingsEntryBool *QgsIdentifyResultsDialog::settingShowReferencedRelations = new QgsSettingsEntryBool( QStringLiteral( "show-referenced-relations" ), QgsSettingsTree::sTreeMap, true, QStringLiteral( "Whether to show referenced relations in the identify feature result" ) );
const QgsSettingsEntryBool *QgsIdentifyResultsDialog::settingShowRelations = new QgsSettingsEntryBool( QStringLiteral( "show-relations" ), QgsSettingsTree::sTreeMap, true, QStringLiteral( "Whether to show relations in the identify feature result" ) );
QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWebView( parent )
@ -374,8 +372,7 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
connect( mActionAutoFeatureForm, &QAction::toggled, this, &QgsIdentifyResultsDialog::mActionAutoFeatureForm_toggled );
connect( mActionHideDerivedAttributes, &QAction::toggled, this, &QgsIdentifyResultsDialog::mActionHideDerivedAttributes_toggled );
connect( mActionHideNullValues, &QAction::toggled, this, &QgsIdentifyResultsDialog::mActionHideNullValues_toggled );
connect( mActionShowReferencingRelations, &QAction::toggled, this, &QgsIdentifyResultsDialog::mActionShowReferencingRelations_toggled );
connect( mActionShowReferencedRelations, &QAction::toggled, this, &QgsIdentifyResultsDialog::mActionShowReferencedRelations_toggled );
connect( mActionShowRelations, &QAction::toggled, this, &QgsIdentifyResultsDialog::mActionShowRelations_toggled );
mOpenFormAction->setDisabled( true );
@ -488,10 +485,8 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
mActionHideDerivedAttributes->setChecked( mySettings.value( QStringLiteral( "Map/hideDerivedAttributes" ), false ).toBool() );
settingsMenu->addAction( mActionHideNullValues );
mActionHideNullValues->setChecked( QgsIdentifyResultsDialog::settingHideNullValues->value() );
settingsMenu->addAction( mActionShowReferencedRelations );
mActionShowReferencedRelations->setChecked( QgsIdentifyResultsDialog::settingShowReferencedRelations->value() );
settingsMenu->addAction( mActionShowReferencingRelations );
mActionShowReferencingRelations->setChecked( QgsIdentifyResultsDialog::settingShowReferencingRelations->value() );
settingsMenu->addAction( mActionShowRelations );
mActionShowRelations->setChecked( QgsIdentifyResultsDialog::settingShowRelations->value() );
}
@ -850,7 +845,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV
}
// add entries for related items coming from referenced relations
if ( QgsIdentifyResultsDialog::settingShowReferencedRelations->value() )
if ( QgsIdentifyResultsDialog::settingShowRelations->value() )
{
const QList<QgsRelation> relations = QgsProject::instance()->relationManager()->referencedRelations( vlayer );
if ( !relations.empty() )
@ -879,7 +874,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV
}
// add entries for related items coming from referencing relations
if ( QgsIdentifyResultsDialog::settingShowReferencingRelations->value() )
if ( QgsIdentifyResultsDialog::settingShowRelations->value() )
{
const QList<QgsRelation> relations = QgsProject::instance()->relationManager()->referencingRelations( vlayer );
if ( !relations.empty() )
@ -2676,14 +2671,9 @@ void QgsIdentifyResultsDialog::mActionHideNullValues_toggled( bool checked )
QgsIdentifyResultsDialog::settingHideNullValues->setValue( checked );
}
void QgsIdentifyResultsDialog::mActionShowReferencedRelations_toggled( bool checked )
void QgsIdentifyResultsDialog::mActionShowRelations_toggled( bool checked )
{
QgsIdentifyResultsDialog::settingShowReferencedRelations->setValue( checked );
}
void QgsIdentifyResultsDialog::mActionShowReferencingRelations_toggled( bool checked )
{
QgsIdentifyResultsDialog::settingShowReferencingRelations->setValue( checked );
QgsIdentifyResultsDialog::settingShowRelations->setValue( checked );
}
void QgsIdentifyResultsDialog::mExpandNewAction_triggered( bool checked )

View File

@ -160,8 +160,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
~QgsIdentifyResultsDialog() override;
static const QgsSettingsEntryBool *settingHideNullValues;
static const QgsSettingsEntryBool *settingShowReferencingRelations;
static const QgsSettingsEntryBool *settingShowReferencedRelations;
static const QgsSettingsEntryBool *settingShowRelations;
//! Adds feature from vector layer
void addFeature( QgsVectorLayer *layer,
@ -304,9 +303,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
void mActionHideNullValues_toggled( bool checked );
void mActionShowReferencingRelations_toggled( bool checked );
void mActionShowReferencedRelations_toggled( bool checked );
void mActionShowRelations_toggled( bool checked );
void mExpandAction_triggered( bool checked ) { Q_UNUSED( checked ) expandAll(); }
void mCollapseAction_triggered( bool checked ) { Q_UNUSED( checked ) collapseAll(); }

View File

@ -383,26 +383,15 @@
<string>Hide derived attributes from results</string>
</property>
</action>
<action name="mActionShowReferencingRelations">
<action name="mActionShowRelations">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show referencing relations</string>
<string>Show Relations</string>
</property>
<property name="toolTip">
<string>Show referencing relations</string>
</property>
</action>
<action name="mActionShowReferencedRelations">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show referenced relations</string>
</property>
<property name="toolTip">
<string>Show referenced relations</string>
<string>Show Relations</string>
</property>
</action>
<action name="mHelpToolAction">