multiple improvements in distant channel search and general display of distant search results

This commit is contained in:
csoler 2020-06-25 21:15:37 +02:00
parent 500f572b98
commit ba486a0029
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
11 changed files with 47 additions and 27 deletions

View File

@ -717,7 +717,7 @@ public:
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
virtual bool clearDistantSearchResults(TurtleRequestId req)=0;
virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) =0;
//////////////////////////////////////////////////////////////////////////////

View File

@ -2402,7 +2402,7 @@ bool p3GxsChannels::retrieveDistantSearchResults(TurtleRequestId req,std::map<Rs
return netService()->retrieveDistantSearchResults(req,results);
}
bool p3GxsChannels::retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)
bool p3GxsChannels::getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)
{
RsGxsGroupSearchResults gs;

View File

@ -70,7 +70,7 @@ protected:
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) ;
virtual bool clearDistantSearchResults(TurtleRequestId req);
virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group);
virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group);
// Overloaded to cache new groups.
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);

View File

@ -467,7 +467,8 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
while(nullptr != item->takeChild(0));
for(auto str:itemInfo.context_strings)
item->addChild(new QTreeWidgetItem(QStringList(QString::fromUtf8(str.c_str()))));
if(!str.empty())
item->addChild(new QTreeWidgetItem(QStringList(QString::fromUtf8(str.c_str()))));
/* Set last post */
qlonglong lastPost = itemInfo.lastpost.toTime_t();

View File

@ -316,6 +316,8 @@ void GxsGroupFrameDialog::updateSearchResults(const TurtleRequestId& sid)
for(auto it3(group_infos.begin());it3!=group_infos.end();++it3)
{
std::cerr << " adding group " << it3->first << " " << it3->second.mGroupId << " \"" << it3->second.mGroupName << "\"" << std::endl;
for(auto s:it3->second.mSearchContexts)
std::cerr << " Context string \"" << s << "\"" << std::endl;
GroupItemInfo i;
i.id = QString(it3->second.mGroupId.toStdString().c_str());
@ -1067,15 +1069,20 @@ void GxsGroupFrameDialog::updateGroupSummary()
{
RsThread::async([this]()
{
std::list<RsGxsGenericGroupData*> groupInfo;
auto groupInfo = new std::list<RsGxsGenericGroupData*>() ;
if(!getGroupData(groupInfo))
if(!getGroupData(*groupInfo))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group info " << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group info." << std::endl;
delete groupInfo;
return;
}
if(groupInfo.empty())
if(groupInfo->empty())
{
std::cerr << __PRETTY_FUNCTION__ << " no group info collected." << std::endl;
delete groupInfo;
return;
}
RsQThreadUtils::postToObject( [this,groupInfo]()
{
@ -1085,7 +1092,7 @@ void GxsGroupFrameDialog::updateGroupSummary()
* Qt::QueuedConnection is important!
*/
insertGroupsData(groupInfo);
insertGroupsData(*groupInfo);
updateSearchResults();
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false);
@ -1104,12 +1111,14 @@ void GxsGroupFrameDialog::updateGroupSummary()
// now delete the data that is not used anymore
for(auto& g:groupInfo)
for(auto& g:*groupInfo)
{
mCachedGroupMetas[g->mMeta.mGroupId] = g->mMeta;
delete g;
}
delete groupInfo;
}, this );
});
}

View File

@ -162,6 +162,7 @@ private:
virtual RsGxsCommentService *getCommentService() { return NULL; }
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map<RsGxsGroupId,RsGxsGroupSearchResults>& /* group_infos */){ return false ;}
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& group_id){ return nullptr ;}
void initUi();

View File

@ -406,11 +406,21 @@ bool GxsChannelDialog::getDistantSearchResults(TurtleRequestId id, std::map<RsGx
return rsGxsChannels->retrieveDistantSearchResults(id,group_infos);
}
RsGxsGenericGroupData *GxsChannelDialog::getDistantSearchResultGroupData(const RsGxsGroupId& group_id)
{
RsGxsChannelGroup channel_group;
if(rsGxsChannels->getDistantSearchResultGroupData(group_id,channel_group))
return new RsGxsGenericGroupData(channel_group);
else
return nullptr;
}
void GxsChannelDialog::checkRequestGroup(const RsGxsGroupId& grpId)
{
RsGxsChannelGroup distant_group;
if( rsGxsChannels->retrieveDistantGroup(grpId,distant_group)) // normally we should also check that the group meta is not already here.
if( rsGxsChannels->getDistantSearchResultGroupData(grpId,distant_group)) // normally we should also check that the group meta is not already here.
{
std::cerr << "GxsChannelDialog::checkRequestGroup() sending turtle request for group data for group " << grpId << std::endl;
rsGxsChannels->turtleGroupRequest(grpId);

View File

@ -43,10 +43,11 @@ public:
protected:
/* GxsGroupFrameDialog */
virtual bool getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &group_infos);
virtual bool getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &group_infos) override;
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& group_id) override;
virtual TurtleRequestId distantSearch(const QString& search_string) ;
virtual void checkRequestGroup(const RsGxsGroupId& grpId) ;
virtual TurtleRequestId distantSearch(const QString& search_string) override;
virtual void checkRequestGroup(const RsGxsGroupId& grpId) override ;
// Implementation of some abstract methods in GxsGroupFrameDialog

View File

@ -858,11 +858,12 @@ bool GxsChannelPostsWidget::getGroupData(RsGxsGenericGroupData *& data)
{
RsGxsChannelGroup distant_group;
if(rsGxsChannels->retrieveDistantGroup(groupId(),distant_group))
if(rsGxsChannels->getDistantSearchResultGroupData(groupId(),distant_group))
{
insertChannelDetails(distant_group);
data = new RsGxsChannelGroup(distant_group);
data = new RsGxsChannelGroup(distant_group);
mGroup = distant_group; // make a local copy to pass on to items
return true ;
}
}

View File

@ -538,23 +538,20 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
RsThread::async([this]()
{
RsGxsChannelGroup group;
std::vector<RsGxsChannelGroup> groups;
if(!rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>{ groupId() }, groups))
if(rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>{ groupId() }, groups) && groups.size()==1)
group = groups[0];
else if(!rsGxsChannels->getDistantSearchResultGroupData(groupId(),group))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to get autodownload value for channel: " << groupId() << std::endl;
std::cerr << __PRETTY_FUNCTION__ << " failed to get group data for channel: " << groupId() << std::endl;
return;
}
if(groups.size() != 1)
{
RsErr() << __PRETTY_FUNCTION__ << " cannot retrieve channel data for group ID " << groupId() << ": ERROR." << std::endl;
return;
}
RsQThreadUtils::postToObject( [this,groups]()
RsQThreadUtils::postToObject( [this,group]()
{
mGroup = groups[0];
mGroup = group;
mChannelPostsModel->updateChannel(groupId());
insertChannelDetails(mGroup);

View File

@ -161,7 +161,7 @@
<item>
<widget class="QTabWidget" name="channel_TW">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">