Suppress Qt 5.15 deprecation warnings

This commit is contained in:
Mat Sutcliffe
2020-05-30 14:53:44 +01:00
parent d4ee4896c1
commit 78987a678f
12 changed files with 29 additions and 13 deletions

View File

@@ -52,7 +52,7 @@ namespace BlackMisc
CLogCategoryList CLogCategoryList::fromQString(const QString &string)
{
return fromQStringList(string.split("|", QString::SkipEmptyParts));
return fromQStringList(string.split("|", Qt::SkipEmptyParts));
}
bool CLogCategoryList::anyStartWith(const QString &prefix) const

View File

@@ -435,7 +435,7 @@ namespace BlackMisc
QFileInfo fileInfo(fullPath);
QStringList dirNames;
dirNames.append(relativePath.split('/', QString::SkipEmptyParts));
dirNames.append(relativePath.split('/', Qt::SkipEmptyParts));
// Replace the first one being the package name with the package root dir
QString packageRootDir = package.path.mid(package.path.lastIndexOf('/') + 1);
dirNames.replace(0, packageRootDir);
@@ -540,7 +540,7 @@ namespace BlackMisc
}
QStringList dirNames;
dirNames.append(relativePath.split('/', QString::SkipEmptyParts));
dirNames.append(relativePath.split('/', Qt::SkipEmptyParts));
// Replace the first one being the package name with the package root dir
QString packageRootDir = package.path.mid(package.path.lastIndexOf('/') + 1);
dirNames.replace(0, packageRootDir);

View File

@@ -295,6 +295,15 @@ namespace BlackMisc
return dt;
}
QDateTime fromStringUtc(const QString& dateTimeString, const QLocale& locale, QLocale::FormatType format)
{
if (dateTimeString.isEmpty()) { return QDateTime(); }
QDateTime dt = locale.toDateTime(dateTimeString, format);
if (!dt.isValid()) { return dt; }
dt.setOffsetFromUtc(0); // must only be applied to valid timestamps
return dt;
}
QDateTime parseMultipleDateTimeFormats(const QString &dateTimeString)
{
if (dateTimeString.isEmpty()) { return QDateTime(); }
@@ -325,10 +334,10 @@ namespace BlackMisc
ts = fromStringUtc(dateTimeString, Qt::TextDate);
if (ts.isValid()) return ts;
ts = fromStringUtc(dateTimeString, Qt::DefaultLocaleLongDate);
ts = fromStringUtc(dateTimeString, QLocale(), QLocale::LongFormat);
if (ts.isValid()) return ts;
ts = fromStringUtc(dateTimeString, Qt::DefaultLocaleShortDate);
ts = fromStringUtc(dateTimeString, QLocale(), QLocale::ShortFormat);
if (ts.isValid()) return ts;
// SystemLocaleShortDate,

View File

@@ -286,6 +286,10 @@ namespace BlackMisc
//! \remark potentially slow, so only to be used when format is unknown
BLACKMISC_EXPORT QDateTime fromStringUtc(const QString &dateTimeString, Qt::DateFormat format = Qt::TextDate);
//! Same as QDateTime::fromString but QDateTime will be set to UTC
//! \remark potentially slow, so only to be used when format is unknown
BLACKMISC_EXPORT QDateTime fromStringUtc(const QString &dateTimeString, const QLocale &locale, QLocale::FormatType format);
//! Parse multiple date time formats
//! \remark potentially slow, so only to be used when format is unknown
//! \remark TZ is UTC

View File

@@ -394,7 +394,7 @@ namespace BlackMisc
if (!equal)
{
errors++;
if (verbose) { ts << "I: " << in.toQString() << endl << "O: " << out.toQString() << Qt::endl; }
if (verbose) { ts << "I: " << in.toQString() << Qt::endl << "O: " << out.toQString() << Qt::endl; }
}
return equal;
}