mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-17 20:04:22 -05:00
Merge pull request #2728 from csoler/v0.6-Turtle-001
Simple change to make SearchDialog use RsEvents to catch turtle search results
This commit is contained in:
commit
a3eae71f0b
@ -37,6 +37,7 @@
|
||||
#include "gui/advsearch/advancedsearchdialog.h"
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsturtle.h>
|
||||
@ -217,6 +218,15 @@ SearchDialog::SearchDialog(QWidget *parent)
|
||||
|
||||
checkText(ui.lineEdit->text());
|
||||
|
||||
// add an event handler to get search results (previously available through notifyQt)
|
||||
|
||||
mEventHandlerId = 0;
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this );
|
||||
}, mEventHandlerId, RsEventType::FILE_TRANSFER );
|
||||
|
||||
}
|
||||
|
||||
SearchDialog::~SearchDialog()
|
||||
@ -235,6 +245,29 @@ SearchDialog::~SearchDialog()
|
||||
|
||||
ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr);
|
||||
ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr);
|
||||
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
void SearchDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::FILE_TRANSFER)
|
||||
return;
|
||||
|
||||
auto fe = dynamic_cast<const RsFileTransferEvent*>(event.get());
|
||||
|
||||
if(!fe || fe->mFileTransferEventCode!=RsFileTransferEventCode::NEW_DISTANT_SEARCH_RESULTS)
|
||||
return;
|
||||
|
||||
for(uint32_t i=0;i<fe->mResults.size();++i)
|
||||
{
|
||||
FileDetail f;
|
||||
f.hash = fe->mResults[i].fHash;
|
||||
f.name = fe->mResults[i].fName;
|
||||
f.size = fe->mResults[i].fSize;
|
||||
|
||||
updateFiles(fe->mRequestId,f);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchDialog::processSettings(bool bLoad)
|
||||
@ -961,7 +994,7 @@ void SearchDialog::processResultQueue()
|
||||
while(!searchResultsQueue.empty() && nb_treated_elements++ < 250)
|
||||
{
|
||||
qulonglong search_id = searchResultsQueue.back().first ;
|
||||
FileDetail& file = searchResultsQueue.back().second ;
|
||||
const FileDetail& file = searchResultsQueue.back().second ;
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cout << "Updating file detail:" << std::endl ;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define _SEARCHDIALOG_H
|
||||
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "retroshare/rsevents.h"
|
||||
#include "ui_SearchDialog.h"
|
||||
#include "retroshare-gui/mainpage.h"
|
||||
|
||||
@ -125,6 +126,7 @@ private:
|
||||
void setIconAndType(QTreeWidgetItem *item, const QString& filename);
|
||||
void downloadDirectory(const QTreeWidgetItem *item, const QString &base);
|
||||
void getSourceFriendsForHash(const RsFileHash &hash,std::list<RsPeerId> &srcIds);
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
/** the advanced search dialog instance */
|
||||
AdvancedSearchDialog * advSearchDialog;
|
||||
@ -176,6 +178,8 @@ private:
|
||||
|
||||
bool _queueIsAlreadyTakenCareOf ;
|
||||
std::vector<std::pair<qulonglong,FileDetail> > searchResultsQueue ;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -482,6 +482,8 @@ void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list<T
|
||||
std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
// Mai 2023: distant turtle search now uses RsEvents.
|
||||
void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list<TurtleFileInfo>& files)
|
||||
{
|
||||
{
|
||||
@ -507,6 +509,7 @@ void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,c
|
||||
emit gotTurtleSearchResult(search_id,det) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type)
|
||||
{
|
||||
|
@ -67,7 +67,9 @@ class NotifyQt: public QObject, public NotifyClient
|
||||
virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string);
|
||||
virtual void notifyChatCleared(const ChatId &chat_id);
|
||||
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
|
||||
#ifdef TO_REMOVE
|
||||
virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files);
|
||||
#endif
|
||||
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups);
|
||||
virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
|
||||
virtual void notifyOwnAvatarChanged() ;
|
||||
|
@ -540,7 +540,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||
qRegisterMetaType<RsPeerId>("RsPeerId") ;
|
||||
|
||||
std::cerr << "connecting signals and slots" << std::endl ;
|
||||
QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
|
||||
// QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
|
||||
QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ;
|
||||
QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ;
|
||||
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
|
||||
|
Loading…
Reference in New Issue
Block a user