Skip to content
Permalink
Browse files

Add standard actions to save/restore default metadata for point cloud…

… layers
  • Loading branch information
nyalldawson committed Oct 27, 2020
1 parent 17c83d7 commit c958562c6c3b9228abf53b570e7c54aca4ecabef
@@ -87,6 +87,10 @@ QgsPointCloudLayerProperties::QgsPointCloudLayerProperties( QgsPointCloudLayer *
QMenu *menuMetadata = new QMenu( this );
mActionLoadMetadata = menuMetadata->addAction( tr( "Load Metadata…" ), this, &QgsPointCloudLayerProperties::loadMetadata );
mActionSaveMetadataAs = menuMetadata->addAction( tr( "Save Metadata…" ), this, &QgsPointCloudLayerProperties::saveMetadataAs );
menuMetadata->addSeparator();
menuMetadata->addAction( tr( "Save as Default" ), this, &QgsPointCloudLayerProperties::saveDefaultMetadata );
menuMetadata->addAction( tr( "Restore Default" ), this, &QgsPointCloudLayerProperties::loadDefaultMetadata );

mBtnMetadata->setMenu( menuMetadata );
buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );

@@ -303,6 +307,33 @@ void QgsPointCloudLayerProperties::saveMetadataAs()
QMessageBox::information( this, tr( "Save Metadata" ), message );
}

void QgsPointCloudLayerProperties::saveDefaultMetadata()
{
mMetadataWidget->acceptMetadata();

bool defaultSavedFlag = false;
QString errorMsg = mLayer->saveDefaultMetadata( defaultSavedFlag );
if ( !defaultSavedFlag )
{
QMessageBox::warning( this, tr( "Default Metadata" ), errorMsg );
}
}

void QgsPointCloudLayerProperties::loadDefaultMetadata()
{
bool defaultLoadedFlag = false;
QString myMessage = mLayer->loadNamedMetadata( mLayer->metadataUri(), defaultLoadedFlag );
//reset if the default metadata was loaded OK only
if ( defaultLoadedFlag )
{
mMetadataWidget->setMetadata( &mLayer->metadata() );
}
else
{
QMessageBox::information( this, tr( "Default Metadata" ), myMessage );
}
}

void QgsPointCloudLayerProperties::showHelp()
{
const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property( "helpPage" );
@@ -46,6 +46,8 @@ class QgsPointCloudLayerProperties : public QgsOptionsDialogBase, private Ui::Qg
void aboutToShowStyleMenu();
void loadMetadata();
void saveMetadataAs();
void saveDefaultMetadata();
void loadDefaultMetadata();
void showHelp();
void urlClicked( const QUrl &url );

0 comments on commit c958562

Please sign in to comment.
You can’t perform that action at this time.