mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-29 17:28:41 -04:00
removed TokenQueue from FriendSelectionWidget
This commit is contained in:
parent
c09e9c407b
commit
5ccc59e2ea
2 changed files with 34 additions and 49 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/common/RSTreeWidgetItem.h"
|
#include "gui/common/RSTreeWidgetItem.h"
|
||||||
#include "gui/common/StatusDefs.h"
|
#include "gui/common/StatusDefs.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "gui/common/PeerDefs.h"
|
#include "gui/common/PeerDefs.h"
|
||||||
#include "gui/common/GroupDefs.h"
|
#include "gui/common/GroupDefs.h"
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
|
@ -92,8 +93,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
||||||
mInSslItemChanged = false;
|
mInSslItemChanged = false;
|
||||||
mInFillList = false;
|
mInFillList = false;
|
||||||
|
|
||||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
|
||||||
|
|
||||||
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
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(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||||
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||||
|
@ -131,7 +130,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
||||||
|
|
||||||
FriendSelectionWidget::~FriendSelectionWidget()
|
FriendSelectionWidget::~FriendSelectionWidget()
|
||||||
{
|
{
|
||||||
delete(mIdQueue);
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +183,11 @@ int FriendSelectionWidget::addColumn(const QString &title)
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendSelectionWidget::showEvent(QShowEvent *e)
|
||||||
|
{
|
||||||
|
if(gxsIds.empty())
|
||||||
|
loadIdentities();
|
||||||
|
}
|
||||||
void FriendSelectionWidget::start()
|
void FriendSelectionWidget::start()
|
||||||
{
|
{
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
|
@ -237,32 +240,36 @@ void FriendSelectionWidget::fillList()
|
||||||
secured_fillList() ;
|
secured_fillList() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
void FriendSelectionWidget::loadIdentities()
|
||||||
{
|
{
|
||||||
// store all IDs locally, and call fillList() ;
|
// store all IDs locally, and call fillList() ;
|
||||||
|
|
||||||
uint32_t token = req.mToken ;
|
RsThread::async([this]()
|
||||||
|
|
||||||
RsGxsIdGroup data;
|
|
||||||
std::vector<RsGxsIdGroup> datavector;
|
|
||||||
std::vector<RsGxsIdGroup>::iterator vit;
|
|
||||||
|
|
||||||
if (!rsIdentity->getGroupData(token, datavector))
|
|
||||||
{
|
{
|
||||||
std::cerr << "FriendSelectionWidget::loadRequest() ERROR. Cannot load data from rsIdentity." << std::endl;
|
std::list<RsGroupMetaData> ids_meta;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
gxsIds.clear() ;
|
if(!rsIdentity->getIdentitiesSummaries(ids_meta))
|
||||||
|
|
||||||
for(uint32_t i=0;i<datavector.size();++i)
|
|
||||||
{
|
{
|
||||||
gxsIds.push_back(datavector[i].mMeta.mGroupId) ;
|
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identities group info for all identities" << std::endl;
|
||||||
//std::cerr << " got ID = " << datavector[i].mMeta.mGroupId << std::endl;
|
return;
|
||||||
}
|
}
|
||||||
|
std::vector<RsGxsGroupId> ids;
|
||||||
|
|
||||||
|
for(auto& meta:ids_meta)
|
||||||
|
ids.push_back(meta.mGroupId) ;
|
||||||
|
|
||||||
|
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!
|
||||||
|
|
||||||
//std::cerr << "Got all " << datavector.size() << " ids from rsIdentity. Calling update of list." << std::endl;
|
|
||||||
fillList() ;
|
fillList() ;
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::secured_fillList()
|
void FriendSelectionWidget::secured_fillList()
|
||||||
|
@ -666,32 +673,13 @@ void FriendSelectionWidget::secured_fillList()
|
||||||
}
|
}
|
||||||
void FriendSelectionWidget::updateDisplay(bool)
|
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
|
// 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)
|
template<> inline void FriendSelectionWidget::setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(const std::set<RsGxsId>& ids, bool add)
|
||||||
{
|
{
|
||||||
mPreSelectedGxsIds = ids ;
|
mPreSelectedGxsIds = ids ;
|
||||||
requestGXSIdList();
|
loadIdentities();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::groupsChanged(int /*type*/)
|
void FriendSelectionWidget::groupsChanged(int /*type*/)
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include <gui/gxs/RsGxsUpdateBroadcastPage.h>
|
#include <gui/gxs/RsGxsUpdateBroadcastPage.h>
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class FriendSelectionWidget;
|
class FriendSelectionWidget;
|
||||||
|
@ -34,7 +33,7 @@ class FriendSelectionWidget;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class RSTreeWidgetItemCompareRole;
|
class RSTreeWidgetItemCompareRole;
|
||||||
|
|
||||||
class FriendSelectionWidget : public QWidget, public TokenResponse
|
class FriendSelectionWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -82,6 +81,7 @@ public:
|
||||||
bool isSortByState();
|
bool isSortByState();
|
||||||
bool isFilterConnected();
|
bool isFilterConnected();
|
||||||
|
|
||||||
|
void loadIdentities();
|
||||||
int selectedItemCount();
|
int selectedItemCount();
|
||||||
std::string selectedId(IdType &idType);
|
std::string selectedId(IdType &idType);
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ public:
|
||||||
void addContextMenuAction(QAction *action);
|
void addContextMenuAction(QAction *action);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void showEvent(QShowEvent *e) override;
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
virtual void loadRequest(const TokenQueue *queue,const TokenRequest& req);
|
|
||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -148,8 +148,6 @@ private:
|
||||||
void selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
void selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
||||||
void setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add);
|
void setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add);
|
||||||
|
|
||||||
void requestGXSIdList() ;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
RSTreeWidgetItemCompareRole *mCompareRole;
|
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||||
|
@ -170,7 +168,6 @@ private:
|
||||||
friend class FriendSelectionDialog ;
|
friend class FriendSelectionDialog ;
|
||||||
|
|
||||||
std::vector<RsGxsGroupId> gxsIds ;
|
std::vector<RsGxsGroupId> gxsIds ;
|
||||||
TokenQueue *mIdQueue ;
|
|
||||||
QList<QAction*> mContextMenuActions;
|
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.
|
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…
Add table
Add a link
Reference in a new issue