Skip to content
Permalink
Browse files

rename QgsSettings::enumSettingValue to enumValue

no python API break
  • Loading branch information
3nids committed Feb 26, 2018
1 parent ef4a518 commit 4b232e491732ab962bc1ce406708464d05c5e8b8
@@ -1774,7 +1774,7 @@ void QgisApp::applyDefaultSettingsToCanvas( QgsMapCanvas *canvas )
canvas->setParallelRenderingEnabled( settings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );
canvas->setMapUpdateInterval( settings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
canvas->setSegmentationTolerance( settings.value( QStringLiteral( "qgis/segmentationTolerance" ), "0.01745" ).toDouble() );
canvas->setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType( settings.enumSettingValue( QStringLiteral( "qgis/segmentationToleranceType" ), QgsAbstractGeometry::MaximumAngle ) ) );
canvas->setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType( settings.enumValue( QStringLiteral( "qgis/segmentationToleranceType" ), QgsAbstractGeometry::MaximumAngle ) ) );
}

int QgisApp::chooseReasonableDefaultIconSize() const
@@ -1984,7 +1984,7 @@ void QgisApp::createActions()
connect( mActionOpenTable, &QAction::triggered, this, [ = ]
{
QgsSettings settings;
QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumSettingValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll );
QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll );
attributeTable( initialMode );
} );
connect( mActionOpenFieldCalc, &QAction::triggered, this, &QgisApp::fieldCalculator );
@@ -76,7 +76,7 @@ void QgsClipboard::replaceWithCopyOf( QgsFeatureStore &featureStore )

QString QgsClipboard::generateClipboardText() const
{
CopyFormat format = QgsSettings().enumSettingValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT );
CopyFormat format = QgsSettings().enumValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT );

switch ( format )
{
@@ -155,7 +155,7 @@ void QgsClipboard::setSystemClipboard()

if ( mFeatureClipboard.count() < 1000 )
{
CopyFormat format = QgsSettings().enumSettingValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT );
CopyFormat format = QgsSettings().enumValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT );

QString htmlCopy;
switch ( format )
@@ -580,10 +580,10 @@ void QgsMapToolOffsetCurve::updateGeometryAndRubberBand( double offset )

QgsGeometry offsetGeom;
QgsSettings s;
QgsGeometry::JoinStyle joinStyle = s.enumSettingValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound );
QgsGeometry::JoinStyle joinStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound );
int quadSegments = s.value( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), 8 ).toInt();
double miterLimit = s.value( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), 5.0 ).toDouble();
QgsGeometry::EndCapStyle capStyle = s.enumSettingValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound );
QgsGeometry::EndCapStyle capStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound );


if ( QgsWkbTypes::geometryType( mOriginalGeometry.wkbType() ) == QgsWkbTypes::LineGeometry )
@@ -631,10 +631,10 @@ QgsOffsetUserWidget::QgsOffsetUserWidget( QWidget *parent )
mCapStyleComboBox->addItem( tr( "Square" ), QgsGeometry::CapSquare );

QgsSettings s;
QgsGeometry::JoinStyle joinStyle = s.enumSettingValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound );
QgsGeometry::JoinStyle joinStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound );
int quadSegments = s.value( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), 8 ).toInt();
double miterLimit = s.value( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), 5.0 ).toDouble();
QgsGeometry::EndCapStyle capStyle = s.enumSettingValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound );
QgsGeometry::EndCapStyle capStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound );

mJoinStyleComboBox->setCurrentIndex( mJoinStyleComboBox->findData( joinStyle ) );
mQuadrantSpinBox->setValue( quadSegments );
@@ -73,7 +73,7 @@ QgsMapToolSimplify::QgsMapToolSimplify( QgsMapCanvas *canvas )
{
QgsSettings settings;
mTolerance = settings.value( QStringLiteral( "digitizing/simplify_tolerance" ), 1 ).toDouble();
mToleranceUnits = settings.enumSettingValue( QStringLiteral( "digitizing/simplify_tolerance_units" ), QgsTolerance::LayerUnits );
mToleranceUnits = settings.enumValue( QStringLiteral( "digitizing/simplify_tolerance_units" ), QgsTolerance::LayerUnits );

mSimplifyDialog = new QgsSimplifyDialog( this, canvas->topLevelWidget() );
}
@@ -388,7 +388,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cmbAttrTableBehavior->addItem( tr( "Show all features" ), QgsAttributeTableFilterModel::ShowAll );
cmbAttrTableBehavior->addItem( tr( "Show selected features" ), QgsAttributeTableFilterModel::ShowSelected );
cmbAttrTableBehavior->addItem( tr( "Show features visible on map" ), QgsAttributeTableFilterModel::ShowVisible );
cmbAttrTableBehavior->setCurrentIndex( cmbAttrTableBehavior->findData( mSettings->enumSettingValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ) ) );
cmbAttrTableBehavior->setCurrentIndex( cmbAttrTableBehavior->findData( mSettings->enumValue( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ) ) );

