Replaced deprecated QDateTime::toTime_t by QDateTime::toSecsSinceEpoch

This commit is contained in:
thunder2 2025-07-20 21:18:36 +02:00
parent 0d37db307c
commit 6251f36e3e
8 changed files with 22 additions and 6 deletions

View file

@ -27,6 +27,7 @@
#include "FeedReaderFeedItem.h" #include "FeedReaderFeedItem.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "retroshare/rsiface.h" #include "retroshare/rsiface.h"
#include "util/DateTime.h"
FeedReaderFeedNotify::FeedReaderFeedNotify(RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent) : FeedReaderFeedNotify::FeedReaderFeedNotify(RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent) :
FeedNotify(parent), mFeedReader(feedReader), mNotify(notify) FeedNotify(parent), mFeedReader(feedReader), mNotify(notify)
@ -135,7 +136,7 @@ FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder */*parent*/)
FeedMsgInfo msgInfo; FeedMsgInfo msgInfo;
msgInfo.title = tr("Test message").toUtf8().constData(); msgInfo.title = tr("Test message").toUtf8().constData();
msgInfo.description = tr("This is a test message.").toUtf8().constData(); msgInfo.description = tr("This is a test message.").toUtf8().constData();
msgInfo.pubDate = QDateTime::currentDateTime().toTime_t(); msgInfo.pubDate = DateTime::DateTimeToTime_t(QDateTime::currentDateTime());
//TODO: parent? //TODO: parent?
return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo); return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo);

View file

@ -40,6 +40,7 @@
#include "util/RsQtVersion.h" #include "util/RsQtVersion.h"
#include "util/RsFile.h" #include "util/RsFile.h"
#include "util/qtthreadsutils.h" #include "util/qtthreadsutils.h"
#include "util/DateTime.h"
#include "retroshare/rsdisc.h" #include "retroshare/rsdisc.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
@ -434,7 +435,7 @@ public:
//Get Last Access on File //Get Last Access on File
if (file.exists()) if (file.exists())
qi64LastDL = file.lastModified().toTime_t(); qi64LastDL = DateTime::DateTimeToTime_t(file.lastModified());
} }
return QVariant(qi64LastDL) ; return QVariant(qi64LastDL) ;
} }

View file

@ -21,6 +21,8 @@
*******************************************************************************/ *******************************************************************************/
#include "guiexprelement.h" #include "guiexprelement.h"
#include "util/DateTime.h"
#define STR_FIELDS_MIN_WFACTOR 20.0 #define STR_FIELDS_MIN_WFACTOR 20.0
#define SIZE_FIELDS_MIN_WFACTOR 8.0 #define SIZE_FIELDS_MIN_WFACTOR 8.0
#define DATE_FIELDS_MIN_WFACTOR 10.0 #define DATE_FIELDS_MIN_WFACTOR 10.0
@ -607,7 +609,7 @@ uint64_t ExprParamElement::getIntValueFromField(QString fieldName, bool isToFiel
#else #else
QDateTime time = dateEdit->date().startOfDay(); QDateTime time = dateEdit->date().startOfDay();
#endif #endif
val = (uint64_t)time.toTime_t(); val = (uint64_t) DateTime::DateTimeToTime_t(time);
break; break;
} }
case SizeSearch: case SizeSearch:

View file

@ -435,7 +435,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
else else
{ {
item->setText(GTW_COLUMN_LAST_POST, itemInfo.lastpost.toString(Qt::ISODate).replace("T"," ")); item->setText(GTW_COLUMN_LAST_POST, itemInfo.lastpost.toString(Qt::ISODate).replace("T"," "));
item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, itemInfo.lastpost.toTime_t()); item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, (qint64) DateTime::DateTimeToTime_t(itemInfo.lastpost));
} }

View file

@ -110,7 +110,7 @@ void SecurityIpItem::updateItemStatic()
} }
QDateTime currentTime = QDateTime::currentDateTime(); QDateTime currentTime = QDateTime::currentDateTime();
ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t())); ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime));
} }
void SecurityIpItem::updateItem() void SecurityIpItem::updateItem()

View file

@ -153,7 +153,7 @@ void SecurityItem::updateItemStatic()
titleLabel->setText(title); titleLabel->setText(title);
QDateTime currentTime = QDateTime::currentDateTime(); QDateTime currentTime = QDateTime::currentDateTime();
timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t())); timeLabel->setText(DateTime::formatLongDateTime(currentTime));
if (mIsHome) if (mIsHome)
{ {

View file

@ -87,3 +87,12 @@ QDateTime DateTime::DateTimeFromTime_t(time_t timeValue)
return QDateTime::fromTime_t(timeValue); return QDateTime::fromTime_t(timeValue);
#endif #endif
} }
time_t DateTime::DateTimeToTime_t(const QDateTime& dateTime)
{
#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0)
return dateTime.toSecsSinceEpoch();
#else
return dateTime.toTime_t();
#endif
}

View file

@ -52,6 +52,9 @@ public:
/* Convert time_t to QDateTime */ /* Convert time_t to QDateTime */
static QDateTime DateTimeFromTime_t(time_t timeValue); static QDateTime DateTimeFromTime_t(time_t timeValue);
/* Convert QDateTime to time_t */
static time_t DateTimeToTime_t(const QDateTime& dateTime);
}; };
#endif #endif