This commit is contained in:
Thunder 2025-07-19 17:43:57 +02:00 committed by GitHub
commit d018beec49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 57 additions and 37 deletions

View file

@ -24,6 +24,7 @@
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "BannedFilesDialog.h" #include "BannedFilesDialog.h"
#include "util/DateTime.h"
#define COLUMN_FILE_NAME 0 #define COLUMN_FILE_NAME 0
#define COLUMN_FILE_HASH 1 #define COLUMN_FILE_HASH 1
@ -80,7 +81,7 @@ void BannedFilesDialog::fillFilesList()
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.mFilename.c_str()),0)); ui.bannedFiles_TW->setItem(row, COLUMN_FILE_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.mFilename.c_str()),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_HASH, new QTableWidgetItem(QIcon(),QString::fromStdString(it->first.toStdString()),0)); ui.bannedFiles_TW->setItem(row, COLUMN_FILE_HASH, new QTableWidgetItem(QIcon(),QString::fromStdString(it->first.toStdString()),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.mSize),0)); ui.bannedFiles_TW->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.mSize),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QDateTime::fromTime_t(it->second.mBanTimeStamp).toString(),0)); ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),DateTime::DateTimeFromTime_t(it->second.mBanTimeStamp).toString(),0));
ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString())); ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString()));

View file

@ -29,6 +29,7 @@
#include <math.h> #include <math.h>
#include "DLListDelegate.h" #include "DLListDelegate.h"
#include "util/DateTime.h"
Q_DECLARE_METATYPE(FileProgressInfo) Q_DECLARE_METATYPE(FileProgressInfo)
@ -261,7 +262,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
break; break;
qi64Value = index.data().value<qint64>(); qi64Value = index.data().value<qint64>();
if (qi64Value < std::numeric_limits<qint64>::max()){ if (qi64Value < std::numeric_limits<qint64>::max()){
QDateTime qdtLastDL = QDateTime::fromTime_t(qi64Value); QDateTime qdtLastDL = DateTime::DateTimeFromTime_t(qi64Value);
painter->drawText(option.rect, Qt::AlignCenter, qdtLastDL.toString("yyyy-MM-dd_hh:mm:ss")); painter->drawText(option.rect, Qt::AlignCenter, qdtLastDL.toString("yyyy-MM-dd_hh:mm:ss"));
} else { } else {
painter->drawText(option.rect, Qt::AlignCenter, tr("File Never Seen")); painter->drawText(option.rect, Qt::AlignCenter, tr("File Never Seen"));

View file

@ -202,8 +202,8 @@ void FriendsDialog::chatMessageReceived(const ChatMessage &msg)
{ {
if(msg.chat_id.isBroadcast()) if(msg.chat_id.isBroadcast())
{ {
QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); QDateTime sendTime = DateTime::DateTimeFromTime_t(msg.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); QDateTime recvTime = DateTime::DateTimeFromTime_t(msg.recvTime);
QString message = QString::fromUtf8(msg.msg.c_str()); QString message = QString::fromUtf8(msg.msg.c_str());
QString name = QString::fromUtf8(rsPeers->getPeerName(msg.broadcast_peer_id).c_str()); QString name = QString::fromUtf8(rsPeers->getPeerName(msg.broadcast_peer_id).c_str());

View file

@ -1022,7 +1022,7 @@ void PostedListWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,b
post.mOlderVersions.insert(post.mMeta.mMsgId); post.mOlderVersions.insert(post.mMeta.mMsgId);
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions);
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, DateTime::DateTimeFromTime_t(post.mMeta.mPublishTs));
return ; return ;
} }
@ -1036,12 +1036,12 @@ void PostedListWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,b
if (item) if (item)
{ {
item->setPost(post); item->setPost(post);
ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); ui->feedWidget->setSort(item, ROLE_PUBLISH, DateTime::DateTimeFromTime_t(meta.mPublishTs));
} }
else else
{ {
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true);
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, DateTime::DateTimeFromTime_t(post.mMeta.mPublishTs));
} }
#ifdef TODO #ifdef TODO
ui->fileWidget->addFiles(post, related); ui->fileWidget->addFiles(post, related);
@ -1067,7 +1067,7 @@ void PostedListWidget::createPostItem(const RsGxsChannelPost& post, bool related
older_versions.insert(meta.mMsgId); older_versions.insert(meta.mMsgId);
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions); GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions);
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, DateTime::DateTimeFromTime_t(meta.mPublishTs));
return ; return ;
} }
@ -1081,12 +1081,12 @@ void PostedListWidget::createPostItem(const RsGxsChannelPost& post, bool related
if (item) if (item)
{ {
item->setPost(post); item->setPost(post);
ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); ui->feedWidget->setSort(item, ROLE_PUBLISH, DateTime::DateTimeFromTime_t(meta.mPublishTs));
} }
else else
{ {
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true); GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true);
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, DateTime::DateTimeFromTime_t(meta.mPublishTs));
} }
ui->fileWidget->addFiles(post, related); ui->fileWidget->addFiles(post, related);

View file

@ -715,7 +715,7 @@ void WikiDialog::GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo,
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str()); groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
//groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc); //groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc);
groupItemInfo.popularity = groupInfo.mPop; groupItemInfo.popularity = groupInfo.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost); groupItemInfo.lastpost = DateTime::DateTimeFromTime_t(groupInfo.mLastPost);
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags; groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;
groupItemInfo.icon = QIcon(IMAGE_WIKI); groupItemInfo.icon = QIcon(IMAGE_WIKI);

View file

@ -47,6 +47,7 @@
#include "retroshare/rsnotify.h" #include "retroshare/rsnotify.h"
#include "util/rstime.h" #include "util/rstime.h"
#include "util/DateTime.h"
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -530,8 +531,8 @@ void ChatLobbyDialog::changeNickname()
*/ */
void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
{ {
QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); QDateTime sendTime = DateTime::DateTimeFromTime_t(msg.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); QDateTime recvTime = DateTime::DateTimeFromTime_t(msg.recvTime);
QString message = QString::fromUtf8(msg.msg.c_str()); QString message = QString::fromUtf8(msg.msg.c_str());
RsGxsId gxs_id = msg.lobby_peer_gxs_id ; RsGxsId gxs_id = msg.lobby_peer_gxs_id ;

View file

@ -416,7 +416,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
name = QString::fromUtf8(historyIt->peerId.toStdString().c_str()); name = QString::fromUtf8(historyIt->peerId.toStdString().c_str());
} }
addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerId.toStdString().c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY); addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerId.toStdString().c_str()), DateTime::DateTimeFromTime_t(historyIt->sendTime), DateTime::DateTimeFromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY);
} }
} }
} }

View file

@ -27,6 +27,7 @@
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/settings/RsharePeerSettings.h" #include "gui/settings/RsharePeerSettings.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "util/DateTime.h"
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
@ -130,8 +131,8 @@ void PopupChatDialog::addChatMsg(const ChatMessage &msg)
{ {
ChatWidget *cw = getChatWidget(); ChatWidget *cw = getChatWidget();
if (cw) { if (cw) {
QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); QDateTime sendTime = DateTime::DateTimeFromTime_t(msg.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); QDateTime recvTime = DateTime::DateTimeFromTime_t(msg.recvTime);
QString additional_info ; QString additional_info ;
QString message = QString::fromUtf8(msg.msg.c_str()); QString message = QString::fromUtf8(msg.msg.c_str());
QString name = msg.incoming? getPeerName(msg.chat_id,additional_info): getOwnName(); QString name = msg.incoming? getPeerName(msg.chat_id,additional_info): getOwnName();

View file

@ -936,7 +936,7 @@ void FriendList::insertPeers()
AvatarDefs::getAvatarFromSslId(RsPeerId(sslDetail.id.toStdString()), sslAvatar); AvatarDefs::getAvatarFromSslId(RsPeerId(sslDetail.id.toStdString()), sslAvatar);
/* last contact */ /* last contact */
QDateTime sslLastContact = QDateTime::fromTime_t(sslDetail.lastConnect); QDateTime sslLastContact = DateTime::DateTimeFromTime_t(sslDetail.lastConnect);
sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact)); sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact));
sslItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, QVariant(sslLastContact)); sslItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, QVariant(sslLastContact));
if (sslLastContact > bestLastContact) { if (sslLastContact > bestLastContact) {

View file

@ -730,13 +730,13 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
{ {
const HierarchicalProfileInformation *hn = getProfileInfo(e); const HierarchicalProfileInformation *hn = getProfileInfo(e);
QDateTime most_recent_time = QDateTime::fromTime_t(0); QDateTime most_recent_time = DateTime::DateTimeFromTime_t(0);
QString most_recent_ip("---"); QString most_recent_ip("---");
for(uint32_t i=0;i<hn->child_node_indices.size();++i) for(uint32_t i=0;i<hn->child_node_indices.size();++i)
{ {
const HierarchicalNodeInformation& node = mLocations[hn->child_node_indices[i]]; const HierarchicalNodeInformation& node = mLocations[hn->child_node_indices[i]];
auto node_time = QDateTime::fromTime_t(node.node_info.lastConnect); auto node_time = DateTime::DateTimeFromTime_t(node.node_info.lastConnect);
if(most_recent_time < node_time) if(most_recent_time < node_time)
{ {
@ -787,7 +787,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
return QVariant(QString::fromUtf8(node->node_info.location.c_str())); return QVariant(QString::fromUtf8(node->node_info.location.c_str()));
} }
case COLUMN_THREAD_LAST_CONTACT: return QVariant(QDateTime::fromTime_t(node->node_info.lastConnect).toString()); case COLUMN_THREAD_LAST_CONTACT: return QVariant(DateTime::DateTimeFromTime_t(node->node_info.lastConnect).toString());
case COLUMN_THREAD_IP: return QVariant( (node->node_info.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(node->node_info) : QString("---")); case COLUMN_THREAD_IP: return QVariant( (node->node_info.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(node->node_info) : QString("---"));
case COLUMN_THREAD_ID: return QVariant( QString::fromStdString(node->node_info.id.toStdString()) ); case COLUMN_THREAD_ID: return QVariant( QString::fromStdString(node->node_info.id.toStdString()) );

View file

@ -424,7 +424,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
} }
/* Set last post */ /* Set last post */
if(itemInfo.lastpost == QDateTime::fromTime_t(0)) if(itemInfo.lastpost == DateTime::DateTimeFromTime_t(0))
{ {
item->setText(GTW_COLUMN_LAST_POST, tr("Never")); item->setText(GTW_COLUMN_LAST_POST, tr("Never"));
item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, QVariant());// To allow them not be sorted with ->setNoDataAsLast(true) item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, QVariant());// To allow them not be sorted with ->setNoDataAsLast(true)
@ -458,7 +458,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags)) if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags))
tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ; tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ;
// if(itemInfo.max_visible_posts) // wtf? this=0 when there are some posts definitely exist - lastpost is recent // if(itemInfo.max_visible_posts) // wtf? this=0 when there are some posts definitely exist - lastpost is recent
if(itemInfo.lastpost == QDateTime::fromTime_t(0)) if(itemInfo.lastpost == DateTime::DateTimeFromTime_t(0))
tooltip += "\n" + tr("Last Post") + ": " + tr("Never") ; tooltip += "\n" + tr("Last Post") + ": " + tr("Never") ;
else else
tooltip += "\n" + tr("Last Post") + ": " + DateTime::formatLongDateTime(itemInfo.lastpost) ; tooltip += "\n" + tr("Last Post") + ": " + DateTime::formatLongDateTime(itemInfo.lastpost) ;

View file

@ -37,6 +37,7 @@
#include "util/qtthreadsutils.h" #include "util/qtthreadsutils.h"
#include "retroshare/rsgxsifacetypes.h" #include "retroshare/rsgxsifacetypes.h"
#include "GxsCommentDialog.h" #include "GxsCommentDialog.h"
#include "util/DateTime.h"
//#define DEBUG_GROUPFRAMEDIALOG //#define DEBUG_GROUPFRAMEDIALOG
@ -331,7 +332,7 @@ void GxsGroupFrameDialog::updateSearchResults(const TurtleRequestId& sid)
i.id = QString(it3->second.mGroupId.toStdString().c_str()); i.id = QString(it3->second.mGroupId.toStdString().c_str());
i.name = QString::fromUtf8(it3->second.mGroupName.c_str()); i.name = QString::fromUtf8(it3->second.mGroupName.c_str());
i.popularity = 0; // could be set to the number of hits i.popularity = 0; // could be set to the number of hits
i.lastpost = QDateTime::fromTime_t(it3->second.mLastMessageTs); i.lastpost = DateTime::DateTimeFromTime_t(it3->second.mLastMessageTs);
i.subscribeFlags = 0; // irrelevant here i.subscribeFlags = 0; // irrelevant here
i.publishKey = false ; // IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags); i.publishKey = false ; // IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags);
i.adminKey = false ; // IS_GROUP_ADMIN(groupInfo.mSubscribeFlags); i.adminKey = false ; // IS_GROUP_ADMIN(groupInfo.mSubscribeFlags);
@ -950,7 +951,7 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *
groupItemInfo.id = QString::fromStdString(groupInfo->mMeta.mGroupId.toStdString()); groupItemInfo.id = QString::fromStdString(groupInfo->mMeta.mGroupId.toStdString());
groupItemInfo.name = QString::fromUtf8(groupInfo->mMeta.mGroupName.c_str()); groupItemInfo.name = QString::fromUtf8(groupInfo->mMeta.mGroupName.c_str());
groupItemInfo.popularity = groupInfo->mMeta.mPop; groupItemInfo.popularity = groupInfo->mMeta.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo->mMeta.mLastPost); groupItemInfo.lastpost = DateTime::DateTimeFromTime_t(groupInfo->mMeta.mLastPost);
groupItemInfo.subscribeFlags = groupInfo->mMeta.mSubscribeFlags; groupItemInfo.subscribeFlags = groupInfo->mMeta.mSubscribeFlags;
groupItemInfo.publishKey = IS_GROUP_PUBLISHER(groupInfo->mMeta.mSubscribeFlags) ; groupItemInfo.publishKey = IS_GROUP_PUBLISHER(groupInfo->mMeta.mSubscribeFlags) ;
groupItemInfo.adminKey = IS_GROUP_ADMIN(groupInfo->mMeta.mSubscribeFlags) ; groupItemInfo.adminKey = IS_GROUP_ADMIN(groupInfo->mMeta.mSubscribeFlags) ;

View file

@ -39,6 +39,7 @@
#include <retroshare/rsidentity.h> #include <retroshare/rsidentity.h>
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "util/DateTime.h"
#define ROLE_MSGID Qt::UserRole #define ROLE_MSGID Qt::UserRole
#define ROLE_PLAINTEXT Qt::UserRole + 1 #define ROLE_PLAINTEXT Qt::UserRole + 1
@ -292,7 +293,7 @@ void ImHistoryBrowser::fillItem(QListWidgetItem *itemWidget, HistoryMsg& msg)
} }
QColor backgroundColor = ui.listWidget->palette().base().color(); QColor backgroundColor = ui.listWidget->palette().base().color();
QString formatMsg = style.formatMessage(type, name, QDateTime::fromTime_t(msg.sendTime), messageText, 0, backgroundColor); QString formatMsg = style.formatMessage(type, name, DateTime::DateTimeFromTime_t(msg.sendTime), messageText, 0, backgroundColor);
itemWidget->setData(Qt::DisplayRole, qVariantFromValue(IMHistoryItemPainter(formatMsg))); itemWidget->setData(Qt::DisplayRole, qVariantFromValue(IMHistoryItemPainter(formatMsg)));
itemWidget->setData(ROLE_MSGID, msg.msgId); itemWidget->setData(ROLE_MSGID, msg.msgId);
@ -467,8 +468,8 @@ QString ImHistoryBrowser::getCurrentItemsQuotedText()
? QString::fromUtf8(details.mNickname.c_str()) ? QString::fromUtf8(details.mNickname.c_str())
: QString::fromUtf8(msg.peerName.c_str()); : QString::fromUtf8(msg.peerName.c_str());
QDateTime date = msg.incoming QDateTime date = msg.incoming
? QDateTime::fromTime_t(msg.sendTime) ? DateTime::DateTimeFromTime_t(msg.sendTime)
: QDateTime::fromTime_t(msg.recvTime); : DateTime::DateTimeFromTime_t(msg.recvTime);
QTextDocument doc; QTextDocument doc;
doc.setHtml(QString::fromUtf8(msg.message.c_str())); doc.setHtml(QString::fromUtf8(msg.message.c_str()));

