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 )