Skip to content

Commit 7bfcaf4

Browse files
committedJun 28, 2018
remove need for factory for system of measurement
1 parent 00cd4b3 commit 7bfcaf4

File tree

6 files changed

+5
-27
lines changed

6 files changed

+5
-27
lines changed
 

‎python/core/auto_additions/qgsunittypes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# The following has been generated automatically from src/core/qgsunittypes.h
2+
QgsUnitTypes.SystemOfMeasurement.baseClass = QgsUnitTypes
23
QgsUnitTypes.DistanceUnit.baseClass = QgsUnitTypes
34
QgsUnitTypes.AreaUnit.baseClass = QgsUnitTypes
45
QgsUnitTypes.AngleUnit.baseClass = QgsUnitTypes

‎src/core/qgsunittypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CORE_EXPORT QgsUnitTypes
4747
ImperialSystem, //!< British Imperial
4848
USCSSystem //!< United States customary system
4949
};
50+
Q_ENUM( SystemOfMeasurement )
5051

5152
//! Units of distance
5253
enum DistanceUnit

‎src/quickgui/plugin/qgsquickplugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ void QgsQuickPlugin::registerTypes( const char *uri )
6666
qRegisterMetaType< QgsCoordinateFormatter::FormatFlags >( "QgsCoordinateFormatter::FormatFlags" );
6767
qRegisterMetaType< QgsCoordinateFormatter::Format >( "QgsCoordinateFormatter::Format" );
6868

69+
qmlRegisterUncreatableType< QgsUnitTypes >( uri, 0, 1, "QgsUnitTypes", "Only enums from QgsUnitTypes can be used" );
70+
6971
qmlRegisterType< QgsProject >( uri, 0, 1, "Project" );
7072
qmlRegisterType< QgsQuickFeatureHighlight >( uri, 0, 1, "FeatureHighlight" );
7173
qmlRegisterType< QgsQuickCoordinateTransformer >( uri, 0, 1, "CoordinateTransformer" );

‎src/quickgui/qgsquickutils.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,6 @@ const QUrl QgsQuickUtils::getThemeIcon( const QString &name ) const
101101
return QUrl( path );
102102
}
103103

104-
QgsUnitTypes::SystemOfMeasurement QgsQuickUtils::systemOfMeasurementFactory( const QString &type )
105-
{
106-
if ( type == QStringLiteral( "Metric" ) )
107-
return QgsUnitTypes::MetricSystem;
108-
109-
if ( type == QStringLiteral( "Imperial" ) )
110-
return QgsUnitTypes::ImperialSystem;
111-
112-
if ( type == QStringLiteral( "USCS" ) )
113-
return QgsUnitTypes::USCSSystem;
114-
115-
return QgsUnitTypes::UnknownSystem;
116-
}
117-
118104
QString QgsQuickUtils::formatPoint(
119105
const QgsPoint &point,
120106
QgsCoordinateFormatter::Format format,

‎src/quickgui/qgsquickutils.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,6 @@ class QUICK_EXPORT QgsQuickUtils: public QObject
136136
*/
137137
Q_INVOKABLE const QUrl getThemeIcon( const QString &name ) const;
138138

139-
/**
140-
* QgsUnitTypes::SystemOfMeasurement factory
141-
* for input type parameter:
142-
* "Metric": QgsUnitTypes::MetricSystem
143-
* "Imperial": QgsUnitTypes::ImperialSystem
144-
* "USCS": QgsUnitTypes::USCSSystem
145-
* else: QgsUnitTypes::UnknownSystem
146-
*
147-
* \since QGIS 3.4
148-
*/
149-
Q_INVOKABLE static QgsUnitTypes::SystemOfMeasurement systemOfMeasurementFactory( const QString &type );
150-
151139
/**
152140
* \copydoc QgsCoordinateFormatter::format()
153141
*

‎tests/src/quickgui/app/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ApplicationWindow {
9494
height: scaleBar.height
9595
mapSettings: mapCanvas.mapSettings
9696
preferredWidth: scaleBar.preferredWidth
97-
systemOfMeasurement: QgsQuick.Utils.systemOfMeasurementFactory("Imperial")
97+
systemOfMeasurement: QgsQuick.QgsUnitTypes.ImperialSystem
9898
z: 1
9999
}
100100

0 commit comments

Comments
 (0)
Please sign in to comment.