View file

@ -26,6 +26,7 @@
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "gui/chat/ChatDialog.h" #include "gui/chat/ChatDialog.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/DateTime.h"
#include "retroshare/rsconfig.h" #include "retroshare/rsconfig.h"
#include "retroshare/rshistory.h" #include "retroshare/rshistory.h"
@ -494,7 +495,7 @@ ChatPage::load()
QString tt ; QString tt ;
tt += tr("Name :")+" " + QString::fromUtf8(detail.name.c_str()) ; tt += tr("Name :")+" " + QString::fromUtf8(detail.name.c_str()) ;
tt += "\n" + tr("PGP id :")+" " + QString::fromStdString(invites[i].destination_pgp_id.toStdString()) ; tt += "\n" + tr("PGP id :")+" " + QString::fromStdString(invites[i].destination_pgp_id.toStdString()) ;
tt += "\n" + tr("Valid until :")+" " + QDateTime::fromTime_t(invites[i].time_of_validity).toString() ; tt += "\n" + tr("Valid until :")+" " + DateTime::DateTimeFromTime_t(invites[i].time_of_validity).toString() ;
item->setData(Qt::UserRole,QString::fromStdString(invites[i].pid.toStdString())) ; item->setData(Qt::UserRole,QString::fromStdString(invites[i].pid.toStdString())) ;
item->setToolTip(tt) ; item->setToolTip(tt) ;
@ -538,7 +539,7 @@ void ChatPage::setPreviewMessages(QString &stylePath, QString styleVariant, QTex
QString nameIncoming = tr("Incoming"); QString nameIncoming = tr("Incoming");
QString nameOutgoing = tr("Outgoing"); QString nameOutgoing = tr("Outgoing");
QDateTime timestmp = QDateTime::fromTime_t(time(NULL)); QDateTime timestmp = DateTime::DateTimeFromTime_t(time(NULL));
QColor backgroundColor = textBrowser->palette().base().color(); QColor backgroundColor = textBrowser->palette().base().color();
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HINCOMING, nameIncoming, timestmp, tr("Incoming message in history"), 0, backgroundColor)); textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HINCOMING, nameIncoming, timestmp, tr("Incoming message in history"), 0, backgroundColor));

