Merge pull request #37135 from elpaso/bugfix-gh29682-vertex-editor-locale

Fix editor vertex with "non-dot" locales
This commit is contained in:
Alessandro Pasotti 2020-06-12 14:40:28 +02:00 committed by GitHub
commit cda283988b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -499,4 +499,11 @@ void CoordinateItemDelegate::setModelData( QWidget *editor, QAbstractItemModel *
}
}
void CoordinateItemDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>( editor );
if ( lineEdit && index.isValid() )
{
lineEdit->setText( QLocale().toString( index.data( ).toDouble( ), 'f', 4 ) );
}
}

View File

@ -140,6 +140,9 @@ class APP_EXPORT CoordinateItemDelegate : public QStyledItemDelegate
protected:
QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &index ) const override;
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
};
#endif // QGSVERTEXEDITOR_H