QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
Encapsulating the common utilies for QgsQuick library. More...
#include <qgsquickutils.h>
Public Member Functions | |
QgsQuickUtils (QObject *parent=nullptr) | |
Create new utilities. More... | |
~QgsQuickUtils ()=default | |
Destructor. More... | |
QString | dumpScreenInfo () const |
Returns a string with information about screen size and resolution - useful for debugging. More... | |
qreal | screenDensity () const |
"dp" is useful for building building components that work well with different screen densities. More... | |
Static Public Member Functions | |
static Q_INVOKABLE QgsCoordinateReferenceSystem | coordinateReferenceSystemFromEpsgId (long epsg) |
Creates crs from epsg code in QML. More... | |
static Q_INVOKABLE QgsPoint | coordinateToPoint (const QGeoCoordinate &coor) |
Converts QGeoCoordinate to QgsPoint. More... | |
static Q_INVOKABLE QVariantMap | createValueRelationCache (const QVariantMap &config, const QgsFeature &formFeature=QgsFeature()) |
Creates a cache for a value relation field. More... | |
static Q_INVOKABLE QgsQuickFeatureLayerPair | featureFactory (const QgsFeature &feature, QgsVectorLayer *layer=nullptr) |
QgsQuickFeatureLayerPair factory for tuple of QgsFeature and QgsVectorLayer used in QgsQUick library. More... | |
static Q_INVOKABLE bool | fileExists (const QString &path) |
Returns whether file on path exists. More... | |
static Q_INVOKABLE QString | formatDistance (double distance, QgsUnitTypes::DistanceUnit units, int decimals, QgsUnitTypes::SystemOfMeasurement destSystem=QgsUnitTypes::MetricSystem) |
Converts distance to human readable distance. More... | |
static Q_INVOKABLE QString | formatPoint (const QgsPoint &point, QgsCoordinateFormatter::Format format=QgsCoordinateFormatter::FormatPair, int decimals=3, QgsCoordinateFormatter::FormatFlags flags=QgsCoordinateFormatter::FlagDegreesUseStringSuffix) |
Formats a point according to the specified parameters. More... | |
static Q_INVOKABLE const QUrl | getEditorComponentSource (const QString &widgetName) |
Returns url to field editor component for a feature form. More... | |
static Q_INVOKABLE QString | getRelativePath (const QString &path, const QString &prefixPath) |
Returns relative path of the file to given prefixPath. More... | |
static Q_INVOKABLE const QUrl | getThemeIcon (const QString &name) |
Returns QUrl to image from library's /images folder. More... | |
static void | humanReadableDistance (double srcDistance, QgsUnitTypes::DistanceUnit srcUnits, QgsUnitTypes::SystemOfMeasurement destSystem, double &destDistance, QgsUnitTypes::DistanceUnit &destUnits) |
Converts distance to human readable distance in destination system of measurement. More... | |
static Q_INVOKABLE void | logMessage (const QString &message, const QString &tag=QString("QgsQuick"), Qgis::MessageLevel level=Qgis::Warning) |
Log message in QgsMessageLog. More... | |
static Q_INVOKABLE QgsPoint | point (double x, double y, double z=std::numeric_limits< double >::quiet_NaN(), double m=std::numeric_limits< double >::quiet_NaN()) |
Creates QgsPoint in QML. More... | |
static Q_INVOKABLE QgsPointXY | pointXY (double x, double y) |
Creates QgsPointXY in QML. More... | |
static Q_INVOKABLE bool | removeFile (const QString &filePath) |
Deletes file from a given path. More... | |
static Q_INVOKABLE double | screenUnitsToMeters (QgsQuickMapSettings *mapSettings, int baseLengthPixels) |
Calculates the distance in meter representing baseLengthPixels pixels on the screen based on the current map settings. More... | |
static Q_INVOKABLE QgsPointXY | transformPoint (const QgsCoordinateReferenceSystem &srcCrs, const QgsCoordinateReferenceSystem &destCrs, const QgsCoordinateTransformContext &context, const QgsPointXY &srcPoint) |
Transforms point between different crs from QML. More... | |
Properties | |
qreal | dp |
"dp" is useful for building building components that work well with different screen densities. More... | |
Encapsulating the common utilies for QgsQuick library.
Definition at line 51 of file qgsquickutils.h.
QgsQuickUtils::QgsQuickUtils | ( | QObject * | parent = nullptr | ) |
Create new utilities.
Definition at line 36 of file qgsquickutils.cpp.
|
default |
Destructor.
|
static |
Creates crs from epsg code in QML.
Makes QgsCoordinateReferenceSystem::fromEpsgId accessible for QML components.
Definition at line 45 of file qgsquickutils.cpp.
|
static |
|
static |
Creates a cache for a value relation field.
This can be used to keep the value map in the local memory if doing multiple lookups in a loop.
config | The widget configuration |
formFeature | The feature currently being edited with current attribute values |
Definition at line 334 of file qgsquickutils.cpp.
QString QgsQuickUtils::dumpScreenInfo | ( | ) | const |
Returns a string with information about screen size and resolution - useful for debugging.
Definition at line 316 of file qgsquickutils.cpp.
|
static |
QgsQuickFeatureLayerPair factory for tuple of QgsFeature and QgsVectorLayer used in QgsQUick library.
feature | QgsFeature linked to new QgsQuickFeature instance. |
layer | QgsVectorLayer which the feature belongs to, optional. |
Definition at line 122 of file qgsquickutils.cpp.
|
static |
|
static |
Converts distance to human readable distance.
This is useful for scalebar texts or output of the GPS accuracy
The resulting units are determined automatically, based on requested system of measurement. e.g. 1222.234 m is converted to 1.2 km
distance | distance in units |
units | units of dist |
decimals | decimal to use |
destSystem | system of measurement of the result |
Definition at line 163 of file qgsquickutils.cpp.
|
static |
Formats a point according to the specified parameters.
The format argument indicates the desired display format for the coordinate.
The precision argument gives the number of decimal places to include for coordinates.
Optional flags can be specified to control the output format.
Definition at line 154 of file qgsquickutils.cpp.
|
static |
Returns url to field editor component for a feature form.
If the widgetName does not match any supported widget, text edit is returned.
widgetName | name of the attribute field widget |
Definition at line 134 of file qgsquickutils.cpp.
|
static |
Returns relative path of the file to given prefixPath.
If prefixPath does not match a path parameter, returns an empty string. If a path starts with "file://", this prefix is ignored.
path | Absolute path to file |
prefixPath |
Definition at line 99 of file qgsquickutils.cpp.
|
static |
Returns QUrl to image from library's /images folder.
Definition at line 127 of file qgsquickutils.cpp.
|
static |
Converts distance to human readable distance in destination system of measurement.
srcDistance | distance in units |
srcUnits | units of dist |
destSystem | system of measurement of the result |
destDistance | output: distance if desired system of measurement |
destUnits | output: unit of destDistance |
Definition at line 185 of file qgsquickutils.cpp.
|
static |
Log message in QgsMessageLog.
Definition at line 117 of file qgsquickutils.cpp.
|
static |
|
static |
|
static |
Deletes file from a given path.
filePath | Absolute path to file |
true
, if removal was successful, otherwise false
.Definition at line 178 of file qgsquickutils.cpp.
qreal QgsQuickUtils::screenDensity | ( | ) | const |
"dp" is useful for building building components that work well with different screen densities.
It stands for density-independent pixels. A width of 10dp is going to be the same physical size on all screens regardless their density. In QML code, all values are specified in screen pixels, so in order to set a width of 10dp, one would use the following code: "width: 10 * QgsQuick.Utils.dp"
1dp is approximately 0.16mm. When screen has 160 DPI (baseline), the value of "dp" is 1. On high DPI screen the value will be greater, e.g. 1.5.
This is a readonly property.
Definition at line 346 of file qgsquickutils.cpp.
|
static |
Calculates the distance in meter representing baseLengthPixels pixels on the screen based on the current map settings.
Definition at line 75 of file qgsquickutils.cpp.
|
static |
Transforms point between different crs from QML.
Definition at line 65 of file qgsquickutils.cpp.
|
read |
"dp" is useful for building building components that work well with different screen densities.
It stands for density-independent pixels. A width of 10dp is going to be the same physical size on all screens regardless their density. In QML code, all values are specified in screen pixels, so in order to set a width of 10dp, one would use the following code: "width: 10 * QgsQuick.Utils.dp"
1dp is approximately 0.16mm. When screen has 160 DPI (baseline), the value of "dp" is 1. On high DPI screen the value will be greater, e.g. 1.5.
This is a readonly property.
Definition at line 66 of file qgsquickutils.h.