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 turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0; virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
virtual bool clearDistantSearchResults(TurtleRequestId req)=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; 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); 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; RsGxsGroupSearchResults gs;

View File

@ -70,7 +70,7 @@ protected:
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string); virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) ; virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) ;
virtual bool clearDistantSearchResults(TurtleRequestId req); 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. // Overloaded to cache new groups.
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet); 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)); while(nullptr != item->takeChild(0));
for(auto str:itemInfo.context_strings) 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 */ /* Set last post */
qlonglong lastPost = itemInfo.lastpost.toTime_t(); 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) 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; 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; GroupItemInfo i;
i.id = QString(it3->second.mGroupId.toStdString().c_str()); i.id = QString(it3->second.mGroupId.toStdString().c_str());
@ -1067,15 +1069,20 @@ void GxsGroupFrameDialog::updateGroupSummary()
{ {
RsThread::async([this]() 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; return;
} }
if(groupInfo.empty()) if(groupInfo->empty())
{
std::cerr << __PRETTY_FUNCTION__ << " no group info collected." << std::endl;
delete groupInfo;
return; return;
}
RsQThreadUtils::postToObject( [this,groupInfo]() RsQThreadUtils::postToObject( [this,groupInfo]()
{ {
@ -1085,7 +1092,7 @@ void GxsGroupFrameDialog::updateGroupSummary()
* Qt::QueuedConnection is important! * Qt::QueuedConnection is important!
*/ */
insertGroupsData(groupInfo); insertGroupsData(*groupInfo);
updateSearchResults(); updateSearchResults();
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false); mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false);
@ -1104,12 +1111,14 @@ void GxsGroupFrameDialog::updateGroupSummary()
// now delete the data that is not used anymore // now delete the data that is not used anymore
for(auto& g:groupInfo) for(auto& g:*groupInfo)
{ {
mCachedGroupMetas[g->mMeta.mGroupId] = g->mMeta; mCachedGroupMetas[g->mMeta.mGroupId] = g->mMeta;
delete g; delete g;
} }
delete groupInfo;
}, this ); }, this );
}); });
} }

View File

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

View File

@ -406,11 +406,21 @@ bool GxsChannelDialog::getDistantSearchResults(TurtleRequestId id, std::map<RsGx
return rsGxsChannels->retrieveDistantSearchResults(id,group_infos); 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) void GxsChannelDialog::checkRequestGroup(const RsGxsGroupId& grpId)
{ {
RsGxsChannelGroup distant_group; 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; std::cerr << "GxsChannelDialog::checkRequestGroup() sending turtle request for group data for group " << grpId << std::endl;
rsGxsChannels->turtleGroupRequest(grpId); rsGxsChannels->turtleGroupRequest(grpId);

View File

@ -43,10 +43,11 @@ public:
protected: protected:
/* GxsGroupFrameDialog */ /* 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 TurtleRequestId distantSearch(const QString& search_string) override;
virtual void checkRequestGroup(const RsGxsGroupId& grpId) ; virtual void checkRequestGroup(const RsGxsGroupId& grpId) override ;
// Implementation of some abstract methods in GxsGroupFrameDialog // Implementation of some abstract methods in GxsGroupFrameDialog

View File

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

View File

@ -538,23 +538,20 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
RsThread::async([this]() RsThread::async([this]()
{ {
RsGxsChannelGroup group;
std::vector<RsGxsChannelGroup> groups; 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; return;
} }
if(groups.size() != 1) RsQThreadUtils::postToObject( [this,group]()
{
RsErr() << __PRETTY_FUNCTION__ << " cannot retrieve channel data for group ID " << groupId() << ": ERROR." << std::endl;
return;
}
RsQThreadUtils::postToObject( [this,groups]()
{ {
mGroup = groups[0]; mGroup = group;
mChannelPostsModel->updateChannel(groupId()); mChannelPostsModel->updateChannel(groupId());
insertChannelDetails(mGroup); insertChannelDetails(mGroup);

View File

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