gxsforums: add expand subtree button to context menu

This commit is contained in:
chelovechishko 2020-07-01 04:23:20 +09:00
parent e7b09ba8dd
commit 958d13951c
2 changed files with 31 additions and 1 deletions

View File

@ -596,6 +596,11 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
QAction* expandAll = new QAction(tr("Expand all"), &contextMnu); QAction* expandAll = new QAction(tr("Expand all"), &contextMnu);
connect(expandAll, SIGNAL(triggered()), ui->threadTreeWidget, SLOT(expandAll())); connect(expandAll, SIGNAL(triggered()), ui->threadTreeWidget, SLOT(expandAll()));
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
QAction* expandSubtree = new QAction(tr("Expand subtree"), &contextMnu);
connect(expandSubtree, SIGNAL(triggered()), this, SLOT(expandSubtree()));
#endif
QAction* collapseAll = new QAction(tr( "Collapse all"), &contextMnu); QAction* collapseAll = new QAction(tr( "Collapse all"), &contextMnu);
connect(collapseAll, SIGNAL(triggered()), ui->threadTreeWidget, SLOT(collapseAll())); connect(collapseAll, SIGNAL(triggered()), ui->threadTreeWidget, SLOT(collapseAll()));
@ -630,6 +635,10 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
markMsgAsUnreadChildren->setDisabled(true); markMsgAsUnreadChildren->setDisabled(true);
replyAct->setDisabled (true); replyAct->setDisabled (true);
replyauthorAct->setDisabled (true); replyauthorAct->setDisabled (true);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
expandSubtree->setDisabled(true);
expandSubtree->setVisible(false);
#endif
} }
if(has_current_post) if(has_current_post)
@ -673,6 +682,9 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
contextMnu.addAction(markMsgAsUnreadChildren); contextMnu.addAction(markMsgAsUnreadChildren);
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(expandAll); contextMnu.addAction(expandAll);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
contextMnu.addAction(expandSubtree);
#endif
contextMnu.addAction(collapseAll); contextMnu.addAction(collapseAll);
if(has_current_post) if(has_current_post)
@ -1325,6 +1337,20 @@ void GxsForumThreadWidget::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
markMsgAsReadUnread(read, true, true); markMsgAsReadUnread(read, true, true);
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
void GxsForumThreadWidget::expandSubtree() {
QAction* the_action = qobject_cast<QAction*>(sender());
if (!the_action) {
return;
}
const QModelIndex current_index = ui->threadTreeWidget->currentIndex();
if (!current_index.isValid()) {
return;
}
ui->threadTreeWidget->expandRecursively(current_index);
}
#endif
bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId) bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId)
{ {
QModelIndex source_index = mThreadModel->getIndexOfMessage(msgId); QModelIndex source_index = mThreadModel->getIndexOfMessage(msgId);

View File

@ -144,6 +144,10 @@ private slots:
void filterColumnChanged(int column); void filterColumnChanged(int column);
void filterItems(const QString &text); void filterItems(const QString &text);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
void expandSubtree();
#endif
private: private:
void insertMessageData(const RsGxsForumMsg &msg); void insertMessageData(const RsGxsForumMsg &msg);
bool getCurrentPost(ForumModelPostEntry& fmpe) const ; bool getCurrentPost(ForumModelPostEntry& fmpe) const ;