add stick posts UI for boards

This commit is contained in:
Vishal Pokala 2026-04-22 18:41:13 +00:00
parent 6b5947b73e
commit d134f12f6f
3 changed files with 19 additions and 0 deletions

View File

@ -364,6 +364,9 @@ void PostedListWidgetWithModel::postContextMenu(const QPoint& point)
menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost()));
#endif
if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
menu.addAction(QIcon(":/images/pin.png"), tr("Pin to top"), this, SLOT(pinPost()))->setData(index);
menu.exec(QCursor::pos());
}
@ -527,6 +530,19 @@ void PostedListWidgetWithModel::copyMessageLink()
QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what());
}
}
void PostedListWidgetWithModel::pinPost()
{
QModelIndex index = qobject_cast<QAction*>(QObject::sender())->data().toModelIndex();
if(!index.isValid())
return;
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>();
if(post.mMeta.mMsgId.isNull())
return;
bool currently_pinned = mGroup.mPinnedPosts.count(post.mMeta.mMsgId) > 0;
rsPosted->pinPost(groupId(), post.mMeta.mMsgId, !currently_pinned);
}
#ifdef TODO
void PostedListWidgetWithModel::editPost()

View File

@ -137,6 +137,7 @@ private slots:
void showPostDetails();
#endif
void postContextMenu(const QPoint&);
void pinPost();
void showAuthorInPeople();
void tabCloseRequested(int index);
void updateSorting(int);

View File

@ -486,6 +486,7 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy
mSortingStrategy = s;
std::sort(mPosts.begin(),mPosts.end(), PostSorter(s));
std::stable_partition(mPosts.begin(),mPosts.end(),[this](const RsPostedPost& p){ return mPostedGroup.mPinnedPosts.count(p.mMeta.mMsgId) > 0; });
postMods();
}
@ -540,6 +541,7 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
createPostsArray(posts);
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
std::stable_partition(mPosts.begin(),mPosts.end(),[this](const RsPostedPost& p){ return mPostedGroup.mPinnedPosts.count(p.mMeta.mMsgId) > 0; });
uint32_t tmpval;
setFilter(QStringList(),tmpval);