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 );