From f0286740f493aa8d62dd87d8aab4bd27ac3a2e0c Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 20 Jul 2025 23:43:49 +0200 Subject: [PATCH] Replaced deprecated QDateTime::toString by QLocale::toString --- retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp | 3 ++- retroshare-gui/src/gui/Identity/IdDialog.cpp | 3 ++- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 2 +- retroshare-gui/src/util/DateTime.cpp | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index 9056b5f31..c3e3129cb 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -28,6 +28,7 @@ #include "gui/common/FilesDefs.h" #include "gui/msgs/MessageComposer.h" #include "gui/RetroShareLink.h" +#include "util/DateTime.h" #include @@ -148,7 +149,7 @@ void IdDetailsDialog::loadIdentity(RsGxsIdGroup data) ui->autoBanIdentities_CB->setVisible(!data.mPgpId.isNull()) ; ui->banoption_label->setVisible(!data.mPgpId.isNull()) ; - ui->lineEdit_Created->setText(QDateTime::fromMSecsSinceEpoch(qint64(1000)*data.mMeta.mPublishTs).toString(Qt::SystemLocaleShortDate)); + ui->lineEdit_Created->setText(QLocale::system().toString(DateTime::DateTimeFromTime_t(data.mMeta.mPublishTs), QLocale::ShortFormat)); time_t now = time(NULL) ; ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 9d38ed5d3..0e63e54ed 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -50,6 +50,7 @@ #include "util/RsQtVersion.h" #include "util/rstime.h" #include "util/rsdebug.h" +#include "util/DateTime.h" #include "retroshare/rsgxsflags.h" #include "retroshare/rsmsgs.h" @@ -1653,7 +1654,7 @@ void IdDialog::loadIdentity(RsGxsIdGroup data) /* get GPG Details from rsPeers */ RsPgpId ownPgpId = rsPeers->getGPGOwnId(); - ui->lineEdit_PublishTS->setText(QDateTime::fromMSecsSinceEpoch(qint64(1000)*data.mMeta.mPublishTs).toString(Qt::SystemLocaleShortDate)); + ui->lineEdit_PublishTS->setText(QLocale::system().toString(DateTime::DateTimeFromTime_t(data.mMeta.mPublishTs), QLocale::ShortFormat)); //ui->lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE)); ui->lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString())); //ui->lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString())); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 56f7568a5..2a8d1c2f1 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -227,7 +227,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & y += font_height; y += font_height/2.0; - QString info_text = QDateTime::fromMSecsSinceEpoch(qint64(1000)*post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate); + QString info_text = QLocale::system().toString(DateTime::DateTimeFromTime_t(post.mMeta.mPublishTs), QLocale::ShortFormat); if(post.mAttachmentCount > 0) info_text += ", " + QString::number(post.mAttachmentCount)+ " " +((post.mAttachmentCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ; diff --git a/retroshare-gui/src/util/DateTime.cpp b/retroshare-gui/src/util/DateTime.cpp index 2699ba0d3..ea81e69fd 100644 --- a/retroshare-gui/src/util/DateTime.cpp +++ b/retroshare-gui/src/util/DateTime.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ #include +#include #include "DateTime.h" #include "rshare.h" @@ -66,7 +67,7 @@ QString DateTime::formatDate(time_t dateValue) QString DateTime::formatDate(const QDate &dateValue) { - return dateValue.toString(Qt::SystemLocaleShortDate); + return QLocale::system().toString(dateValue, QLocale::ShortFormat); } QString DateTime::formatTime(time_t timeValue) @@ -76,7 +77,7 @@ QString DateTime::formatTime(time_t timeValue) QString DateTime::formatTime(const QTime &timeValue) { - return timeValue.toString(Qt::SystemLocaleShortDate); + return QLocale::system().toString(timeValue, QLocale::ShortFormat); } QDateTime DateTime::DateTimeFromTime_t(time_t timeValue)