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
@ -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;
|
||||
}
|
||||
|
@ -973,7 +973,7 @@ 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
|
||||
@ -984,33 +984,43 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
||||
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL || (redacted?(GxsIdDetails::ICON_TYPE_REDACTED):0));
|
||||
item->moveToThread(ui->threadTreeWidget->thread());
|
||||
|
||||
QString text;
|
||||
|
||||
if(redacted)
|
||||
item->setText(COLUMN_THREAD_TITLE, tr("[ ... Redacted message ... ]"));
|
||||
else
|
||||
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
|
||||
|
||||
QDateTime qtime;
|
||||
QString sort;
|
||||
|
||||
if (useChildTS)
|
||||
qtime.setTime_t(msg.mMeta.mChildTs);
|
||||
else
|
||||
//msg.mMeta.mChildTs Was not updated when received new child
|
||||
// so do it here.
|
||||
QDateTime qtime;
|
||||
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()));
|
||||
@ -1062,6 +1072,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
||||
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