20#include "qgsversion.h"
22#include <QCoreApplication>
75 string.remove( QLocale().groupSeparator() );
76 return QLocale().toDouble(
string, &ok );
82 string.remove( QLocale().groupSeparator() );
83 return QLocale().toInt(
string, &ok );
89 string.remove( QLocale().groupSeparator() );
90 return QLocale().toLongLong(
string, &ok );
101 if ( ( size >> ( 8 *
sizeof( size ) - 1 ) ) != 0 )
103 QgsDebugError( QStringLiteral(
"qgsMalloc - bad size requested: %1" ).arg( size ) );
107 void *p = malloc( size );
110 QgsDebugError( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
123 if ( !lhs.isValid() )
124 return rhs.isValid();
125 else if ( lhs.isNull() )
126 return rhs.isValid() && !rhs.isNull();
127 else if ( !rhs.isValid() || rhs.isNull() )
130 switch ( lhs.userType() )
132 case QMetaType::Type::Int:
133 return lhs.toInt() < rhs.toInt();
134 case QMetaType::Type::UInt:
135 return lhs.toUInt() < rhs.toUInt();
136 case QMetaType::Type::LongLong:
137 return lhs.toLongLong() < rhs.toLongLong();
138 case QMetaType::Type::ULongLong:
139 return lhs.toULongLong() < rhs.toULongLong();
140 case QMetaType::Type::Double:
141 return lhs.toDouble() < rhs.toDouble();
142 case QMetaType::Type::QChar:
143 return lhs.toChar() < rhs.toChar();
144 case QMetaType::Type::QDate:
145 return lhs.toDate() < rhs.toDate();
146 case QMetaType::Type::QTime:
147 return lhs.toTime() < rhs.toTime();
148 case QMetaType::Type::QDateTime:
149 return lhs.toDateTime() < rhs.toDateTime();
150 case QMetaType::Type::Bool:
151 return lhs.toBool() < rhs.toBool();
153 case QMetaType::Type::QVariantList:
155 const QList<QVariant> &lhsl = lhs.toList();
156 const QList<QVariant> &rhsl = rhs.toList();
158 int i, n = std::min( lhsl.size(), rhsl.size() );
159 for ( i = 0; i < n && lhsl[i].userType() == rhsl[i].userType() &&
qgsVariantEqual( lhsl[i], rhsl[i] ); i++ )
163 return lhsl.size() < rhsl.size();
168 case QMetaType::Type::QStringList:
170 const QStringList &lhsl = lhs.toStringList();
171 const QStringList &rhsl = rhs.toStringList();
173 int i, n = std::min( lhsl.size(), rhsl.size() );
174 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
178 return lhsl.size() < rhsl.size();
180 return lhsl[i] < rhsl[i];
184 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
198uint
qHash(
const QVariant &variant )
200 if ( !variant.isValid() || variant.isNull() )
201 return std::numeric_limits<uint>::max();
203 switch ( variant.userType() )
205 case QMetaType::Type::Int:
206 return qHash( variant.toInt() );
207 case QMetaType::Type::UInt:
208 return qHash( variant.toUInt() );
209 case QMetaType::Type::Bool:
210 return qHash( variant.toBool() );
211 case QMetaType::Type::Double:
212 return qHash( variant.toDouble() );
213 case QMetaType::Type::LongLong:
214 return qHash( variant.toLongLong() );
215 case QMetaType::Type::ULongLong:
216 return qHash( variant.toULongLong() );
217 case QMetaType::Type::QString:
218 return qHash( variant.toString() );
219 case QMetaType::Type::QChar:
220 return qHash( variant.toChar() );
221 case QMetaType::Type::QVariantList:
222 return qHash( variant.toList() );
223 case QMetaType::Type::QStringList:
224 return qHash( variant.toStringList() );
225 case QMetaType::Type::QByteArray:
226 return qHash( variant.toByteArray() );
227 case QMetaType::Type::QDate:
228 return qHash( variant.toDate() );
229 case QMetaType::Type::QTime:
230 return qHash( variant.toTime() );
231 case QMetaType::Type::QDateTime:
232 return qHash( variant.toDateTime() );
233 case QMetaType::Type::QUrl:
234 case QMetaType::Type::QLocale:
235 case QMetaType::Type::QRegularExpression:
236#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
237 case QMetaType::Type::QRegExp:
239 return qHash( variant.toString() );
244 return std::numeric_limits<uint>::max();
249 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
254 return QStringLiteral(
"1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
255 "1:10000,1:5000,1:2500,1:1000,1:500" );
260 return QString::fromUtf8( VERSION );
272 return QString::fromUtf8( RELEASE_NAME );
282 return GEOSversion();
287 static const int version = QStringLiteral(
"%1%2%3" )
288 .arg( GEOS_VERSION_MAJOR, 2, 10, QChar(
'0' ) )
289 .arg( GEOS_VERSION_MINOR, 2, 10, QChar(
'0' ) )
297 return GEOS_VERSION_MAJOR;
302 return GEOS_VERSION_MINOR;
307 static const int version = atoi(
xstr( GEOS_VERSION_PATCH ) );
311#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
313bool 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_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/stroke minimum width in mm.
static QString version()
Version string.
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 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 int versionInt()
Version number used for comparing versions using the "Check QGIS Version" function.
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 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)
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
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)