mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix Forum Item sort on LastPost View.
msg.mMeta.mChildTs Was not updated when received new child so do it when creating GxsIdRSTreeWidgetItem.
This commit is contained in:
parent
f3d1a6c1ec
commit
beab81e134
@ -39,20 +39,20 @@ uint32_t RsGxsGrpMetaData::serial_size(uint32_t api_version)
|
||||
|
||||
s += mGroupId.serial_size();
|
||||
s += mOrigGrpId.serial_size();
|
||||
s += mParentGrpId.serial_size();
|
||||
s += mParentGrpId.serial_size();
|
||||
s += GetTlvStringSize(mGroupName);
|
||||
s += 4; // mGroupFlags
|
||||
s += 4; // mPublishTs
|
||||
s += 4; // mCircleType
|
||||
s += 4; // mAuthenFlag
|
||||
s += 4; // mGroupFlags
|
||||
s += 4; // mPublishTs
|
||||
s += 4; // mCircleType
|
||||
s += 4; // mAuthenFlag
|
||||
s += mAuthorId.serial_size();
|
||||
s += GetTlvStringSize(mServiceString);
|
||||
s += mCircleId.serial_size();
|
||||
s += mCircleId.serial_size();
|
||||
s += signSet.TlvSize();
|
||||
s += keys.TlvSize();
|
||||
|
||||
if(api_version == RS_GXS_GRP_META_DATA_VERSION_ID_0002)
|
||||
s += 4; // mSignFlag
|
||||
s += 4; // mSignFlag
|
||||
else if(api_version != RS_GXS_GRP_META_DATA_VERSION_ID_0001)
|
||||
std::cerr << "(EE) wrong/unknown API version " << api_version << " requested in RsGxsGrpMetaData::serial_size()" << std::endl;
|
||||
|
||||
@ -203,7 +203,7 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
||||
int RsGxsMsgMetaData::refcount = 0;
|
||||
|
||||
RsGxsMsgMetaData::RsGxsMsgMetaData(){
|
||||
|
||||
clear();
|
||||
//std::cout << "\nrefcount++ : " << ++refcount << std::endl;
|
||||
return;
|
||||
}
|
||||
@ -227,8 +227,8 @@ uint32_t RsGxsMsgMetaData::serial_size()
|
||||
|
||||
s += signSet.TlvSize();
|
||||
s += GetTlvStringSize(mMsgName);
|
||||
s += 4; // mPublishTS
|
||||
s += 4; // mMsgFlags
|
||||
s += 4; // mPublishTS
|
||||
s += 4; // mMsgFlags
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -311,7 +311,7 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
|
||||
|
||||
ok &= signSet.GetTlv(data, *size, &offset);
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mMsgName);
|
||||
uint32_t t=0;
|
||||
uint32_t t=0;
|
||||
ok &= getRawUInt32(data, *size, &offset, &t);
|
||||
mPublishTs = t;
|
||||
ok &= getRawUInt32(data, *size, &offset, &mMsgFlags);
|
||||
|
@ -973,44 +973,54 @@ void GxsForumThreadWidget::fillThreadStatus(QString text)
|
||||
ui->progressText->setText(text);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
|
||||
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *parent)
|
||||
{
|
||||
// Early check for a message that should be hidden because its author
|
||||
// is flagged with a bad reputation
|
||||
|
||||
|
||||
bool redacted = rsIdentity->isBanned(msg.mMeta.mAuthorId) ;
|
||||
|
||||
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL || (redacted?(GxsIdDetails::ICON_TYPE_REDACTED):0));
|
||||
// Early check for a message that should be hidden because its author
|
||||
// is flagged with a bad reputation
|
||||
|
||||
|
||||
bool redacted = rsIdentity->isBanned(msg.mMeta.mAuthorId) ;
|
||||
|
||||
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL || (redacted?(GxsIdDetails::ICON_TYPE_REDACTED):0));
|
||||
item->moveToThread(ui->threadTreeWidget->thread());
|
||||
|
||||
QString text;
|
||||
|
||||
if(redacted)
|
||||
if(redacted)
|
||||
item->setText(COLUMN_THREAD_TITLE, tr("[ ... Redacted message ... ]"));
|
||||
else
|
||||
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
|
||||
|
||||
|
||||
//msg.mMeta.mChildTs Was not updated when received new child
|
||||
// so do it here.
|
||||
QDateTime qtime;
|
||||
QString sort;
|
||||
qtime.setTime_t(msg.mMeta.mPublishTs);
|
||||
|
||||
if (useChildTS)
|
||||
qtime.setTime_t(msg.mMeta.mChildTs);
|
||||
else
|
||||
qtime.setTime_t(msg.mMeta.mPublishTs);
|
||||
|
||||
text = DateTime::formatDateTime(qtime);
|
||||
sort = qtime.toString("yyyyMMdd_hhmmss");
|
||||
QString itemText = DateTime::formatDateTime(qtime);
|
||||
QString itemSort = QString::number(msg.mMeta.mPublishTs);//Don't need to format it as for sort.
|
||||
|
||||
if (useChildTS)
|
||||
{
|
||||
qtime.setTime_t(msg.mMeta.mPublishTs);
|
||||
text += " / ";
|
||||
text += DateTime::formatDateTime(qtime);
|
||||
sort += "_" + qtime.toString("yyyyMMdd_hhmmss");
|
||||
for(QTreeWidgetItem *grandParent = parent; grandParent!=NULL; grandParent = grandParent->parent())
|
||||
{
|
||||
//Update Parent Child TimeStamp
|
||||
QString oldTSText = grandParent->text(COLUMN_THREAD_DATE);
|
||||
QString oldTSSort = grandParent->data(COLUMN_THREAD_DATE, ROLE_THREAD_SORT).toString();
|
||||
|
||||
QString oldCTSText = oldTSText.split("|").at(0);
|
||||
QString oldPTSText = oldTSText.contains("|") ? oldTSText.split(" | ").at(1) : oldCTSText;//If first time parent get only its mPublishTs
|
||||
QString oldCTSSort = oldTSSort.split("|").at(0);
|
||||
QString oldPTSSort = oldTSSort.contains("|") ? oldTSSort.split(" | ").at(1) : oldCTSSort;
|
||||
if (oldCTSSort.toDouble() < itemSort.toDouble())
|
||||
{
|
||||
grandParent->setText(COLUMN_THREAD_DATE, DateTime::formatDateTime(qtime) + " | " + oldPTSText);
|
||||
grandParent->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, itemSort + " | " + oldPTSSort);
|
||||
}
|
||||
}
|
||||
}
|
||||
item->setText(COLUMN_THREAD_DATE, text);
|
||||
item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, sort);
|
||||
|
||||
item->setText(COLUMN_THREAD_DATE, itemText);
|
||||
item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, itemSort);
|
||||
|
||||
// Set later with GxsIdRSTreeWidgetItem::setId
|
||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId.toStdString()));
|
||||
@ -1061,7 +1071,8 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
||||
#endif
|
||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msg.mMeta.mMsgStatus);
|
||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, false);
|
||||
|
||||
|
||||
if (parent) parent->addChild(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
unsigned int newCount() { return mNewCount; }
|
||||
unsigned int unreadCount() { return mUnreadCount; }
|
||||
|
||||
QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn);
|
||||
QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *parent = NULL);
|
||||
QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId);
|
||||
|
||||
// Callback for all Loads.
|
||||
|
@ -218,8 +218,7 @@ void GxsForumsFillThread::run()
|
||||
std::cerr << "GxsForumsFillThread::run() adding " << msg.mMeta.mMsgId << std::endl;
|
||||
#endif
|
||||
|
||||
QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn);
|
||||
threadPair.second->addChild(item);
|
||||
QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn, threadPair.second);
|
||||
|
||||
calculateExpand(msg, item);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user