Skip to content
Permalink
Browse files

use Qgsettins::enumSettingValue where possible

  • Loading branch information
3nids committed Feb 19, 2018
1 parent 4d6b0e6 commit 1a1b197cedcbd289ff06b1e4ec8bb94e0f0bbc57
@@ -28,7 +28,6 @@
%Include qgsdatadefinedsizelegend.sip
%Include qgsdataitemprovider.sip
%Include qgsdataitemproviderregistry.sip
%Include qgsdatasourceuri.sip
%Include qgsdatetimestatisticalsummary.sip
%Include qgsdatumtransform.sip
%Include qgsdbfilterproxymodel.sip
@@ -127,7 +126,6 @@
%Include qgsvectorlayerundocommand.sip
%Include qgsvectorlayerundopassthroughcommand.sip
%Include qgsvectorlayerutils.sip
%Include qgsvectorsimplifymethod.sip
%Include qgsvirtuallayerdefinition.sip
%Include qgsvirtuallayerdefinitionutils.sip
%Include qgsmapthemecollection.sip
@@ -258,7 +256,6 @@
%Include symbology/qgsgeometrygeneratorsymbollayer.sip
%Include layertree/qgslayertreeutils.sip
%Include locator/qgslocatorcontext.sip
%Include geometry/qgsabstractgeometry.sip
%Include geometry/qgsbox3d.sip
%Include geometry/qgscircularstring.sip
%Include geometry/qgscircle.sip
@@ -305,6 +302,7 @@
%Include qgscredentials.sip
%Include qgsdataitem.sip
%Include qgsdataprovider.sip
%Include qgsdatasourceuri.sip
%Include qgsfeature.sip
%Include qgsfeedback.sip
%Include qgsfield.sip
@@ -353,6 +351,7 @@
%Include qgsvectorlayerfeaturecounter.sip
%Include qgsvectorlayerjoinbuffer.sip
%Include qgsvectorlayertools.sip
%Include qgsvectorsimplifymethod.sip
%Include qgssettings.sip
%Include annotations/qgsannotation.sip
%Include annotations/qgsannotationmanager.sip
@@ -370,8 +369,9 @@
%Include raster/qgsrasterlayer.sip
%Include raster/qgsrasterdataprovider.sip
%Include raster/qgsrasterinterface.sip
%Include geometry/qgspoint.sip
%Include geometry/qgsabstractgeometry.sip
%Include geometry/qgsgeometry.sip
%Include geometry/qgspoint.sip
%Include geocms/geonode/qgsgeonoderequest.sip
%Include gps/qgsgpsconnection.sip
%Include gps/qgsgpsdetector.sip
@@ -80,7 +80,7 @@ The Qgis class provides global constants for use throughout the application.

static const double DEFAULT_SNAP_TOLERANCE;

static const int DEFAULT_SNAP_UNITS;
static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS;
};


@@ -9,6 +9,7 @@




class QgsSnappingConfig
{
%Docstring
@@ -9,6 +9,7 @@




class QgsTolerance
{
%Docstring
@@ -8,6 +8,7 @@




class QgsVectorSimplifyMethod
{
%Docstring
@@ -539,6 +539,14 @@ of colors.
%End
public:

enum ColorTextFormat
{
HexRgb,
HexRgbA,
Rgb,
Rgba
};

QgsColorTextWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Construct a new color line edit widget.
@@ -1770,7 +1770,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.value( QStringLiteral( "qgis/segmentationToleranceType" ), "0" ).toInt() ) );
canvas->setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType( settings.enumSettingValue( QStringLiteral( "qgis/segmentationToleranceType" ), QgsAbstractGeometry::MaximumAngle ) ) );
}

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

QString QgsClipboard::generateClipboardText() const
{
QgsSettings settings;
CopyFormat format = AttributesWithWKT;
if ( settings.contains( QStringLiteral( "/qgis/copyFeatureFormat" ) ) )
format = static_cast< CopyFormat >( settings.value( QStringLiteral( "qgis/copyFeatureFormat" ), true ).toInt() );
else
{
//old format setting
format = settings.value( QStringLiteral( "qgis/copyGeometryAsWKT" ), true ).toBool() ? AttributesWithWKT : AttributesOnly;
}
CopyFormat format = QgsSettings().enumSettingValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT );

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

if ( mFeatureClipboard.count() < 1000 )
{
QgsSettings settings;
CopyFormat format = AttributesWithWKT;
if ( settings.contains( QStringLiteral( "/qgis/copyFeatureFormat" ) ) )
{
format = static_cast< CopyFormat >( settings.value( QStringLiteral( "qgis/copyFeatureFormat" ), true ).toInt() );
}
CopyFormat format = QgsSettings().enumSettingValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT );

QString htmlCopy;
switch ( format )
@@ -58,6 +58,7 @@ class APP_EXPORT QgsClipboard : public QObject
AttributesWithWKT, //!< Tab delimited text, with geometry in WKT format
GeoJSON, //!< GeoJSON FeatureCollection format
};
Q_ENUM( CopyFormat )

/**
* Constructor for the clipboard.
@@ -115,6 +115,7 @@ class APP_EXPORT QgsCustomization : public QObject
User = 1, // Set by user
Default = 2 // Default customization loaded and set
};
Q_ENUM( Status )

//! Returns the instance pointer, creating the object on the first call
static QgsCustomization *instance();
@@ -580,10 +580,10 @@ void QgsMapToolOffsetCurve::updateGeometryAndRubberBand( double offset )

QgsGeometry offsetGeom;
QgsSettings s;
QgsGeometry::JoinStyle joinStyle = static_cast< QgsGeometry::JoinStyle >( s.value( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound ).toInt() );
QgsGeometry::JoinStyle joinStyle = s.enumSettingValue( 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 = static_cast< QgsGeometry::EndCapStyle >( s.value( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound ).toInt() );
QgsGeometry::EndCapStyle capStyle = s.enumSettingValue( 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 = static_cast< QgsGeometry::JoinStyle >( s.value( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound ).toInt() );
QgsGeometry::JoinStyle joinStyle = s.enumSettingValue( 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 = static_cast< QgsGeometry::EndCapStyle >( s.value( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound ).toInt() );
QgsGeometry::EndCapStyle capStyle = s.enumSettingValue( 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 = ( QgsTolerance::UnitType ) settings.value( QStringLiteral( "digitizing/simplify_tolerance_units" ), 0 ).toInt();
mToleranceUnits = settings.enumSettingValue( 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->value( QStringLiteral( "/qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ).toInt() ) );
cmbAttrTableBehavior->setCurrentIndex( cmbAttrTableBehavior->findData( mSettings->enumSettingValue( 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->value( QStringLiteral( "/qgis/simplifyDrawingHints" ), ( int )QgsVectorSimplifyMethod::GeometrySimplification ).toInt() != QgsVectorSimplifyMethod::NoSimplification );
mSimplifyDrawingGroupBox->setChecked( mSettings->enumSettingValue( 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() );

@@ -633,11 +633,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mComboCopyFeatureFormat->addItem( tr( "Plain text, no geometry" ), QgsClipboard::AttributesOnly );
mComboCopyFeatureFormat->addItem( tr( "Plain text, WKT geometry" ), QgsClipboard::AttributesWithWKT );
mComboCopyFeatureFormat->addItem( tr( "GeoJSON" ), QgsClipboard::GeoJSON );
if ( mSettings->contains( QStringLiteral( "/qgis/copyFeatureFormat" ) ) )
mComboCopyFeatureFormat->setCurrentIndex( mComboCopyFeatureFormat->findData( mSettings->value( QStringLiteral( "/qgis/copyFeatureFormat" ), true ).toInt() ) );
else
mComboCopyFeatureFormat->setCurrentIndex( mComboCopyFeatureFormat->findData( mSettings->value( QStringLiteral( "/qgis/copyGeometryAsWKT" ), true ).toBool() ?
QgsClipboard::AttributesWithWKT : QgsClipboard::AttributesOnly ) );
mComboCopyFeatureFormat->setCurrentIndex( mComboCopyFeatureFormat->findData( mSettings->value( QStringLiteral( "/qgis/copyFeatureFormat" ), QgsClipboard::AttributesWithWKT ) ) );
leNullValue->setText( QgsApplication::nullRepresentation() );
cbxIgnoreShapeEncoding->setChecked( mSettings->value( QStringLiteral( "/qgis/ignoreShapeEncoding" ), true ).toBool() );

@@ -874,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() );
int defSnapUnits = mSettings->value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS ).toInt();
QgsTolerance::UnitType defSnapUnits = mSettings->enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );
if ( defSnapUnits == QgsTolerance::ProjectUnits || defSnapUnits == QgsTolerance::LayerUnits )
{
index = mDefaultSnappingToleranceComboBox->findText( tr( "map units" ) );
@@ -578,6 +578,7 @@ SET(QGIS_CORE_MOC_HDRS
qgscredentials.h
qgsdataitem.h
qgsdataprovider.h
qgsdatasourceuri.h
qgsdbfilterproxymodel.h
qgsfeature.h
qgsfeedback.h
@@ -639,6 +640,7 @@ SET(QGIS_CORE_MOC_HDRS
qgsvectorlayerjoinbuffer.h
qgsvectorlayerrenderer.h
qgsvectorlayertools.h
qgsvectorsimplifymethod.h
qgsmapthemecollection.h
qgswebpage.h
qgswebview.h
@@ -670,8 +672,9 @@ SET(QGIS_CORE_MOC_HDRS
raster/qgsrasterinterface.h
raster/qgsrasterlayerrenderer.h

geometry/qgspoint.h
geometry/qgsabstractgeometry.h
geometry/qgsgeometry.h
geometry/qgspoint.h

geocms/geonode/qgsgeonoderequest.h

@@ -809,7 +812,6 @@ SET(QGIS_CORE_HDRS
qgsdatadefinedsizelegend.h
qgsdataitemprovider.h
qgsdataitemproviderregistry.h
qgsdatasourceuri.h
qgsdatetimestatisticalsummary.h
qgsdatumtransform.h
qgsdbfilterproxymodel.h
@@ -924,7 +926,6 @@ SET(QGIS_CORE_HDRS
qgsvectorlayerundocommand.h
qgsvectorlayerundopassthroughcommand.h
qgsvectorlayerutils.h
qgsvectorsimplifymethod.h
qgsvirtuallayerdefinition.h
qgsvirtuallayerdefinitionutils.h
qgsmapthemecollection.h
@@ -1079,7 +1080,6 @@ SET(QGIS_CORE_HDRS

locator/qgslocatorcontext.h

geometry/qgsabstractgeometry.h
geometry/qgsbox3d.h
geometry/qgscircularstring.h
geometry/qgscircle.h
@@ -52,6 +52,7 @@ typedef QVector< QVector< QVector< QgsPoint > > > QgsCoordinateSequence;
*/
class CORE_EXPORT QgsAbstractGeometry
{
Q_GADGET

#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
@@ -101,6 +102,7 @@ class CORE_EXPORT QgsAbstractGeometry
* curve and closest point on its approximation. */
MaximumDifference
};
Q_ENUM( SegmentationToleranceType )

/**
* Constructor for QgsAbstractGeometry.
@@ -86,7 +86,7 @@ const double Qgis::DEFAULT_Z_COORDINATE = 0.0;

const double Qgis::DEFAULT_SNAP_TOLERANCE = 12.0;

const int Qgis::DEFAULT_SNAP_UNITS = 1;
const QgsTolerance::UnitType Qgis::DEFAULT_SNAP_UNITS = QgsTolerance::Pixels;

#ifdef Q_OS_WIN
const double Qgis::UI_SCALE_FACTOR = 1.5;
@@ -19,7 +19,6 @@
#define QGIS_H

#include <QEvent>
#include "qgis_sip.h"
#include <QString>
#include <QRegExp>
#include <QMetaType>
@@ -35,6 +34,7 @@
#include <cmath>
#include <qnumeric.h>

#include "qgstolerance.h"
#include "qgswkbtypes.h"
#include "qgis_core.h"
#include "qgis_sip.h"
@@ -160,7 +160,7 @@ class CORE_EXPORT Qgis
* Default snapping distance units.
* \since QGIS 3.0
*/
static const int DEFAULT_SNAP_UNITS;
static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS;
};

// hack to workaround warnings when casting void pointers
@@ -36,6 +36,7 @@
// (Radim Blazek 4/2012)
class CORE_EXPORT QgsDataSourceUri
{
Q_GADGET
public:
enum SslMode
{
@@ -46,6 +47,7 @@ class CORE_EXPORT QgsDataSourceUri
SslVerifyCa,
SslVerifyFull
};
Q_ENUM( SslMode )

//! default constructor
QgsDataSourceUri();
@@ -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 = static_cast<SnappingMode>( QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_mode" ), AllLayers ).toInt() );
SnappingMode mode = QgsSettings().enumSettingValue( 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 = static_cast<SnappingType>( QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snap_type" ), Vertex ).toInt() );
SnappingType type = QgsSettings().enumSettingValue( 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 = static_cast<QgsTolerance::UnitType>( QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS ).toInt() );
QgsTolerance::UnitType units = QgsSettings().enumSettingValue( 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 = ( QgsTolerance::UnitType )QgsSettings().value( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS ).toInt();
QgsTolerance::UnitType units = QgsSettings().enumSettingValue( QStringLiteral( "/qgis/digitizing/default_snapping_tolerance_unit" ), Qgis::DEFAULT_SNAP_UNITS );

Q_FOREACH ( QgsMapLayer *ml, layers )
{

0 comments on commit 1a1b197

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