fixed connexion between posted items and async API, and removed dead code and debug info

This commit is contained in:
csoler 2020-02-19 21:52:55 +01:00
parent d3bd237cde
commit 5645d71699
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
13 changed files with 29 additions and 275 deletions

View File

@ -302,17 +302,17 @@ bool p3Posted::createPost(uint32_t &token, RsPostedPost &msg)
bool p3Posted::getBoardsInfo(
const std::list<RsGxsGroupId>& boardsIds,
std::vector<RsPostedGroup>& channelsInfo )
std::vector<RsPostedGroup>& groupsInfo )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, boardsIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupData(token, channelsInfo) && !channelsInfo.empty();
return getGroupData(token, groupsInfo) && !groupsInfo.empty();
}
bool p3Posted::getBoardContent( const RsGxsGroupId& channelId,
bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
const std::set<RsGxsMessageId>& contentsIds,
std::vector<RsPostedPost>& posts,
std::vector<RsGxsComment>& comments )
@ -322,7 +322,7 @@ bool p3Posted::getBoardContent( const RsGxsGroupId& channelId,
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
msgIds[channelId] = contentsIds;
msgIds[groupId] = contentsIds;
if( !requestMsgInfo(token, opts, msgIds) ||
waitToken(token) != RsTokenService::COMPLETE ) return false;

View File

@ -58,12 +58,10 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
return RsGxsIfaceHelper::receiveChanges(changes);
}
bool getBoardsInfo(
const std::list<RsGxsGroupId>& boardsIds,
std::vector<RsPostedGroup>& channelsInfo ) override;
bool getBoardsInfo(const std::list<RsGxsGroupId>& boardsIds,
std::vector<RsPostedGroup>& groupsInfo ) override;
bool getBoardContent(
const RsGxsGroupId& boardId,
bool getBoardContent(const RsGxsGroupId& groupId,
const std::set<RsGxsMessageId>& contentsIds,
std::vector<RsPostedPost>& posts,
std::vector<RsGxsComment>& comments ) override;

View File

@ -627,6 +627,7 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
std::cerr << " more than 1 item correspond to this ID. Removing!" << std::endl;
#endif
delete clist.front() ;
clist.pop_front();
}
item = clist.front() ;

View File

@ -172,10 +172,7 @@ void PostedCardView::loadGroup()
std::vector<RsPostedGroup> groups;
const std::list<RsGxsGroupId> groupIds = { groupId() };
#warning Code needed in rsPosted
#ifdef TODO
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
#endif
if(!rsPosted->getBoardsInfo(groupIds,groups))
{
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
return;
@ -210,10 +207,7 @@ void PostedCardView::loadMessage()
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
#endif
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
{
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
return;
@ -265,10 +259,7 @@ void PostedCardView::loadComment()
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(),msgIds,posts,comments))
#endif
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments))
{
RsErr() << "PostedCardView::loadGroup() ERROR getting data" << std::endl;
return;

View File

@ -182,10 +182,7 @@ void PostedItem::loadGroup()
std::vector<RsPostedGroup> groups;
const std::list<RsGxsGroupId> groupIds = { groupId() };
#warning Code needed in rsPosted
#ifdef TODO
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
#endif
if(!rsPosted->getBoardsInfo(groupIds,groups))
{
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
return;
@ -220,10 +217,7 @@ void PostedItem::loadMessage()
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
#endif
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
{
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
return;
@ -283,12 +277,9 @@ void PostedItem::loadComment()
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(),msgIds,posts,comments))
#endif
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments))
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
return;
}

View File

@ -42,7 +42,7 @@
#define POSTED_DEFAULT_LISTING_LENGTH 10
#define POSTED_MAX_INDEX 10000
#define DEBUG_POSTED_LIST_WIDGET
//#define DEBUG_POSTED_LIST_WIDGET
#define BOARD_DEFAULT_IMAGE ":/icons/png/posted.png"
@ -714,35 +714,45 @@ void PostedListWidget::applyRanking()
foreach (PostedCardView *item, mPostCardView)
{
#ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
std::cerr << std::endl;
#endif
if (item->getPost().mMeta.mPublishTs < min_ts)
{
#ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "\t Skipping OLD";
std::cerr << std::endl;
#endif
item->hide();
continue;
}
if (counter >= mPostIndex + mPostShow)
{
#ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "\t END - Counter too high";
std::cerr << std::endl;
#endif
item->hide();
}
else if (counter >= mPostIndex)
{
#ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "\t Adding to Layout";
std::cerr << std::endl;
#endif
/* add it in! */
cviewlayout->addWidget(item);
item->show();
}
else
{
#ifdef DEBUG_POSTED_LIST_WIDGET
std::cerr << "\t Skipping to Low";
std::cerr << std::endl;
#endif
item->hide();
}
++counter;

View File

@ -78,8 +78,7 @@
/** Constructor */
WikiDialog::WikiDialog(QWidget *parent)
: RsGxsUpdateBroadcastPage(rsWiki, parent)
WikiDialog::WikiDialog(QWidget *parent) : RsGxsUpdateBroadcastPage(rsWiki, parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);

View File

@ -101,7 +101,7 @@ void GxsChannelGroupItem::loadGroup()
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
return;
}

