added quick and dirty turtle search for channels in Files search tab

This commit is contained in:
csoler 2018-06-13 22:46:27 +02:00
parent be1e127a93
commit 7a135c5c43
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
10 changed files with 86 additions and 44 deletions

View File

@ -764,6 +764,8 @@ protected:
*/
int createMessage(RsNxsMsg* msg);
RsNetworkExchangeService *netService() const { return mNetService ; }
private:
/*!
* convenience function to create sign

View File

@ -5103,13 +5103,13 @@ bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid)
return true;
}
void RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id)
TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id)
{
mGxsNetTunnel->turtleGroupRequest(group_id,this) ;
return mGxsNetTunnel->turtleGroupRequest(group_id,this) ;
}
void RsGxsNetService::turtleSearchRequest(const std::string& match_string)
TurtleRequestId RsGxsNetService::turtleSearchRequest(const std::string& match_string)
{
mGxsNetTunnel->turtleSearchRequest(match_string,this) ;
return mGxsNetTunnel->turtleSearchRequest(match_string,this) ;
}
static bool termSearch(const std::string& src, const std::string& substring)

View File

@ -127,8 +127,8 @@ public:
* These four methods are used to request distant search and receive the results.
* \param group_id
*/
virtual void turtleGroupRequest(const RsGxsGroupId& group_id);
virtual void turtleSearchRequest(const std::string& match_string);
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id);
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
virtual bool search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos) ;

View File

