20 #include "qgsversion.h"
22 #include <QCoreApplication>
28 #include "qgsconfig.h"
36 #define xstr(x) str(x)
74 string.remove( QLocale().groupSeparator() );
75 return QLocale().toDouble(
string, &ok );
81 string.remove( QLocale().groupSeparator() );
82 return QLocale().toInt(
string, &ok );
88 string.remove( QLocale().groupSeparator() );
89 return QLocale().toLongLong(
string, &ok );
96 QgsDebugMsg( QStringLiteral(
"Zero size requested" ) );
100 if ( ( size >> ( 8 *
sizeof( size ) - 1 ) ) != 0 )
102 QgsDebugMsg( QStringLiteral(
"qgsMalloc - bad size requested: %1" ).arg( size ) );
106 void *p = malloc( size );
109 QgsDebugMsg( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
122 if ( !lhs.isValid() )
123 return rhs.isValid();
124 else if ( lhs.isNull() )
125 return rhs.isValid() && !rhs.isNull();
126 else if ( !rhs.isValid() || rhs.isNull() )
129 switch ( lhs.type() )
132 return lhs.toInt() < rhs.toInt();
134 return lhs.toUInt() < rhs.toUInt();
135 case QVariant::LongLong:
136 return lhs.toLongLong() < rhs.toLongLong();
137 case QVariant::ULongLong:
138 return lhs.toULongLong() < rhs.toULongLong();
139 case QVariant::Double:
140 return lhs.toDouble() < rhs.toDouble();
142 return lhs.toChar() < rhs.toChar();
144 return lhs.toDate() < rhs.toDate();
146 return lhs.toTime() < rhs.toTime();
147 case QVariant::DateTime:
148 return lhs.toDateTime() < rhs.toDateTime();
150 return lhs.toBool() < rhs.toBool();
154 const QList<QVariant> &lhsl = lhs.toList();
155 const QList<QVariant> &rhsl = rhs.toList();
157 int i, n = std::min( lhsl.size(), rhsl.size() );
158 for ( i = 0; i < n && lhsl[i].type() == rhsl[i].type() &&
qgsVariantEqual( lhsl[i], rhsl[i] ); i++ )
162 return lhsl.size() < rhsl.size();
167 case QVariant::StringList:
169 const QStringList &lhsl = lhs.toStringList();
170 const QStringList &rhsl = rhs.toStringList();
172 int i, n = std::min( lhsl.size(), rhsl.size() );
173 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
177 return lhsl.size() < rhsl.size();
179 return lhsl[i] < rhsl[i];
183 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
194 if ( path.startsWith( QLatin1String(
"/vsizip/" ), Qt::CaseInsensitive ) )
195 return QStringLiteral(
"/vsizip/" );
196 else if ( path.endsWith( QLatin1String(
".shp.zip" ), Qt::CaseInsensitive ) )
199 if ( GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_VECTOR,
nullptr,
nullptr ) )
201 return QStringLiteral(
"/vsizip/" );
203 else if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) )
204 return QStringLiteral(
"/vsizip/" );
205 else if ( path.startsWith( QLatin1String(
"/vsitar/" ), Qt::CaseInsensitive ) ||
206 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) ||
207 path.endsWith( QLatin1String(
".tar.gz" ), Qt::CaseInsensitive ) ||
208 path.endsWith( QLatin1String(
".tgz" ), Qt::CaseInsensitive ) )
209 return QStringLiteral(
"/vsitar/" );
210 else if ( path.startsWith( QLatin1String(
"/vsigzip/" ), Qt::CaseInsensitive ) ||
211 path.endsWith( QLatin1String(
".gz" ), Qt::CaseInsensitive ) )
212 return QStringLiteral(
"/vsigzip/" );
217 uint
qHash(
const QVariant &variant )
219 if ( !variant.isValid() || variant.isNull() )
220 return std::numeric_limits<uint>::max();
222 switch ( variant.type() )
225 return qHash( variant.toInt() );
227 return qHash( variant.toUInt() );
229 return qHash( variant.toBool() );
230 case QVariant::Double:
231 return qHash( variant.toDouble() );
232 case QVariant::LongLong:
233 return qHash( variant.toLongLong() );
234 case QVariant::ULongLong:
235 return qHash( variant.toULongLong() );
236 case QVariant::String:
237 return qHash( variant.toString() );
239 return qHash( variant.toChar() );
241 return qHash( variant.toList() );
242 case QVariant::StringList:
243 return qHash( variant.toStringList() );
244 case QVariant::ByteArray:
245 return qHash( variant.toByteArray() );
247 return qHash( variant.toDate() );
249 return qHash( variant.toTime() );
250 case QVariant::DateTime:
251 return qHash( variant.toDateTime() );
253 case QVariant::Locale:
254 case QVariant::RegularExpression:
255 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
256 case QVariant::RegExp:
258 return qHash( variant.toString() );
263 return std::numeric_limits<uint>::max();
268 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
273 return QStringLiteral(
"1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
274 "1:10000,1:5000,1:2500,1:1000,1:500" );
279 return QString::fromUtf8( VERSION );
291 return QString::fromUtf8( RELEASE_NAME );
301 return GEOSversion();
306 static const int version = QStringLiteral(
"%1%2%3" )
307 .arg( GEOS_VERSION_MAJOR, 2, 10, QChar(
'0' ) )
308 .arg( GEOS_VERSION_MINOR, 2, 10, QChar(
'0' ) )
316 return GEOS_VERSION_MAJOR;
321 return GEOS_VERSION_MINOR;
326 static const int version = atoi(
xstr( GEOS_VERSION_PATCH ) );
330 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
332 bool qMapLessThanKey<QVariantList>(
const QVariantList &key1,
const QVariantList &key2 )
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 QgsTolerance::UnitType DEFAULT_SNAP_UNITS
Default snapping distance units.
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 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.
UnitType
Type of unit of tolerance value from settings.
@ Pixels
Pixels unit of tolerance.
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.
void * qgsMalloc(size_t size)
Allocates size bytes and returns a pointer to the allocated memory.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.