View file

@ -53,6 +53,7 @@
#include "gui/Identity/IdDialog.h" #include "gui/Identity/IdDialog.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
#include "util/DateTime.h"
#define COL_PENDING_ID 0 #define COL_PENDING_ID 0
#define COL_PENDING_DESTINATION 1 #define COL_PENDING_DESTINATION 1
@ -255,7 +256,7 @@ void GxsTransportStatistics::updateContent()
item -> setData(COL_PENDING_DATASTATUS, Qt::DisplayRole, getStatusString(rec.status)); item -> setData(COL_PENDING_DATASTATUS, Qt::DisplayRole, getStatusString(rec.status));
item -> setData(COL_PENDING_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(rec.data_size)); item -> setData(COL_PENDING_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(rec.data_size));
item -> setData(COL_PENDING_DATAHASH, Qt::DisplayRole, QString::fromStdString(rec.data_hash.toStdString())); item -> setData(COL_PENDING_DATAHASH, Qt::DisplayRole, QString::fromStdString(rec.data_hash.toStdString()));
item -> setData(COL_PENDING_SEND, Qt::DisplayRole, QDateTime::fromTime_t(rec.send_TS).toString()); item -> setData(COL_PENDING_SEND, Qt::DisplayRole, DateTime::DateTimeFromTime_t(rec.send_TS).toString());
item -> setData(COL_PENDING_GROUP_ID, Qt::DisplayRole, QString::fromStdString(rec.group_id.toStdString())); item -> setData(COL_PENDING_GROUP_ID, Qt::DisplayRole, QString::fromStdString(rec.group_id.toStdString()));
item -> setData(COL_PENDING_DESTINATION_ID, Qt::DisplayRole, QString::fromStdString(rec.recipient.toStdString())); item -> setData(COL_PENDING_DESTINATION_ID, Qt::DisplayRole, QString::fromStdString(rec.recipient.toStdString()));
item -> setData(COL_PENDING_SENDTIME, Qt::DisplayRole, QString::number(now - rec.send_TS)); item -> setData(COL_PENDING_SENDTIME, Qt::DisplayRole, QString::number(now - rec.send_TS));
@ -296,7 +297,7 @@ void GxsTransportStatistics::updateContent()
groupTreeWidget->addTopLevelItem(item); groupTreeWidget->addTopLevelItem(item);
groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end()); groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end());
QString msg_time_string = (stat.last_publish_TS>0)?QString("(Last msg: %1)").arg(QDateTime::fromTime_t((uint)stat.last_publish_TS).toString()):"" ; QString msg_time_string = (stat.last_publish_TS>0)?QString("(Last msg: %1)").arg(DateTime::DateTimeFromTime_t((uint)stat.last_publish_TS).toString()):"" ;
item->setData(COL_GROUP_PUBLISHTS, Qt::DisplayRole, msg_time_string) ; item->setData(COL_GROUP_PUBLISHTS, Qt::DisplayRole, msg_time_string) ;
item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs) ) ; item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs) ) ;
@ -340,7 +341,7 @@ void GxsTransportStatistics::updateContent()
sitem->setData(COL_GROUP_UNIQUE_ID, Qt::DisplayRole,QString::fromStdString(meta.mMsgId.toStdString())); sitem->setData(COL_GROUP_UNIQUE_ID, Qt::DisplayRole,QString::fromStdString(meta.mMsgId.toStdString()));
sitem->setData(COL_GROUP_AUTHOR_ID, Qt::DisplayRole, QString::fromStdString(meta.mAuthorId.toStdString())) ; sitem->setData(COL_GROUP_AUTHOR_ID, Qt::DisplayRole, QString::fromStdString(meta.mAuthorId.toStdString())) ;
sitem->setText(COL_GROUP_PUBLISHTS, QDateTime::fromTime_t(meta.mPublishTs).toString()); sitem->setText(COL_GROUP_PUBLISHTS, DateTime::DateTimeFromTime_t(meta.mPublishTs).toString());
sitem->setData(COL_GROUP_PUBLISHTS, Qt::UserRole, qdatetime); sitem->setData(COL_GROUP_PUBLISHTS, Qt::UserRole, qdatetime);
} }
} }

