Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40022 from qgis-bot/backport-39778-to-release-3_16
[Backport release-3_16] Bugfix gh39757 shared locale sort
- Loading branch information
Showing
25 changed files
with
557 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# The following has been generated automatically from src/core/qgis.h | ||
Qgis.DataType.baseClass = Qgis | ||
Qgis.PythonMacroMode.baseClass = Qgis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,3 +115,4 @@ void QgsRasterShader::readXml( const QDomElement &elem ) | |
setRasterShaderFunction( colorRampShader ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*************************************************************************** | ||
qgslocaleawarenumericlineeditdelegate.cpp - QgsLocaleAwareNumericLineEditDelegate | ||
--------------------- | ||
begin : 5.11.2020 | ||
copyright : (C) 2020 by Alessandro Pasotti | ||
email : elpaso at itopen dot it | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include <QLineEdit> | ||
|
||
#include "qgslocaleawarenumericlineeditdelegate.h" | ||
#include "qgsdoublevalidator.h" | ||
#include "qgsguiutils.h" | ||
|
||
/// @cond PRIVATE | ||
|
||
QgsLocaleAwareNumericLineEditDelegate::QgsLocaleAwareNumericLineEditDelegate( Qgis::DataType dataType, QWidget *parent ) | ||
: QStyledItemDelegate( parent ) | ||
, mDataType( dataType ) | ||
{ | ||
} | ||
|
||
QWidget *QgsLocaleAwareNumericLineEditDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const | ||
{ | ||
Q_UNUSED( option ) | ||
Q_UNUSED( index ) | ||
auto editor = new QLineEdit{ parent }; | ||
editor->setValidator( new QgsDoubleValidator( QgsGuiUtils::significantDigits( mDataType ), editor ) ); | ||
return editor; | ||
} | ||
|
||
void QgsLocaleAwareNumericLineEditDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const | ||
{ | ||
QLineEdit *lineEdit { qobject_cast<QLineEdit *>( editor ) }; | ||
if ( ! lineEdit ) | ||
{ | ||
QStyledItemDelegate::setEditorData( editor, index ); | ||
} | ||
|
||
const QVariant value { index.data( ) }; | ||
return lineEdit->setText( displayText( value, QLocale() ) ); | ||
} | ||
|
||
void QgsLocaleAwareNumericLineEditDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const | ||
{ | ||
QLineEdit *lineEdit { qobject_cast<QLineEdit *>( editor ) }; | ||
if ( ! editor ) | ||
{ | ||
QStyledItemDelegate::setModelData( editor, model, index ); | ||
} | ||
const double value { QgsDoubleValidator::toDouble( lineEdit->text() ) }; | ||
model->setData( index, value ); | ||
} | ||
|
||
QString QgsLocaleAwareNumericLineEditDelegate::displayText( const QVariant &value, const QLocale & ) const | ||
{ | ||
return QgsGuiUtils::displayValueWithMaximumDecimals( mDataType, value.toDouble( ) ); | ||
} | ||
|
||
void QgsLocaleAwareNumericLineEditDelegate::setDataType( const Qgis::DataType &dataType ) | ||
{ | ||
mDataType = dataType; | ||
} | ||
|
||
///@endcond |
Oops, something went wrong.