25
25
#include " qgsgeometryutils.h"
26
26
#include " qgsproject.h"
27
27
#include " qgscoordinatetransform.h"
28
+ #include " qgsdoublevalidator.h"
28
29
29
30
#include < QLabel>
30
31
#include < QTableWidget>
@@ -237,13 +238,7 @@ bool QgsVertexEditorModel::setData( const QModelIndex &index, const QVariant &va
237
238
}
238
239
239
240
// Get double value wrt current locale.
240
- bool ok;
241
- double doubleValue = QLocale ().toDouble ( value.toString (), &ok );
242
- // If not valid and locale's decimal point is not '.' let's try with english locale
243
- if ( ! ok && QLocale ().decimalPoint () != ' .' )
244
- {
245
- doubleValue = QLocale ( QLocale::English ).toDouble ( value.toString () );
246
- }
241
+ const double doubleValue { QgsDoubleValidator::toDouble ( value.toString () ) };
247
242
248
243
double x = ( index.column () == 0 ? doubleValue : mLockedFeature ->vertexMap ().at ( index.row () )->point ().x () );
249
244
double y = ( index.column () == 1 ? doubleValue : mLockedFeature ->vertexMap ().at ( index.row () )->point ().y () );
@@ -267,8 +262,8 @@ bool QgsVertexEditorModel::setData( const QModelIndex &index, const QVariant &va
267
262
y = result.y ();
268
263
}
269
264
}
270
- double z = ( index.column () == mZCol ? value. toDouble () : mLockedFeature ->vertexMap ().at ( index.row () )->point ().z () );
271
- double m = ( index.column () == mMCol ? value. toDouble () : mLockedFeature ->vertexMap ().at ( index.row () )->point ().m () );
265
+ double z = ( index.column () == mZCol ? doubleValue : mLockedFeature ->vertexMap ().at ( index.row () )->point ().z () );
266
+ double m = ( index.column () == mMCol ? doubleValue : mLockedFeature ->vertexMap ().at ( index.row () )->point ().m () );
272
267
QgsPoint p ( QgsWkbTypes::PointZM, x, y, z, m );
273
268
274
269
mLockedFeature ->layer ()->beginEditCommand ( QObject::tr ( " Moved vertices" ) );
@@ -489,7 +484,7 @@ QString CoordinateItemDelegate::displayText( const QVariant &value, const QLocal
489
484
QWidget *CoordinateItemDelegate::createEditor ( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index ) const
490
485
{
491
486
QLineEdit *lineEdit = new QLineEdit ( parent );
492
- QDoubleValidator *validator = new QDoubleValidator ( );
487
+ QgsDoubleValidator *validator = new QgsDoubleValidator ( lineEdit );
493
488
if ( !index.data ( MIN_RADIUS_ROLE ).isNull () )
494
489
validator->setBottom ( index.data ( MIN_RADIUS_ROLE ).toDouble () );
495
490
lineEdit->setValidator ( validator );
@@ -510,7 +505,7 @@ void CoordinateItemDelegate::setEditorData( QWidget *editor, const QModelIndex &
510
505
QLineEdit *lineEdit = qobject_cast<QLineEdit *>( editor );
511
506
if ( lineEdit && index.isValid () )
512
507
{
513
- lineEdit->setText ( QLocale (). toString ( index.data ( ).toDouble ( ), ' f ' , displayDecimalPlaces () ) );
508
+ lineEdit->setText ( displayText ( index.data ( ).toDouble ( ), QLocale () ) );
514
509
}
515
510
}
516
511
0 commit comments