Skip to content

Commit

Permalink
Fix Qt 6.8 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Oct 21, 2024
1 parent 5d49c61 commit 9086eed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
12 changes: 11 additions & 1 deletion libshvcoreqt/src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <shv/coreqt/log.h>

#include <QVariant>
#include <QTimeZone>

namespace shv::coreqt::rpc {

Expand Down Expand Up @@ -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_MAJOR >= 6
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: {
Expand Down Expand Up @@ -175,7 +180,12 @@ template<> QDateTime shv::chainpack::RpcValue::to<QDateTime>() const
if (!isValid() || !isDateTime()) {
return QDateTime();
}
return QDateTime::fromMSecsSinceEpoch(toDateTime().msecsSinceEpoch(), Qt::TimeSpec::UTC);
auto dt = toDateTime();
#if QT_VERSION_MAJOR >= 6
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
Expand Down
7 changes: 7 additions & 0 deletions libshvvisu/src/logview/dlgloginspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ DlgLogInspector::DlgLogInspector(const QString &shv_path, QWidget *parent) :
ui(new Ui::DlgLogInspector)
{
ui->setupUi(this);
#if QT_VERSION_MAJOR >= 6
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);
Expand Down
28 changes: 11 additions & 17 deletions libshvvisu/src/logview/dlgloginspector.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<item>
<widget class="QDateTimeEdit" name="edSince">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not defined</string>
Expand All @@ -74,9 +74,6 @@
<property name="calendarPopup">
<bool>true</bool>
</property>
<property name="timeSpec">
<enum>Qt::UTC</enum>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -107,7 +104,7 @@
<item>
<widget class="QDateTimeEdit" name="edUntil">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not defined</string>
Expand All @@ -125,9 +122,6 @@
<property name="calendarPopup">
<bool>true</bool>
</property>
<property name="timeSpec">
<enum>Qt::UTC</enum>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -166,7 +160,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -212,7 +206,7 @@
<item row="2" column="1">
<widget class="QSpinBox" name="edMaxRecordCount">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
Expand All @@ -234,7 +228,7 @@
<item row="2" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -247,7 +241,7 @@
<item row="3" column="1">
<widget class="QSpinBox" name="edTimeout">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="suffix">
<string> sec</string>
Expand Down Expand Up @@ -353,10 +347,10 @@
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
Expand Down Expand Up @@ -416,7 +410,7 @@
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -465,7 +459,7 @@
<x>0</x>
<y>0</y>
<width>1152</width>
<height>354</height>
<height>295</height>
</rect>
</property>
</widget>
Expand All @@ -492,7 +486,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down

0 comments on commit 9086eed

Please sign in to comment.