mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-23 14:41:04 -04:00
fixed voting in Boards
This commit is contained in:
parent
347b3ac9aa
commit
20346fc30e
4 changed files with 42 additions and 9 deletions
|
@ -442,9 +442,41 @@ bool p3Posted::createBoard(RsPostedGroup& board)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Posted::voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& voterId)
|
bool p3Posted::voteForPost(bool up,const RsGxsGroupId& postGrpId,const RsGxsMessageId& postMsgId,const RsGxsId& authorId)
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) " << __PRETTY_FUNCTION__ << ": Not implemented yet"<< std::endl;
|
// Do some basic tests
|
||||||
|
|
||||||
|
if(!rsIdentity->isOwnId(authorId)) // This is ruled out before waitToken complains. Not sure it's needed.
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << ": vote submitted with an ID that is not yours! This cannot work." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsGxsVote vote;
|
||||||
|
|
||||||
|
vote.mMeta.mGroupId = postGrpId;
|
||||||
|
vote.mMeta.mThreadId = postMsgId;
|
||||||
|
vote.mMeta.mParentId = postMsgId;
|
||||||
|
vote.mMeta.mAuthorId = authorId;
|
||||||
|
|
||||||
|
if (up)
|
||||||
|
vote.mVoteType = GXS_VOTE_UP;
|
||||||
|
else
|
||||||
|
vote.mVoteType = GXS_VOTE_DOWN;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
|
||||||
|
if(!createNewVote(token, vote))
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " Error! Failed submitting vote to (group,msg) " << postGrpId << "," << postMsgId << " from author " << authorId << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,17 +128,17 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
|
||||||
return mCommentService->createGxsComment(token, msg) && waitToken(token) == RsTokenService::COMPLETE ;
|
return mCommentService->createGxsComment(token, msg) && waitToken(token) == RsTokenService::COMPLETE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool createNewVote(uint32_t &token, RsGxsVote &msg)
|
virtual bool createNewVote(uint32_t &token, RsGxsVote &msg) override
|
||||||
{
|
{
|
||||||
return mCommentService->createGxsVote(token, msg);
|
return mCommentService->createGxsVote(token, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool acknowledgeComment(
|
virtual bool acknowledgeComment(
|
||||||
uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId )
|
uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) override
|
||||||
{ return acknowledgeMsg(token, msgId); }
|
{ return acknowledgeMsg(token, msgId); }
|
||||||
|
|
||||||
virtual bool acknowledgeVote(
|
virtual bool acknowledgeVote(
|
||||||
uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId )
|
uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) override
|
||||||
{
|
{
|
||||||
if (mCommentService->acknowledgeVote(token, msgId)) return true;
|
if (mCommentService->acknowledgeVote(token, msgId)) return true;
|
||||||
return acknowledgeMsg(token, msgId);
|
return acknowledgeMsg(token, msgId);
|
||||||
|
|
|
@ -145,7 +145,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
||||||
{
|
{
|
||||||
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
|
QWidget *w = new BoardPostDisplayWidget(post,mDisplayMode,parent);
|
||||||
|
|
||||||
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),this,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool)));
|
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool)));
|
||||||
|
|
||||||
w->adjustSize();
|
w->adjustSize();
|
||||||
w->setFixedSize(option.rect.size());
|
w->setFixedSize(option.rect.size());
|
||||||
|
@ -169,7 +169,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->postsTree->setModel(mPostedPostsModel = new RsPostedPostsModel());
|
ui->postsTree->setModel(mPostedPostsModel = new RsPostedPostsModel());
|
||||||
ui->postsTree->setItemDelegate(mPostedPostsDelegate = new PostedPostDelegate());
|
ui->postsTree->setItemDelegate(mPostedPostsDelegate = new PostedPostDelegate(this));
|
||||||
ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width
|
ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width
|
||||||
ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level
|
ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level
|
||||||
ui->postsTree->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
ui->postsTree->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
|
|
@ -38,13 +38,14 @@ class PostedListWidgetWithModel;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class RsPostedPostsModel;
|
class RsPostedPostsModel;
|
||||||
|
class PostedListWidgetWithModel;
|
||||||
|
|
||||||
class PostedPostDelegate: public QAbstractItemDelegate
|
class PostedPostDelegate: public QAbstractItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostedPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){}
|
PostedPostDelegate(PostedListWidgetWithModel *p,QObject *parent=0) : QAbstractItemDelegate(parent),mCellWidthPix(100),mPostListWidget(p),mDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT){}
|
||||||
virtual ~PostedPostDelegate(){}
|
virtual ~PostedPostDelegate(){}
|
||||||
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override;
|
||||||
|
@ -60,8 +61,8 @@ class PostedPostDelegate: public QAbstractItemDelegate
|
||||||
private:
|
private:
|
||||||
QSize cellSize(const QSize& w) const; // Converts the supplied size to the cell size for the current container.
|
QSize cellSize(const QSize& w) const; // Converts the supplied size to the cell size for the current container.
|
||||||
// The client should then scale its widget to fit the given size.
|
// The client should then scale its widget to fit the given size.
|
||||||
|
|
||||||
int mCellWidthPix;
|
int mCellWidthPix;
|
||||||
|
PostedListWidgetWithModel *mPostListWidget; // used for sending vote signals and so on.
|
||||||
BoardPostDisplayWidget::DisplayMode mDisplayMode;
|
BoardPostDisplayWidget::DisplayMode mDisplayMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue