20#include "moc_qgslocaleawarenumericlineeditdelegate.cpp" 
   26QgsLocaleAwareNumericLineEditDelegate::QgsLocaleAwareNumericLineEditDelegate( 
Qgis::DataType dataType, QWidget *parent )
 
   27  : QStyledItemDelegate( parent )
 
   28  , mDataType( dataType )
 
   32QWidget *QgsLocaleAwareNumericLineEditDelegate::createEditor( QWidget *parent, 
const QStyleOptionViewItem &option, 
const QModelIndex &index )
 const 
   36  auto editor = 
new QLineEdit { parent };
 
   41void QgsLocaleAwareNumericLineEditDelegate::setEditorData( QWidget *editor, 
const QModelIndex &index )
 const 
   43  QLineEdit *lineEdit { qobject_cast<QLineEdit *>( editor ) };
 
   46    const QVariant value = index.data();
 
   47    lineEdit->setText( displayText( value, QLocale() ) );
 
   51    QStyledItemDelegate::setEditorData( editor, index );
 
   55void QgsLocaleAwareNumericLineEditDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, 
const QModelIndex &index )
 const 
   57  QLineEdit *lineEdit { qobject_cast<QLineEdit *>( editor ) };
 
   60    QStyledItemDelegate::setModelData( editor, model, index );
 
   63  model->setData( index, value );
 
   66QString QgsLocaleAwareNumericLineEditDelegate::displayText( 
const QVariant &value, 
const QLocale & )
 const 
   71void QgsLocaleAwareNumericLineEditDelegate::setDataType( 
const Qgis::DataType &dataType )
 
DataType
Raster data types.
 
A custom validator which allows entry of doubles in a locale-tolerant way.
 
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
 
int significantDigits(const Qgis::DataType rasterDataType)
Returns the maximum number of significant digits a for the given rasterDataType.
 
QString displayValueWithMaximumDecimals(const Qgis::DataType dataType, const double value, bool displayTrailingZeroes)
Returns a localized string representation of the value with the appropriate number of decimals suppor...