Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Vertex editor: make displayed coordinate precision configurable
  • Loading branch information
mhugent committed Nov 2, 2020
1 parent 47a08a4 commit d49d458
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/vertextool/qgsvertexeditor.cpp
Expand Up @@ -477,7 +477,8 @@ CoordinateItemDelegate::CoordinateItemDelegate( QObject *parent )

QString CoordinateItemDelegate::displayText( const QVariant &value, const QLocale &locale ) const
{
return locale.toString( value.toDouble(), 'f', 4 );
int dp = QgsProject::instance()->readNumEntry( QStringLiteral( "PositionPrecision" ), QStringLiteral( "/DecimalPlaces" ), 4 );
return locale.toString( value.toDouble(), 'f', dp );
}

QWidget *CoordinateItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index ) const
Expand All @@ -504,6 +505,7 @@ void CoordinateItemDelegate::setEditorData( QWidget *editor, const QModelIndex &
QLineEdit *lineEdit = qobject_cast<QLineEdit *>( editor );
if ( lineEdit && index.isValid() )
{
lineEdit->setText( QLocale().toString( index.data( ).toDouble( ), 'f', 4 ) );
int dp = QgsProject::instance()->readNumEntry( QStringLiteral( "PositionPrecision" ), QStringLiteral( "/DecimalPlaces" ), 4 );
lineEdit->setText( QLocale().toString( index.data( ).toDouble( ), 'f', dp ) );
}
}

0 comments on commit d49d458

Please sign in to comment.