QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Member Functions | Static Public Member Functions | Properties | List of all members
QgsQuickUtils Class Reference

Encapsulating the common utilies for QgsQuick library. More...

#include <qgsquickutils.h>

Inheritance diagram for QgsQuickUtils:
Inheritance graph
[legend]

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 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 getFileName (const QString &path)
 Extracts filename from path. 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 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...
 

Detailed Description

Encapsulating the common utilies for QgsQuick library.

Note
QML Type: Utils (Singleton)
Since
QGIS 3.2

Definition at line 51 of file qgsquickutils.h.

Constructor & Destructor Documentation

QgsQuickUtils::QgsQuickUtils ( QObject *  parent = nullptr)

Create new utilities.

Definition at line 32 of file qgsquickutils.cpp.

QgsQuickUtils::~QgsQuickUtils ( )
default

Destructor.

Member Function Documentation

QgsCoordinateReferenceSystem QgsQuickUtils::coordinateReferenceSystemFromEpsgId ( long  epsg)
static

Creates crs from epsg code in QML.

Makes QgsCoordinateReferenceSystem::fromEpsgId accessible for QML components.

Since
QGIS 3.4

Definition at line 41 of file qgsquickutils.cpp.

QgsPoint QgsQuickUtils::coordinateToPoint ( const QGeoCoordinate &  coor)
static

Converts QGeoCoordinate to QgsPoint.

Since
QGIS 3.4

Definition at line 56 of file qgsquickutils.cpp.

QString QgsQuickUtils::dumpScreenInfo ( ) const

Returns a string with information about screen size and resolution - useful for debugging.

Definition at line 294 of file qgsquickutils.cpp.

QgsQuickFeatureLayerPair QgsQuickUtils::featureFactory ( const QgsFeature feature,
QgsVectorLayer layer = nullptr 
)
static

QgsQuickFeatureLayerPair factory for tuple of QgsFeature and QgsVectorLayer used in QgsQUick library.

Parameters
featureQgsFeature linked to new QgsQuickFeature instance.
layerQgsVectorLayer which the feature belongs to, optional.
Since
QGIS 3.4

Definition at line 107 of file qgsquickutils.cpp.

bool QgsQuickUtils::fileExists ( const QString &  path)
static

Returns whether file on path exists.

Since
QGIS 3.4

Definition at line 88 of file qgsquickutils.cpp.

QString QgsQuickUtils::formatDistance ( double  distance,
QgsUnitTypes::DistanceUnit  units,
int  decimals,
QgsUnitTypes::SystemOfMeasurement  destSystem = QgsUnitTypes::MetricSystem 
)
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

Parameters
distancedistance in units
unitsunits of dist
decimalsdecimal to use
destSystemsystem of measurement of the result
Returns
string represetation of dist in desired destSystem. For distance less than 0, 0 is returned.
Since
QGIS 3.4

Definition at line 147 of file qgsquickutils.cpp.

QString QgsQuickUtils::formatPoint ( const QgsPoint point,
QgsCoordinateFormatter::Format  format = QgsCoordinateFormatter::FormatPair,
int  decimals = 3,
QgsCoordinateFormatter::FormatFlags  flags = QgsCoordinateFormatter::FlagDegreesUseStringSuffix 
)
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.

Since
QGIS 3.4

Definition at line 138 of file qgsquickutils.cpp.

const QUrl QgsQuickUtils::getEditorComponentSource ( const QString &  widgetName)
static

Returns url to field editor component for a feature form.

If the widgetName does not match any supported widget, text edit is returned.

Parameters
widgetNamename of the attribute field widget
Since
QGIS 3.4

Definition at line 119 of file qgsquickutils.cpp.

QString QgsQuickUtils::getFileName ( const QString &  path)
static

Extracts filename from path.

Since
QGIS 3.4

Definition at line 95 of file qgsquickutils.cpp.

const QUrl QgsQuickUtils::getThemeIcon ( const QString &  name)
static

Returns QUrl to image from library's /images folder.

Since
QGIS 3.4

Definition at line 112 of file qgsquickutils.cpp.

void QgsQuickUtils::humanReadableDistance ( double  srcDistance,
QgsUnitTypes::DistanceUnit  srcUnits,
QgsUnitTypes::SystemOfMeasurement  destSystem,
double &  destDistance,
QgsUnitTypes::DistanceUnit destUnits 
)
static

Converts distance to human readable distance in destination system of measurement.

See also
QgsQuickUtils::formatDistance()
Parameters
srcDistancedistance in units
srcUnitsunits of dist
destSystemsystem of measurement of the result
destDistanceoutput: distance if desired system of measurement
destUnitsoutput: unit of destDistance
Since
QGIS 3.4

Definition at line 163 of file qgsquickutils.cpp.

void QgsQuickUtils::logMessage ( const QString &  message,
const QString &  tag = QString( "QgsQuick" ),
Qgis::MessageLevel  level = Qgis::Warning 
)
static

Log message in QgsMessageLog.

Definition at line 102 of file qgsquickutils.cpp.

QgsPoint QgsQuickUtils::point ( double  x,
double  y,
double  z = std::numeric_limits<double>::quiet_NaN(),
double  m = std::numeric_limits<double>::quiet_NaN() 
)
static

Creates QgsPoint in QML.

Since
QGIS 3.4

Definition at line 51 of file qgsquickutils.cpp.

QgsPointXY QgsQuickUtils::pointXY ( double  x,
double  y 
)
static

Creates QgsPointXY in QML.

Since
QGIS 3.4

Definition at line 46 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 312 of file qgsquickutils.cpp.

double QgsQuickUtils::screenUnitsToMeters ( QgsQuickMapSettings mapSettings,
int  baseLengthPixels 
)
static

Calculates the distance in meter representing baseLengthPixels pixels on the screen based on the current map settings.

Definition at line 71 of file qgsquickutils.cpp.

QgsPointXY QgsQuickUtils::transformPoint ( const QgsCoordinateReferenceSystem srcCrs,
const QgsCoordinateReferenceSystem destCrs,
const QgsCoordinateTransformContext context,
const QgsPointXY srcPoint 
)
static

Transforms point between different crs from QML.

Since
QGIS 3.4

Definition at line 61 of file qgsquickutils.cpp.

Property Documentation

qreal QgsQuickUtils::dp
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.


The documentation for this class was generated from the following files: