5555#include " qgssettings.h"
5656#include " qgsrendererpropertiesdialog.h"
5757#include " qgsstyle.h"
58+ #include " qgsauxiliarystorage.h"
59+ #include " qgsnewauxiliarylayerdialog.h"
5860
5961#include " layertree/qgslayertreelayer.h"
6062#include " qgslayertree.h"
@@ -81,6 +83,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
8183 : QgsOptionsDialogBase( QStringLiteral( " VectorLayerProperties" ), parent, fl )
8284 , mLayer( lyr )
8385 , mOriginalSubsetSQL( lyr->subsetString () )
86+ , mAuxiliaryLayerActionNew( nullptr )
8487{
8588 setupUi ( this );
8689 connect ( mLayerOrigNameLineEdit , &QLineEdit::textEdited, this , &QgsVectorLayerProperties::mLayerOrigNameLineEdit_textEdited );
@@ -349,6 +352,16 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
349352
350353 connect ( mRefreshLayerCheckBox , &QCheckBox::toggled, mRefreshLayerIntervalSpinBox , &QDoubleSpinBox::setEnabled );
351354
355+ // auxiliary layer
356+ QMenu *menu = new QMenu ( this );
357+
358+ mAuxiliaryLayerActionNew = new QAction ( tr ( " Create" ), this );
359+ menu->addAction ( mAuxiliaryLayerActionNew );
360+ connect ( mAuxiliaryLayerActionNew , &QAction::triggered, this , &QgsVectorLayerProperties::onAuxiliaryLayerNew );
361+
362+ mAuxiliaryStorageActions ->setMenu ( menu );
363+
364+ updateAuxiliaryStoragePage ();
352365}
353366
354367void QgsVectorLayerProperties::toggleEditing ()
@@ -1453,3 +1466,52 @@ void QgsVectorLayerProperties::showHelp()
14531466{
14541467 QgsHelp::openHelp ( QStringLiteral ( " working_with_vector/vector_properties.html" ) );
14551468}
1469+
1470+ void QgsVectorLayerProperties::updateAuxiliaryStoragePage ()
1471+ {
1472+ const QgsAuxiliaryLayer *alayer = mLayer ->auxiliaryLayer ();
1473+
1474+ if ( alayer )
1475+ {
1476+ // set widgets to enable state
1477+ mAuxiliaryStorageInformationGrpBox ->setEnabled ( true );
1478+ mAuxiliaryStorageFieldsGrpBox ->setEnabled ( true );
1479+
1480+ // update key
1481+ mAuxiliaryStorageKeyLineEdit ->setText ( alayer->joinInfo ().targetFieldName () );
1482+
1483+ // update feature count
1484+ int features = alayer->featureCount ();
1485+ mAuxiliaryStorageFeaturesLineEdit ->setText ( QString::number ( features ) );
1486+
1487+ // update actions
1488+ mAuxiliaryLayerActionNew ->setEnabled ( false );
1489+ }
1490+ else
1491+ {
1492+ mAuxiliaryStorageInformationGrpBox ->setEnabled ( false );
1493+ mAuxiliaryStorageFieldsGrpBox ->setEnabled ( false );
1494+
1495+ if ( mLayer ->isSpatial () )
1496+ mAuxiliaryLayerActionNew ->setEnabled ( true );
1497+
1498+ mAuxiliaryStorageFieldsTree ->clear ();
1499+ mAuxiliaryStorageKeyLineEdit ->setText ( QString () );
1500+ mAuxiliaryStorageFieldsLineEdit ->setText ( QString () );
1501+ mAuxiliaryStorageFeaturesLineEdit ->setText ( QString () );
1502+ }
1503+ }
1504+
1505+ void QgsVectorLayerProperties::onAuxiliaryLayerNew ()
1506+ {
1507+ QgsAuxiliaryLayer *alayer = mLayer ->auxiliaryLayer ();
1508+
1509+ if ( alayer || !mLayer ->isSpatial () )
1510+ return ;
1511+
1512+ QgsNewAuxiliaryLayerDialog dlg ( mLayer , this );
1513+ if ( dlg.exec () == QDialog::Accepted )
1514+ {
1515+ updateAuxiliaryStoragePage ();
1516+ }
1517+ }
0 commit comments