merge bitcoin-core/gui#349: replace QDateTime::fromTime_t with QDateTime::fromSecsSinceEpoch

This commit is contained in:
Kittywhiskers Van Gogh 2024-10-22 09:12:56 +00:00
parent 70d4e08011
commit ba5ad1fc6c
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
8 changed files with 16 additions and 12 deletions

View File

@ -819,8 +819,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromTime_t(tip_info->header_time));
setNumBlocks(tip_info->block_height, QDateTime::fromTime_t(tip_info->block_time), QString::fromStdString(tip_info->block_hash.ToString()), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD);
modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromSecsSinceEpoch(tip_info->header_time));
setNumBlocks(tip_info->block_height, QDateTime::fromSecsSinceEpoch(tip_info->block_time), QString::fromStdString(tip_info->block_hash.ToString()), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD);
connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks);
connect(_clientModel, &ClientModel::additionalDataSyncProgressChanged, this, &BitcoinGUI::setAdditionalDataSyncProgress);
@ -1281,7 +1281,7 @@ void BitcoinGUI::updateNetworkState()
}
if (fNetworkBecameActive || fNetworkBecameInactive) {
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD);
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromSecsSinceEpoch(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD);
}
nCountPrev = count;
@ -1545,7 +1545,7 @@ void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress)
// If masternodeSync->Reset() has been called make sure status bar shows the correct information.
if (nSyncProgress == -1) {
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD);
setNumBlocks(m_node.getNumBlocks(), QDateTime::fromSecsSinceEpoch(m_node.getLastBlockTime()), QString::fromStdString(m_node.getLastBlockHash()), m_node.getVerificationProgress(), false, SynchronizationState::INIT_DOWNLOAD);
if (clientModel->getNumConnections()) {
labelBlocksIcon->show();
startSpinner();

View File

@ -251,7 +251,7 @@ bool ClientModel::isReleaseVersion() const
QString ClientModel::formatClientStartupTime() const
{
return QDateTime::fromTime_t(GetStartupTime()).toString();
return QDateTime::fromSecsSinceEpoch(GetStartupTime()).toString();
}
QString ClientModel::dataDir() const
@ -329,7 +329,7 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_
bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
Q_ARG(int, tip.block_height),
Q_ARG(QDateTime, QDateTime::fromTime_t(tip.block_time)),
Q_ARG(QDateTime, QDateTime::fromSecsSinceEpoch(tip.block_time)),
Q_ARG(QString, QString::fromStdString(tip.block_hash.ToString())),
Q_ARG(double, verificationProgress),
Q_ARG(bool, fHeader),

View File

@ -263,7 +263,7 @@ QString dateTimeStr(const QDateTime &date)
QString dateTimeStr(qint64 nTime)
{
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
return dateTimeStr(QDateTime::fromSecsSinceEpoch((qint32)nTime));
}
QFont fixedPitchFont(bool use_embedded_font)

View File

@ -234,7 +234,7 @@ bool RecentRequestEntryLessThan::operator()(const RecentRequestEntry& left, cons
switch(column)
{
case RecentRequestsTableModel::Date:
return pLeft->date.toTime_t() < pRight->date.toTime_t();
return pLeft->date.toSecsSinceEpoch() < pRight->date.toSecsSinceEpoch();
case RecentRequestsTableModel::Label:
return pLeft->recipient.label < pRight->recipient.label;
case RecentRequestsTableModel::Message:

View File

@ -7,6 +7,8 @@
#include <qt/sendcoinsrecipient.h>
#include <string>
#include <QAbstractTableModel>
#include <QStringList>
#include <QDateTime>
@ -26,9 +28,9 @@ public:
SERIALIZE_METHODS(RecentRequestEntry, obj) {
unsigned int date_timet;
SER_WRITE(obj, date_timet = obj.date.toTime_t());
SER_WRITE(obj, date_timet = obj.date.toSecsSinceEpoch());
READWRITE(obj.nVersion, obj.id, date_timet, obj.recipient);
SER_READ(obj, obj.date = QDateTime::fromTime_t(date_timet));
SER_READ(obj, obj.date = QDateTime::fromSecsSinceEpoch(date_timet));
}
};

View File

@ -696,7 +696,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
setNumConnections(model->getNumConnections());
connect(model, &ClientModel::numConnectionsChanged, this, &RPCConsole::setNumConnections);
setNumBlocks(bestblock_height, QDateTime::fromTime_t(bestblock_date), QString::fromStdString(bestblock_hash.ToString()), verification_progress, false);
setNumBlocks(bestblock_height, QDateTime::fromSecsSinceEpoch(bestblock_date), QString::fromStdString(bestblock_hash.ToString()), verification_progress, false);
connect(model, &ClientModel::numBlocksChanged, this, &RPCConsole::setNumBlocks);
connect(model, &ClientModel::chainLockChanged, this, &RPCConsole::setChainLock);

View File

@ -7,7 +7,9 @@
#include <qt/transactiontablemodel.h>
#include <qt/transactionrecord.h>
#include <algorithm>
#include <cstdlib>
#include <optional>
TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
QSortFilterProxyModel(parent),

View File

@ -697,7 +697,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case TypeRole:
return rec->type;
case DateRole:
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
return QDateTime::fromSecsSinceEpoch(rec->time);
case DateRoleInt:
return qint64(rec->time);
case WatchonlyRole: