mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
turned some std::list<PeerId> into std::set, as it automatically prevents duplicates
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8138 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f1309a8cbe
commit
c9d5c7b3cb
51 changed files with 269 additions and 266 deletions
|
@ -1343,8 +1343,11 @@ void FriendList::recommendfriend()
|
|||
default:
|
||||
return;
|
||||
}
|
||||
std::set<RsPeerId> sids ;
|
||||
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
sids.insert(*it) ;
|
||||
|
||||
MessageComposer::recommendFriend(ids);
|
||||
MessageComposer::recommendFriend(sids);
|
||||
}
|
||||
|
||||
void FriendList::pastePerson()
|
||||
|
@ -1596,7 +1599,7 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &s
|
|||
{
|
||||
RsGroupInfo groupInfo;
|
||||
if (rsPeers->getGroupInfo(peerId, groupInfo)) {
|
||||
std::list<RsPgpId>::iterator gpgIt;
|
||||
std::set<RsPgpId>::iterator gpgIt;
|
||||
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) {
|
||||
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
|
||||
}
|
||||
|
|
|
@ -4,65 +4,65 @@
|
|||
#include <QDialogButtonBox>
|
||||
#include "FriendSelectionDialog.h"
|
||||
|
||||
std::list<RsPgpId> FriendSelectionDialog::selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
std::set<RsPgpId> FriendSelectionDialog::selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
FriendSelectionWidget::Modus modus,
|
||||
FriendSelectionWidget::ShowTypes show_type,
|
||||
const std::list<RsPgpId>& pre_selected_ids)
|
||||
const std::set<RsPgpId>& pre_selected_ids)
|
||||
{
|
||||
std::list<std::string> psids ;
|
||||
for(std::list<RsPgpId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
|
||||
psids.push_back( (*it).toStdString() ) ;
|
||||
std::set<std::string> psids ;
|
||||
for(std::set<RsPgpId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
|
||||
psids.insert( (*it).toStdString() ) ;
|
||||
|
||||
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_GPG,psids) ;
|
||||
|
||||
dialog.setWindowTitle(caption) ;
|
||||
|
||||
if(QDialog::Rejected == dialog.exec())
|
||||
return std::list<RsPgpId>() ;
|
||||
return std::set<RsPgpId>() ;
|
||||
|
||||
std::list<RsPgpId> sids ;
|
||||
std::set<RsPgpId> sids ;
|
||||
dialog.friends_widget->selectedIds<RsPgpId,FriendSelectionWidget::IDTYPE_GPG>(sids,false) ;
|
||||
|
||||
return sids ;
|
||||
}
|
||||
std::list<RsPeerId> FriendSelectionDialog::selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
std::set<RsPeerId> FriendSelectionDialog::selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
FriendSelectionWidget::Modus modus,
|
||||
FriendSelectionWidget::ShowTypes show_type,
|
||||
const std::list<RsPeerId>& pre_selected_ids)
|
||||
const std::set<RsPeerId>& pre_selected_ids)
|
||||
{
|
||||
std::list<std::string> psids ;
|
||||
for(std::list<RsPeerId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
|
||||
psids.push_back( (*it).toStdString() ) ;
|
||||
std::set<std::string> psids ;
|
||||
for(std::set<RsPeerId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
|
||||
psids.insert( (*it).toStdString() ) ;
|
||||
|
||||
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,psids) ;
|
||||
|
||||
dialog.setWindowTitle(caption) ;
|
||||
|
||||
if(QDialog::Rejected == dialog.exec())
|
||||
return std::list<RsPeerId>() ;
|
||||
return std::set<RsPeerId>() ;
|
||||
|
||||
std::list<RsPeerId> sids ;
|
||||
std::set<RsPeerId> sids ;
|
||||
dialog.friends_widget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(sids,false) ;
|
||||
|
||||
return sids ;
|
||||
}
|
||||
std::list<RsGxsId> FriendSelectionDialog::selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
std::set<RsGxsId> FriendSelectionDialog::selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
FriendSelectionWidget::Modus modus,
|
||||
FriendSelectionWidget::ShowTypes show_type,
|
||||
const std::list<RsGxsId>& pre_selected_ids)
|
||||
const std::set<RsGxsId>& pre_selected_ids)
|
||||
{
|
||||
std::list<std::string> psids ;
|
||||
for(std::list<RsGxsId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
|
||||
psids.push_back( (*it).toStdString() ) ;
|
||||
std::set<std::string> psids ;
|
||||
for(std::set<RsGxsId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
|
||||
psids.insert( (*it).toStdString() ) ;
|
||||
|
||||
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,psids) ;
|
||||
|
||||
dialog.setWindowTitle(caption) ;
|
||||
|
||||
if(QDialog::Rejected == dialog.exec())
|
||||
return std::list<RsGxsId>() ;
|
||||
return std::set<RsGxsId>() ;
|
||||
|
||||
std::list<RsGxsId> sids ;
|
||||
std::set<RsGxsId> sids ;
|
||||
dialog.friends_widget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(sids,false) ;
|
||||
|
||||
return sids ;
|
||||
|
@ -71,7 +71,7 @@ FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& head
|
|||
FriendSelectionWidget::Modus modus,
|
||||
FriendSelectionWidget::ShowTypes show_type,
|
||||
FriendSelectionWidget::IdType pre_selected_id_type,
|
||||
const std::list<std::string>& pre_selected_ids)
|
||||
const std::set<std::string>& pre_selected_ids)
|
||||
: QDialog(parent)
|
||||
{
|
||||
friends_widget = new FriendSelectionWidget(this) ;
|
||||
|
|
|
@ -8,26 +8,26 @@
|
|||
class FriendSelectionDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
static std::list<RsPgpId> selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
static std::set<RsPgpId> selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
|
||||
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP,
|
||||
const std::list<RsPgpId>& pre_selected_ids = std::list<RsPgpId>()) ;
|
||||
const std::set<RsPgpId>& pre_selected_ids = std::set<RsPgpId>()) ;
|
||||
|
||||
static std::list<RsPeerId> selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
static std::set<RsPeerId> selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
|
||||
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL,
|
||||
const std::list<RsPeerId>& pre_selected_ids = std::list<RsPeerId>()) ;
|
||||
const std::set<RsPeerId>& pre_selected_ids = std::set<RsPeerId>()) ;
|
||||
|
||||
static std::list<RsGxsId> selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
static std::set<RsGxsId> selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
|
||||
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GXS,
|
||||
const std::list<RsGxsId>& pre_selected_ids = std::list<RsGxsId>()) ;
|
||||
const std::set<RsGxsId>& pre_selected_ids = std::set<RsGxsId>()) ;
|
||||
|
||||
private:
|
||||
virtual ~FriendSelectionDialog() ;
|
||||
FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type,
|
||||
FriendSelectionWidget::IdType pre_selected_id_type,
|
||||
const std::list<std::string>& pre_selected_ids) ;
|
||||
const std::set<std::string>& pre_selected_ids) ;
|
||||
|
||||
FriendSelectionWidget *friends_widget ;
|
||||
};
|
||||
|
|
|
@ -266,22 +266,22 @@ void FriendSelectionWidget::secured_fillList()
|
|||
mInFillList = true;
|
||||
|
||||
// get selected items
|
||||
std::list<RsPeerId> sslIdsSelected;
|
||||
std::set<RsPeerId> sslIdsSelected;
|
||||
if (mShowTypes & SHOW_SSL) {
|
||||
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
|
||||
}
|
||||
|
||||
std::list<std::string> groupIdsSelected;
|
||||
std::set<std::string> groupIdsSelected;
|
||||
if (mShowTypes & SHOW_GROUP) {
|
||||
selectedIds<std::string,IDTYPE_GROUP>(groupIdsSelected,true);
|
||||
}
|
||||
|
||||
std::list<RsPgpId> gpgIdsSelected;
|
||||
std::set<RsPgpId> gpgIdsSelected;
|
||||
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
|
||||
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
|
||||
}
|
||||
|
||||
std::list<RsGxsId> gxsIdsSelected;
|
||||
std::set<RsGxsId> gxsIdsSelected;
|
||||
if (mShowTypes & SHOW_GXS)
|
||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
||||
|
||||
|
@ -881,7 +881,7 @@ std::string FriendSelectionWidget::selectedId(IdType &idType)
|
|||
return idFromItem(item);
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &ids, bool onlyDirectSelected)
|
||||
void FriendSelectionWidget::selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected)
|
||||
{
|
||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||
QTreeWidgetItem *item;
|
||||
|
@ -938,7 +938,7 @@ void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &i
|
|||
break;
|
||||
}
|
||||
if (!id.empty() && std::find(ids.begin(), ids.end(), id) == ids.end()) {
|
||||
ids.push_back(id);
|
||||
ids.insert(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -955,7 +955,7 @@ void FriendSelectionWidget::selectAll()
|
|||
setSelected(mListModus, *itemIterator, true);
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::string> &ids, bool add)
|
||||
void FriendSelectionWidget::setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add)
|
||||
{
|
||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||
QTreeWidgetItem *item;
|
||||
|
@ -973,7 +973,7 @@ void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::s
|
|||
case IDTYPE_SSL:
|
||||
case IDTYPE_GXS:
|
||||
if (idType == itemType) {
|
||||
if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
|
||||
if (ids.find(id) != ids.end()) {
|
||||
setSelected(mListModus, item, true);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -83,19 +83,19 @@ public:
|
|||
int selectedItemCount();
|
||||
std::string selectedId(IdType &idType);
|
||||
|
||||
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::list<ID_CLASS>& ids, bool onlyDirectSelected)
|
||||
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::set<ID_CLASS>& ids, bool onlyDirectSelected)
|
||||
{
|
||||
std::list<std::string> tmpids ;
|
||||
std::set<std::string> tmpids ;
|
||||
selectedIds(TYPE, tmpids, onlyDirectSelected);
|
||||
ids.clear() ;
|
||||
for(std::list<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
||||
ids.push_back(ID_CLASS(*it)) ;
|
||||
for(std::set<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
||||
ids.insert(ID_CLASS(*it)) ;
|
||||
}
|
||||
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void setSelectedIds(const std::list<ID_CLASS>& ids, bool add)
|
||||
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void setSelectedIds(const std::set<ID_CLASS>& ids, bool add)
|
||||
{
|
||||
std::list<std::string> tmpids ;
|
||||
for(typename std::list<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
tmpids.push_back((*it).toStdString()) ;
|
||||
std::set<std::string> tmpids ;
|
||||
for(typename std::set<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
tmpids.insert((*it).toStdString()) ;
|
||||
setSelectedIds(TYPE, tmpids, add);
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,8 @@ private:
|
|||
void secured_fillList();
|
||||
bool filterItem(QTreeWidgetItem *item, const QString &text);
|
||||
|
||||
void selectedIds(IdType idType, std::list<std::string> &ids, bool onlyDirectSelected);
|
||||
void setSelectedIds(IdType idType, const std::list<std::string> &ids, bool add);
|
||||
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() ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue