Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review of the raster metadata viewer #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 51 additions & 36 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
, mGradientWidth( 0.0 )
, mMapCanvas( canvas )
, mHistogramWidget( nullptr )
, mMetadataFilled( false )
{
mGrayMinimumMaximumEstimated = true;
mRGBMinimumMaximumEstimated = true;
Expand Down Expand Up @@ -700,41 +701,9 @@ void QgsRasterLayerProperties::sync()
*/

//these properties (layer name and label) are provided by the qgsmaplayer superclass
leLayerSource->setText( mRasterLayer->source() );
mLayerOrigNameLineEd->setText( mRasterLayer->originalName() );
leDisplayName->setText( mRasterLayer->name() );

//display the raster dimensions and no data value
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
}
else
{
// TODO: Account for fixedWidth and fixedHeight WMS layers
lblColumns->setText( tr( "Columns: " ) + tr( "n/a" ) );
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
}

if ( mRasterLayer->dataProvider()->dataType( 1 ) == Qgis::ARGB32
|| mRasterLayer->dataProvider()->dataType( 1 ) == Qgis::ARGB32_Premultiplied )
{
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
}
else
{
// TODO: all bands
if ( mRasterLayer->dataProvider()->sourceHasNoDataValue( 1 ) )
{
lblNoData->setText( tr( "No-Data Value: %1" ).arg( mRasterLayer->dataProvider()->sourceNoDataValue( 1 ) ) );
}
else
{
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
}
}

//get the thumbnail for the layer
QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
pixmapThumbnail->setPixmap( thumbnail );
Expand All @@ -759,8 +728,10 @@ void QgsRasterLayerProperties::sync()
*/
//populate the metadata tab's text browser widget with gdal metadata info
QString myStyle = QgsApplication::reportStyleSheet();
txtbMetadata->document()->setDefaultStyleSheet( myStyle );
txtbMetadata->setHtml( mRasterLayer->htmlMetadata() );
myStyle.append( QStringLiteral( "body { margin: 10px; }\n " ) );
teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
mMetadataFilled = true;

// WMS Name as layer short name
mLayerShortNameLineEdit->setText( mRasterLayer->shortName() );
Expand Down Expand Up @@ -968,19 +939,57 @@ void QgsRasterLayerProperties::apply()
QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
pixmapThumbnail->setPixmap( thumbnail );

if ( mRasterLayer->shortName() != mLayerShortNameLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setShortName( mLayerShortNameLineEdit->text() );

if ( mRasterLayer->title() != mLayerTitleLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setTitle( mLayerTitleLineEdit->text() );

if ( mRasterLayer->abstract() != mLayerAbstractTextEdit->toPlainText() )
mMetadataFilled = false;
mRasterLayer->setAbstract( mLayerAbstractTextEdit->toPlainText() );

if ( mRasterLayer->keywordList() != mLayerKeywordListLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setKeywordList( mLayerKeywordListLineEdit->text() );

if ( mRasterLayer->dataUrl() != mLayerDataUrlLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setDataUrl( mLayerDataUrlLineEdit->text() );

if ( mRasterLayer->dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
mMetadataFilled = false;
mRasterLayer->setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );

//layer attribution and metadataUrl
if ( mRasterLayer->attribution() != mLayerAttributionLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setAttribution( mLayerAttributionLineEdit->text() );

if ( mRasterLayer->attributionUrl() != mLayerAttributionUrlLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setAttributionUrl( mLayerAttributionUrlLineEdit->text() );

if ( mRasterLayer->metadataUrl() != mLayerMetadataUrlLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setMetadataUrl( mLayerMetadataUrlLineEdit->text() );

if ( mRasterLayer->metadataUrlType() != mLayerMetadataUrlTypeComboBox->currentText() )
mMetadataFilled = false;
mRasterLayer->setMetadataUrlType( mLayerMetadataUrlTypeComboBox->currentText() );

if ( mRasterLayer->metadataUrlFormat() != mLayerMetadataUrlFormatComboBox->currentText() )
mMetadataFilled = false;
mRasterLayer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );

if ( mRasterLayer->legendUrl() != mLayerLegendUrlLineEdit->text() )
mMetadataFilled = false;
mRasterLayer->setLegendUrl( mLayerLegendUrlLineEdit->text() );

if ( mRasterLayer->legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
mMetadataFilled = false;
mRasterLayer->setLegendUrlFormat( mLayerLegendUrlFormatComboBox->currentText() );

// update symbology
Expand Down Expand Up @@ -1107,8 +1116,8 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()

//populate the metadata tab's text browser widget with gdal metadata info
QString myStyle = QgsApplication::reportStyleSheet();
txtbMetadata->setHtml( mRasterLayer->htmlMetadata() );
txtbMetadata->document()->setDefaultStyleSheet( myStyle );
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
}

void QgsRasterLayerProperties::on_mRenderTypeComboBox_currentIndexChanged( int index )
Expand Down Expand Up @@ -1438,6 +1447,12 @@ void QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged( int indx )
{
mHistogramWidget->setActive( false );
}

if ( indx == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
//set the metadata contents (which can be expensive)
teMetadataViewer->clear();
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
mMetadataFilled = true;
}

void QgsRasterLayerProperties::on_pbnImportTransparentPixelValues_clicked()
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsrasterlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
QgsMapLayerStyle mOldStyle;

bool mDisableRenderTypeComboBoxCurrentIndexChanged = false;

bool mMetadataFilled;
};
#endif
Loading