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:
csoler 2015-04-17 21:36:22 +00:00
parent f1309a8cbe
commit c9d5c7b3cb
51 changed files with 269 additions and 266 deletions

View file

@ -55,7 +55,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
ui.setupUi(this);
m_bProcessSettings = false;
myChatLobbyUserNotify = NULL;
myChatLobbyUserNotify = NULL;
QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged()));
QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&)));
@ -195,29 +195,29 @@ ChatLobbyWidget::~ChatLobbyWidget()
UserNotify *ChatLobbyWidget::getUserNotify(QObject *parent)
{
if (!myChatLobbyUserNotify){
myChatLobbyUserNotify = new ChatLobbyUserNotify(parent);
connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int)));
}
return myChatLobbyUserNotify;
}
void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count)
{
ChatLobbyDialog *dialog=NULL;
dialog=_lobby_infos[id].dialog;
if(!dialog) return;
QToolButton* notifyButton=dialog->getChatWidget()->getNotifyButton();
if (!notifyButton) return;
dialog->getChatWidget()->setNotify(myChatLobbyUserNotify);
if (count>0){
notifyButton->setVisible(true);
notifyButton->setIcon(_lobby_infos[id].default_icon);
notifyButton->setToolTip(QString("(%1)").arg(count));
} else {
notifyButton->setVisible(false);
}
if (!myChatLobbyUserNotify){
myChatLobbyUserNotify = new ChatLobbyUserNotify(parent);
connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int)));
}
return myChatLobbyUserNotify;
}
void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count)
{
ChatLobbyDialog *dialog=NULL;
dialog=_lobby_infos[id].dialog;
if(!dialog) return;
QToolButton* notifyButton=dialog->getChatWidget()->getNotifyButton();
if (!notifyButton) return;
dialog->getChatWidget()->setNotify(myChatLobbyUserNotify);
if (count>0){
notifyButton->setVisible(true);
notifyButton->setIcon(_lobby_infos[id].default_icon);
notifyButton->setToolTip(QString("(%1)").arg(count));
} else {
notifyButton->setVisible(false);
}
}
void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
@ -350,7 +350,7 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d)
connect(d,SIGNAL(lobbyLeave(ChatLobbyId)),this,SLOT(unsubscribeChatLobby(ChatLobbyId))) ;
connect(d,SIGNAL(typingEventReceived(ChatLobbyId)),this,SLOT(updateTypingStatus(ChatLobbyId))) ;
connect(d,SIGNAL(messageReceived(bool,ChatLobbyId,QDateTime,QString,QString)),this,SLOT(updateMessageChanged(bool,ChatLobbyId,QDateTime,QString,QString))) ;
connect(d,SIGNAL(messageReceived(bool,ChatLobbyId,QDateTime,QString,QString)),this,SLOT(updateMessageChanged(bool,ChatLobbyId,QDateTime,QString,QString))) ;
connect(d,SIGNAL(peerJoined(ChatLobbyId)),this,SLOT(updatePeerEntering(ChatLobbyId))) ;
connect(d,SIGNAL(peerLeft(ChatLobbyId)),this,SLOT(updatePeerLeaving(ChatLobbyId))) ;
@ -618,7 +618,7 @@ void ChatLobbyWidget::createChatLobby()
privacyLevel = action->data().toInt();
}
std::list<RsPeerId> friends;
std::set<RsPeerId> friends;
CreateLobbyDialog(friends, privacyLevel).exec();
}
@ -636,7 +636,7 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item)
else
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
}
void ChatLobbyWidget::subscribeChatLobbyAs()
{
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
@ -656,31 +656,31 @@ void ChatLobbyWidget::subscribeChatLobbyAs()
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
ChatDialog::chatFriend(ChatId(id),true) ;
}
void ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor)
{
QTreeWidgetItem *item = getTreeWidgetItem(id) ;
if(item != NULL) {
if(item->type() == TYPE_LOBBY) {
if(_lobby_infos.find(id) == _lobby_infos.end()) {
showBlankPage(id) ;
} else {
//ChatLobbyDialog cldChatLobby =_lobby_infos[id].dialog;
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
ChatLobbyDialog *cldCW=NULL ;
if (NULL != (cldCW = dynamic_cast<ChatLobbyDialog *>(ui.stackedWidget->currentWidget())))
cldCW->getChatWidget()->scrollToAnchor(anchor);
ui.lobbyTreeWidget->setCurrentItem(item);
}
}
}
}
void ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor)
{
QTreeWidgetItem *item = getTreeWidgetItem(id) ;
if(item != NULL) {
if(item->type() == TYPE_LOBBY) {
if(_lobby_infos.find(id) == _lobby_infos.end()) {
showBlankPage(id) ;
} else {
//ChatLobbyDialog cldChatLobby =_lobby_infos[id].dialog;
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
ChatLobbyDialog *cldCW=NULL ;
if (NULL != (cldCW = dynamic_cast<ChatLobbyDialog *>(ui.stackedWidget->currentWidget())))
cldCW->getChatWidget()->scrollToAnchor(anchor);
ui.lobbyTreeWidget->setCurrentItem(item);
}
}
}
}
void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
{
if (item == NULL || item->type() != TYPE_LOBBY) {
@ -853,10 +853,10 @@ void ChatLobbyWidget::unsubscribeChatLobby(ChatLobbyId id)
if(it != _lobby_infos.end())
{
if (myChatLobbyUserNotify){
myChatLobbyUserNotify->chatLobbyCleared(id, "");
}
if (myChatLobbyUserNotify){
myChatLobbyUserNotify->chatLobbyCleared(id, "");
}
ui.stackedWidget->removeWidget(it->second.dialog) ;
_lobby_infos.erase(it) ;
}
@ -906,18 +906,18 @@ void ChatLobbyWidget::updateCurrentLobby()
filterItems(ui.filterLineEdit->text());
}
}
void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateTime time, QString senderName, QString msg)
void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateTime time, QString senderName, QString msg)
{
QTreeWidgetItem *current_item = ui.lobbyTreeWidget->currentItem();
bool bIsCurrentItem = (current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id);
if (myChatLobbyUserNotify){
if (incoming) myChatLobbyUserNotify->chatLobbyNewMessage(id, time, senderName, msg);
}
bool bIsCurrentItem = (current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id);
if (myChatLobbyUserNotify){
if (incoming) myChatLobbyUserNotify->chatLobbyNewMessage(id, time, senderName, msg);
}
// Don't show anything for current lobby.
//
if(bIsCurrentItem)
if(bIsCurrentItem)
return ;
_lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ;