mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
removed TokenQueue from FriendSelectionWidget
This commit is contained in:
parent
c09e9c407b
commit
5ccc59e2ea
@ -27,6 +27,7 @@
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "gui/common/GroupDefs.h"
|
||||
#include "rshare.h"
|
||||
@ -92,8 +93,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
||||
mInSslItemChanged = false;
|
||||
mInFillList = false;
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
||||
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||
@ -131,7 +130,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
||||
|
||||
FriendSelectionWidget::~FriendSelectionWidget()
|
||||
{
|
||||
delete(mIdQueue);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -185,6 +183,11 @@ int FriendSelectionWidget::addColumn(const QString &title)
|
||||
return column;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::showEvent(QShowEvent *e)
|
||||
{
|
||||
if(gxsIds.empty())
|
||||
loadIdentities();
|
||||
}
|
||||
void FriendSelectionWidget::start()
|
||||
{
|
||||
mStarted = true;
|
||||
@ -237,32 +240,36 @@ void FriendSelectionWidget::fillList()
|
||||
secured_fillList() ;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
||||
void FriendSelectionWidget::loadIdentities()
|
||||
{
|
||||
// store all IDs locally, and call fillList() ;
|
||||
|
||||
uint32_t token = req.mToken ;
|
||||
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
std::vector<RsGxsIdGroup>::iterator vit;
|
||||
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "FriendSelectionWidget::loadRequest() ERROR. Cannot load data from rsIdentity." << std::endl;
|
||||
return ;
|
||||
}
|
||||
std::list<RsGroupMetaData> ids_meta;
|
||||
|
||||
gxsIds.clear() ;
|
||||
if(!rsIdentity->getIdentitiesSummaries(ids_meta))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identities group info for all identities" << std::endl;
|
||||
return;
|
||||
}
|
||||
std::vector<RsGxsGroupId> ids;
|
||||
|
||||
for(uint32_t i=0;i<datavector.size();++i)
|
||||
{
|
||||
gxsIds.push_back(datavector[i].mMeta.mGroupId) ;
|
||||
//std::cerr << " got ID = " << datavector[i].mMeta.mGroupId << std::endl;
|
||||
}
|
||||
for(auto& meta:ids_meta)
|
||||
ids.push_back(meta.mGroupId) ;
|
||||
|
||||
//std::cerr << "Got all " << datavector.size() << " ids from rsIdentity. Calling update of list." << std::endl;
|
||||
fillList() ;
|
||||
RsQThreadUtils::postToObject( [ids,this]()
|
||||
{
|
||||
/* Here it goes any code you want to be executed on the Qt Gui
|
||||
* thread, for example to update the data model with new information
|
||||
* after a blocking call to RetroShare API complete */
|
||||
|
||||
gxsIds = ids; // we do that is the GUI thread. Dont try it on another thread!
|
||||
|
||||
fillList() ;
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::secured_fillList()
|
||||
@ -666,32 +673,13 @@ void FriendSelectionWidget::secured_fillList()
|
||||
}
|
||||
void FriendSelectionWidget::updateDisplay(bool)
|
||||
{
|
||||
requestGXSIdList() ;
|
||||
loadIdentities() ;
|
||||
}
|
||||
void FriendSelectionWidget::requestGXSIdList()
|
||||
{
|
||||
if (!mIdQueue)
|
||||
return;
|
||||
|
||||
//mStateHelper->setLoading(IDDIALOG_IDLIST, true);
|
||||
//mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
||||
//mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDLIST);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST);
|
||||
}
|
||||
|
||||
// This call is inlined so that there's no linking conflict with MinGW on Windows
|
||||
template<> inline void FriendSelectionWidget::setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(const std::set<RsGxsId>& ids, bool add)
|
||||
{
|
||||
mPreSelectedGxsIds = ids ;
|
||||
requestGXSIdList();
|
||||
loadIdentities();
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::groupsChanged(int /*type*/)
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QDialog>
|
||||
|
||||
#include <gui/gxs/RsGxsUpdateBroadcastPage.h>
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
namespace Ui {
|
||||
class FriendSelectionWidget;
|
||||
@ -34,7 +33,7 @@ class FriendSelectionWidget;
|
||||
class QTreeWidgetItem;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
|
||||
class FriendSelectionWidget : public QWidget, public TokenResponse
|
||||
class FriendSelectionWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -82,6 +81,7 @@ public:
|
||||
bool isSortByState();
|
||||
bool isFilterConnected();
|
||||
|
||||
void loadIdentities();
|
||||
int selectedItemCount();
|
||||
std::string selectedId(IdType &idType);
|
||||
|
||||
@ -115,9 +115,9 @@ public:
|
||||
void addContextMenuAction(QAction *action);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
virtual void loadRequest(const TokenQueue *queue,const TokenRequest& req);
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
signals:
|
||||
@ -148,8 +148,6 @@ private:
|
||||
void selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
||||
void setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add);
|
||||
|
||||
void requestGXSIdList() ;
|
||||
|
||||
private:
|
||||
bool mStarted;
|
||||
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||
@ -170,7 +168,6 @@ private:
|
||||
friend class FriendSelectionDialog ;
|
||||
|
||||
std::vector<RsGxsGroupId> gxsIds ;
|
||||
TokenQueue *mIdQueue ;
|
||||
QList<QAction*> mContextMenuActions;
|
||||
|
||||
std::set<RsGxsId> mPreSelectedGxsIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them.
|
||||
|
Loading…
Reference in New Issue
Block a user