19#include "moc_qgis.cpp"
21#include "qgsversion.h"
23#include <QCoreApplication>
76 string.remove( QLocale().groupSeparator() );
77 return QLocale().toDouble(
string, &ok );
83 string.remove( QLocale().groupSeparator() );
84 return QLocale().toInt(
string, &ok );
90 string.remove( QLocale().groupSeparator() );
91 return QLocale().toLongLong(
string, &ok );
102 if ( ( size >> ( 8 *
sizeof( size ) - 1 ) ) != 0 )
104 QgsDebugError( QStringLiteral(
"qgsMalloc - bad size requested: %1" ).arg( size ) );
108 void *p = malloc( size );
111 QgsDebugError( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
124 if ( !lhs.isValid() )
125 return rhs.isValid();
126 else if ( lhs.isNull() )
127 return rhs.isValid() && !rhs.isNull();
128 else if ( !rhs.isValid() || rhs.isNull() )
131 switch ( lhs.userType() )
133 case QMetaType::Type::Int:
134 return lhs.toInt() < rhs.toInt();
135 case QMetaType::Type::UInt:
136 return lhs.toUInt() < rhs.toUInt();
137 case QMetaType::Type::LongLong:
138 return lhs.toLongLong() < rhs.toLongLong();
139 case QMetaType::Type::ULongLong:
140 return lhs.toULongLong() < rhs.toULongLong();
141 case QMetaType::Type::Double:
142 return lhs.toDouble() < rhs.toDouble();
143 case QMetaType::Type::QChar:
144 return lhs.toChar() < rhs.toChar();
145 case QMetaType::Type::QDate:
146 return lhs.toDate() < rhs.toDate();
147 case QMetaType::Type::QTime:
148 return lhs.toTime() < rhs.toTime();
149 case QMetaType::Type::QDateTime:
150 return lhs.toDateTime() < rhs.toDateTime();
151 case QMetaType::Type::Bool:
152 return lhs.toBool() < rhs.toBool();
154 case QMetaType::Type::QVariantList:
156 const QList<QVariant> &lhsl = lhs.toList();
157 const QList<QVariant> &rhsl = rhs.toList();
159 int i, n = std::min( lhsl.size(), rhsl.size() );
160 for ( i = 0; i < n && lhsl[i].userType() == rhsl[i].userType() &&
qgsVariantEqual( lhsl[i], rhsl[i] ); i++ )
164 return lhsl.size() < rhsl.size();
169 case QMetaType::Type::QStringList:
171 const QStringList &lhsl = lhs.toStringList();
172 const QStringList &rhsl = rhs.toStringList();
174 int i, n = std::min( lhsl.size(), rhsl.size() );
175 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
179 return lhsl.size() < rhsl.size();
181 return lhsl[i] < rhsl[i];
185 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
199uint
qHash(
const QVariant &variant )
201 if ( !variant.isValid() || variant.isNull() )
202 return std::numeric_limits<uint>::max();
204 switch ( variant.userType() )
206 case QMetaType::Type::Int:
207 return qHash( variant.toInt() );
208 case QMetaType::Type::UInt:
209 return qHash( variant.toUInt() );
210 case QMetaType::Type::Bool:
211 return qHash( variant.toBool() );
212 case QMetaType::Type::Double:
213 return qHash( variant.toDouble() );
214 case QMetaType::Type::LongLong:
215 return qHash( variant.toLongLong() );
216 case QMetaType::Type::ULongLong:
217 return qHash( variant.toULongLong() );
218 case QMetaType::Type::QString:
219 return qHash( variant.toString() );
220 case QMetaType::Type::QChar:
221 return qHash( variant.toChar() );
222 case QMetaType::Type::QVariantList:
223 return qHash( variant.toList() );
224 case QMetaType::Type::QStringList:
225 return qHash( variant.toStringList() );
226 case QMetaType::Type::QByteArray:
227 return qHash( variant.toByteArray() );
228 case QMetaType::Type::QDate:
229 return qHash( variant.toDate() );
230 case QMetaType::Type::QTime:
231 return qHash( variant.toTime() );
232 case QMetaType::Type::QDateTime:
233 return qHash( variant.toDateTime() );
234 case QMetaType::Type::QUrl:
235 case QMetaType::Type::QLocale:
236 case QMetaType::Type::QRegularExpression:
237#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
238 case QMetaType::Type::QRegExp:
240 return qHash( variant.toString() );
245 return std::numeric_limits<uint>::max();
250 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
255 return QStringLiteral(
"1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
256 "1:10000,1:5000,1:2500,1:1000,1:500" );
261 return QString::fromUtf8( VERSION );
273 return QString::fromUtf8( RELEASE_NAME );
283 return GEOSversion();
288 static const int version = QStringLiteral(
"%1%2%3" )
289 .arg( GEOS_VERSION_MAJOR, 2, 10, QChar(
'0' ) )
290 .arg( GEOS_VERSION_MINOR, 2, 10, QChar(
'0' ) )
298 return GEOS_VERSION_MAJOR;
303 return GEOS_VERSION_MINOR;
308 static const int version = atoi(
xstr( GEOS_VERSION_PATCH ) );
312#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
314bool 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)