added UI to pin up posts

This commit is contained in:
csoler 2018-08-30 14:07:14 +02:00
parent e5f65e950c
commit 380ebf2a5c
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C

View File

@ -783,6 +783,7 @@ void GxsForumThreadWidget::calculateIconsAndFonts(QTreeWidgetItem *item, bool &h
bool isNew = IS_MSG_NEW(status); bool isNew = IS_MSG_NEW(status);
bool unread = IS_MSG_UNREAD(status); bool unread = IS_MSG_UNREAD(status);
bool missing = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool(); bool missing = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool();
RsGxsMessageId msgId(item->data(COLUMN_THREAD_MSGID,Qt::DisplayRole).toString().toStdString());
// set icon // set icon
if (missing) { if (missing) {
@ -811,6 +812,8 @@ void GxsForumThreadWidget::calculateIconsAndFonts(QTreeWidgetItem *item, bool &h
calculateIconsAndFonts(item->child(index), myReadChilddren, myUnreadChilddren); calculateIconsAndFonts(item->child(index), myReadChilddren, myUnreadChilddren);
} }
bool is_pinned = mForumGroup.mPinnedPosts.ids.find(msgId) != mForumGroup.mPinnedPosts.ids.end();
// set font // set font
for (int i = 0; i < COLUMN_THREAD_COUNT; ++i) { for (int i = 0; i < COLUMN_THREAD_COUNT; ++i) {
QFont qf = item->font(i); QFont qf = item->font(i);
@ -832,6 +835,15 @@ void GxsForumThreadWidget::calculateIconsAndFonts(QTreeWidgetItem *item, bool &h
/* Missing message */ /* Missing message */
item->setForeground(i, textColorMissing()); item->setForeground(i, textColorMissing());
} }
if(is_pinned)
{
qf.setBold(true);
item->setForeground(i, textColorUnread());
item->setData(i,Qt::BackgroundRole, QBrush(QColor(255,200,180))) ;
}
else
item->setData(i,Qt::BackgroundRole, QBrush());
item->setFont(i, qf); item->setFont(i, qf);
} }
@ -1186,6 +1198,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
// Early check for a message that should be hidden because its author // Early check for a message that should be hidden because its author
// is flagged with a bad reputation // is flagged with a bad reputation
bool is_pinned = mForumGroup.mPinnedPosts.ids.find(msg.mMeta.mMsgId) != mForumGroup.mPinnedPosts.ids.end();
uint32_t idflags =0; uint32_t idflags =0;
RsReputations::ReputationLevel reputation_level = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId,&idflags) ; RsReputations::ReputationLevel reputation_level = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId,&idflags) ;
@ -1198,6 +1211,8 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
if(redacted) if(redacted)
item->setText(COLUMN_THREAD_TITLE, tr("[ ... Redacted message ... ]")); item->setText(COLUMN_THREAD_TITLE, tr("[ ... Redacted message ... ]"));
else if(is_pinned)
item->setText(COLUMN_THREAD_TITLE, tr("[PINNED] ") + QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
else else
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str())); item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
@ -1234,7 +1249,8 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
qtime.setTime_t(msg.mMeta.mPublishTs); qtime.setTime_t(msg.mMeta.mPublishTs);
QString itemText = DateTime::formatDateTime(qtime); QString itemText = DateTime::formatDateTime(qtime);
QString itemSort = QString::number(msg.mMeta.mPublishTs);//Don't need to format it as for sort. // This is an attempt to put pinned posts on the top. We should rather use a QSortFilterProxyModel here.
QString itemSort = is_pinned?QString::number(0):QString::number(msg.mMeta.mPublishTs);//Don't need to format it as for sort.
if (useChildTS) if (useChildTS)
{ {
@ -2112,6 +2128,8 @@ void GxsForumThreadWidget::togglePinUpPost()
uint32_t token; uint32_t token;
rsGxsForums->updateGroup(token,mForumGroup); rsGxsForums->updateGroup(token,mForumGroup);
updateDisplay(true) ;
} }
void GxsForumThreadWidget::createthread() void GxsForumThreadWidget::createthread()