added mechanism for voting. Not working yet

This commit is contained in:
csoler 2020-08-11 22:10:22 +02:00
parent 4bc90ea9ad
commit 347b3ac9aa
5 changed files with 29 additions and 2 deletions

View file

@ -145,6 +145,8 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
{
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),this,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool)));
w->adjustSize();
w->setFixedSize(option.rect.size());
@ -176,6 +178,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
ui->postsTree->sortByColumn(0, Qt::AscendingOrder);
ui->postsTree->setAutoSelect(true);
ui->idChooser->setFlags(IDCHOOSER_ID_REQUIRED);
connect(ui->sortStrategy_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(updateSorting(int)));
connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(next10Posts()));
connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts()));
@ -630,7 +634,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group)
ui->logoLabel->setPixmap(chanImage);
ui->logoLabel->setFixedSize(QSize(ui->logoLabel->height()*chanImage.width()/(float)chanImage.height(),ui->logoLabel->height())); // make the logo have the same aspect ratio than the original image
ui->submitPostButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH));
//ui->submitPostButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH));
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
ui->subscribeToolButton->setEnabled(true);
@ -917,6 +921,18 @@ void PostedListWidgetWithModel::subscribeGroup(bool subscribe)
} );
}
void PostedListWidgetWithModel::voteMsg(RsGxsGrpMsgIdPair msg,bool up_or_down)
{
RsGxsId voter_id ;
if(ui->idChooser->getChosenId(voter_id) != GxsIdChooser::KnowId)
{
std::cerr << "(EE) No id returned by GxsIdChooser. Somthing's wrong?" << std::endl;
return;
}
rsPosted->voteForPost(up_or_down,msg.first,msg.second,voter_id);
}
#ifdef TODO
class PostedPostsReadData
{