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); int createMessage(RsNxsMsg* msg);
RsNetworkExchangeService *netService() const { return mNetService ; }
private: private:
/*! /*!
* convenience function to create sign * convenience function to create sign

View File

@ -5103,13 +5103,13 @@ bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid)
return true; 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) 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. * These four methods are used to request distant search and receive the results.
* \param group_id * \param group_id
*/ */
virtual void turtleGroupRequest(const RsGxsGroupId& group_id); virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id);
virtual void turtleSearchRequest(const std::string& match_string); virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
virtual bool search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos) ; 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) 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 ; RsGxsNetTunnelTurtleSearchSubstringItem search_item ;
search_item.substring_match = match_string ; search_item.substring_match = match_string ;

View File

@ -36,6 +36,7 @@
#include "services/p3service.h" #include "services/p3service.h"
#include "retroshare/rsreputations.h" #include "retroshare/rsreputations.h"
#include "retroshare/rsidentity.h" #include "retroshare/rsidentity.h"
#include "retroshare/rsturtle.h"
#include "rsgds.h" #include "rsgds.h"
/*! /*!
@ -102,8 +103,8 @@ public:
virtual uint32_t getDefaultSyncAge() =0; virtual uint32_t getDefaultSyncAge() =0;
virtual uint32_t getDefaultKeepAge() =0; virtual uint32_t getDefaultKeepAge() =0;
virtual void turtleGroupRequest(const RsGxsGroupId& group_id)=0; virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual void turtleSearchRequest(const std::string& match_string)=0; virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
virtual bool search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos) =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/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsgxscommon.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 createComment(uint32_t &token, RsGxsComment &comment) = 0;
//virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0; //virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
virtual void turtleGroupRequest(const RsGxsGroupId& group_id)=0; virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id)=0;
virtual void turtleSearchRequest(const std::string& match_string)=0; virtual TurtleRequestId turtleSearchRequest(const std::string& match_string)=0;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 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 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 bool loadList(std::list<RsItem *>& loadList); // @see p3Config::loadList(std::list<RsItem *>&)
virtual void turtleGroupRequest(const RsGxsGroupId& group_id); virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id);
virtual void turtleSearchRequest(const std::string& match_string); virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
// 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

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

View File

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