QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsquickutils.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsquickutils.cpp
3  --------------------------------------
4  Date : Nov 2017
5  Copyright : (C) 2017 by Peter Petrik
6  Email : zilolv at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15
16 #include <QApplication>
17 #include <QDesktopWidget>
18 #include <QString>
19
20 #include "qgis.h"
22 #include "qgscoordinatetransform.h"
23 #include "qgsdistancearea.h"
24 #include "qgslogger.h"
25 #include "qgsvectorlayer.h"
26 #include "qgsfeature.h"
27 #include "qgsapplication.h"
29
31 #include "qgsquickmapsettings.h"
32 #include "qgsquickutils.h"
33 #include "qgsunittypes.h"
34
35
36 QgsQuickUtils::QgsQuickUtils( QObject *parent )
37  : QObject( parent )
38  , mScreenDensity( calculateScreenDensity() )
39 {
40 }
41
46 {
48 }
49
50 QgsPointXY QgsQuickUtils::pointXY( double x, double y )
51 {
52  return QgsPointXY( x, y );
53 }
54
55 QgsPoint QgsQuickUtils::point( double x, double y, double z, double m )
56 {
57  return QgsPoint( x, y, z, m );
58 }
59
60 QgsPoint QgsQuickUtils::coordinateToPoint( const QGeoCoordinate &coor )
61 {
62  return QgsPoint( coor.longitude(), coor.latitude(), coor.altitude() );
63 }
64
66  const QgsCoordinateReferenceSystem &destCrs,
67  const QgsCoordinateTransformContext &context,
68  const QgsPointXY &srcPoint )
69 {
70  QgsCoordinateTransform mTransform( srcCrs, destCrs, context );
71  QgsPointXY pt = mTransform.transform( srcPoint );
72  return pt;
73 }
74
75 double QgsQuickUtils::screenUnitsToMeters( QgsQuickMapSettings *mapSettings, int baseLengthPixels )
76 {
77  if ( mapSettings == nullptr ) return 0.0;
78
79  QgsDistanceArea mDistanceArea;
80  mDistanceArea.setEllipsoid( QStringLiteral( "WGS84" ) );
81  mDistanceArea.setSourceCrs( mapSettings->destinationCrs(), mapSettings->transformContext() );
82
83  // calculate the geographic distance from the central point of extent
84  // to the specified number of points on the right side
85  QSize s = mapSettings->outputSize();
86  QPoint pointCenter( s.width() / 2, s.height() / 2 );
87  QgsPointXY p1 = mapSettings->screenToCoordinate( pointCenter );
88  QgsPointXY p2 = mapSettings->screenToCoordinate( pointCenter + QPoint( baseLengthPixels, 0 ) );
89  return mDistanceArea.measureLine( p1, p2 );
90 }
91
92 bool QgsQuickUtils::fileExists( const QString &path )
93 {
94  QFileInfo check_file( path );
95  // check if file exists and if yes: Is it really a file and no directory?
96  return ( check_file.exists() && check_file.isFile() );
97 }
98
99 QString QgsQuickUtils::getRelativePath( const QString &path, const QString &prefixPath )
100 {
101  QString modPath = path;
102  QString filePrefix( "file://" );
103
104  if ( path.startsWith( filePrefix ) )
105  {
106  modPath = modPath.replace( filePrefix, QString() );
107  }
108
109  if ( prefixPath.isEmpty() ) return modPath;
110
111  // Do not use a canonical path for non-existing path
112  if ( !QFileInfo( path ).exists() )
113  {
114  if ( !prefixPath.isEmpty() && modPath.startsWith( prefixPath ) )
115  {
116  return modPath.replace( prefixPath, QString() );
117  }
118  }
119  else
120  {
121  QDir absoluteDir( modPath );
122  QDir prefixDir( prefixPath );
123  QString canonicalPath = absoluteDir.canonicalPath();
124  QString prefixCanonicalPath = prefixDir.canonicalPath() + "/";
125
126  if ( prefixCanonicalPath.length() > 1 && canonicalPath.startsWith( prefixCanonicalPath ) )
127  {
128  return canonicalPath.replace( prefixCanonicalPath, QString() );
129  }
130  }
131
132  return QString();
133 }
134
135 void QgsQuickUtils::logMessage( const QString &message, const QString &tag, Qgis::MessageLevel level )
136 {
137  QgsMessageLog::logMessage( message, tag, level );
138 }
139
141 {
142  return QgsQuickFeatureLayerPair( feature, layer );
143 }
144
145 const QUrl QgsQuickUtils::getThemeIcon( const QString &name )
146 {
147  QString path = QStringLiteral( "qrc:/%1.svg" ).arg( name );
148  QgsDebugMsg( QStringLiteral( "Using icon %1 from %2" ).arg( name, path ) );
149  return QUrl( path );
150 }
151
152 const QUrl QgsQuickUtils::getEditorComponentSource( const QString &widgetName )
153 {
154  QString path( "qgsquick%1.qml" );
155  QStringList supportedWidgets = { QStringLiteral( "textedit" ),
156  QStringLiteral( "valuemap" ),
157  QStringLiteral( "valuerelation" ),
158  QStringLiteral( "checkbox" ),
159  QStringLiteral( "externalresource" ),
160  QStringLiteral( "datetime" ),
161  QStringLiteral( "range" )
162  };
163  if ( supportedWidgets.contains( widgetName ) )
164  {
165  return QUrl( path.arg( widgetName ) );
166  }
167  else
168  {
169  return QUrl( path.arg( QStringLiteral( "textedit" ) ) );
170  }
171 }
172
174  const QgsPoint &point,
176  int decimals,
177  QgsCoordinateFormatter::FormatFlags flags )
178 {
179  return QgsCoordinateFormatter::format( point, format, decimals, flags );
180 }
181
182 QString QgsQuickUtils::formatDistance( double distance,
184  int decimals,
186 {
187  double destDistance;
188  QgsUnitTypes::DistanceUnit destUnits;
189
190  humanReadableDistance( distance, units, destSystem, destDistance, destUnits );
191
192  return QStringLiteral( "%1 %2" )
193  .arg( QString::number( destDistance, 'f', decimals ) )
194  .arg( QgsUnitTypes::toAbbreviatedString( destUnits ) );
195 }
196
197 bool QgsQuickUtils::removeFile( const QString &filePath )
198 {
199  QFile file( filePath );
200  return file.remove( filePath );
201 }
202
203
206  double &destDistance, QgsUnitTypes::DistanceUnit &destUnits )
207 {
208  if ( ( destSystem == QgsUnitTypes::MetricSystem ) || ( destSystem == QgsUnitTypes::UnknownSystem ) )
209  {
210  return formatToMetricDistance( srcDistance, srcUnits, destDistance, destUnits );
211  }
212  else if ( destSystem == QgsUnitTypes::ImperialSystem )
213  {
214  return formatToImperialDistance( srcDistance, srcUnits, destDistance, destUnits );
215  }
216  else if ( destSystem == QgsUnitTypes::USCSSystem )
217  {
218  return formatToUSCSDistance( srcDistance, srcUnits, destDistance, destUnits );
219  }
220  else
221  {
222  Q_ASSERT( false ); //should never happen
223  }
224 }
225
226 void QgsQuickUtils::formatToMetricDistance( double srcDistance,
228  double &destDistance,
229  QgsUnitTypes::DistanceUnit &destUnits )
230 {
231  double dist = srcDistance * QgsUnitTypes::fromUnitToUnitFactor( srcUnits, QgsUnitTypes::DistanceMillimeters );
232  if ( dist < 0 )
233  {
234  destDistance = 0;
236  return;
237  }
238
240  if ( dist > mmToKm )
241  {
242  destDistance = dist / mmToKm;
244  return;
245  }
246
248  if ( dist > mmToM )
249  {
250  destDistance = dist / mmToM;
251  destUnits = QgsUnitTypes::DistanceMeters;
252  return;
253  }
254
256  if ( dist > mmToCm )
257  {
258  destDistance = dist / mmToCm;
260  return;
261  }
262
263  destDistance = dist;
265 }
266
267 void QgsQuickUtils::formatToImperialDistance( double srcDistance,
269  double &destDistance,
270  QgsUnitTypes::DistanceUnit &destUnits )
271 {
272  double dist = srcDistance * QgsUnitTypes::fromUnitToUnitFactor( srcUnits, QgsUnitTypes::DistanceFeet );
273  if ( dist < 0 )
274  {
275  destDistance = 0;
276  destUnits = QgsUnitTypes::DistanceFeet;
277  return;
278  }
279
281  if ( dist > feetToMile )
282  {
283  destDistance = dist / feetToMile;
284  destUnits = QgsUnitTypes::DistanceMiles;
285  return;
286  }
287
289  if ( dist > feetToYard )
290  {
291  destDistance = dist / feetToYard;
292  destUnits = QgsUnitTypes::DistanceYards;
293  return;
294  }
295
296  destDistance = dist;
297  destUnits = QgsUnitTypes::DistanceFeet;
298  return;
299 }
300
301 void QgsQuickUtils::formatToUSCSDistance( double srcDistance,
303  double &destDistance,
304  QgsUnitTypes::DistanceUnit &destUnits )
305 {
306  double dist = srcDistance * QgsUnitTypes::fromUnitToUnitFactor( srcUnits, QgsUnitTypes::DistanceFeet );
307  if ( dist < 0 )
308  {
309  destDistance = 0;
310  destUnits = QgsUnitTypes::DistanceFeet;
311  return;
312  }
313
315  if ( dist > feetToMile )
316  {
317  destDistance = dist / feetToMile;
319  return;
320  }
321
323  if ( dist > feetToYard )
324  {
325  destDistance = dist / feetToYard;
326  destUnits = QgsUnitTypes::DistanceYards;
327  return;
328  }
329
330  destDistance = dist;
331  destUnits = QgsUnitTypes::DistanceFeet;
332  return;
333 }
334
336 {
337  QRect rec = QApplication::desktop()->screenGeometry();
338  int dpiX = QApplication::desktop()->physicalDpiX();
339  int dpiY = QApplication::desktop()->physicalDpiY();
340  int height = rec.height();
341  int width = rec.width();
342  double sizeX = static_cast<double>( width ) / dpiX * 25.4;
343  double sizeY = static_cast<double>( height ) / dpiY * 25.4;
344
345  QString msg;
346  msg += tr( "screen resolution: %1x%2 px\n" ).arg( width ).arg( height );
347  msg += tr( "screen DPI: %1x%2\n" ).arg( dpiX ).arg( dpiY );
348  msg += tr( "screen size: %1x%2 mm\n" ).arg( QString::number( sizeX, 'f', 0 ), QString::number( sizeY, 'f', 0 ) );
349  msg += tr( "screen density: %1" ).arg( mScreenDensity );
350  return msg;
351 }
352
353 QVariantMap QgsQuickUtils::createValueRelationCache( const QVariantMap &config, const QgsFeature &formFeature )
354 {
355  QVariantMap valueMap;
357
358  for ( const QgsValueRelationFieldFormatter::ValueRelationItem &item : qgis::as_const( cache ) )
359  {
360  valueMap.insert( item.key.toString(), item.value );
361  }
362  return valueMap;
363 }
364
365 QString QgsQuickUtils::evaluateExpression( const QgsQuickFeatureLayerPair &pair, QgsProject *activeProject, const QString &expression )
366 {
367  QList<QgsExpressionContextScope *> scopes;
369  scopes << QgsExpressionContextUtils::projectScope( activeProject );
370  scopes << QgsExpressionContextUtils::layerScope( pair.layer() );
371
372  QgsExpressionContext context( scopes );
373  context.setFeature( pair.feature() );
374  QgsExpression expr( expression );
375  return expr.evaluate( &context ).toString();
376 }
377
379 {
380  QgsFeatureIds qgsFids;
381  for ( const int &fid : fids )
382  qgsFids << fid;
383  layer->selectByIds( qgsFids, behavior );
384 }
385
387 {
388  return mScreenDensity;
389 }
390
391 qreal QgsQuickUtils::calculateScreenDensity()
392 {
393  // calculate screen density for calculation of real pixel sizes from density-independent pixels
394  int dpiX = QApplication::desktop()->physicalDpiX();
395  int dpiY = QApplication::desktop()->physicalDpiY();
396  int dpi = dpiX < dpiY ? dpiX : dpiY; // In case of asymmetrical DPI. Improbable
397  return dpi / 160.; // 160 DPI is baseline for density-independent pixels in Android
398 }
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
qgsvaluerelationfieldformatter.h
qgsquickfeaturelayerpair.h
QgsUnitTypes::ImperialSystem
@ ImperialSystem
British Imperial.
Definition: qgsunittypes.h:48
QgsQuickUtils::evaluateExpression
static Q_INVOKABLE QString evaluateExpression(const QgsQuickFeatureLayerPair &pair, QgsProject *activeProject, const QString &expression)
Evaluates expression.
Definition: qgsquickutils.cpp:365
QgsExpressionContextUtils::globalScope
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Definition: qgsexpressioncontextutils.cpp:33
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:264
QgsQuickUtils::pointXY
static Q_INVOKABLE QgsPointXY pointXY(double x, double y)
Creates QgsPointXY in QML.
Definition: qgsquickutils.cpp:50
QgsUnitTypes::toAbbreviatedString
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
Definition: qgsunittypes.cpp:269
qgsfeature.h
qgis.h
qgsunittypes.h
QgsVectorLayer::selectByIds
Q_INVOKABLE void selectByIds(const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection)
Selects matching features using a list of feature IDs.
Definition: qgsvectorlayer.cpp:523
QgsQuickUtils::createValueRelationCache
static Q_INVOKABLE QVariantMap createValueRelationCache(const QVariantMap &config, const QgsFeature &formFeature=QgsFeature())
Creates a cache for a value relation field.
Definition: qgsquickutils.cpp:353
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:67
QgsCoordinateTransform::transform
QgsPointXY transform(const QgsPointXY &point, TransformDirection direction=ForwardTransform) const SIP_THROW(QgsCsException)
Transform the point from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:239
QgsQuickFeatureLayerPair::layer
QgsVectorLayer layer
Vector layer to which the feature belongs.
Definition: qgsquickfeaturelayerpair.h:49
QgsUnitTypes::DistanceKilometers
@ DistanceKilometers
Kilometers.
Definition: qgsunittypes.h:70
QgsUnitTypes::SystemOfMeasurement
SystemOfMeasurement
Systems of unit measurement.
Definition: qgsunittypes.h:44
QgsQuickUtils::removeFile
static Q_INVOKABLE bool removeFile(const QString &filePath)
Deletes file from a given path.
Definition: qgsquickutils.cpp:197
QgsQuickUtils::dumpScreenInfo
QString dumpScreenInfo() const
Returns a string with information about screen size and resolution - useful for debugging.
Definition: qgsquickutils.cpp:335
QgsQuickMapSettings::screenToCoordinate
Q_INVOKABLE QgsPoint screenToCoordinate(const QPointF &point) const
Convert a screen coordinate to a map coordinate.
Definition: qgsquickmapsettings.cpp:119
QgsProject
Definition: qgsproject.h:92
QgsQuickUtils::formatDistance
static Q_INVOKABLE QString formatDistance(double distance, QgsUnitTypes::DistanceUnit units, int decimals, QgsUnitTypes::SystemOfMeasurement destSystem=QgsUnitTypes::MetricSystem)
Converts distance to human readable distance.
Definition: qgsquickutils.cpp:182
qgsapplication.h
QgsQuickMapSettings
Definition: qgsquickmapsettings.h:46
QgsUnitTypes::fromUnitToUnitFactor
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
Definition: qgsunittypes.cpp:352
QgsDistanceArea::setEllipsoid
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Definition: qgsdistancearea.cpp:66
QgsQuickUtils::formatPoint
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.
Definition: qgsquickutils.cpp:173
QgsQuickMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs
CRS of destination coordinate reference system.
Definition: qgsquickmapsettings.h:105
QgsExpressionContextUtils::projectScope
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
Definition: qgsexpressioncontextutils.cpp:221
QgsQuickMapSettings::outputSize
QSize outputSize
The size of the resulting map image.
Definition: qgsquickmapsettings.h:91
QgsQuickUtils::logMessage
static Q_INVOKABLE void logMessage(const QString &message, const QString &tag=QString("QgsQuick"), Qgis::MessageLevel level=Qgis::Warning)
Log message in QgsMessageLog.
Definition: qgsquickutils.cpp:135
QgsDistanceArea::measureLine
double measureLine(const QVector< QgsPointXY > &points) const
Measures the length of a line with multiple segments.
Definition: qgsdistancearea.cpp:273
QgsUnitTypes::DistanceFeet
@ DistanceFeet
Imperial feet.
Definition: qgsunittypes.h:71
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
QgsQuickUtils::featureFactory
static Q_INVOKABLE QgsQuickFeatureLayerPair featureFactory(const QgsFeature &feature, QgsVectorLayer *layer=nullptr)
QgsQuickFeatureLayerPair factory for tuple of QgsFeature and QgsVectorLayer used in QgsQUick library.
Definition: qgsquickutils.cpp:140
qgscoordinatetransform.h
QgsQuickFeatureLayerPair::feature
QgsFeature feature
Feature that belongs to layer.
Definition: qgsquickfeaturelayerpair.h:56
QgsDistanceArea::setSourceCrs
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
Definition: qgsdistancearea.cpp:60
QgsVectorLayer::SelectBehavior
SelectBehavior
Selection behavior.
Definition: qgsvectorlayer.h:410
QgsCoordinateFormatter::format
static QString format(const QgsPointXY &point, Format format, int precision=12, FormatFlags flags=FlagDegreesUseStringSuffix)
Formats a point according to the specified parameters.
Definition: qgscoordinateformatter.cpp:61
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsUnitTypes::MetricSystem
@ MetricSystem
International System of Units (SI)
Definition: qgsunittypes.h:47
QgsExpression::evaluate
QVariant evaluate()
Evaluate the feature and return the result.
Definition: qgsexpression.cpp:346
QgsQuickUtils::fileExists
static Q_INVOKABLE bool fileExists(const QString &path)
Returns whether file on path exists.
Definition: qgsquickutils.cpp:92
qgsvectorlayer.h
QgsPointXY
Definition: qgspointxy.h:43
QgsQuickMapSettings::transformContext
Q_INVOKABLE QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition: qgsquickmapsettings.cpp:70
QgsQuickUtils::screenDensity
qreal screenDensity() const
"dp" is useful for building building components that work well with different screen densities.
Definition: qgsquickutils.cpp:386
QgsQuickUtils::getEditorComponentSource
static const Q_INVOKABLE QUrl getEditorComponentSource(const QString &widgetName)
Returns url to field editor component for a feature form.
Definition: qgsquickutils.cpp:152
QgsUnitTypes::USCSSystem
@ USCSSystem
United States customary system.
Definition: qgsunittypes.h:49
QgsQuickUtils::coordinateToPoint
static Q_INVOKABLE QgsPoint coordinateToPoint(const QGeoCoordinate &coor)
Converts QGeoCoordinate to QgsPoint.
Definition: qgsquickutils.cpp:60
Qgis::MessageLevel
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:101
QgsValueRelationFieldFormatter::ValueRelationCache
QVector< QgsValueRelationFieldFormatter::ValueRelationItem > ValueRelationCache
Definition: qgsvaluerelationfieldformatter.h:70
QgsUnitTypes::DistanceMillimeters
@ DistanceMillimeters
Millimeters.
Definition: qgsunittypes.h:77
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsUnitTypes::DistanceCentimeters
@ DistanceCentimeters
Centimeters.
Definition: qgsunittypes.h:76
QgsValueRelationFieldFormatter::createCache
QVariant createCache(QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config) const override
Create a cache for a given field.
Definition: qgsvaluerelationfieldformatter.cpp:116
QgsCoordinateFormatter::Format
Format
Available formats for displaying coordinates.
Definition: qgscoordinateformatter.h:47
QgsMessageLog::logMessage
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Definition: qgsmessagelog.cpp:27
QgsQuickUtils::screenUnitsToMeters
static Q_INVOKABLE double screenUnitsToMeters(QgsQuickMapSettings *mapSettings, int baseLengthPixels)
Calculates the distance in meter representing baseLengthPixels pixels on the screen based on the curr...
Definition: qgsquickutils.cpp:75
QgsUnitTypes::DistanceYards
@ DistanceYards
Imperial yards.
Definition: qgsunittypes.h:73
QgsUnitTypes::UnknownSystem
@ UnknownSystem
Unknown system of measurement.
Definition: qgsunittypes.h:46
QgsQuickUtils::coordinateReferenceSystemFromEpsgId
static Q_INVOKABLE QgsCoordinateReferenceSystem coordinateReferenceSystemFromEpsgId(long epsg)
Creates crs from epsg code in QML.
Definition: qgsquickutils.cpp:45
QgsUnitTypes::DistanceMiles
@ DistanceMiles
Terrestrial miles.
Definition: qgsunittypes.h:74
QgsDistanceArea
Definition: qgsdistancearea.h:49
QgsQuickUtils::getRelativePath
static Q_INVOKABLE QString getRelativePath(const QString &path, const QString &prefixPath)
Returns relative path of the file to given prefixPath.
Definition: qgsquickutils.cpp:99
qgsquickutils.h
QgsCoordinateReferenceSystem::fromEpsgId
static Q_INVOKABLE QgsCoordinateReferenceSystem fromEpsgId(long epsg)
Creates a CRS from a given EPSG ID.
Definition: qgscoordinatereferencesystem.cpp:207
qgsdistancearea.h
QgsFeature
Definition: qgsfeature.h:55
QgsUnitTypes::DistanceNauticalMiles
@ DistanceNauticalMiles
Nautical miles.
Definition: qgsunittypes.h:72
qgslogger.h
QgsQuickUtils::getThemeIcon
static const Q_INVOKABLE QUrl getThemeIcon(const QString &name)
Returns QUrl to image from library's /images folder.
Definition: qgsquickutils.cpp:145
QgsQuickUtils::transformPoint
static Q_INVOKABLE QgsPointXY transformPoint(const QgsCoordinateReferenceSystem &srcCrs, const QgsCoordinateReferenceSystem &destCrs, const QgsCoordinateTransformContext &context, const QgsPointXY &srcPoint)
Transforms point between different crs from QML.
Definition: qgsquickutils.cpp:65
QgsQuickUtils::QgsQuickUtils
QgsQuickUtils(QObject *parent=nullptr)
Create new utilities.
Definition: qgsquickutils.cpp:36
QgsExpression
Definition: qgsexpression.h:113
QgsQuickUtils::point
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.
Definition: qgsquickutils.cpp:55
qgscoordinatereferencesystem.h
qgsquickmapsettings.h
QgsQuickUtils::selectFeaturesInLayer
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 feat...
Definition: qgsquickutils.cpp:378
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:521