@ -958,7 +958,7 @@ TurtleRequestId RsGxsNetTunnelService::turtleGroupRequest(const RsGxsGroupId& gr
TurtleRequestId RsGxsNetTunnelService::turtleSearchRequest(const std::string& match_string,RsNetworkExchangeService *client_service)
{
GXS_NET_TUNNEL_DEBUG() << ": starting a turtle search request for string\"" << match_string << "\"" << std::endl;
GXS_NET_TUNNEL_DEBUG() << ": starting a turtle search request for string \"" << match_string << "\"" << std::endl;
RsGxsNetTunnelTurtleSearchSubstringItem search_item ;
search_item.substring_match = match_string ;

View File

@ -36,6 +36,7 @@
#include "services/p3service.h"
#include "retroshare/rsreputations.h"
#include "retroshare/rsidentity.h"
#include "retroshare/rsturtle.h"
#include "rsgds.h"
/*!
@ -102,8 +103,8 @@ public:
virtual uint32_t getDefaultSyncAge() =0;
virtual uint32_t getDefaultKeepAge() =0;
virtual void turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual void turtleSearchRequest(const std::string& match_string)=0;
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
virtual bool search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos) =0;

View File

@ -33,6 +33,7 @@
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsgxscommon.h"
#include "retroshare/rsturtle.h"
@ -96,8 +97,8 @@ virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &p
//virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0;
//virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
virtual void turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual void turtleSearchRequest(const std::string& match_string)=0;
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;

View File

@ -1695,10 +1695,12 @@ void p3GxsChannels::handle_event(uint32_t event_type, const std::string &elabel)
}
}
void p3GxsChannels::turtleGroupRequest(const RsGxsGroupId& group_id)
TurtleRequestId p3GxsChannels::turtleGroupRequest(const RsGxsGroupId& group_id)
{
return netService()->turtleGroupRequest(group_id) ;
}
void p3GxsChannels::turtleSearchRequest(const std::string& match_string)
TurtleRequestId p3GxsChannels::turtleSearchRequest(const std::string& match_string)
{
return netService()->turtleSearchRequest(match_string) ;
}

View File

@ -72,8 +72,8 @@ virtual void service_tick();
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList); // @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&)
virtual bool loadList(std::list<RsItem *>& loadList); // @see p3Config::loadList(std::list<RsItem *>&)
virtual void turtleGroupRequest(const RsGxsGroupId& group_id);
virtual void turtleSearchRequest(const std::string& match_string);
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id);
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
// Overloaded to cache new groups.
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);

View File

@ -38,6 +38,7 @@
#include "gui/common/RSTreeWidgetItem.h"
#include "util/QtVersion.h"
#include "retroshare/rsgxschannels.h"
#include <retroshare/rsfiles.h>
#include <retroshare/rsturtle.h>
#include <retroshare/rsexpr.h>
@ -165,8 +166,10 @@ SearchDialog::SearchDialog(QWidget *parent)
QHeaderView_setSectionResizeModeColumn(_smheader, SS_KEYWORDS_COL, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_smheader, SS_RESULTS_COL, QHeaderView::Interactive);
_smheader->resizeSection ( SS_KEYWORDS_COL, 160 );
_smheader->resizeSection ( SS_RESULTS_COL, 50 );
float f = QFontMetricsF(font()).height()/14.0 ;
_smheader->resizeSection ( SS_KEYWORDS_COL, 160*f );
_smheader->resizeSection ( SS_RESULTS_COL, 50*f );
ui.searchResultWidget->setColumnCount(SR_COL_COUNT);
_smheader = ui.searchResultWidget->header () ;
@ -174,12 +177,12 @@ SearchDialog::SearchDialog(QWidget *parent)
QHeaderView_setSectionResizeModeColumn(_smheader, SR_SIZE_COL, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_smheader, SR_SOURCES_COL, QHeaderView::Interactive);
_smheader->resizeSection ( SR_NAME_COL, 240 );
_smheader->resizeSection ( SR_SIZE_COL, 75 );
_smheader->resizeSection ( SR_SOURCES_COL, 75 );
_smheader->resizeSection ( SR_TYPE_COL, 75 );
_smheader->resizeSection ( SR_AGE_COL, 90 );
_smheader->resizeSection ( SR_HASH_COL, 240 );
_smheader->resizeSection ( SR_NAME_COL, 240*f );
_smheader->resizeSection ( SR_SIZE_COL, 75*f );
_smheader->resizeSection ( SR_SOURCES_COL, 75*f );
_smheader->resizeSection ( SR_TYPE_COL, 75*f );
_smheader->resizeSection ( SR_AGE_COL, 90*f );
_smheader->resizeSection ( SR_HASH_COL, 240*f );
// set header text aligment
QTreeWidgetItem * headerItem = ui.searchResultWidget->headerItem();
@ -201,10 +204,11 @@ SearchDialog::SearchDialog(QWidget *parent)
// load settings
processSettings(true);
ui._ownFiles_CB->setMinimumWidth(20);
ui._friendListsearch_SB->setMinimumWidth(20);
ui._anonF2Fsearch_CB->setMinimumWidth(20);
ui.label->setMinimumWidth(20);
ui._channels_CB->setMinimumWidth(20 * f);
ui._ownFiles_CB->setMinimumWidth(20*f);
ui._friendListsearch_SB->setMinimumWidth(20*f);
ui._anonF2Fsearch_CB->setMinimumWidth(20*f);
ui.label->setMinimumWidth(20*f);
// workaround for Qt bug, be solved in next Qt release 4.7.0
// https://bugreports.qt-project.org/browse/QTBUG-8270
@ -862,6 +866,13 @@ void SearchDialog::searchKeywords(const QString& keywords)
else
req_id = rsFiles->turtleSearch(lin_exp) ;
}
else if(ui._channels_CB->isChecked())
{
if(n==1)
req_id = rsGxsChannels->turtleSearchRequest(words.front()) ;
else
QMessageBox::critical(this,"Cannot search multiple words yet.","Search for multiple words is not implemented yet.") ;
}
else
req_id = RSRandom::random_u32() ; // generate a random 32 bits request id

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>758</width>
<height>339</height>
<width>1531</width>
<height>889</height>
</rect>
</property>
<property name="sizePolicy">
@ -32,7 +32,16 @@
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -55,15 +64,24 @@
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="LineEditClear" name="lineEdit">
<property name="toolTip">
@ -99,6 +117,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_channels_CB">
<property name="text">
<string>Channels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_friendListsearch_SB">
<property name="toolTip">
@ -307,7 +332,7 @@
<string>Any</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeAny.png</normaloff>:/images/FileTypeAny.png</iconset>
</property>
</item>
@ -316,7 +341,7 @@
<string>Archive</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeArchive.png</normaloff>:/images/FileTypeArchive.png</iconset>
</property>
</item>
@ -325,7 +350,7 @@
<string>Audio</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeAudio.png</normaloff>:/images/FileTypeAudio.png</iconset>
</property>
</item>
@ -334,7 +359,7 @@
<string>CD-Image</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeCDImage.png</normaloff>:/images/FileTypeCDImage.png</iconset>
</property>
</item>
@ -343,7 +368,7 @@
<string>Document</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeDocument.png</normaloff>:/images/FileTypeDocument.png</iconset>
</property>
</item>
@ -352,7 +377,7 @@
<string>Picture</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypePicture.png</normaloff>:/images/FileTypePicture.png</iconset>
</property>
</item>
@ -361,7 +386,7 @@
<string>Program</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeProgram.png</normaloff>:/images/FileTypeProgram.png</iconset>
</property>
</item>
@ -370,7 +395,7 @@
<string>Video</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/FileTypeVideo.png</normaloff>:/images/FileTypeVideo.png</iconset>
</property>
</item>
@ -379,7 +404,7 @@
<string>Directory</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/folder16.png</normaloff>:/images/folder16.png</iconset>
</property>
</item>
@ -406,7 +431,7 @@
<string>Download selected</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset resource="../images.qrc">
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
</property>
</widget>
@ -432,7 +457,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>