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

@@ -28,6 +28,9 @@ swiftConfig(allowNoisyWarnings) {
QMAKE_CXXFLAGS_WARN_ON *= /wd4251 /wd4275 /wd4514 /wd4800 /wd4097 /wd4706 /wd4710 /wd4530 QMAKE_CXXFLAGS_WARN_ON *= /wd4251 /wd4275 /wd4514 /wd4800 /wd4097 /wd4706 /wd4710 /wd4530
} }
} }
else {
DEFINES *= QT_NO_DEPRECATED_WARNINGS
}
# gcc 5 can warn about missing override keyword, # gcc 5 can warn about missing override keyword,
# gcc 6 can do it without thousands of warnings in qt headers # gcc 6 can do it without thousands of warnings in qt headers

View File

@@ -265,7 +265,7 @@ namespace BlackCore
{ {
// ; !CLIENTS section // ; !CLIENTS section
const int i = currentLine.lastIndexOf(' '); const int i = currentLine.lastIndexOf(' ');
const QVector<QStringRef> attributes = currentLine.midRef(i).trimmed().split(':', QString::SkipEmptyParts); const QVector<QStringRef> attributes = currentLine.midRef(i).trimmed().split(':', Qt::SkipEmptyParts);
for (const QStringRef &attr : attributes) { clientSectionAttributes.push_back(attr.toString().trimmed().toLower()); } for (const QStringRef &attr : attributes) { clientSectionAttributes.push_back(attr.toString().trimmed().toLower()); }
section = SectionNone; // reset section = SectionNone; // reset

View File

@@ -388,7 +388,7 @@ namespace BlackGui
void CHotkeyDialog::selectAction() void CHotkeyDialog::selectAction()
{ {
if (m_actionHotkey.getAction().isEmpty()) { return; } if (m_actionHotkey.getAction().isEmpty()) { return; }
const QStringList tokens = m_actionHotkey.getAction().split("/", QString::SkipEmptyParts); const QStringList tokens = m_actionHotkey.getAction().split("/", Qt::SkipEmptyParts);
QModelIndex parentIndex = QModelIndex(); QModelIndex parentIndex = QModelIndex();
for (const QString &token : tokens) for (const QString &token : tokens)

View File

@@ -24,7 +24,7 @@
</size> </size>
</property> </property>
<property name="features"> <property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set> <set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable</set>
</property> </property>
<property name="allowedAreas"> <property name="allowedAreas">
<set>Qt::NoDockWidgetArea</set> <set>Qt::NoDockWidgetArea</set>
@@ -96,7 +96,7 @@
</size> </size>
</property> </property>
<property name="features"> <property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set> <set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable</set>
</property> </property>
<property name="allowedAreas"> <property name="allowedAreas">
<set>Qt::NoDockWidgetArea</set> <set>Qt::NoDockWidgetArea</set>

View File

@@ -117,7 +117,7 @@
<item row="0" column="1" colspan="7"> <item row="0" column="1" colspan="7">
<widget class="QFontComboBox" name="cb_SettingsGuiFont"> <widget class="QFontComboBox" name="cb_SettingsGuiFont">
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum> <enum>QComboBox::AdjustToContents</enum>
</property> </property>
</widget> </widget>
</item> </item>

View File

@@ -109,7 +109,7 @@ namespace BlackGui
for (const QString &actionPath : as_const(keys)) for (const QString &actionPath : as_const(keys))
{ {
QString currentPath; QString currentPath;
const QStringList tokens = actionPath.split("/", QString::SkipEmptyParts); const QStringList tokens = actionPath.split("/", Qt::SkipEmptyParts);
CActionItem *parentItem = m_rootItem.data(); CActionItem *parentItem = m_rootItem.data();
for (const auto &token : tokens) for (const auto &token : tokens)
{ {

View File

@@ -52,7 +52,7 @@ namespace BlackMisc
CLogCategoryList CLogCategoryList::fromQString(const QString &string) 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 bool CLogCategoryList::anyStartWith(const QString &prefix) const

View File

@@ -435,7 +435,7 @@ namespace BlackMisc
QFileInfo fileInfo(fullPath); QFileInfo fileInfo(fullPath);
QStringList dirNames; 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 // Replace the first one being the package name with the package root dir
QString packageRootDir = package.path.mid(package.path.lastIndexOf('/') + 1); QString packageRootDir = package.path.mid(package.path.lastIndexOf('/') + 1);
dirNames.replace(0, packageRootDir); dirNames.replace(0, packageRootDir);
@@ -540,7 +540,7 @@ namespace BlackMisc
} }
QStringList dirNames; 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 // Replace the first one being the package name with the package root dir
QString packageRootDir = package.path.mid(package.path.lastIndexOf('/') + 1); QString packageRootDir = package.path.mid(package.path.lastIndexOf('/') + 1);
dirNames.replace(0, packageRootDir); dirNames.replace(0, packageRootDir);

View File

@@ -295,6 +295,15 @@ namespace BlackMisc
return dt; 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) QDateTime parseMultipleDateTimeFormats(const QString &dateTimeString)
{ {
if (dateTimeString.isEmpty()) { return QDateTime(); } if (dateTimeString.isEmpty()) { return QDateTime(); }
@@ -325,10 +334,10 @@ namespace BlackMisc
ts = fromStringUtc(dateTimeString, Qt::TextDate); ts = fromStringUtc(dateTimeString, Qt::TextDate);
if (ts.isValid()) return ts; if (ts.isValid()) return ts;
ts = fromStringUtc(dateTimeString, Qt::DefaultLocaleLongDate); ts = fromStringUtc(dateTimeString, QLocale(), QLocale::LongFormat);
if (ts.isValid()) return ts; if (ts.isValid()) return ts;
ts = fromStringUtc(dateTimeString, Qt::DefaultLocaleShortDate); ts = fromStringUtc(dateTimeString, QLocale(), QLocale::ShortFormat);
if (ts.isValid()) return ts; if (ts.isValid()) return ts;
// SystemLocaleShortDate, // SystemLocaleShortDate,

View File

@@ -286,6 +286,10 @@ namespace BlackMisc
//! \remark potentially slow, so only to be used when format is unknown //! \remark potentially slow, so only to be used when format is unknown
BLACKMISC_EXPORT QDateTime fromStringUtc(const QString &dateTimeString, Qt::DateFormat format = Qt::TextDate); 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 //! Parse multiple date time formats
//! \remark potentially slow, so only to be used when format is unknown //! \remark potentially slow, so only to be used when format is unknown
//! \remark TZ is UTC //! \remark TZ is UTC

View File

@@ -394,7 +394,7 @@ namespace BlackMisc
if (!equal) if (!equal)
{ {
errors++; 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; return equal;
} }

View File

@@ -304,7 +304,7 @@
</widget> </widget>
<widget class="BlackGui::CDockWidgetInfoBar" name="dw_InfoBarStatus"> <widget class="BlackGui::CDockWidgetInfoBar" name="dw_InfoBarStatus">
<property name="features"> <property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set> <set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable</set>
</property> </property>
<property name="allowedAreas"> <property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set> <set>Qt::TopDockWidgetArea</set>