added login to pin up posts

This commit is contained in:
csoler 2018-08-30 11:48:37 +02:00
parent e12c17c6f0
commit e5f65e950c
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 31 additions and 3 deletions

View File

@ -870,7 +870,7 @@ QString GxsIdDetails::getFailedText(const RsGxsId &id)
QString GxsIdDetails::getEmptyIdText() QString GxsIdDetails::getEmptyIdText()
{ {
return QApplication::translate("GxsIdDetails", "No Signature"); return QApplication::translate("GxsIdDetails", "[None]");
} }
QString GxsIdDetails::getNameForType(GxsIdDetailsType type, const RsIdentityDetails &details) QString GxsIdDetails::getNameForType(GxsIdDetailsType type, const RsIdentityDetails &details)

View File

@ -489,10 +489,15 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
} }
QMenu contextMnu(this); QMenu contextMnu(this);
QList<QTreeWidgetItem*> selectedItems = ui->threadTreeWidget->selectedItems();
QAction *editAct = new QAction(QIcon(IMAGE_MESSAGEEDIT), tr("Edit"), &contextMnu); QAction *editAct = new QAction(QIcon(IMAGE_MESSAGEEDIT), tr("Edit"), &contextMnu);
connect(editAct, SIGNAL(triggered()), this, SLOT(editforummessage())); connect(editAct, SIGNAL(triggered()), this, SLOT(editforummessage()));
bool is_pinned = mForumGroup.mPinnedPosts.ids.find(mThreadId) != mForumGroup.mPinnedPosts.ids.end();
QAction *pinUpPostAct = new QAction(QIcon(IMAGE_MESSAGE), (is_pinned?tr("Un-pin this post"):tr("Pin this post up")), &contextMnu);
connect(pinUpPostAct , SIGNAL(triggered()), this, SLOT(togglePinUpPost()));
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply"), &contextMnu); QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply"), &contextMnu);
connect(replyAct, SIGNAL(triggered()), this, SLOT(replytoforummessage())); connect(replyAct, SIGNAL(triggered()), this, SLOT(replytoforummessage()));
@ -582,8 +587,6 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
replyauthorAct->setDisabled (true); replyauthorAct->setDisabled (true);
} }
QList<QTreeWidgetItem*> selectedItems = ui->threadTreeWidget->selectedItems();
if(selectedItems.size() == 1) if(selectedItems.size() == 1)
{ {
QTreeWidgetItem *item = *selectedItems.begin(); QTreeWidgetItem *item = *selectedItems.begin();
@ -607,6 +610,9 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
break ; break ;
} }
} }
if(IS_GROUP_ADMIN(mSubscribeFlags))
contextMnu.addAction(pinUpPostAct);
} }
contextMnu.addAction(replyAct); contextMnu.addAction(replyAct);
@ -653,6 +659,7 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
contextMnu.addAction(showinpeopleAct); contextMnu.addAction(showinpeopleAct);
contextMnu.addAction(replyauthorAct); contextMnu.addAction(replyauthorAct);
} }
} }
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
@ -2087,6 +2094,26 @@ void GxsForumThreadWidget::createmessage()
/* window will destroy itself! */ /* window will destroy itself! */
} }
void GxsForumThreadWidget::togglePinUpPost()
{
if (groupId().isNull() || mThreadId.isNull())
return;
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
QString thread_title = (item != NULL)?item->text(COLUMN_THREAD_TITLE):QString() ;
std::cerr << "Toggling Pin-up state of post " << mThreadId.toStdString() << ": \"" << thread_title.toStdString() << "\"" << std::endl;
if(mForumGroup.mPinnedPosts.ids.find(mThreadId) == mForumGroup.mPinnedPosts.ids.end())
mForumGroup.mPinnedPosts.ids.insert(mThreadId) ;
else
mForumGroup.mPinnedPosts.ids.erase(mThreadId) ;
uint32_t token;
rsGxsForums->updateGroup(token,mForumGroup);
}
void GxsForumThreadWidget::createthread() void GxsForumThreadWidget::createthread()
{ {
if (groupId().isNull ()) { if (groupId().isNull ()) {

View File

@ -107,6 +107,7 @@ private slots:
void subscribeGroup(bool subscribe); void subscribeGroup(bool subscribe);
void createthread(); void createthread();
void togglePinUpPost();
void createmessage(); void createmessage();
void previousMessage(); void previousMessage();