From e2a233122f527282149fd5c79425874100db5aec Mon Sep 17 00:00:00 2001 From: Fanda Vacek Date: Mon, 21 Oct 2024 19:53:46 +0200 Subject: [PATCH] Fix Qt 6.8 deprecations --- libshvcoreqt/src/rpc.cpp | 12 +++++++++- libshvvisu/src/logview/dlgloginspector.cpp | 7 ++++++ libshvvisu/src/logview/dlgloginspector.ui | 28 +++++++++------------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/libshvcoreqt/src/rpc.cpp b/libshvcoreqt/src/rpc.cpp index 620b9f3f4..50b5984c2 100644 --- a/libshvcoreqt/src/rpc.cpp +++ b/libshvcoreqt/src/rpc.cpp @@ -3,6 +3,7 @@ #include #include +#include namespace shv::coreqt::rpc { @@ -33,7 +34,11 @@ QVariant rpcValueToQVariant(const chainpack::RpcValue &v, bool *ok) } case chainpack::RpcValue::Type::DateTime: { chainpack::RpcValue::DateTime cdt = v.toDateTime(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + QDateTime dt = QDateTime::fromMSecsSinceEpoch(cdt.msecsSinceEpoch(), QTimeZone::fromSecondsAheadOfUtc(cdt.utcOffsetMin() * 60)); +#else QDateTime dt = QDateTime::fromMSecsSinceEpoch(cdt.msecsSinceEpoch(), Qt::OffsetFromUTC, cdt.utcOffsetMin() * 60); +#endif return dt; } case chainpack::RpcValue::Type::List: { @@ -175,7 +180,12 @@ template<> QDateTime shv::chainpack::RpcValue::to() const if (!isValid() || !isDateTime()) { return QDateTime(); } - return QDateTime::fromMSecsSinceEpoch(toDateTime().msecsSinceEpoch(), Qt::TimeSpec::UTC); + auto dt = toDateTime(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + return QDateTime::fromMSecsSinceEpoch(dt.msecsSinceEpoch(), QTimeZone::fromSecondsAheadOfUtc(dt.utcOffsetMin() * 60)); +#else + return QDateTime::fromMSecsSinceEpoch(dt.msecsSinceEpoch(), Qt::OffsetFromUTC, dt.utcOffsetMin() * 60); +#endif } #ifdef __GNUC__ #pragma GCC diagnostic pop diff --git a/libshvvisu/src/logview/dlgloginspector.cpp b/libshvvisu/src/logview/dlgloginspector.cpp index d6d590c9d..e4a8df490 100644 --- a/libshvvisu/src/logview/dlgloginspector.cpp +++ b/libshvvisu/src/logview/dlgloginspector.cpp @@ -44,6 +44,13 @@ DlgLogInspector::DlgLogInspector(const QString &shv_path, QWidget *parent) : ui(new Ui::DlgLogInspector) { ui->setupUi(this); +#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + ui->edSince->setTimeZone(QTimeZone::UTC); + ui->edUntil->setTimeZone(QTimeZone::UTC); +#else + ui->edSince->setTimeSpec(Qt::UTC); + ui->edUntil->setTimeSpec(Qt::UTC); +#endif setShvPath(shv_path); { auto *m = new QMenu(this); diff --git a/libshvvisu/src/logview/dlgloginspector.ui b/libshvvisu/src/logview/dlgloginspector.ui index 5df5733e6..a17508f79 100644 --- a/libshvvisu/src/logview/dlgloginspector.ui +++ b/libshvvisu/src/logview/dlgloginspector.ui @@ -56,7 +56,7 @@ - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter Not defined @@ -74,9 +74,6 @@ true - - Qt::UTC - @@ -107,7 +104,7 @@ - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter Not defined @@ -125,9 +122,6 @@ true - - Qt::UTC - @@ -166,7 +160,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -212,7 +206,7 @@ - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter 0 @@ -234,7 +228,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -247,7 +241,7 @@ - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter sec @@ -353,10 +347,10 @@ - QFrame::NoFrame + QFrame::Shape::NoFrame - QFrame::Raised + QFrame::Shadow::Raised @@ -416,7 +410,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -465,7 +459,7 @@ 0 0 1152 - 354 + 295 @@ -492,7 +486,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal