started updating ForumFillThread to new model

This commit is contained in:
csoler 2018-11-20 23:28:07 +01:00
parent d8f9559b0e
commit 2066248b3b
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
4 changed files with 191 additions and 12 deletions

View file

@ -23,9 +23,10 @@
#include "GxsForumsFillThread.h"
#include "GxsForumThreadWidget.h"
#include "GxsForumModel.h"
#include "retroshare/rsgxsflags.h"
#include <retroshare/rsgxsforums.h>
#include "retroshare/rsgxsforums.h"
#include <iostream>
#include <algorithm>
@ -553,4 +554,75 @@ void GxsForumsFillThread::run()
deleteLater();
}
QTreeWidgetItem *GxsForumsFillThread::convertMsgToThreadWidget(const RsGxsForumMsg& msg, bool useChildTS, uint32_t filterColumn, ForumModelIndex parent)
{
ForumModelPostEntry fentry;
fentry.mMsgId = msg.mMeta.mMsgId;
fentry.mPublishTs = msg.mMeta.mPublishTs;
fentry.mParent = parent;
if(mForumGroup.mPinnedPosts.ids.find(msg.mMeta.mMsgId) != mForumGroup.mPinnedPosts.ids.end())
fentry.mFlags |= ForumModelPostEntry::FLAG_POST_IS_PINNED;
// Early check for a message that should be hidden because its author
// is flagged with a bad reputation
uint32_t idflags =0;
RsReputations::ReputationLevel reputation_level = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId,&idflags) ;
bool redacted = false;
if(reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
// We use a specific item model for forums in order to handle the post pinning.
if(reputation_level == RsReputations::REPUTATION_UNKNOWN)
fentry.mReputationWarningLevel = 3 ;
else if(reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
fentry.mReputationWarningLevel = 2 ;
else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(mForumGroup.mMeta.mSignFlags,idflags))
fentry.mReputationWarningLevel = 1 ;
else
fentry.mReputationWarningLevel = 0 ;
#ifdef TODO
// This is an attempt to put pinned posts on the top. We should rather use a QSortFilterProxyModel here.
QString itemSort = QString::number(msg.mMeta.mPublishTs);//Don't need to format it as for sort.
if (useChildTS)
{
for(QTreeWidgetItem *grandParent = parent; grandParent!=NULL; grandParent = grandParent->parent())
{
//Update Parent Child TimeStamp
QString oldTSSort = grandParent->data(COLUMN_THREAD_DATE, ROLE_THREAD_SORT).toString();
QString oldCTSSort = oldTSSort.split("|").at(0);
QString oldPTSSort = oldTSSort.contains("|") ? oldTSSort.split(" | ").at(1) : oldCTSSort;
#ifdef SHOW_COMBINED_DATES
QString oldTSText = grandParent->text(COLUMN_THREAD_DATE);
QString oldCTSText = oldTSText.split("|").at(0);
QString oldPTSText = oldTSText.contains("|") ? oldTSText.split(" | ").at(1) : oldCTSText;//If first time parent get only its mPublishTs
#endif
if (oldCTSSort.toDouble() < itemSort.toDouble())
{
#ifdef SHOW_COMBINED_DATES
grandParent->setText(COLUMN_THREAD_DATE, DateTime::formatDateTime(qtime) + " | " + oldPTSText);
#endif
grandParent->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, itemSort + " | " + oldPTSSort);
}
}
}
#endif
//#TODO
#if 0
if (IS_GROUP_SUBSCRIBED(subscribeFlags) && !(msginfo.mMsgFlags & RS_DISTRIB_MISSING_MSG)) {
rsGxsForums->getMessageStatus(msginfo.forumId, msginfo.msgId, status);
} else {
// show message as read
status = RSGXS_MSG_STATUS_READ;
}
#endif
if (parent) parent->addChild(item);
return item;
}