Skip to content

Commit e8ddc48

Browse files
Gustrytimlinux
authored andcommitted
review of the raster metadata viewer (#4726)
1 parent 4717766 commit e8ddc48

File tree

4 files changed

+925
-992
lines changed

4 files changed

+925
-992
lines changed

src/app/qgsrasterlayerproperties.cpp

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
8282
, mGradientWidth( 0.0 )
8383
, mMapCanvas( canvas )
8484
, mHistogramWidget( nullptr )
85+
, mMetadataFilled( false )
8586
{
8687
mGrayMinimumMaximumEstimated = true;
8788
mRGBMinimumMaximumEstimated = true;
@@ -700,41 +701,9 @@ void QgsRasterLayerProperties::sync()
700701
*/
701702

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

707-
//display the raster dimensions and no data value
708-
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
709-
{
710-
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
711-
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
712-
}
713-
else
714-
{
715-
// TODO: Account for fixedWidth and fixedHeight WMS layers
716-
lblColumns->setText( tr( "Columns: " ) + tr( "n/a" ) );
717-
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
718-
}
719-
720-
if ( mRasterLayer->dataProvider()->dataType( 1 ) == Qgis::ARGB32
721-
|| mRasterLayer->dataProvider()->dataType( 1 ) == Qgis::ARGB32_Premultiplied )
722-
{
723-
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
724-
}
725-
else
726-
{
727-
// TODO: all bands
728-
if ( mRasterLayer->dataProvider()->sourceHasNoDataValue( 1 ) )
729-
{
730-
lblNoData->setText( tr( "No-Data Value: %1" ).arg( mRasterLayer->dataProvider()->sourceNoDataValue( 1 ) ) );
731-
}
732-
else
733-
{
734-
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
735-
}
736-
}
737-
738707
//get the thumbnail for the layer
739708
QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
740709
pixmapThumbnail->setPixmap( thumbnail );
@@ -759,8 +728,10 @@ void QgsRasterLayerProperties::sync()
759728
*/
760729
//populate the metadata tab's text browser widget with gdal metadata info
761730
QString myStyle = QgsApplication::reportStyleSheet();
762-
txtbMetadata->document()->setDefaultStyleSheet( myStyle );
763-
txtbMetadata->setHtml( mRasterLayer->htmlMetadata() );
731+
myStyle.append( QStringLiteral( "body { margin: 10px; }\n " ) );
732+
teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
733+
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
734+
mMetadataFilled = true;
764735

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

942+
if ( mRasterLayer->shortName() != mLayerShortNameLineEdit->text() )
943+
mMetadataFilled = false;
971944
mRasterLayer->setShortName( mLayerShortNameLineEdit->text() );
945+
946+
if ( mRasterLayer->title() != mLayerTitleLineEdit->text() )
947+
mMetadataFilled = false;
972948
mRasterLayer->setTitle( mLayerTitleLineEdit->text() );
949+
950+
if ( mRasterLayer->abstract() != mLayerAbstractTextEdit->toPlainText() )
951+
mMetadataFilled = false;
973952
mRasterLayer->setAbstract( mLayerAbstractTextEdit->toPlainText() );
953+
954+
if ( mRasterLayer->keywordList() != mLayerKeywordListLineEdit->text() )
955+
mMetadataFilled = false;
974956
mRasterLayer->setKeywordList( mLayerKeywordListLineEdit->text() );
957+
958+
if ( mRasterLayer->dataUrl() != mLayerDataUrlLineEdit->text() )
959+
mMetadataFilled = false;
975960
mRasterLayer->setDataUrl( mLayerDataUrlLineEdit->text() );
961+
962+
if ( mRasterLayer->dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText() )
963+
mMetadataFilled = false;
976964
mRasterLayer->setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
965+
977966
//layer attribution and metadataUrl
967+
if ( mRasterLayer->attribution() != mLayerAttributionLineEdit->text() )
968+
mMetadataFilled = false;
978969
mRasterLayer->setAttribution( mLayerAttributionLineEdit->text() );
970+
971+
if ( mRasterLayer->attributionUrl() != mLayerAttributionUrlLineEdit->text() )
972+
mMetadataFilled = false;
979973
mRasterLayer->setAttributionUrl( mLayerAttributionUrlLineEdit->text() );
974+
975+
if ( mRasterLayer->metadataUrl() != mLayerMetadataUrlLineEdit->text() )
976+
mMetadataFilled = false;
980977
mRasterLayer->setMetadataUrl( mLayerMetadataUrlLineEdit->text() );
978+
979+
if ( mRasterLayer->metadataUrlType() != mLayerMetadataUrlTypeComboBox->currentText() )
980+
mMetadataFilled = false;
981981
mRasterLayer->setMetadataUrlType( mLayerMetadataUrlTypeComboBox->currentText() );
982+
983+
if ( mRasterLayer->metadataUrlFormat() != mLayerMetadataUrlFormatComboBox->currentText() )
984+
mMetadataFilled = false;
982985
mRasterLayer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );
986+
987+
if ( mRasterLayer->legendUrl() != mLayerLegendUrlLineEdit->text() )
988+
mMetadataFilled = false;
983989
mRasterLayer->setLegendUrl( mLayerLegendUrlLineEdit->text() );
990+
991+
if ( mRasterLayer->legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText() )
992+
mMetadataFilled = false;
984993
mRasterLayer->setLegendUrlFormat( mLayerLegendUrlFormatComboBox->currentText() );
985994

986995
// update symbology
@@ -1107,8 +1116,8 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
11071116

11081117
//populate the metadata tab's text browser widget with gdal metadata info
11091118
QString myStyle = QgsApplication::reportStyleSheet();
1110-
txtbMetadata->setHtml( mRasterLayer->htmlMetadata() );
1111-
txtbMetadata->document()->setDefaultStyleSheet( myStyle );
1119+
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
1120+
teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
11121121
}
11131122

11141123
void QgsRasterLayerProperties::on_mRenderTypeComboBox_currentIndexChanged( int index )
@@ -1438,6 +1447,12 @@ void QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged( int indx )
14381447
{
14391448
mHistogramWidget->setActive( false );
14401449
}
1450+
1451+
if ( indx == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
1452+
//set the metadata contents (which can be expensive)
1453+
teMetadataViewer->clear();
1454+
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
1455+
mMetadataFilled = true;
14411456
}
14421457

14431458
void QgsRasterLayerProperties::on_pbnImportTransparentPixelValues_clicked()

src/app/qgsrasterlayerproperties.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
192192
QgsMapLayerStyle mOldStyle;
193193

194194
bool mDisableRenderTypeComboBoxCurrentIndexChanged = false;
195+
196+
bool mMetadataFilled;
195197
};
196198
#endif

0 commit comments

Comments
 (0)