View File

@ -104,10 +104,7 @@ void PostedGroupItem::loadGroup()
std::vector<RsPostedGroup> groups;
const std::list<RsGxsGroupId> groupIds = { groupId() };
#warning Code needed in rsPosted
#ifdef TODO
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
#endif
if(!rsPosted->getBoardsInfo(groupIds,groups))
{
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
return;

View File

@ -45,21 +45,6 @@ GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, cons
/* load data if we can */
mGroupId = groupId;
mGxsIface = iface;
#ifdef TO_REMOVE
mNextTokenType = 0;
mTokenTypeGroup = nextTokenType();
mLoadQueue = NULL;
if (mGxsIface && autoUpdate) {
/* Connect to update broadcast */
mUpdateBroadcastBase = new RsGxsUpdateBroadcastBase(mGxsIface);
connect(mUpdateBroadcastBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplaySlot(bool)));
} else {
mUpdateBroadcastBase = NULL;
}
#endif
}
GxsGroupFeedItem::~GxsGroupFeedItem()
@ -69,16 +54,6 @@ GxsGroupFeedItem::~GxsGroupFeedItem()
std::cerr << std::endl;
#endif
#ifdef TO_REMOVE
if (mLoadQueue) {
delete mLoadQueue;
}
if (mUpdateBroadcastBase)
{
delete(mUpdateBroadcastBase);
}
#endif
}
void GxsGroupFeedItem::unsubscribe()
@ -132,17 +107,6 @@ void GxsGroupFeedItem::fillDisplaySlot(bool complete)
requestGroup();
}
#ifdef TO_REMOVE
void GxsGroupFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool /*complete*/)
{
std::set<RsGxsGroupId> grpIds;
updateBroadcastBase->getAllGrpIds(grpIds);
if (grpIds.find(groupId()) != grpIds.end())
requestGroup();
}
#endif
/***********************************************************/
void GxsGroupFeedItem::requestGroup()

View File

@ -221,50 +221,11 @@ bool GxsIdChooser::isInConstraintSet(const RsGxsId& id) const
void GxsIdChooser::setEntryEnabled(int indx,bool /*enabled*/)
{
removeItem(indx) ;
#ifdef TO_REMOVE
// bool disable = !enabled ;
//
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
// //QStandardItem* item = model->item(index);
//
// QModelIndex ii = model->index(indx,0);
//
// // visually disable by greying out - works only if combobox has been painted already and palette returns the wanted color
// //model->setFlags(ii,disable ? (model->flags(ii) & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)) : (Qt::ItemIsSelectable|Qt::ItemIsEnabled));
//
// uint32_t v = enabled?(1|32):(0);
//
// std::cerr << "GxsIdChooser::setEnabledEntry: i=" << indx << ", v=" << v << std::endl;
//
// // clear item data in order to use default color
// //model->setData(ii,disable ? (QComboBox::palette().color(QPalette::Disabled, QPalette::Text)) : QVariant(), Qt::TextColorRole);
// model->setData(ii,QVariant(v),Qt::UserRole-1) ;
//
// std::cerr << "model data after operation: " << model->data(ii,Qt::UserRole-1).toUInt() << std::endl;
#endif
}
uint32_t GxsIdChooser::countEnabledEntries() const
{
return count() ;
#ifdef TO_REMOVE
// uint32_t res = 0 ;
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
//
// for(uint32_t i=0;i<model->rowCount();++i)
// {
// QModelIndex ii = model->index(i,0);
// uint32_t v = model->data(ii,Qt::UserRole-1).toUInt() ;
//
// std::cerr << "GxsIdChooser::countEnabledEntries(): i=" << i << ", v=" << v << std::endl;
// if(v > 0)
// ++res ;
// }
//
// return res ;
#endif
}
void GxsIdChooser::loadPrivateIds()

View File

@ -106,35 +106,6 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
if (groupId().isNull()) {
return;
}
#ifdef TO_REMOVE
bool updateGroup = false;
const std::set<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
if(grpIdsMeta.find(groupId())!=grpIdsMeta.end())
updateGroup = true;
const std::set<RsGxsGroupId> &grpIds = getGrpIds();
if (!groupId().isNull() && grpIds.find(groupId())!=grpIds.end())
{
updateGroup = true;
/* Do we need to fill all posts? */
requestAllPosts();
} else {
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgs;
getAllMsgIds(msgs);
if (!msgs.empty()) {
auto mit = msgs.find(groupId());
if (mit != msgs.end()) {
requestPosts(mit->second);
}
}
}
if (updateGroup) {
requestGroupData();
}
#endif
}
void GxsMessageFramePostWidget::fillThreadAddPost(const QVariant &post, bool related, int current, int count)