View file

@ -25,7 +25,7 @@
QString DateTime::formatLongDate(time_t dateValue) QString DateTime::formatLongDate(time_t dateValue)
{ {
return formatLongDate(QDateTime::fromTime_t(dateValue).date()); return formatLongDate(DateTimeFromTime_t(dateValue).date());
} }
QString DateTime::formatLongDate(const QDate &dateValue) QString DateTime::formatLongDate(const QDate &dateValue)
@ -41,7 +41,7 @@ QString DateTime::formatLongDate(const QDate &dateValue)
QString DateTime::formatLongDateTime(time_t datetimeValue) QString DateTime::formatLongDateTime(time_t datetimeValue)
{ {
return formatLongDateTime(QDateTime::fromTime_t(datetimeValue)); return formatLongDateTime(DateTimeFromTime_t(datetimeValue));
} }
QString DateTime::formatLongDateTime(const QDateTime &datetimeValue) QString DateTime::formatLongDateTime(const QDateTime &datetimeValue)
@ -51,7 +51,7 @@ QString DateTime::formatLongDateTime(const QDateTime &datetimeValue)
QString DateTime::formatDateTime(time_t datetimeValue) QString DateTime::formatDateTime(time_t datetimeValue)
{ {
return formatDateTime(QDateTime::fromTime_t(datetimeValue)); return formatDateTime(DateTimeFromTime_t(datetimeValue));
} }
QString DateTime::formatDateTime(const QDateTime &datetimeValue) QString DateTime::formatDateTime(const QDateTime &datetimeValue)
@ -61,7 +61,7 @@ QString DateTime::formatDateTime(const QDateTime &datetimeValue)
QString DateTime::formatDate(time_t dateValue) QString DateTime::formatDate(time_t dateValue)
{ {
return formatDate(QDateTime::fromTime_t(dateValue).date()); return formatDate(DateTimeFromTime_t(dateValue).date());
} }
QString DateTime::formatDate(const QDate &dateValue) QString DateTime::formatDate(const QDate &dateValue)
@ -71,10 +71,19 @@ QString DateTime::formatDate(const QDate &dateValue)
QString DateTime::formatTime(time_t timeValue) QString DateTime::formatTime(time_t timeValue)
{ {
return formatTime(QDateTime::fromTime_t(timeValue).time()); return formatTime(DateTimeFromTime_t(timeValue).time());
} }
QString DateTime::formatTime(const QTime &timeValue) QString DateTime::formatTime(const QTime &timeValue)
{ {
return timeValue.toString(Qt::SystemLocaleShortDate); return timeValue.toString(Qt::SystemLocaleShortDate);
} }
QDateTime DateTime::DateTimeFromTime_t(time_t timeValue)
{
#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0)
return QDateTime::fromSecsSinceEpoch(timeValue);
#else
return QDateTime::fromTime_t(timeValue);
#endif
}

View file

@ -49,6 +49,9 @@ public:
/* format date and time (see formatDate & formatTime) */ /* format date and time (see formatDate & formatTime) */
static QString formatDateTime(time_t datetimeValue); static QString formatDateTime(time_t datetimeValue);
static QString formatDateTime(const QDateTime &datetimeValue); static QString formatDateTime(const QDateTime &datetimeValue);
/* Convert time_t to QDateTime */
static QDateTime DateTimeFromTime_t(time_t timeValue);
}; };
#endif #endif