20 #include "qgsversion.h"
22 #include <QCoreApplication>
28 #include "qgsconfig.h"
68 string.remove( QLocale().groupSeparator() );
69 return QLocale().toDouble(
string, &ok );
75 string.remove( QLocale().groupSeparator() );
76 return QLocale().toInt(
string, &ok );
82 string.remove( QLocale().groupSeparator() );
83 return QLocale().toLongLong(
string, &ok );
88 if ( size == 0 ||
long( size ) < 0 )
90 QgsDebugMsg( QStringLiteral(
"Negative or zero size %1." ).arg( size ) );
93 void *p = malloc( size );
96 QgsDebugMsg( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
103 if ( nmemb == 0 ||
long( nmemb ) < 0 || size == 0 ||
long( size ) < 0 )
105 QgsDebugMsg( QStringLiteral(
"Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) );
111 memset( p, 0, nmemb * 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.type() )
134 return lhs.toInt() < rhs.toInt();
136 return lhs.toUInt() < rhs.toUInt();
137 case QVariant::LongLong:
138 return lhs.toLongLong() < rhs.toLongLong();
139 case QVariant::ULongLong:
140 return lhs.toULongLong() < rhs.toULongLong();
141 case QVariant::Double:
142 return lhs.toDouble() < rhs.toDouble();
144 return lhs.toChar() < rhs.toChar();
146 return lhs.toDate() < rhs.toDate();
148 return lhs.toTime() < rhs.toTime();
149 case QVariant::DateTime:
150 return lhs.toDateTime() < rhs.toDateTime();
152 return lhs.toBool() < rhs.toBool();
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].type() == rhsl[i].type() &&
qgsVariantEqual( lhsl[i], rhsl[i] ); i++ )
164 return lhsl.size() < rhsl.size();
169 case QVariant::StringList:
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;
196 if ( path.startsWith( QLatin1String(
"/vsizip/" ), Qt::CaseInsensitive ) )
197 return QStringLiteral(
"/vsizip/" );
198 else if ( path.endsWith( QLatin1String(
".shp.zip" ), Qt::CaseInsensitive ) )
201 if ( GDALIdentifyDriver( path.toUtf8().constData(),
nullptr ) )
203 return QStringLiteral(
"/vsizip/" );
205 else if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) )
206 return QStringLiteral(
"/vsizip/" );
207 else if ( path.startsWith( QLatin1String(
"/vsitar/" ), Qt::CaseInsensitive ) ||
208 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) ||
209 path.endsWith( QLatin1String(
".tar.gz" ), Qt::CaseInsensitive ) ||
210 path.endsWith( QLatin1String(
".tgz" ), Qt::CaseInsensitive ) )
211 return QStringLiteral(
"/vsitar/" );
212 else if ( path.startsWith( QLatin1String(
"/vsigzip/" ), Qt::CaseInsensitive ) ||
213 path.endsWith( QLatin1String(
".gz" ), Qt::CaseInsensitive ) )
214 return QStringLiteral(
"/vsigzip/" );
219 uint
qHash(
const QVariant &variant )
221 if ( !variant.isValid() || variant.isNull() )
222 return std::numeric_limits<uint>::max();
224 switch ( variant.type() )
227 return qHash( variant.toInt() );
229 return qHash( variant.toUInt() );
231 return qHash( variant.toBool() );
232 case QVariant::Double:
233 return qHash( variant.toDouble() );
234 case QVariant::LongLong:
235 return qHash( variant.toLongLong() );
236 case QVariant::ULongLong:
237 return qHash( variant.toULongLong() );
238 case QVariant::String:
239 return qHash( variant.toString() );
241 return qHash( variant.toChar() );
243 return qHash( variant.toList() );
244 case QVariant::StringList:
245 return qHash( variant.toStringList() );
246 case QVariant::ByteArray:
247 return qHash( variant.toByteArray() );
249 return qHash( variant.toDate() );
251 return qHash( variant.toTime() );
252 case QVariant::DateTime:
253 return qHash( variant.toDateTime() );
255 case QVariant::Locale:
256 case QVariant::RegExp:
257 return qHash( variant.toString() );
262 return std::numeric_limits<uint>::max();
267 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
272 return QStringLiteral(
"1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
273 "1:10000,1:5000,1:2500,1:1000,1:500" );
278 return QString::fromUtf8( VERSION );
290 return QString::fromUtf8( RELEASE_NAME );
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 for 2.5d geometry This value have to be assigned to the Z coordinate for t...
static const char * QGIS_DEV_VERSION
The development version.
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_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm.
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 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 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.
bool qMapLessThanKey< QVariantList >(const QVariantList &key1, const QVariantList &key2)
Compares two QVariantList values and returns whether the first is less than the second.
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 * qgsCalloc(size_t nmemb, size_t size)
Allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the alloc...
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.