Skip to content

Commit

Permalink
[GUI] Show Epoch up to 3 decimal digits when needed
Browse files Browse the repository at this point in the history
and in more places
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Jun 11, 2024
1 parent 641c890 commit 2e1e6bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/core/layertree/qgslayertreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,15 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const

if ( layer->isSpatial() && layer->crs().isValid() )
{
QString layerCrs = layer->crs().authid();
if ( !std::isnan( layer->crs().coordinateEpoch() ) )
{
layerCrs += QStringLiteral( " @ %1" ).arg( qgsDoubleToString( layer->crs().coordinateEpoch(), 3 ) );
}
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
title += tr( " (%1 - %2)" ).arg( QgsWkbTypes::displayString( vl->wkbType() ), layer->crs().authid() ).toHtmlEscaped();
title += tr( " (%1 - %2)" ).arg( QgsWkbTypes::displayString( vl->wkbType() ), layerCrs ).toHtmlEscaped();
else
title += tr( " (%1)" ).arg( layer->crs().authid() ).toHtmlEscaped();
title += tr( " (%1)" ).arg( layerCrs ).toHtmlEscaped();
}

QStringList parts;
Expand Down
2 changes: 1 addition & 1 deletion src/core/proj/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ QString QgsCoordinateReferenceSystem::userFriendlyIdentifier( IdentifierType typ
id = QObject::tr( "Custom CRS: %1" ).arg( type == MediumString ? ( toProj().left( 50 ) + QString( QChar( 0x2026 ) ) )
: toProj() );
if ( !id.isEmpty() && !std::isnan( d->mCoordinateEpoch ) )
id += QStringLiteral( " @ %1" ).arg( d->mCoordinateEpoch );
id += QStringLiteral( " @ %1" ).arg( qgsDoubleToString( d->mCoordinateEpoch, 3 ) );

return id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2955,7 +2955,7 @@ QString QgsMapLayer::crsHtmlMetadata() const
// coordinate epoch
if ( !std::isnan( c.coordinateEpoch() ) )
{
metadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Coordinate Epoch" ) + QStringLiteral( "</td><td>%1</td></tr>\n" ).arg( c.coordinateEpoch() );
metadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Coordinate Epoch" ) + QStringLiteral( "</td><td>%1</td></tr>\n" ).arg( qgsDoubleToString( c.coordinateEpoch(), 3 ) );
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/core/qgsmaplayermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,15 @@ QVariant QgsMapLayerModel::data( const QModelIndex &index, int role ) const
title = "<b>" + title + "</b>";
if ( layer->isSpatial() && layer->crs().isValid() )
{
QString layerCrs = layer->crs().authid();
if ( !std::isnan( layer->crs().coordinateEpoch() ) )
{
layerCrs += QStringLiteral( " @ %1" ).arg( qgsDoubleToString( layer->crs().coordinateEpoch(), 3 ) );
}
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
title = tr( "%1 (%2 - %3)" ).arg( title, QgsWkbTypes::displayString( vl->wkbType() ), layer->crs().authid() );
title = tr( "%1 (%2 - %3)" ).arg( title, QgsWkbTypes::displayString( vl->wkbType() ), layerCrs );
else
title = tr( "%1 (%2) " ).arg( title, layer->crs().authid() );
title = tr( "%1 (%2)" ).arg( title, layerCrs );
}
parts << title;

Expand Down

0 comments on commit 2e1e6bb

Please sign in to comment.