25 QgsLocaleAwareNumericLineEditDelegate::QgsLocaleAwareNumericLineEditDelegate(
Qgis::DataType dataType, QWidget *parent )
26 : QStyledItemDelegate( parent )
27 , mDataType( dataType )
31 QWidget *QgsLocaleAwareNumericLineEditDelegate::createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const
35 auto editor =
new QLineEdit{ parent };
40 void QgsLocaleAwareNumericLineEditDelegate::setEditorData( QWidget *editor,
const QModelIndex &index )
const
42 QLineEdit *lineEdit { qobject_cast<QLineEdit *>( editor ) };
45 const QVariant value = index.data( );
46 lineEdit->setText( displayText( value, QLocale() ) );
50 QStyledItemDelegate::setEditorData( editor, index );
54 void QgsLocaleAwareNumericLineEditDelegate::setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const
56 QLineEdit *lineEdit { qobject_cast<QLineEdit *>( editor ) };
59 QStyledItemDelegate::setModelData( editor, model, index );
62 model->setData( index, value );
65 QString QgsLocaleAwareNumericLineEditDelegate::displayText(
const QVariant &value,
const QLocale & )
const
70 void QgsLocaleAwareNumericLineEditDelegate::setDataType(
const Qgis::DataType &dataType )
DataType
Raster data types.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
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...