mAttrTableViewComboBox->clear();
mAttrTableViewComboBox->addItem( tr( "Remember last view" ), -1 );
@@ -576,7 +576,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
spinMaxThreads->setValue( QgsApplication::maxThreads() );

// Default simplify drawing configuration
mSimplifyDrawingGroupBox->setChecked( mSettings->enumSettingValue( QStringLiteral( "/qgis/simplifyDrawingHints" ), QgsVectorSimplifyMethod::GeometrySimplification ) != QgsVectorSimplifyMethod::NoSimplification );
mSimplifyDrawingGroupBox->setChecked( mSettings->enumValue( QStringLiteral( "/qgis/simplifyDrawingHints" ), QgsVectorSimplifyMethod::GeometrySimplification ) != QgsVectorSimplifyMethod::NoSimplification );
mSimplifyDrawingSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/simplifyDrawingTol" ), Qgis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat() );
mSimplifyDrawingAtProvider->setChecked( !mSettings->value( QStringLiteral( "/qgis/simplifyLocal" ), true ).toBool() );

@@ -870,7 +870,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mDefaultSnapModeComboBox->setCurrentIndex( mDefaultSnapModeComboBox->findData( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_type" ), QgsSnappingConfig::Vertex ).toInt() ) );
mDefaultSnappingToleranceSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), Qgis::DEFAULT_SNAP_TOLERANCE ).toDouble() );
mSearchRadiusVertexEditSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/digitizing/search_radius_vertex_edit" ), 10 ).toDouble() );
QgsTolerance::UnitType defSnapUnits = mSettings->enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
QgsTolerance::UnitType defSnapUnits = mSettings->enumValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
if ( defSnapUnits == QgsTolerance::ProjectUnits || defSnapUnits == QgsTolerance::LayerUnits )
{
index = mDefaultSnappingToleranceComboBox->findText( tr( "map units" ) );
@@ -228,8 +228,8 @@ class CORE_EXPORT QgsSettings : public QObject
* \note The enum needs to be declared with Q_ENUM, and flags with Q_FLAG (not Q_FLAGS).
*/
template <class T>
T enumSettingValue( const QString &key, const T &defaultValue,
const Section section = NoSection, bool flag = false ) const
T enumValue( const QString &key, const T &defaultValue,
const Section section = NoSection, bool flag = false ) const
{
T v;
if ( !flag )
@@ -118,16 +118,16 @@ void QgsSnappingConfig::reset()
{
// get defaults values. They are both used for standard and advanced configuration (per layer)
bool enabled = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool();
SnappingMode mode = QgsSettings().enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), AllLayers );
SnappingMode mode = QgsSettings().enumValue( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), AllLayers );
if ( mode == 0 )
{
// backward compatibility with QGIS 2.x
// could be removed in 3.4+
mode = AllLayers;
}
SnappingType type = QgsSettings().enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snap_type" ), Vertex );
SnappingType type = QgsSettings().enumValue( QStringLiteral( "/qgis/digitizing/default_snap_type" ), Vertex );
double tolerance = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), Qgis::DEFAULT_SNAP_TOLERANCE ).toDouble();
QgsTolerance::UnitType units = QgsSettings().enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
QgsTolerance::UnitType units = QgsSettings().enumValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );

// assign main (standard) config
mEnabled = enabled;
@@ -370,7 +370,7 @@ bool QgsSnappingConfig::addLayers( const QList<QgsMapLayer *> &layers )
bool enabled = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), true ).toBool();
SnappingType type = ( SnappingType )QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_type" ), Vertex ).toInt();
double tolerance = QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance" ), Qgis::DEFAULT_SNAP_TOLERANCE ).toDouble();
QgsTolerance::UnitType units = QgsSettings().enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
QgsTolerance::UnitType units = QgsSettings().enumValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );

Q_FOREACH ( QgsMapLayer *ml, layers )
{
@@ -73,7 +73,7 @@ double QgsTolerance::vertexSearchRadius( const QgsMapSettings &mapSettings )
{
QgsSettings settings;
double tolerance = settings.value( QStringLiteral( "qgis/digitizing/search_radius_vertex_edit" ), 10 ).toDouble();
UnitType units = settings.enumSettingValue( QStringLiteral( "qgis/digitizing/search_radius_vertex_edit_unit" ), QgsTolerance::Pixels );
UnitType units = settings.enumValue( QStringLiteral( "qgis/digitizing/search_radius_vertex_edit_unit" ), QgsTolerance::Pixels );
if ( units == LayerUnits )
units = ProjectUnits;
return toleranceInProjectUnits( tolerance, nullptr, mapSettings, units );
@@ -83,15 +83,15 @@ double QgsTolerance::vertexSearchRadius( QgsMapLayer *layer, const QgsMapSetting
{
QgsSettings settings;
double tolerance = settings.value( QStringLiteral( "qgis/digitizing/search_radius_vertex_edit" ), 10 ).toDouble();
UnitType units = settings.enumSettingValue( QStringLiteral( "qgis/digitizing/search_radius_vertex_edit_unit" ), QgsTolerance::Pixels );
UnitType units = settings.enumValue( QStringLiteral( "qgis/digitizing/search_radius_vertex_edit_unit" ), QgsTolerance::Pixels );
return toleranceInMapUnits( tolerance, layer, mapSettings, units );
}

double QgsTolerance::defaultTolerance( QgsMapLayer *layer, const QgsMapSettings &mapSettings )
{
QgsSettings settings;
double tolerance = settings.value( QStringLiteral( "qgis/digitizing/default_snapping_tolerance" ), Qgis::DEFAULT_SNAP_TOLERANCE ).toDouble();
UnitType units = settings.enumSettingValue( QStringLiteral( "qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
UnitType units = settings.enumValue( QStringLiteral( "qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
return toleranceInMapUnits( tolerance, layer, mapSettings, units );
}

@@ -162,8 +162,8 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,

// Default simplify drawing settings
QgsSettings settings;
mSimplifyMethod.setSimplifyHints( settings.enumSettingValue( QStringLiteral( "qgis/simplifyDrawingHints" ), mSimplifyMethod.simplifyHints(), QgsSettings::NoSection, true ) );
mSimplifyMethod.setSimplifyAlgorithm( settings.enumSettingValue( QStringLiteral( "qgis/simplifyAlgorithm" ), mSimplifyMethod.simplifyAlgorithm() ) );
mSimplifyMethod.setSimplifyHints( settings.enumValue( QStringLiteral( "qgis/simplifyDrawingHints" ), mSimplifyMethod.simplifyHints(), QgsSettings::NoSection, true ) );
mSimplifyMethod.setSimplifyAlgorithm( settings.enumValue( QStringLiteral( "qgis/simplifyAlgorithm" ), mSimplifyMethod.simplifyAlgorithm() ) );
mSimplifyMethod.setThreshold( settings.value( QStringLiteral( "qgis/simplifyDrawingTol" ), mSimplifyMethod.threshold() ).toFloat() );
mSimplifyMethod.setForceLocalOptimization( settings.value( QStringLiteral( "qgis/simplifyLocal" ), mSimplifyMethod.forceLocalOptimization() ).toBool() );
mSimplifyMethod.setMaximumScale( settings.value( QStringLiteral( "qgis/simplifyMaxScale" ), mSimplifyMethod.maximumScale() ).toFloat() );
@@ -42,7 +42,7 @@ QgsLayoutItemPropertiesDialog::QgsLayoutItemPropertiesDialog( QWidget *parent, Q
QgsSettings settings;
double lastWidth = settings.value( QStringLiteral( "LayoutDesigner/lastItemWidth" ), QStringLiteral( "50" ) ).toDouble();
double lastHeight = settings.value( QStringLiteral( "LayoutDesigner/lastItemHeight" ), QStringLiteral( "50" ) ).toDouble();
QgsUnitTypes::LayoutUnit lastSizeUnit = settings.enumSettingValue( QStringLiteral( "LayoutDesigner/lastSizeUnit" ), QgsUnitTypes::LayoutMillimeters );
QgsUnitTypes::LayoutUnit lastSizeUnit = settings.enumValue( QStringLiteral( "LayoutDesigner/lastSizeUnit" ), QgsUnitTypes::LayoutMillimeters );
setItemSize( QgsLayoutSize( lastWidth, lastHeight, lastSizeUnit ) );

mPosUnitsComboBox->linkToWidget( mXPosSpin );
@@ -1410,7 +1410,7 @@ QgsColorTextWidget::QgsColorTextWidget( QWidget *parent )

//restore format setting
QgsSettings settings;
mFormat = settings.enumSettingValue( QStringLiteral( "ColorWidgets/textWidgetFormat" ), HexRgb );
mFormat = settings.enumValue( QStringLiteral( "ColorWidgets/textWidgetFormat" ), HexRgb );

updateText();
}
@@ -151,7 +151,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget *parent )
//segmentation parameters
QgsSettings settings;
double segmentationTolerance = settings.value( QStringLiteral( "qgis/segmentationTolerance" ), "0.01745" ).toDouble();
QgsAbstractGeometry::SegmentationToleranceType toleranceType = settings.enumSettingValue( QStringLiteral( "qgis/segmentationToleranceType" ), QgsAbstractGeometry::MaximumAngle );
QgsAbstractGeometry::SegmentationToleranceType toleranceType = settings.enumValue( QStringLiteral( "qgis/segmentationToleranceType" ), QgsAbstractGeometry::MaximumAngle );
mSettings.setSegmentationTolerance( segmentationTolerance );
mSettings.setSegmentationToleranceType( toleranceType );

@@ -101,7 +101,7 @@ QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, i
if ( mode == DefaultQgsSetting )
{
QgsSettings settings;
mode = settings.enumSettingValue( QStringLiteral( "Map/identifyMode" ), ActiveLayer );
mode = settings.enumValue( QStringLiteral( "Map/identifyMode" ), ActiveLayer );
}

if ( mode == LayerSelection )
@@ -71,7 +71,7 @@ QgsGrassOptions::QgsGrassOptions( QWidget *parent )
mModulesDebugCheckBox->setChecked( QgsGrass::modulesDebug() );

// Browser
QgsRasterProjector::Precision crsTransform = settings.enumSettingValue( mImportSettingsPath + "/crsTransform", QgsRasterProjector::Approximate );
QgsRasterProjector::Precision crsTransform = settings.enumValue( mImportSettingsPath + "/crsTransform", QgsRasterProjector::Approximate );
mCrsTransformationComboBox->addItem( QgsRasterProjector::precisionLabel( QgsRasterProjector::Approximate ), QgsRasterProjector::Approximate );
mCrsTransformationComboBox->addItem( QgsRasterProjector::precisionLabel( QgsRasterProjector::Exact ), QgsRasterProjector::Exact );
mCrsTransformationComboBox->setCurrentIndex( mCrsTransformationComboBox->findData( crsTransform ) );
@@ -846,7 +846,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData *data, Qt::DropAction )
projector->destExtentSize( rasterProvider->extent(), rasterProvider->xSize(), rasterProvider->ySize(),
newExtent, newXSize, newYSize );
}
QgsRasterProjector::Precision precision = settings.enumSettingValue( QStringLiteral( "GRASS/browser/import/crsTransform" ), QgsRasterProjector::Approximate );
QgsRasterProjector::Precision precision = settings.enumValue( QStringLiteral( "GRASS/browser/import/crsTransform" ), QgsRasterProjector::Approximate );
projector->setPrecision( precision );

pipe->set( projector );
@@ -70,7 +70,7 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString &connName

cb_useEstimatedMetadata->setChecked( settings.value( key + "/estimatedMetadata", false ).toBool() );

cbxSSLmode->setCurrentIndex( cbxSSLmode->findData( settings.enumSettingValue( key + "/sslmode", QgsDataSourceUri::SslPrefer ) ) );
cbxSSLmode->setCurrentIndex( cbxSSLmode->findData( settings.enumValue( key + "/sslmode", QgsDataSourceUri::SslPrefer ) ) );

if ( settings.value( key + "/saveUsername" ).toString() == QLatin1String( "true" ) )
{

0 comments on commit 4b232e4

Please sign in to comment.
You can’t perform that action at this time.