mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-09-14 11:06:01 +05:00
add stick posts UI for boards
This commit is contained in:
parent
6b5947b73e
commit
d134f12f6f
@ -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()
|
||||
|
||||
@ -137,6 +137,7 @@ private slots:
|
||||
void showPostDetails();
|
||||
#endif
|
||||
void postContextMenu(const QPoint&);
|
||||
void pinPost();
|
||||
void showAuthorInPeople();
|
||||
void tabCloseRequested(int index);
|
||||
void updateSorting(int);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user