View File

@ -481,55 +481,6 @@ QIcon GxsForumThreadWidget::groupIcon()
return QIcon();
}
#ifdef TO_REMOVE
void GxsForumThreadWidget::changeEvent(QEvent *e)
{
RsGxsUpdateBroadcastWidget::changeEvent(e);
switch (e->type()) {
case QEvent::StyleChange:
//calculateIconsAndFonts();
break;
default:
// remove compiler warnings
break;
}
}
static void removeMessages(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds, QList<RsGxsMessageId> &removeMsgId)
{
QList<RsGxsMessageId> removedMsgId;
for (auto grpIt = msgIds.begin(); grpIt != msgIds.end(); )
{
std::set<RsGxsMessageId> &msgs = grpIt->second;
QList<RsGxsMessageId>::const_iterator removeMsgIt;
for (removeMsgIt = removeMsgId.begin(); removeMsgIt != removeMsgId.end(); ++removeMsgIt) {
if(msgs.find(*removeMsgIt) != msgs.end())
{
removedMsgId.push_back(*removeMsgIt);
msgs.erase(*removeMsgIt);
}
}
if (msgs.empty()) {
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >::iterator grpItErase = grpIt++;
msgIds.erase(grpItErase);
} else {
++grpIt;
}
}
if (!removedMsgId.isEmpty()) {
QList<RsGxsMessageId>::const_iterator removedMsgIt;
for (removedMsgIt = removedMsgId.begin(); removedMsgIt != removedMsgId.end(); ++removedMsgIt) {
// remove first message id
removeMsgId.removeOne(*removedMsgIt);
}
}
}
#endif
void GxsForumThreadWidget::saveExpandedItems(QList<RsGxsMessageId>& expanded_items) const
{
expanded_items.clear();
@ -565,16 +516,6 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
#ifdef DEBUG_FORUMS
std::cerr << "udateDisplay: groupId()=" << groupId()<< std::endl;
#endif
#ifdef TO_REMOVE
if(mUpdating)
{
#ifdef DEBUG_FORUMS
std::cerr << " Already updating. Return!"<< std::endl;
#endif
return;
}
#endif
if(groupId().isNull())
{
#ifdef DEBUG_FORUMS
@ -590,55 +531,6 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
#endif
complete = true;
}
#ifdef TO_REMOVE
if(!complete)
{
#ifdef DEBUG_FORUMS
std::cerr << " checking changed group data and msgs"<< std::endl;
#endif
const std::set<RsGxsGroupId> &grpIdsMeta = getGrpIdsMeta();
if(grpIdsMeta.find(groupId())!=grpIdsMeta.end())
{
#ifdef DEBUG_FORUMS
std::cerr << " grpMeta change. reloading!" << std::endl;
#endif
complete = true;
}
const std::set<RsGxsGroupId> &grpIds = getGrpIds();
if (grpIds.find(groupId())!=grpIds.end())
{
#ifdef DEBUG_FORUMS
std::cerr << " grp data change. reloading!" << std::endl;
#endif
complete = true;
}
else
{
// retrieve the list of modified msg ids
// if current group is listed in the map, reload the whole hierarchy
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
getAllMsgIds(msgIds);
// if (!mIgnoredMsgId.empty()) /* Filter ignored messages */
// removeMessages(msgIds, mIgnoredMsgId);
if (msgIds.find(groupId()) != msgIds.end())
{
#ifdef DEBUG_FORUMS
std::cerr << " msg data change. reloading!" << std::endl;
#endif
complete=true;
}
}
}
#endif
if(complete) // need to update the group data, reload the messages etc.
{
saveExpandedItems(mSavedExpandedMessages);
@ -1214,27 +1106,6 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
bool redacted =
(overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
#ifdef TO_REMOVE
bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate();
uint32_t status = msg.mMeta.mMsgStatus ;//item->data(RsGxsForumModel::COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
QModelIndex index = getCurrentIndex();
if (IS_MSG_NEW(status)) {
if (setToReadOnActive) {
/* set to read */
mThreadModel->setMsgReadStatus(mThreadProxyModel->mapToSource(index),true,false);
} else {
/* set to unread by user */
mThreadModel->setMsgReadStatus(mThreadProxyModel->mapToSource(index),false,false);
}
} else {
if (setToReadOnActive && IS_MSG_UNREAD(status)) {
/* set to read */
mThreadModel->setMsgReadStatus(mThreadProxyModel->mapToSource(index), true,false);
}
}
#endif
ui->time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs));
ui->by_label->setId(msg.mMeta.mAuthorId);
ui->lineRight->show();