19#include "moc_qgis.cpp"
21#include "qgsversion.h"
23#include <QCoreApplication>
38#define qgis_xstr(x) qgis_str(x)
84 string.remove( QLocale().groupSeparator() );
85 return QLocale().toDouble(
string, &ok );
91 string.remove( QLocale().groupSeparator() );
92 return QLocale().toInt(
string, &ok );
98 string.remove( QLocale().groupSeparator() );
99 return QLocale().toLongLong(
string, &ok );
110 if ( ( size >> ( 8 *
sizeof( size ) - 1 ) ) != 0 )
112 QgsDebugError( QStringLiteral(
"qgsMalloc - bad size requested: %1" ).arg( size ) );
116 void *p = malloc( size );
119 QgsDebugError( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
132 if ( !lhs.isValid() )
134 return rhs.isValid() ? -1 : 0;
136 else if ( lhs.isNull() )
138 if ( !rhs.isValid() )
144 else if ( !rhs.isValid() || rhs.isNull() )
150 switch ( lhs.userType() )
152 case QMetaType::Type::Int:
153 case QMetaType::Type::Char:
154 case QMetaType::Type::Short:
156 const int lhsInt = lhs.toInt();
157 const int rhsInt = rhs.toInt();
158 return lhsInt < rhsInt ? -1 : ( lhsInt == rhsInt ? 0 : 1 );
160 case QMetaType::Type::UInt:
161 case QMetaType::Type::UChar:
162 case QMetaType::Type::UShort:
164 const uint lhsUInt = lhs.toUInt();
165 const uint rhsUInt = rhs.toUInt();
166 return lhsUInt < rhsUInt ? -1 : ( lhsUInt == rhsUInt ? 0 : 1 );
168 case QMetaType::Type::LongLong:
169 case QMetaType::Type::Long:
171 const qlonglong lhsLongLong = lhs.toLongLong();
172 const qlonglong rhsLongLong = rhs.toLongLong();
173 return lhsLongLong < rhsLongLong ? -1 : ( lhsLongLong == rhsLongLong ? 0 : 1 );
175 case QMetaType::Type::ULongLong:
176 case QMetaType::Type::ULong:
178 const qulonglong lhsULongLong = lhs.toULongLong();
179 const qulonglong rhsULongLong = rhs.toULongLong();
180 return lhsULongLong < rhsULongLong ? -1 : ( lhsULongLong == rhsULongLong ? 0 : 1 );
182 case QMetaType::Type::Double:
184 const double lhsDouble = lhs.toDouble();
185 const double rhsDouble = rhs.toDouble();
188 const bool lhsIsNan = std::isnan( lhsDouble );
189 const bool rhsIsNan = std::isnan( rhsDouble );
192 return rhsIsNan ? 0 : -1;
199 return lhsDouble < rhsDouble ? -1 : ( lhsDouble == rhsDouble ? 0 : 1 );
201 case QMetaType::Type::Float:
203 const float lhsFloat = lhs.toFloat();
204 const float rhsFloat = rhs.toFloat();
207 const bool lhsIsNan = std::isnan( lhsFloat );
208 const bool rhsIsNan = std::isnan( rhsFloat );
211 return rhsIsNan ? 0 : -1;
218 return lhsFloat < rhsFloat ? -1 : ( lhsFloat == rhsFloat ? 0 : 1 );
220 case QMetaType::Type::QChar:
222 const QChar lhsChar = lhs.toChar();
223 const QChar rhsChar = rhs.toChar();
224 return lhsChar < rhsChar ? -1 : ( lhsChar == rhsChar ? 0 : 1 );
226 case QMetaType::Type::QDate:
228 const QDate lhsDate = lhs.toDate();
229 const QDate rhsDate = rhs.toDate();
230 return lhsDate < rhsDate ? -1 : ( lhsDate == rhsDate ? 0 : 1 );
232 case QMetaType::Type::QTime:
234 const QTime lhsTime = lhs.toTime();
235 const QTime rhsTime = rhs.toTime();
236 return lhsTime < rhsTime ? -1 : ( lhsTime == rhsTime ? 0 : 1 );
238 case QMetaType::Type::QDateTime:
240 const QDateTime lhsTime = lhs.toDateTime();
241 const QDateTime rhsTime = rhs.toDateTime();
242 return lhsTime < rhsTime ? -1 : ( lhsTime == rhsTime ? 0 : 1 );
244 case QMetaType::Type::Bool:
246 const bool lhsBool = lhs.toBool();
247 const bool rhsBool = rhs.toBool();
248 return lhsBool == rhsBool ? 0 : ( lhsBool ? 1 : -1 );
251 case QMetaType::Type::QVariantList:
253 const QList<QVariant> &lhsl = lhs.toList();
254 const QList<QVariant> &rhsl = rhs.toList();
256 int i, n = std::min( lhsl.size(), rhsl.size() );
257 for ( i = 0; i < n && lhsl[i].userType() == rhsl[i].userType() &&
qgsVariantCompare( lhsl[i], rhsl[i] ) == 0; i++ )
261 return lhsl.size() < rhsl.size() ? -1 : ( lhsl.size() > rhsl.size() ? 1 : 0 );
266 case QMetaType::Type::QStringList:
268 const QStringList &lhsl = lhs.toStringList();
269 const QStringList &rhsl = rhs.toStringList();
271 int i, n = std::min( lhsl.size(), rhsl.size() );
272 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
276 return lhsl.size() < rhsl.size() ? -1 : ( lhsl.size() > rhsl.size() ? 1 : 0 );
278 return lhsl[i] < rhsl[i] ? -1 : ( lhsl[i] == rhsl[i] ? 0 : 1 );
282 return QString::localeAwareCompare( lhs.toString(), rhs.toString() );
302uint
qHash(
const QVariant &variant )
304 if ( !variant.isValid() || variant.isNull() )
305 return std::numeric_limits<uint>::max();
307 switch ( variant.userType() )
309 case QMetaType::Type::Int:
310 return qHash( variant.toInt() );
311 case QMetaType::Type::UInt:
312 return qHash( variant.toUInt() );
313 case QMetaType::Type::Bool:
314 return qHash( variant.toBool() );
315 case QMetaType::Type::Double:
316 return qHash( variant.toDouble() );
317 case QMetaType::Type::LongLong:
318 return qHash( variant.toLongLong() );
319 case QMetaType::Type::ULongLong:
320 return qHash( variant.toULongLong() );
321 case QMetaType::Type::QString:
322 return qHash( variant.toString() );
323 case QMetaType::Type::QChar:
324 return qHash( variant.toChar() );
325 case QMetaType::Type::QVariantList:
326 return qHash( variant.toList() );
327 case QMetaType::Type::QStringList:
328 return qHash( variant.toStringList() );
329 case QMetaType::Type::QByteArray:
330 return qHash( variant.toByteArray() );
331 case QMetaType::Type::QDate:
332 return qHash( variant.toDate() );
333 case QMetaType::Type::QTime:
334 return qHash( variant.toTime() );
335 case QMetaType::Type::QDateTime:
336 return qHash( variant.toDateTime() );
337 case QMetaType::Type::QUrl:
338 case QMetaType::Type::QLocale:
339 case QMetaType::Type::QRegularExpression:
340#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
341 case QMetaType::Type::QRegExp:
343 return qHash( variant.toString() );
348 return std::numeric_limits<uint>::max();
353 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
358 return QStringLiteral(
"1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
359 "1:10000,1:5000,1:2500,1:1000,1:500" );
364 return QString::fromUtf8( VERSION );
376 return QString::fromUtf8( RELEASE_NAME );
386 return GEOSversion();
391 static const int version = QStringLiteral(
"%1%2%3" )
392 .arg( GEOS_VERSION_MAJOR, 2, 10, QChar(
'0' ) )
393 .arg( GEOS_VERSION_MINOR, 2, 10, QChar(
'0' ) )
401 return GEOS_VERSION_MAJOR;
406 return GEOS_VERSION_MINOR;
415#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
417bool qMapLessThanKey<QVariantList>(
const QVariantList &key1,
const QVariantList &key2 )
static const Qgis::MapToolUnit DEFAULT_SNAP_UNITS
Default snapping distance units.
MapToolUnit
Type of unit of tolerance value from settings.
@ Pixels
Pixels unit of tolerance.
static const double DEFAULT_LINE_WIDTH
The default width (in millimeters) for line symbols.
static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/stroke minimum width in mm.
static QString version()
Version string.
static const int PREVIEW_JOB_DELAY_MS
Delay between the scheduling of 2 preview jobs.
static const double DEFAULT_Z_COORDINATE
Default Z coordinate value.
static const char * QGIS_DEV_VERSION
The development version.
static QString geosVersion()
GEOS string version linked.
static const double DEFAULT_SNAP_TOLERANCE
Default snapping distance tolerance.
static const double DEFAULT_M_COORDINATE
Default M coordinate value.
static const double DEFAULT_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm.
static int geosVersionPatch()
GEOS Patch version number linked.
static const QColor DEFAULT_HIGHLIGHT_COLOR
Default highlight color.
static Q_DECL_DEPRECATED const double SCALE_PRECISION
Fudge factor used to compare two scales.
static const int MAXIMUM_LAYER_PREVIEW_TIME_MS
Maximum rendering time for a layer of a preview job.
static QString devVersion()
The development version.
static QString releaseName()
Release name.
static QString defaultProjectScales()
A string with default project scales.
static const float DEFAULT_MAPTOPIXEL_THRESHOLD
Default threshold between map coordinates and device coordinates for map2pixel simplification.
static int geosVersionMajor()
GEOS Major version number linked.
static const double DEFAULT_SEARCH_RADIUS_MM
Identify search radius in mm.
static const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
static int versionInt()
Version number used for comparing versions using the "Check QGIS Version" function.
static const int USER_CRS_START_ID
Minimum ID number for a user-defined projection.
static int geosVersionMinor()
GEOS Minor version number linked.
static int geosVersionInt()
GEOS version number linked.
static const double UI_SCALE_FACTOR
UI scaling factor.
static const double DEFAULT_POINT_SIZE
The default size (in millimeters) for point marker symbols.
static QString vsiPrefixForPath(const QString &path)
Returns a the vsi prefix which corresponds to a file path, or an empty string if the path is not asso...
void * qgsMalloc(size_t size)
Allocates size bytes and returns a pointer to the allocated memory.
qlonglong qgsPermissiveToLongLong(QString string, bool &ok)
Converts a string to an qlonglong in a permissive way, e.g., allowing for incorrect numbers of digits...
bool qgsVariantEqual(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether they are equal, two NULL values are always treated a...
uint qHash(const QVariant &variant)
Hash for QVariant.
double qgsPermissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, e.g., allowing for incorrect numbers of digits bet...
int qgsPermissiveToInt(QString string, bool &ok)
Converts a string to an integer in a permissive way, e.g., allowing for incorrect numbers of digits b...
void qgsFree(void *ptr)
Frees the memory space pointed to by ptr.
QString qgsVsiPrefix(const QString &path)
Returns a the vsi prefix which corresponds to a file path, or an empty string if the path is not asso...
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
int qgsVariantCompare(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
#define QgsDebugError(str)