QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Encapsulating the common utilities 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 QString | dateTimeFieldFormat (const QString &fieldFormat) |
Returns field format's name for given string representing field format defined in QgsDateTimeFieldFormatter. More... | |
static Q_INVOKABLE QString | evaluateExpression (const QgsQuickFeatureLayerPair &pair, QgsProject *activeProject, const QString &expression) |
Evaluates expression. 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 QString | fieldType (const QgsField &field) |
Returns the QVariant typeName of a field. 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 void | selectFeaturesInLayer (QgsVectorLayer *layer, const QList< int > &fids, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection) |
Selects features in a layer This method is required since QML cannot perform the conversion of a feature ID to a QgsFeatureId (i.e. 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 utilities for QgsQuick library.
Definition at line 52 of file qgsquickutils.h.
QgsQuickUtils::QgsQuickUtils | ( | QObject * | parent = nullptr | ) |
Create new utilities.
Definition at line 37 of file qgsquickutils.cpp.
|
default |
Destructor.
|
static |
Creates crs from epsg code in QML.
Makes QgsCoordinateReferenceSystem::fromEpsgId accessible for QML components.
Definition at line 46 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 354 of file qgsquickutils.cpp.
|
static |
Returns field format's name for given string representing field format defined in QgsDateTimeFieldFormatter.
fieldFormat | string representing formats from QgsDateTimeFieldFormatter. |
Definition at line 392 of file qgsquickutils.cpp.
QString QgsQuickUtils::dumpScreenInfo | ( | ) | const |
Returns a string with information about screen size and resolution - useful for debugging.
Definition at line 336 of file qgsquickutils.cpp.
|
static |
Evaluates expression.
pair | Used to define a context scope. |
activeProject | Used to define a context scope. |
expression |
Definition at line 366 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 141 of file qgsquickutils.cpp.
|
static |
Returns the QVariant typeName of a field.
This is a stable identifier (compared to the provider field name).
field | QgsField |
Definition at line 387 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 183 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 174 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 153 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 100 of file qgsquickutils.cpp.
|
static |
Returns QUrl to image from library's /images folder.
Definition at line 146 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 205 of file qgsquickutils.cpp.
|
static |
Log message in QgsMessageLog.
Definition at line 136 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 198 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 412 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 76 of file qgsquickutils.cpp.
|
static |
Selects features in a layer This method is required since QML cannot perform the conversion of a feature ID to a QgsFeatureId (i.e.
a qint64)
layer | the vector layer |
fids | the list of feature IDs |
behavior | the selection behavior |
Definition at line 379 of file qgsquickutils.cpp.
|
static |
Transforms point between different crs from QML.
Definition at line 66 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 1 of file qgsquickutils.h.