mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added new base class GxsMessageFramePostWidget for post-based services like Channels and Posted.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7466 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b1f7523248
commit
1de9e4a842
@ -24,7 +24,6 @@
|
||||
#include <QMessageBox>
|
||||
#include "PostedCreatePostDialog.h"
|
||||
#include "ui_PostedCreatePostDialog.h"
|
||||
#include "PostedUserTypes.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
@ -89,7 +88,7 @@ void PostedCreatePostDialog::createPost()
|
||||
|
||||
uint32_t token;
|
||||
mPosted->createPost(token, post);
|
||||
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST);
|
||||
// mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST);
|
||||
|
||||
accept();
|
||||
}
|
||||
|
@ -28,57 +28,29 @@
|
||||
|
||||
#include "PostedCreatePostDialog.h"
|
||||
#include "PostedItem.h"
|
||||
#include "PostedUserTypes.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#include <retroshare/rsposted.h>
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
//#define POSTEDDIALOG_LISTING 1
|
||||
//#define POSTEDDIALOG_CURRENTFORUM 2
|
||||
#define POSTEDDIALOG_INSERTTHREADS 3
|
||||
//#define POSTEDDIALOG_INSERTCHILD 4
|
||||
//#define POSTEDDIALOG_INSERT_POST 5
|
||||
//#define POSTEDDIALOG_REPLY_MESSAGE 6
|
||||
|
||||
/****************************************************************
|
||||
*/
|
||||
|
||||
// token types to deal with
|
||||
|
||||
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
||||
#define POSTED_MAX_INDEX 10000
|
||||
|
||||
/** Constructor */
|
||||
PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent)
|
||||
: GxsMessageFrameWidget(rsPosted, parent),
|
||||
: GxsMessageFramePostWidget(rsPosted, parent),
|
||||
ui(new Ui::PostedListWidget)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
mStateHelper->addWidget(mTokenTypePosts, ui->hotSortButton);
|
||||
mStateHelper->addWidget(mTokenTypePosts, ui->newSortButton);
|
||||
mStateHelper->addWidget(mTokenTypePosts, ui->topSortButton);
|
||||
|
||||
// No progress yet
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressLabel, UISTATE_LOADING_VISIBLE);
|
||||
|
||||
// mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui->nameLabel);
|
||||
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->postButton);
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->logoLabel);
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->subscribeToolButton);
|
||||
|
||||
/* Setup Queue */
|
||||
mPostedQueue = new TokenQueue(rsPosted->getTokenService(), this);
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->submitPostButton);
|
||||
// mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
||||
|
||||
connect(ui->hotSortButton, SIGNAL(clicked()), this, SLOT(getRankings()));
|
||||
connect(ui->newSortButton, SIGNAL(clicked()), this, SLOT(getRankings()));
|
||||
@ -94,6 +66,8 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
|
||||
mPostIndex = 0;
|
||||
mPostShow = POSTED_DEFAULT_LISTING_LENGTH;
|
||||
|
||||
mTokenTypeVote = nextTokenType();
|
||||
|
||||
ui->hotSortButton->setChecked(true);
|
||||
|
||||
/* fill in the available OwnIds for signing */
|
||||
@ -114,58 +88,6 @@ PostedListWidget::~PostedListWidget()
|
||||
processSettings(false);
|
||||
}
|
||||
|
||||
void PostedListWidget::updateDisplay(bool complete)
|
||||
{
|
||||
std::cerr << "rsPosted->updateDisplay()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (complete) {
|
||||
/* Fill complete */
|
||||
requestGroupData();
|
||||
requestPosts();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPostedId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool updateGroup = false;
|
||||
|
||||
const std::list<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
|
||||
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mPostedId) != grpIdsMeta.end()) {
|
||||
updateGroup = true;
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &grpIds = getGrpIds();
|
||||
if (!mPostedId.isNull() && std::find(grpIds.begin(), grpIds.end(), mPostedId) != grpIds.end()) {
|
||||
updateGroup = true;
|
||||
/* Do we need to fill all posts? */
|
||||
requestPosts();
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
||||
getAllMsgIds(msgs);
|
||||
if (!msgs.empty())
|
||||
{
|
||||
std::cerr << "rsPosted->msgsChanged():";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit;
|
||||
mit = msgs.find(mPostedId);
|
||||
if(mit != msgs.end())
|
||||
{
|
||||
std::cerr << "current Group -> updating Displayed Items";
|
||||
std::cerr << std::endl;
|
||||
updateDisplayedItems(mit->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateGroup) {
|
||||
requestGroupData();
|
||||
}
|
||||
}
|
||||
|
||||
void PostedListWidget::processSettings(bool load)
|
||||
{
|
||||
// Settings->beginGroup(QString("PostedListWidget"));
|
||||
@ -179,38 +101,11 @@ void PostedListWidget::processSettings(bool load)
|
||||
// Settings->endGroup();
|
||||
}
|
||||
|
||||
void PostedListWidget::setGroupId(const RsGxsGroupId &groupId)
|
||||
{
|
||||
if (mPostedId == groupId) {
|
||||
if (!groupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mPostedId = groupId;
|
||||
mName = mPostedId.isNull () ? "" : tr("Loading");
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
fillComplete();
|
||||
}
|
||||
|
||||
QString PostedListWidget::groupName(bool withUnreadCount)
|
||||
{
|
||||
QString name = mPostedId.isNull () ? tr("No name") : mName;
|
||||
|
||||
// if (withUnreadCount && mUnreadCount) {
|
||||
// name += QString(" (%1)").arg(mUnreadCount);
|
||||
// }
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon PostedListWidget::groupIcon()
|
||||
{
|
||||
// if (mStateHelper->isLoading(TOKEN_TYPE_GROUP_DATA) || mStateHelper->isLoading(TOKEN_TYPE_POSTS)) {
|
||||
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypePosts)) {
|
||||
// return QIcon(":/images/kalarm.png");
|
||||
// }
|
||||
}
|
||||
|
||||
// if (mNewCount) {
|
||||
// return QIcon(":/images/message-state-new.png");
|
||||
@ -247,14 +142,14 @@ void PostedListWidget::openComments(uint32_t /*feed_type*/, const RsGxsGroupId &
|
||||
|
||||
void PostedListWidget::newPost()
|
||||
{
|
||||
if (mPostedId.isNull())
|
||||
if (groupId().isNull())
|
||||
return;
|
||||
|
||||
if (!IS_GROUP_SUBSCRIBED(mSubscribeFlags)) {
|
||||
if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) {
|
||||
return;
|
||||
}
|
||||
|
||||
PostedCreatePostDialog *cp = new PostedCreatePostDialog(mPostedQueue, rsPosted, mPostedId, this);
|
||||
PostedCreatePostDialog *cp = new PostedCreatePostDialog(mTokenQueue, rsPosted, groupId(), this);
|
||||
cp->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
@ -290,7 +185,7 @@ void PostedListWidget::updateShowText()
|
||||
|
||||
void PostedListWidget::getRankings()
|
||||
{
|
||||
if (mPostedId.isNull())
|
||||
if (groupId().isNull())
|
||||
return;
|
||||
|
||||
std::cerr << "PostedListWidget::getRankings()";
|
||||
@ -368,50 +263,7 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
|
||||
|
||||
uint32_t token;
|
||||
rsPosted->createVote(token, vote);
|
||||
mPostedQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE);
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
void PostedListWidget::updateDisplayedItems(const std::vector<RsGxsMessageId> &msgIds)
|
||||
{
|
||||
mPostedQueue->cancelActiveRequestTokens(TOKEN_USER_TYPE_POST_MOD);
|
||||
|
||||
if (mPostedId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_POST, false);
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false);
|
||||
mStateHelper->clear(TOKEN_USER_TYPE_POST);
|
||||
emit groupChanged(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgIds.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_POST, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
GxsMsgReq msgs;
|
||||
msgs[mPostedId] = msgIds;
|
||||
|
||||
std::cerr << "PostedListWidget::updateDisplayedItems(" << mPostedId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::vector<RsGxsMessageId>::const_iterator it;
|
||||
for(it = msgIds.begin(); it != msgIds.end(); it++)
|
||||
{
|
||||
std::cerr << "\t\tMsgId: " << *it;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgs, TOKEN_USER_TYPE_POST_MOD);
|
||||
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, mTokenTypeVote);
|
||||
}
|
||||
|
||||
void PostedListWidget::createNewGxsId()
|
||||
@ -422,6 +274,8 @@ void PostedListWidget::createNewGxsId()
|
||||
ui->idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
void PostedListWidget::acknowledgeVoteMsg(const uint32_t &token)
|
||||
{
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
@ -437,76 +291,9 @@ void PostedListWidget::loadVoteData(const uint32_t &/*token*/)
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void PostedListWidget::requestGroupData()
|
||||
{
|
||||
#ifdef DEBUG_POSTED
|
||||
std::cerr << "PostedListWidget::requestGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
|
||||
mPostedQueue->cancelActiveRequestTokens(TOKEN_USER_TYPE_TOPIC);
|
||||
|
||||
if (mPostedId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_TOPIC, false);
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_TOPIC, false);
|
||||
mStateHelper->clear(TOKEN_USER_TYPE_TOPIC);
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_TOPIC, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mPostedId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_USER_TYPE_TOPIC);
|
||||
}
|
||||
|
||||
void PostedListWidget::loadGroupData(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "PostedListWidget::loadGroupData()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::vector<RsPostedGroup> groups;
|
||||
rsPosted->getGroupData(token, groups);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_TOPIC, false);
|
||||
|
||||
if (groups.size() == 1)
|
||||
{
|
||||
insertPostedDetails(groups[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "PostedListWidget::loadGroupData() ERROR Invalid Number of Groups...";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_TOPIC, false);
|
||||
mStateHelper->clear(TOKEN_USER_TYPE_TOPIC);
|
||||
}
|
||||
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void PostedListWidget::insertPostedDetails(const RsPostedGroup &group)
|
||||
{
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_TOPIC, true);
|
||||
|
||||
mSubscribeFlags = group.mMeta.mSubscribeFlags;
|
||||
|
||||
/* set name */
|
||||
mName = QString::fromUtf8(group.mMeta.mGroupName.c_str());
|
||||
|
||||
if (mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
||||
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
||||
{
|
||||
mStateHelper->setWidgetEnabled(ui->submitPostButton, true);
|
||||
}
|
||||
@ -515,7 +302,7 @@ void PostedListWidget::insertPostedDetails(const RsPostedGroup &group)
|
||||
mStateHelper->setWidgetEnabled(ui->submitPostButton, false);
|
||||
}
|
||||
|
||||
// ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(mSubscribeFlags));
|
||||
// ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
@ -523,78 +310,6 @@ void PostedListWidget::insertPostedDetails(const RsPostedGroup &group)
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void PostedListWidget::requestPosts()
|
||||
{
|
||||
std::cerr << "PostedListWidget::loadCurrentForumThreads(" << mPostedId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
clearPosts();
|
||||
|
||||
mPostedQueue->cancelActiveRequestTokens(TOKEN_USER_TYPE_POST);
|
||||
|
||||
if (mPostedId.isNull())
|
||||
{
|
||||
std::cerr << "PostedListWidget::loadCurrentForumThreads() Empty GroupId .. ignoring Req";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_POST, false);
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false);
|
||||
mStateHelper->clear(TOKEN_USER_TYPE_POST);
|
||||
emit groupChanged(this);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_POST, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
/* initiate loading */
|
||||
RsTokReqOptions opts;
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
grpIds.push_back(mPostedId);
|
||||
|
||||
std::cerr << "PostedListWidget::requestGroupThreadData_InsertThreads(" << mPostedId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
uint32_t token;
|
||||
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST);
|
||||
}
|
||||
|
||||
void PostedListWidget::acknowledgePostMsg(const uint32_t &token)
|
||||
{
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
|
||||
// just acknowledge, don't load anything
|
||||
rsPosted->acknowledgeMsg(token, msgId);
|
||||
}
|
||||
|
||||
void PostedListWidget::loadPostData(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "PostedListWidget::loadGroupThreadData_InsertThreads()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_POST, true);
|
||||
clearPosts();
|
||||
|
||||
std::vector<RsPostedPost> posts;
|
||||
rsPosted->getPostData(token, posts);
|
||||
std::vector<RsPostedPost>::iterator vit;
|
||||
|
||||
for(vit = posts.begin(); vit != posts.end(); vit++)
|
||||
{
|
||||
RsPostedPost& p = *vit;
|
||||
loadPost(p);
|
||||
}
|
||||
|
||||
applyRanking();
|
||||
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void PostedListWidget::loadPost(const RsPostedPost &post)
|
||||
{
|
||||
PostedItem *item = new PostedItem(this, 0, post, true);
|
||||
@ -602,13 +317,20 @@ void PostedListWidget::loadPost(const RsPostedPost &post)
|
||||
mPosts.insert(post.mMeta.mMsgId, item);
|
||||
//QLayout *alayout = ui.scrollAreaWidgetContents->layout();
|
||||
//alayout->addWidget(item);
|
||||
mPostList.push_back(item);
|
||||
mPostItems.push_back(item);
|
||||
}
|
||||
|
||||
static bool CmpPIHot(const PostedItem *a, const PostedItem *b)
|
||||
static bool CmpPIHot(const GxsFeedItem *a, const GxsFeedItem *b)
|
||||
{
|
||||
const RsPostedPost &postA = a->getPost();
|
||||
const RsPostedPost &postB = b->getPost();
|
||||
const PostedItem *aa = dynamic_cast<const PostedItem*>(a);
|
||||
const PostedItem *bb = dynamic_cast<const PostedItem*>(b);
|
||||
|
||||
if (!aa || !bb) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const RsPostedPost &postA = aa->getPost();
|
||||
const RsPostedPost &postB = bb->getPost();
|
||||
|
||||
if (postA.mHotScore == postB.mHotScore)
|
||||
{
|
||||
@ -618,10 +340,17 @@ static bool CmpPIHot(const PostedItem *a, const PostedItem *b)
|
||||
return (postA.mHotScore > postB.mHotScore);
|
||||
}
|
||||
|
||||
static bool CmpPITop(const PostedItem *a, const PostedItem *b)
|
||||
static bool CmpPITop(const GxsFeedItem *a, const GxsFeedItem *b)
|
||||
{
|
||||
const RsPostedPost &postA = a->getPost();
|
||||
const RsPostedPost &postB = b->getPost();
|
||||
const PostedItem *aa = dynamic_cast<const PostedItem*>(a);
|
||||
const PostedItem *bb = dynamic_cast<const PostedItem*>(b);
|
||||
|
||||
if (!aa || !bb) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const RsPostedPost &postA = aa->getPost();
|
||||
const RsPostedPost &postB = bb->getPost();
|
||||
|
||||
if (postA.mTopScore == postB.mTopScore)
|
||||
{
|
||||
@ -631,9 +360,16 @@ static bool CmpPITop(const PostedItem *a, const PostedItem *b)
|
||||
return (postA.mTopScore > postB.mTopScore);
|
||||
}
|
||||
|
||||
static bool CmpPINew(const PostedItem *a, const PostedItem *b)
|
||||
static bool CmpPINew(const GxsFeedItem *a, const GxsFeedItem *b)
|
||||
{
|
||||
return (a->getPost().mNewScore > b->getPost().mNewScore);
|
||||
const PostedItem *aa = dynamic_cast<const PostedItem*>(a);
|
||||
const PostedItem *bb = dynamic_cast<const PostedItem*>(b);
|
||||
|
||||
if (!aa || !bb) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (aa->getPost().mNewScore > bb->getPost().mNewScore);
|
||||
}
|
||||
|
||||
void PostedListWidget::applyRanking()
|
||||
@ -651,17 +387,17 @@ void PostedListWidget::applyRanking()
|
||||
case RsPosted::HotRankType:
|
||||
std::cerr << "PostedListWidget::applyRanking() HOT";
|
||||
std::cerr << std::endl;
|
||||
mPostList.sort(CmpPIHot);
|
||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPIHot);
|
||||
break;
|
||||
case RsPosted::NewRankType:
|
||||
std::cerr << "PostedListWidget::applyRanking() NEW";
|
||||
std::cerr << std::endl;
|
||||
mPostList.sort(CmpPINew);
|
||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPINew);
|
||||
break;
|
||||
case RsPosted::TopRankType:
|
||||
std::cerr << "PostedListWidget::applyRanking() TOP";
|
||||
std::cerr << std::endl;
|
||||
mPostList.sort(CmpPITop);
|
||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPITop);
|
||||
break;
|
||||
}
|
||||
mLastSortMethod = mSortMethod;
|
||||
@ -673,10 +409,12 @@ void PostedListWidget::applyRanking()
|
||||
QLayout *alayout = ui->scrollAreaWidgetContents->layout();
|
||||
int counter = 0;
|
||||
time_t min_ts = 0;
|
||||
std::list<PostedItem *>::iterator it;
|
||||
for(it = mPostList.begin(); it != mPostList.end(); it++)
|
||||
foreach (GxsFeedItem *feedItem, mPostItems)
|
||||
{
|
||||
PostedItem *item = (*it);
|
||||
PostedItem *item = dynamic_cast<PostedItem*>(feedItem);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
||||
std::cerr << std::endl;
|
||||
|
||||
@ -720,47 +458,9 @@ void PostedListWidget::applyRanking()
|
||||
|
||||
void PostedListWidget::clearPosts()
|
||||
{
|
||||
std::cerr << "PostedListWidget::clearPosts()" << std::endl;
|
||||
|
||||
std::list<PostedItem *> postedItems;
|
||||
std::list<PostedItem *>::iterator pit;
|
||||
|
||||
QLayout *alayout = ui->scrollAreaWidgetContents->layout();
|
||||
int count = alayout->count();
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
QLayoutItem *litem = alayout->itemAt(i);
|
||||
if (!litem)
|
||||
{
|
||||
std::cerr << "PostedListWidget::clearPosts() missing litem";
|
||||
std::cerr << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
PostedItem *item = dynamic_cast<PostedItem *>(litem->widget());
|
||||
if (item)
|
||||
{
|
||||
std::cerr << "PostedListWidget::clearPosts() item: " << item;
|
||||
std::cerr << std::endl;
|
||||
|
||||
postedItems.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "PostedListWidget::clearPosts() Found Child, which is not a PostedItem???";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
for(pit = postedItems.begin(); pit != postedItems.end(); pit++)
|
||||
{
|
||||
PostedItem *item = *pit;
|
||||
alayout->removeWidget(item);
|
||||
delete item;
|
||||
}
|
||||
GxsMessageFramePostWidget::clearPosts();
|
||||
|
||||
mPosts.clear();
|
||||
mPostList.clear();
|
||||
}
|
||||
|
||||
void PostedListWidget::shallowClearPosts()
|
||||
@ -804,22 +504,6 @@ void PostedListWidget::shallowClearPosts()
|
||||
}
|
||||
}
|
||||
|
||||
void PostedListWidget::setAllMessagesRead(bool read)
|
||||
{
|
||||
// if (mPostedId.isNull() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// QList<GxsChannelPostItem *>::iterator mit;
|
||||
// for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); ++mit) {
|
||||
// GxsChannelPostItem *item = *mit;
|
||||
// RsGxsGrpMsgIdPair msgPair = std::make_pair(item->groupId(), item->messageId());
|
||||
|
||||
// uint32_t token;
|
||||
// rsGxsChannels->setMessageReadStatus(token, msgPair, read);
|
||||
// }
|
||||
}
|
||||
|
||||
//void PostedListWidget::subscribeGroup(bool subscribe)
|
||||
//{
|
||||
// if (mChannelId.isNull()) {
|
||||
@ -831,15 +515,52 @@ void PostedListWidget::setAllMessagesRead(bool read)
|
||||
//// mChannelQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
||||
//}
|
||||
|
||||
void PostedListWidget::updateCurrentDisplayComplete(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "PostedListWidget::updateCurrentDisplayComplete()";
|
||||
std::cerr << std::endl;
|
||||
//void PostedListWidget::acknowledgeSubscribeChange(const uint32_t &token)
|
||||
//{
|
||||
// std::cerr << "PostedListWidget::acknowledgeSubscribeChange()";
|
||||
// std::cerr << std::endl;
|
||||
|
||||
// std::vector<RsPostedPost> posts;
|
||||
// RsGxsGroupId groupId;
|
||||
// rsPosted->acknowledgeGrp(token, groupId);
|
||||
|
||||
// insertGroups();
|
||||
//}
|
||||
|
||||
bool PostedListWidget::insertGroupData(const uint32_t &token, RsGroupMetaData &metaData)
|
||||
{
|
||||
std::vector<RsPostedGroup> groups;
|
||||
rsPosted->getGroupData(token, groups);
|
||||
|
||||
if (groups.size() == 1)
|
||||
{
|
||||
insertPostedDetails(groups[0]);
|
||||
metaData = groups[0].mMeta;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PostedListWidget::insertPosts(const uint32_t &token)
|
||||
{
|
||||
std::vector<RsPostedPost> posts;
|
||||
rsPosted->getPostData(token, posts);
|
||||
|
||||
mStateHelper->setActive(TOKEN_USER_TYPE_POST, true);
|
||||
std::vector<RsPostedPost>::iterator vit;
|
||||
for(vit = posts.begin(); vit != posts.end(); vit++)
|
||||
{
|
||||
RsPostedPost& p = *vit;
|
||||
loadPost(p);
|
||||
}
|
||||
|
||||
applyRanking();
|
||||
}
|
||||
|
||||
void PostedListWidget::insertRelatedPosts(const uint32_t &token)
|
||||
{
|
||||
std::vector<RsPostedPost> posts;
|
||||
rsPosted->getRelatedPosts(token, posts);
|
||||
|
||||
std::vector<RsPostedPost>::iterator vit;
|
||||
for(vit = posts.begin(); vit != posts.end(); vit++)
|
||||
@ -871,22 +592,15 @@ void PostedListWidget::updateCurrentDisplayComplete(const uint32_t &token)
|
||||
}
|
||||
|
||||
applyRanking();
|
||||
|
||||
mStateHelper->setLoading(TOKEN_USER_TYPE_POST, false);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
//void PostedListWidget::acknowledgeSubscribeChange(const uint32_t &token)
|
||||
//{
|
||||
// std::cerr << "PostedListWidget::acknowledgeSubscribeChange()";
|
||||
// std::cerr << std::endl;
|
||||
void PostedListWidget::setMessageRead(GxsFeedItem *item, bool read)
|
||||
{
|
||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(item->groupId(), item->messageId());
|
||||
|
||||
// std::vector<RsPostedPost> posts;
|
||||
// RsGxsGroupId groupId;
|
||||
// rsPosted->acknowledgeGrp(token, groupId);
|
||||
|
||||
// insertGroups();
|
||||
//}
|
||||
uint32_t token;
|
||||
rsPosted->setMessageReadStatus(token, msgPair, read);
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
@ -897,37 +611,10 @@ void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||
std::cerr << "PostedListWidget::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (queue == mPostedQueue)
|
||||
if (queue == mTokenQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case TOKEN_USER_TYPE_TOPIC:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadGroupData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TOKEN_USER_TYPE_POST:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_ACK:
|
||||
acknowledgePostMsg(req.mToken);
|
||||
break;
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadPostData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TOKEN_USER_TYPE_VOTE:
|
||||
if (req.mUserType == mTokenTypeVote) {
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_ACK:
|
||||
@ -937,18 +624,8 @@ void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TOKEN_USER_TYPE_POST_MOD:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
updateCurrentDisplayComplete(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
// case TOKEN_USER_TYPE_POST_RANKINGS:
|
||||
// switch(req.mAnsType)
|
||||
// {
|
||||
@ -962,10 +639,7 @@ void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||
// case TOKEN_USER_TYPE_SUBSCRIBE_CHANGE:
|
||||
// acknowledgeSubscribeChange(req.mToken);
|
||||
// break;
|
||||
default:
|
||||
std::cerr << "PostedListWidget::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GxsMessageFramePostWidget::loadRequest(queue, req);
|
||||
}
|
||||
|
@ -26,20 +26,18 @@
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include "gui/gxs/GxsMessageFrameWidget.h"
|
||||
#include "gui/gxs/GxsMessageFramePostWidget.h"
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class RsPostedGroup;
|
||||
class RsPostedPost;
|
||||
class PostedItem;
|
||||
class UIStateHelper;
|
||||
|
||||
namespace Ui {
|
||||
class PostedListWidget;
|
||||
}
|
||||
|
||||
class PostedListWidget : public GxsMessageFrameWidget, public FeedHolder, public TokenResponse
|
||||
class PostedListWidget : public GxsMessageFramePostWidget, public FeedHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -48,11 +46,7 @@ public:
|
||||
~PostedListWidget();
|
||||
|
||||
/* GxsMessageFrameWidget */
|
||||
virtual RsGxsGroupId groupId() { return mPostedId; }
|
||||
virtual void setGroupId(const RsGxsGroupId &postedId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
virtual QIcon groupIcon();
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
|
||||
/* FeedHolder */
|
||||
virtual QScrollArea *getScrollArea();
|
||||
@ -60,11 +54,16 @@ public:
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
/* NEW GXS FNS */
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
/* GXS functions */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
/* GxsMessageFramePostWidget */
|
||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
||||
virtual void insertPosts(const uint32_t &token);
|
||||
virtual void insertRelatedPosts(const uint32_t &token);
|
||||
virtual void setMessageRead(GxsFeedItem *item, bool read);
|
||||
virtual void clearPosts();
|
||||
|
||||
private slots:
|
||||
void createNewGxsId();
|
||||
@ -84,8 +83,6 @@ private:
|
||||
void processSettings(bool load);
|
||||
void updateShowText();
|
||||
|
||||
void clearPosts();
|
||||
|
||||
/*!
|
||||
* Only removes it from layout
|
||||
*/
|
||||
@ -93,18 +90,11 @@ private:
|
||||
|
||||
void loadPost(const RsPostedPost &post);
|
||||
|
||||
void requestGroupData();
|
||||
void loadGroupData(const uint32_t &token);
|
||||
void insertPostedDetails(const RsPostedGroup &group);
|
||||
|
||||
// subscribe/unsubscribe ack.
|
||||
// void acknowledgeSubscribeChange(const uint32_t &token);
|
||||
|
||||
// posts
|
||||
void acknowledgePostMsg(const uint32_t &token);
|
||||
void loadPostData(const uint32_t &token);
|
||||
void requestPosts();
|
||||
|
||||
// votes
|
||||
void acknowledgeVoteMsg(const uint32_t& token);
|
||||
void loadVoteData(const uint32_t &token);
|
||||
@ -114,28 +104,15 @@ private:
|
||||
//void applyRanking(const PostedRanking& ranks);
|
||||
void applyRanking();
|
||||
|
||||
// update displayed item
|
||||
void updateDisplayedItems(const std::vector<RsGxsMessageId>& msgIds);
|
||||
void updateCurrentDisplayComplete(const uint32_t& token);
|
||||
|
||||
private:
|
||||
int mSortMethod;
|
||||
int mLastSortMethod;
|
||||
int mPostIndex;
|
||||
int mPostShow;
|
||||
|
||||
int mSubscribeFlags;
|
||||
RsGxsGroupId mPostedId;
|
||||
QString mName;
|
||||
uint32_t mTokenTypeVote;
|
||||
|
||||
QMap<RsGxsMessageId, PostedItem*> mPosts;
|
||||
std::list<PostedItem *> mPostList;
|
||||
|
||||
TokenQueue *mPostedQueue;
|
||||
|
||||
//CommentHolder* mCommentHolder;
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::PostedListWidget *ui;
|
||||
|
@ -1,11 +0,0 @@
|
||||
#ifndef POSTEDUSERTYPES_H
|
||||
#define POSTEDUSERTYPES_H
|
||||
|
||||
#define TOKEN_USER_TYPE_POST 4
|
||||
#define TOKEN_USER_TYPE_VOTE 5
|
||||
#define TOKEN_USER_TYPE_TOPIC 6
|
||||
#define TOKEN_USER_TYPE_POST_MOD 7
|
||||
#define TOKEN_USER_TYPE_POST_RANKINGS 8
|
||||
#define TOKEN_USER_TYPE_SUBSCRIBE_CHANGE 9
|
||||
|
||||
#endif // POSTEDUSERTYPES_H
|
331
retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp
Normal file
331
retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp
Normal file
@ -0,0 +1,331 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "GxsMessageFramePostWidget.h"
|
||||
#include "GxsFeedItem.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
|
||||
//#define ENABLE_DEBUG 1
|
||||
|
||||
GxsMessageFramePostWidget::GxsMessageFramePostWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent)
|
||||
: GxsMessageFrameWidget(ifaceImpl, parent)
|
||||
{
|
||||
mTokenQueue = new TokenQueue(ifaceImpl->getTokenService(), this);
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
mNextTokenType = 0;
|
||||
|
||||
mTokenTypeGroupData = nextTokenType();
|
||||
mTokenTypePosts = nextTokenType();
|
||||
mTokenTypeRelatedPosts = nextTokenType();
|
||||
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::setGroupId(const RsGxsGroupId &groupId)
|
||||
{
|
||||
if (mGroupId == groupId) {
|
||||
if (!groupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mGroupId = groupId;
|
||||
mGroupName = mGroupId.isNull () ? "" : tr("Loading");
|
||||
groupNameChanged(mGroupName);
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
fillComplete();
|
||||
}
|
||||
|
||||
RsGxsGroupId GxsMessageFramePostWidget::groupId()
|
||||
{
|
||||
return mGroupId;
|
||||
}
|
||||
|
||||
QString GxsMessageFramePostWidget::groupName(bool withUnreadCount)
|
||||
{
|
||||
QString name = mGroupId.isNull () ? tr("No name") : mGroupName;
|
||||
|
||||
// if (withUnreadCount && mUnreadCount) {
|
||||
// name += QString(" (%1)").arg(mUnreadCount);
|
||||
// }
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::updateDisplay(bool complete)
|
||||
{
|
||||
if (complete) {
|
||||
/* Fill complete */
|
||||
requestGroupData();
|
||||
requestPosts();
|
||||
return;
|
||||
}
|
||||
|
||||
bool updateGroup = false;
|
||||
if (mGroupId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
|
||||
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mGroupId) != grpIdsMeta.end()) {
|
||||
updateGroup = true;
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &grpIds = getGrpIds();
|
||||
if (!mGroupId.isNull() && std::find(grpIds.begin(), grpIds.end(), mGroupId) != grpIds.end()) {
|
||||
updateGroup = true;
|
||||
/* Do we need to fill all posts? */
|
||||
requestPosts();
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
||||
getAllMsgIds(msgs);
|
||||
if (!msgs.empty()) {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit = msgs.find(mGroupId);
|
||||
if (mit != msgs.end()) {
|
||||
requestRelatedPosts(mit->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateGroup) {
|
||||
requestGroupData();
|
||||
}
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::setAllMessagesRead(bool read)
|
||||
{
|
||||
if (mGroupId.isNull() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (GxsFeedItem *item, mPostItems) {
|
||||
setMessageRead(item, read);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::clearPosts()
|
||||
{
|
||||
/* clear all messages */
|
||||
foreach (GxsFeedItem *item, mPostItems) {
|
||||
delete(item);
|
||||
}
|
||||
mPostItems.clear();
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/**************************************************************/
|
||||
|
||||
void GxsMessageFramePostWidget::requestGroupData()
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::requestGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
|
||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypeGroupData);
|
||||
|
||||
if (mGroupId.isNull()) {
|
||||
mStateHelper->setActive(mTokenTypeGroupData, false);
|
||||
mStateHelper->setLoading(mTokenTypeGroupData, false);
|
||||
mStateHelper->clear(mTokenTypeGroupData);
|
||||
|
||||
mGroupName.clear();
|
||||
groupNameChanged(mGroupName);
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(mTokenTypeGroupData, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mGroupId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, mTokenTypeGroupData);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::loadGroupData(const uint32_t &token)
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::loadGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsGroupMetaData metaData;
|
||||
bool ok = insertGroupData(token, metaData);
|
||||
|
||||
mStateHelper->setLoading(mTokenTypeGroupData, false);
|
||||
|
||||
if (ok) {
|
||||
mSubscribeFlags = metaData.mSubscribeFlags;
|
||||
|
||||
mGroupName = QString::fromUtf8(metaData.mGroupName.c_str());
|
||||
groupNameChanged(mGroupName);
|
||||
} else {
|
||||
std::cerr << "GxsMessageFramePostWidget::loadGroupData() ERROR Not just one Group";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->clear(mTokenTypeGroupData);
|
||||
|
||||
mGroupName.clear();
|
||||
groupNameChanged(mGroupName);
|
||||
}
|
||||
|
||||
mStateHelper->setActive(mTokenTypeGroupData, ok);
|
||||
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::requestPosts()
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::requestPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* Request all posts */
|
||||
clearPosts();
|
||||
|
||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypePosts);
|
||||
|
||||
if (mGroupId.isNull()) {
|
||||
mStateHelper->setActive(mTokenTypePosts, false);
|
||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||
mStateHelper->clear(mTokenTypePosts);
|
||||
emit groupChanged(this);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(mTokenTypePosts, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mGroupId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, mTokenTypePosts);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::loadPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mStateHelper->setActive(mTokenTypePosts, true);
|
||||
|
||||
insertPosts(token);
|
||||
|
||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::requestRelatedPosts(const std::vector<RsGxsMessageId> &msgIds)
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::requestRelatedPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypeRelatedPosts);
|
||||
|
||||
if (mGroupId.isNull()) {
|
||||
mStateHelper->setActive(mTokenTypePosts, false);
|
||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||
mStateHelper->clear(mTokenTypePosts);
|
||||
emit groupChanged(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgIds.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(mTokenTypePosts, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
|
||||
|
||||
uint32_t token;
|
||||
std::vector<RsGxsGrpMsgIdPair> relatedMsgIds;
|
||||
for (std::vector<RsGxsMessageId>::const_iterator msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
|
||||
relatedMsgIds.push_back(RsGxsGrpMsgIdPair(mGroupId, *msgIt));
|
||||
}
|
||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, relatedMsgIds, mTokenTypeRelatedPosts);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::loadRelatedPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::loadRelatedPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mStateHelper->setActive(mTokenTypePosts, true);
|
||||
|
||||
insertRelatedPosts(token);
|
||||
|
||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void GxsMessageFramePostWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef ENABLE_DEBUG
|
||||
std::cerr << "GxsMessageFramePostWidget::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mTokenQueue)
|
||||
{
|
||||
if (req.mUserType == mTokenTypeGroupData) {
|
||||
loadGroupData(req.mToken);
|
||||
} else if (req.mUserType == mTokenTypePosts) {
|
||||
loadPosts(req.mToken);
|
||||
} else if (req.mUserType == mTokenTypeRelatedPosts) {
|
||||
loadRelatedPosts(req.mToken);
|
||||
} else {
|
||||
std::cerr << "GxsMessageFramePostWidget::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
86
retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h
Normal file
86
retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h
Normal file
@ -0,0 +1,86 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef GXSMESSAGEFRAMEPOSTWIDGET_H
|
||||
#define GXSMESSAGEFRAMEPOSTWIDGET_H
|
||||
|
||||
#include "GxsMessageFrameWidget.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
class GxsFeedItem;
|
||||
class UIStateHelper;
|
||||
|
||||
class GxsMessageFramePostWidget : public GxsMessageFrameWidget, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GxsMessageFramePostWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = NULL);
|
||||
|
||||
/* GxsMessageFrameWidget */
|
||||
virtual RsGxsGroupId groupId();
|
||||
virtual void setGroupId(const RsGxsGroupId &groupId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
// virtual QIcon groupIcon() = 0;
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
|
||||
/* GXS functions */
|
||||
uint32_t nextTokenType() { return ++mNextTokenType; }
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
int subscribeFlags() { return mSubscribeFlags; }
|
||||
|
||||
protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
virtual void groupNameChanged(const QString &/*name*/) {}
|
||||
|
||||
virtual void setMessageRead(GxsFeedItem *item, bool read) = 0;
|
||||
virtual void clearPosts();
|
||||
|
||||
/* GXS functions */
|
||||
void requestGroupData();
|
||||
void loadGroupData(const uint32_t &token);
|
||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData) = 0;
|
||||
|
||||
void requestPosts();
|
||||
void loadPosts(const uint32_t &token);
|
||||
virtual void insertPosts(const uint32_t &token) = 0;
|
||||
|
||||
void requestRelatedPosts(const std::vector<RsGxsMessageId> &msgIds);
|
||||
void loadRelatedPosts(const uint32_t &token);
|
||||
virtual void insertRelatedPosts(const uint32_t &token) = 0;
|
||||
|
||||
protected:
|
||||
TokenQueue *mTokenQueue;
|
||||
uint32_t mTokenTypeGroupData;
|
||||
uint32_t mTokenTypePosts;
|
||||
uint32_t mTokenTypeRelatedPosts;
|
||||
UIStateHelper *mStateHelper;
|
||||
QList<GxsFeedItem*> mPostItems;
|
||||
|
||||
private:
|
||||
RsGxsGroupId mGroupId; /* current group */
|
||||
QString mGroupName;
|
||||
int mSubscribeFlags;
|
||||
uint32_t mNextTokenType;
|
||||
};
|
||||
|
||||
#endif // GXSMESSAGEFRAMEPOSTWIDGET_H
|
@ -6,6 +6,8 @@ RsGxsUpdateBroadcastWidget::RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper *ifaceIm
|
||||
{
|
||||
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this);
|
||||
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
|
||||
|
||||
mInterfaceHelper = ifaceImpl;
|
||||
}
|
||||
|
||||
RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget()
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIdsMeta();
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds);
|
||||
|
||||
RsGxsIfaceHelper *interfaceHelper() { return mInterfaceHelper; }
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
@ -42,4 +44,5 @@ private slots:
|
||||
|
||||
private:
|
||||
RsGxsUpdateBroadcastBase *mBase;
|
||||
RsGxsIfaceHelper *mInterfaceHelper;
|
||||
};
|
||||
|
@ -35,13 +35,6 @@
|
||||
* #define DEBUG_CHANNEL
|
||||
***/
|
||||
|
||||
//#define USE_THREAD
|
||||
|
||||
#define TOKEN_TYPE_MESSAGE_CHANGE 4
|
||||
#define TOKEN_TYPE_GROUP_DATA 6
|
||||
#define TOKEN_TYPE_POSTS 7
|
||||
#define TOKEN_TYPE_RELATEDPOSTS 8
|
||||
|
||||
/* Filters */
|
||||
#define FILTER_TITLE 1
|
||||
#define FILTER_MSG 2
|
||||
@ -50,31 +43,27 @@
|
||||
|
||||
/** Constructor */
|
||||
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) :
|
||||
GxsMessageFrameWidget(rsGxsChannels, parent),
|
||||
GxsMessageFramePostWidget(rsGxsChannels, parent),
|
||||
ui(new Ui::GxsChannelPostsWidget)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
|
||||
// No progress yet
|
||||
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressLabel, UISTATE_LOADING_VISIBLE);
|
||||
mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||
// mStateHelper->addWidget(mTokenTypePosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||
// mStateHelper->addWidget(mTokenTypePosts, ui->progressLabel, UISTATE_LOADING_VISIBLE);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui->nameLabel);
|
||||
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
||||
|
||||
mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->postButton);
|
||||
mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->logoLabel);
|
||||
mStateHelper->addWidget(TOKEN_TYPE_GROUP_DATA, ui->subscribeToolButton);
|
||||
|
||||
mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this);
|
||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
|
||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
|
||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
||||
|
||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
||||
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
||||
// connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
||||
|
||||
/* add filter actions */
|
||||
ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title"));
|
||||
@ -92,7 +81,6 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
||||
|
||||
ui->nameLabel->setMinimumWidth(20);
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
mInProcessSettings = false;
|
||||
|
||||
/* load settings */
|
||||
@ -121,48 +109,6 @@ GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||
delete(mAutoDownloadAction);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::updateDisplay(bool complete)
|
||||
{
|
||||
if (complete) {
|
||||
/* Fill complete */
|
||||
requestGroupData();
|
||||
requestPosts();
|
||||
return;
|
||||
}
|
||||
|
||||
bool updateGroup = false;
|
||||
if (mChannelId.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
|
||||
if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), mChannelId) != grpIdsMeta.end()) {
|
||||
updateGroup = true;
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &grpIds = getGrpIds();
|
||||
if (!mChannelId.isNull() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) {
|
||||
updateGroup = true;
|
||||
/* Do we need to fill all posts? */
|
||||
requestPosts();
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
||||
getAllMsgIds(msgs);
|
||||
if (!msgs.empty())
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit = msgs.find(mChannelId);
|
||||
if(mit != msgs.end())
|
||||
{
|
||||
requestRelatedPosts(mit->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateGroup) {
|
||||
requestGroupData();
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::processSettings(bool load)
|
||||
{
|
||||
mInProcessSettings = true;
|
||||
@ -178,36 +124,19 @@ void GxsChannelPostsWidget::processSettings(bool load)
|
||||
mInProcessSettings = false;
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::setGroupId(const RsGxsGroupId &groupId)
|
||||
void GxsChannelPostsWidget::groupNameChanged(const QString &name)
|
||||
{
|
||||
if (mChannelId == groupId) {
|
||||
if (!groupId.isNull()) {
|
||||
return;
|
||||
if (groupId().isNull()) {
|
||||
ui->nameLabel->setText(tr("No Channel Selected"));
|
||||
ui->logoLabel->setPixmap(QPixmap(":/images/channels.png"));
|
||||
} else {
|
||||
ui->nameLabel->setText(name);
|
||||
}
|
||||
}
|
||||
|
||||
mChannelId = groupId;
|
||||
ui->nameLabel->setText(mChannelId.isNull () ? "" : tr("Loading"));
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
fillComplete();
|
||||
}
|
||||
|
||||
QString GxsChannelPostsWidget::groupName(bool withUnreadCount)
|
||||
{
|
||||
QString name = mChannelId.isNull () ? tr("No name") : ui->nameLabel->text();
|
||||
|
||||
// if (withUnreadCount && mUnreadCount) {
|
||||
// name += QString(" (%1)").arg(mUnreadCount);
|
||||
// }
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon GxsChannelPostsWidget::groupIcon()
|
||||
{
|
||||
if (mStateHelper->isLoading(TOKEN_TYPE_GROUP_DATA) || mStateHelper->isLoading(TOKEN_TYPE_POSTS)) {
|
||||
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypePosts)) {
|
||||
return QIcon(":/images/kalarm.png");
|
||||
}
|
||||
|
||||
@ -243,31 +172,22 @@ void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &
|
||||
|
||||
void GxsChannelPostsWidget::createMsg()
|
||||
{
|
||||
if (mChannelId.isNull()) {
|
||||
if (groupId().isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IS_GROUP_SUBSCRIBED(mSubscribeFlags)) {
|
||||
if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) {
|
||||
return;
|
||||
}
|
||||
|
||||
CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(mChannelId);
|
||||
CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(groupId());
|
||||
msgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
//void GxsChannelPostsWidget::channelMsgReadSatusChanged(const QString& channelId, const QString& /*msgId*/, int /*status*/)
|
||||
//{
|
||||
// updateMessageSummaryList(channelId.toStdString());
|
||||
//}
|
||||
|
||||
void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||
{
|
||||
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, true);
|
||||
|
||||
mSubscribeFlags = group.mMeta.mSubscribeFlags;
|
||||
|
||||
/* IMAGE */
|
||||
QPixmap chanImage;
|
||||
if (group.mImage.mData != NULL) {
|
||||
@ -277,10 +197,7 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||
}
|
||||
ui->logoLabel->setPixmap(chanImage);
|
||||
|
||||
/* set Channel name */
|
||||
ui->nameLabel->setText(QString::fromUtf8(group.mMeta.mGroupName.c_str()));
|
||||
|
||||
if (mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
||||
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
||||
{
|
||||
mStateHelper->setWidgetEnabled(ui->postButton, true);
|
||||
}
|
||||
@ -289,22 +206,12 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||
mStateHelper->setWidgetEnabled(ui->postButton, false);
|
||||
}
|
||||
|
||||
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(mSubscribeFlags));
|
||||
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
|
||||
|
||||
bool autoDownload = rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId);
|
||||
setAutoDownload(autoDownload);
|
||||
}
|
||||
|
||||
static bool sortChannelMsgSummaryAsc(const RsGxsChannelPost &msg1, const RsGxsChannelPost &msg2)
|
||||
{
|
||||
return (msg1.mMeta.mPublishTs > msg2.mMeta.mPublishTs);
|
||||
}
|
||||
|
||||
static bool sortChannelMsgSummaryDesc(const RsGxsChannelPost &msg1, const RsGxsChannelPost &msg2)
|
||||
{
|
||||
return (msg1.mMeta.mPublishTs < msg2.mMeta.mPublishTs);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::filterChanged(int filter)
|
||||
{
|
||||
if (mInProcessSettings) {
|
||||
@ -321,10 +228,13 @@ void GxsChannelPostsWidget::filterItems(const QString& text)
|
||||
int filter = ui->filterLineEdit->currentFilter();
|
||||
|
||||
/* Search exisiting item */
|
||||
QList<GxsChannelPostItem*>::iterator lit;
|
||||
for (lit = mChannelPostItems.begin(); lit != mChannelPostItems.end(); lit++)
|
||||
QList<GxsFeedItem*>::iterator lit;
|
||||
for (lit = mPostItems.begin(); lit != mPostItems.end(); lit++)
|
||||
{
|
||||
GxsChannelPostItem *item = *lit;
|
||||
GxsChannelPostItem *item = dynamic_cast<GxsChannelPostItem*>(*lit);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
filterItem(item,text,filter);
|
||||
}
|
||||
}
|
||||
@ -362,6 +272,16 @@ bool GxsChannelPostsWidget::filterItem(GxsChannelPostItem *pItem, const QString
|
||||
return (bVisible);
|
||||
}
|
||||
|
||||
static bool sortChannelMsgSummaryAsc(const RsGxsChannelPost &msg1, const RsGxsChannelPost &msg2)
|
||||
{
|
||||
return (msg1.mMeta.mPublishTs > msg2.mMeta.mPublishTs);
|
||||
}
|
||||
|
||||
static bool sortChannelMsgSummaryDesc(const RsGxsChannelPost &msg1, const RsGxsChannelPost &msg2)
|
||||
{
|
||||
return (msg1.mMeta.mPublishTs < msg2.mMeta.mPublishTs);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &posts, bool related)
|
||||
{
|
||||
std::vector<RsGxsChannelPost>::const_iterator it;
|
||||
@ -381,9 +301,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||
{
|
||||
GxsChannelPostItem *item = NULL;
|
||||
if (related) {
|
||||
foreach (GxsChannelPostItem *loopItem, mChannelPostItems) {
|
||||
foreach (GxsFeedItem *loopItem, mPostItems) {
|
||||
if (loopItem->messageId() == it->mMeta.mMsgId) {
|
||||
item = loopItem;
|
||||
item = dynamic_cast<GxsChannelPostItem*>(loopItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -396,7 +316,7 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||
if (!ui->filterLineEdit->text().isEmpty())
|
||||
filterItem(item, ui->filterLineEdit->text(), ui->filterLineEdit->currentFilter());
|
||||
|
||||
mChannelPostItems.push_back(item);
|
||||
mPostItems.push_back(item);
|
||||
if (related) {
|
||||
ui->verticalLayout->insertWidget(0, item);
|
||||
} else {
|
||||
@ -406,181 +326,14 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void GxsChannelPostsWidget::updateChannelMsgs()
|
||||
{
|
||||
if (fillThread) {
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::updateChannelMsgs() stop current fill thread" << std::endl;
|
||||
#endif
|
||||
// stop current fill thread
|
||||
GxsChannelFillThread *thread = fillThread;
|
||||
fillThread = NULL;
|
||||
thread->stop();
|
||||
delete(thread);
|
||||
|
||||
progressLabel->hide();
|
||||
progressBar->hide();
|
||||
}
|
||||
|
||||
if (!rsChannels) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* replace all the messages with new ones */
|
||||
QList<ChanMsgItem *>::iterator mit;
|
||||
for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) {
|
||||
delete (*mit);
|
||||
}
|
||||
mChanMsgItems.clear();
|
||||
|
||||
ChannelInfo ci;
|
||||
if (!rsChannels->getChannelInfo(mChannelId, ci)) {
|
||||
postButton->setEnabled(false);
|
||||
nameLabel->setText(tr("No Channel Selected"));
|
||||
logoLabel->setPixmap(QPixmap(":/images/channels.png"));
|
||||
logoLabel->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap chanImage;
|
||||
if (ci.pngImageLen != 0) {
|
||||
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
|
||||
} else {
|
||||
chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
|
||||
}
|
||||
logoLabel->setPixmap(chanImage);
|
||||
logoLabel->setEnabled(true);
|
||||
|
||||
/* set Channel name */
|
||||
nameLabel->setText(QString::fromStdWString(ci.channelName));
|
||||
|
||||
if (ci.channelFlags & RS_DISTRIB_PUBLISH) {
|
||||
postButton->setEnabled(true);
|
||||
} else {
|
||||
postButton->setEnabled(false);
|
||||
}
|
||||
|
||||
if (!(ci.channelFlags & RS_DISTRIB_ADMIN) &&
|
||||
(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)) {
|
||||
actionEnable_Auto_Download->setEnabled(true);
|
||||
} else {
|
||||
actionEnable_Auto_Download->setEnabled(false);
|
||||
}
|
||||
|
||||
#ifdef USE_THREAD
|
||||
progressLabel->show();
|
||||
progressBar->reset();
|
||||
progressBar->show();
|
||||
|
||||
// create fill thread
|
||||
fillThread = new GxsChannelFillThread(this, mChannelId);
|
||||
|
||||
// connect thread
|
||||
connect(fillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection);
|
||||
connect(fillThread, SIGNAL(addMsg(QString,QString,int,int)), this, SLOT(fillThreadAddMsg(QString,QString,int,int)), Qt::BlockingQueuedConnection);
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::updateChannelMsgs() Start fill thread" << std::endl;
|
||||
#endif
|
||||
|
||||
// start thread
|
||||
fillThread->start();
|
||||
#else
|
||||
std::list<ChannelMsgSummary> msgs;
|
||||
std::list<ChannelMsgSummary>::iterator it;
|
||||
rsChannels->getChannelMsgList(mChannelId, msgs);
|
||||
|
||||
msgs.sort(sortChannelMsgSummary);
|
||||
|
||||
for (it = msgs.begin(); it != msgs.end(); it++) {
|
||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
||||
mChanMsgItems.push_back(cmi);
|
||||
verticalLayout_2->addWidget(cmi);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::fillThreadFinished()
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished()" << std::endl;
|
||||
#endif
|
||||
|
||||
// thread has finished
|
||||
GxsChannelFillThread *thread = dynamic_cast<GxsChannelFillThread*>(sender());
|
||||
if (thread) {
|
||||
if (thread == fillThread) {
|
||||
// current thread has finished, hide progressbar and release thread
|
||||
progressBar->hide();
|
||||
progressLabel->hide();
|
||||
fillThread = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
if (thread->wasStopped()) {
|
||||
// thread was stopped
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished() Thread was stopped" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished() Delete thread" << std::endl;
|
||||
#endif
|
||||
|
||||
thread->deleteLater();
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::fillThreadFinished done()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count)
|
||||
{
|
||||
if (sender() == fillThread) {
|
||||
// show fill progress
|
||||
if (count) {
|
||||
progressBar->setValue(current * progressBar->maximum() / count);
|
||||
}
|
||||
|
||||
lockLayout(NULL, true);
|
||||
|
||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true);
|
||||
mChanMsgItems.push_back(cmi);
|
||||
verticalLayout->addWidget(cmi);
|
||||
cmi->show();
|
||||
|
||||
lockLayout(cmi, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GxsChannelPostsWidget::setAllMessagesRead(bool read)
|
||||
{
|
||||
if (mChannelId.isNull() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<GxsChannelPostItem *>::iterator mit;
|
||||
for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); ++mit) {
|
||||
GxsChannelPostItem *item = *mit;
|
||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(item->groupId(), item->messageId());
|
||||
|
||||
uint32_t token;
|
||||
rsGxsChannels->setMessageReadStatus(token, msgPair, read);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::subscribeGroup(bool subscribe)
|
||||
{
|
||||
if (mChannelId.isNull()) {
|
||||
if (groupId().isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
rsGxsChannels->subscribeToGroup(token, mChannelId, subscribe);
|
||||
rsGxsChannels->subscribeToGroup(token, groupId(), subscribe);
|
||||
// mChannelQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE);
|
||||
}
|
||||
|
||||
@ -605,237 +358,41 @@ void GxsChannelPostsWidget::toggleAutoDownload()
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::clearPosts()
|
||||
bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaData &metaData)
|
||||
{
|
||||
/* replace all the messages with new ones */
|
||||
QList<GxsChannelPostItem *>::iterator mit;
|
||||
for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) {
|
||||
delete (*mit);
|
||||
}
|
||||
mChannelPostItems.clear();
|
||||
}
|
||||
|
||||
/**********************************************************************************************
|
||||
* New Stuff here.
|
||||
*************/
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsChannelPostsWidget::requestGroupData()
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::requestGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
|
||||
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_DATA);
|
||||
|
||||
if (mChannelId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_GROUP_DATA);
|
||||
|
||||
ui->nameLabel->setText(tr("No Channel Selected"));
|
||||
ui->logoLabel->setPixmap(QPixmap(":/images/channels.png"));
|
||||
|
||||
emit groupChanged(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mChannelId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_GROUP_DATA);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadGroupData(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadGroupData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
rsGxsChannels->getGroupData(token, groups);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false);
|
||||
|
||||
if (groups.size() == 1)
|
||||
{
|
||||
insertChannelDetails(groups[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsChannelPostsWidget::loadGroupData() ERROR Not just one Group";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_GROUP_DATA);
|
||||
metaData = groups[0].mMeta;
|
||||
return true;
|
||||
}
|
||||
|
||||
emit groupChanged(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::requestPosts()
|
||||
void GxsChannelPostsWidget::insertPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::requestPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* Request all posts */
|
||||
clearPosts();
|
||||
|
||||
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTS);
|
||||
|
||||
if (mChannelId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_TYPE_POSTS, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_POSTS);
|
||||
emit groupChanged(this);
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(mChannelId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_POSTS);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
rsGxsChannels->getPostData(token, posts);
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_POSTS, true);
|
||||
|
||||
insertChannelPosts(posts, false);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::requestRelatedPosts(const std::vector<RsGxsMessageId> &msgIds)
|
||||
void GxsChannelPostsWidget::insertRelatedPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::requestRelatedPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_RELATEDPOSTS);
|
||||
|
||||
if (mChannelId.isNull()) {
|
||||
mStateHelper->setActive(TOKEN_TYPE_POSTS, false);
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
|
||||
mStateHelper->clear(TOKEN_TYPE_POSTS);
|
||||
emit groupChanged(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgIds.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, true);
|
||||
emit groupChanged(this);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
|
||||
|
||||
uint32_t token;
|
||||
std::vector<RsGxsGrpMsgIdPair> relatedMsgIds;
|
||||
for (std::vector<RsGxsMessageId>::const_iterator msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
|
||||
relatedMsgIds.push_back(RsGxsGrpMsgIdPair(mChannelId, *msgIt));
|
||||
}
|
||||
mChannelQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, relatedMsgIds, TOKEN_TYPE_RELATEDPOSTS);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadRelatedPosts(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadRelatedPosts()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
rsGxsChannels->getRelatedPosts(token, posts);
|
||||
|
||||
mStateHelper->setActive(TOKEN_TYPE_POSTS, true);
|
||||
|
||||
insertChannelPosts(posts, true);
|
||||
|
||||
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
|
||||
emit groupChanged(this);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::acknowledgeMessageUpdate(const uint32_t &token)
|
||||
void GxsChannelPostsWidget::setMessageRead(GxsFeedItem *item, bool read)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::acknowledgeMessageUpdate() TODO";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(item->groupId(), item->messageId());
|
||||
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId> msgId;
|
||||
rsGxsChannels->acknowledgeMsg(token, msgId);
|
||||
if (msgId.first == mChannelId)
|
||||
{
|
||||
requestPosts();
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_CHANNEL
|
||||
std::cerr << "GxsChannelPostsWidget::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mChannelQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case TOKEN_TYPE_MESSAGE_CHANGE:
|
||||
acknowledgeMessageUpdate(req.mToken);
|
||||
break;
|
||||
case TOKEN_TYPE_GROUP_DATA:
|
||||
loadGroupData(req.mToken);
|
||||
break;
|
||||
case TOKEN_TYPE_POSTS:
|
||||
loadPosts(req.mToken);
|
||||
break;
|
||||
case TOKEN_TYPE_RELATEDPOSTS:
|
||||
loadRelatedPosts(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "GxsChannelPostsWidget::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint32_t token;
|
||||
rsGxsChannels->setMessageReadStatus(token, msgPair, read);
|
||||
}
|
||||
|
@ -24,12 +24,10 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "gui/gxs/GxsMessageFrameWidget.h"
|
||||
#include "gui/gxs/GxsMessageFramePostWidget.h"
|
||||
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
namespace Ui {
|
||||
class GxsChannelPostsWidget;
|
||||
}
|
||||
@ -37,10 +35,8 @@ class GxsChannelPostsWidget;
|
||||
//class ChanMsgItem;
|
||||
class GxsChannelPostItem;
|
||||
class QTreeWidgetItem;
|
||||
class UIStateHelper;
|
||||
class QBoxLayout;
|
||||
|
||||
class GxsChannelPostsWidget : public GxsMessageFrameWidget, public TokenResponse, public FeedHolder
|
||||
class GxsChannelPostsWidget : public GxsMessageFramePostWidget, public FeedHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -51,11 +47,7 @@ public:
|
||||
~GxsChannelPostsWidget();
|
||||
|
||||
/* GxsMessageFrameWidget */
|
||||
virtual RsGxsGroupId groupId() { return mChannelId; }
|
||||
virtual void setGroupId(const RsGxsGroupId &channelId);
|
||||
virtual QString groupName(bool withUnreadCount);
|
||||
virtual QIcon groupIcon();
|
||||
virtual void setAllMessagesRead(bool read);
|
||||
|
||||
/* FeedHolder */
|
||||
virtual QScrollArea *getScrollArea();
|
||||
@ -63,11 +55,13 @@ public:
|
||||
virtual void openChat(const RsPeerId& peerId);
|
||||
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
|
||||
|
||||
/* NEW GXS FNS */
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
/* GxsMessageFramePostWidget */
|
||||
virtual void groupNameChanged(const QString &name);
|
||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
||||
virtual void insertPosts(const uint32_t &token);
|
||||
virtual void insertRelatedPosts(const uint32_t &token);
|
||||
virtual void setMessageRead(GxsFeedItem *item, bool read);
|
||||
|
||||
private slots:
|
||||
void createMsg();
|
||||
@ -83,39 +77,14 @@ private:
|
||||
void processSettings(bool load);
|
||||
|
||||
void setAutoDownload(bool autoDl);
|
||||
void clearPosts();
|
||||
|
||||
/* NEW GXS FNS */
|
||||
void requestGroupData();
|
||||
void loadGroupData(const uint32_t &token);
|
||||
|
||||
void requestPosts();
|
||||
void loadPosts(const uint32_t &token);
|
||||
|
||||
void requestRelatedPosts(const std::vector<RsGxsMessageId> &msgIds);
|
||||
void loadRelatedPosts(const uint32_t &token);
|
||||
bool filterItem(GxsChannelPostItem *pItem, const QString &text, const int filter);
|
||||
|
||||
void insertChannelDetails(const RsGxsChannelGroup &group);
|
||||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, bool related);
|
||||
|
||||
void acknowledgeMessageUpdate(const uint32_t &token);
|
||||
|
||||
bool filterItem(GxsChannelPostItem *pItem, const QString &text, const int filter);
|
||||
|
||||
RsGxsGroupId mChannelId; /* current Channel */
|
||||
int mSubscribeFlags;
|
||||
TokenQueue *mChannelQueue;
|
||||
|
||||
/* Layout Pointers */
|
||||
QBoxLayout *mMsgLayout;
|
||||
|
||||
//QList<ChanMsgItem *> mChanMsgItems;
|
||||
QList<GxsChannelPostItem *> mChannelPostItems;
|
||||
|
||||
private:
|
||||
QAction *mAutoDownloadAction;
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
bool mInProcessSettings;
|
||||
|
||||
/* UI - from Designer */
|
||||
|
@ -1180,7 +1180,6 @@ posted {
|
||||
gui/Posted/PostedItem.h \
|
||||
gui/Posted/PostedGroupDialog.h \
|
||||
gui/Posted/PostedCreatePostDialog.h \
|
||||
gui/Posted/PostedUserTypes.h \
|
||||
gui/Posted/PostedUserNotify.h
|
||||
|
||||
#gui/Posted/PostedCreateCommentDialog.h \
|
||||
@ -1225,6 +1224,7 @@ gxsgui {
|
||||
gui/gxs/GxsCreateCommentDialog.h \
|
||||
gui/gxs/GxsGroupFrameDialog.h \
|
||||
gui/gxs/GxsMessageFrameWidget.h \
|
||||
gui/gxs/GxsMessageFramePostWidget.h \
|
||||
gui/gxs/GxsFeedItem.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||
@ -1259,6 +1259,7 @@ gxsgui {
|
||||
gui/gxs/GxsCreateCommentDialog.cpp \
|
||||
gui/gxs/GxsGroupFrameDialog.cpp \
|
||||
gui/gxs/GxsMessageFrameWidget.cpp \
|
||||
gui/gxs/GxsMessageFramePostWidget.cpp \
|
||||
gui/gxs/GxsFeedItem.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastBase.cpp \
|
||||
gui/gxs/RsGxsUpdateBroadcastWidget.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user