added comment count to details

This commit is contained in:
csoler 2020-09-09 23:14:20 +02:00
parent e234cb933d
commit 4d934993f3
6 changed files with 48 additions and 0 deletions

View File

@ -52,6 +52,7 @@ void GxsCommentDialog::init()
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
connect(ui->idChooser, SIGNAL(idsLoaded()), this, SLOT(idChooserReady()));
connect(ui->treeWidget,SIGNAL(commentsLoaded(int)),this,SLOT(notifyCommentsLoaded(int)));
connect(ui->commentButton, SIGNAL(clicked()), ui->treeWidget, SLOT(makeComment()));
connect(ui->sortBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sortComments(int)));
@ -95,6 +96,11 @@ void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::set<RsG
ui->treeWidget->requestComments(mGrpId,msg_versions,most_recent_msgId);
}
void GxsCommentDialog::notifyCommentsLoaded(int n)
{
emit commentsLoaded(n);
}
void GxsCommentDialog::refresh()
{
std::cerr << "GxsCommentDialog::refresh()";

View File

@ -48,6 +48,10 @@ private slots:
void idChooserReady();
void voterSelectionChanged( int index );
void sortComments(int);
void notifyCommentsLoaded(int n);
signals:
void commentsLoaded(int);
private:
void init();

View File

@ -489,6 +489,30 @@ void GxsCommentTreeWidget::addItem(RsGxsMessageId itemId, RsGxsMessageId parentI
}
}
int treeCount(QTreeWidget *tree, QTreeWidgetItem *parent = 0)
{
int count = 0;
if (parent == 0) {
int topCount = tree->topLevelItemCount();
for (int i = 0; i < topCount; i++) {
QTreeWidgetItem *item = tree->topLevelItem(i);
if (item->isExpanded()) {
count += treeCount(tree, item);
}
}
count += topCount;
} else {
int childCount = parent->childCount();
for (int i = 0; i < childCount; i++) {
QTreeWidgetItem *item = parent->child(i);
if (item->isExpanded()) {
count += treeCount(tree, item);
}
}
count += childCount;
}
return count;
}
void GxsCommentTreeWidget::loadThread(const uint32_t &token)
{
clearItems();
@ -496,6 +520,8 @@ void GxsCommentTreeWidget::loadThread(const uint32_t &token)
service_loadThread(token);
completeItems();
emit commentsLoaded(treeCount(this));
}
void GxsCommentTreeWidget::acknowledgeComment(const uint32_t &token)

View File

@ -80,6 +80,9 @@ public slots:
void markSpammer();
void banUser();
signals:
void commentsLoaded(int);
protected:
void vote(const RsGxsGroupId &groupId, const RsGxsMessageId &threadId,

View File

@ -343,6 +343,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
mChannelPostsDelegate->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_16_9);
connect(ui->postsTree,SIGNAL(zoomRequested(bool)),this,SLOT(updateZoomFactor(bool)));
connect(ui->commentsDialog,SIGNAL(commentsLoaded(int)),this,SLOT(updateCommentsCount(int)));
ui->channelPostFiles_TV->setModel(mChannelPostFilesModel = new RsGxsChannelPostFilesModel(this));
ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate());
@ -734,6 +735,13 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
}
}
void GxsChannelPostsWidgetWithModel::updateCommentsCount(int n)
{
if(n > 0)
ui->details_TW->setTabText(2,tr("Comments (%1)").arg(n));
else
ui->details_TW->setTabText(2,tr("Comments"));
}
void GxsChannelPostsWidgetWithModel::updateGroupData()
{
if(groupId().isNull())

View File

@ -161,6 +161,7 @@ private slots:
public slots:
void sortColumnFiles(int col,Qt::SortOrder so);
void sortColumnPostFiles(int col,Qt::SortOrder so);
void updateCommentsCount(int n);
private:
void processSettings(bool load);