Start the CreateLobbyDialog from the list of chat lobbies with the privacy level of the selected item.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4866 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-01-30 23:20:42 +00:00
parent 75f152a21f
commit 55d53e6dd4
3 changed files with 27 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#define ROLE_SORT Qt::UserRole
#define ROLE_ID Qt::UserRole + 1
#define ROLE_SUBSCRIBED Qt::UserRole + 2
#define ROLE_PRIVACYLEVEL Qt::UserRole + 3
#define TYPE_FOLDER 0
#define TYPE_LOBBY 1
@ -65,11 +66,13 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
privateLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
privateLobbyItem->setText(COLUMN_NAME, tr("Private Lobbies"));
privateLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "1");
privateLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE);
lobbyTreeWidget->insertTopLevelItem(0, privateLobbyItem);
publicLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
publicLobbyItem->setText(COLUMN_NAME, tr("Public Lobbies"));
publicLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "2");
publicLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC);
lobbyTreeWidget->insertTopLevelItem(1, publicLobbyItem);
lobbyTreeWidget->expandAll();
@ -83,11 +86,15 @@ ChatLobbyWidget::~ChatLobbyWidget()
void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu()
{
QTreeWidgetItem *item = lobbyTreeWidget->currentItem();
QMenu contextMnu(this);
contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create chat lobby"), this, SLOT(createChatLobby()));
if (item && item->type() == TYPE_FOLDER) {
QAction *action = contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create chat lobby"), this, SLOT(createChatLobby()));
action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt());
}
QTreeWidgetItem *item = lobbyTreeWidget->currentItem();
if (item && item->type() == TYPE_LOBBY) {
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) {
contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeItem()));
@ -96,6 +103,10 @@ void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu()
}
}
if (contextMnu.children().count() == 0) {
return;
}
contextMnu.exec(QCursor::pos());
}
@ -272,8 +283,14 @@ void ChatLobbyWidget::updateDisplay()
void ChatLobbyWidget::createChatLobby()
{
int privacyLevel = 0;
QAction *action = qobject_cast<QAction*>(sender());
if (action) {
privacyLevel = action->data().toInt();
}
std::list<std::string> friends;
CreateLobbyDialog(friends).exec();
CreateLobbyDialog(friends, privacyLevel).exec();
}
static void subscribeLobby(QTreeWidgetItem *item)

View File

@ -30,7 +30,7 @@
#include "gui/common/PeerDefs.h"
#include "ChatDialog.h"
CreateLobbyDialog::CreateLobbyDialog(const std::list<std::string>& peer_list,QWidget *parent, Qt::WFlags flags) :
CreateLobbyDialog::CreateLobbyDialog(const std::list<std::string>& peer_list, int privacyLevel, QWidget *parent, Qt::WFlags flags) :
QDialog(parent, flags)
{
ui = new Ui::CreateLobbyDialog() ;
@ -56,6 +56,10 @@ CreateLobbyDialog::CreateLobbyDialog(const std::list<std::string>& peer_list,QWi
ui->keyShareList->start();
ui->keyShareList->setSelectedSslIds(peer_list, false);
if (privacyLevel) {
ui->security_CB->setCurrentIndex((privacyLevel == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? 0 : 1);
}
checkTextFields();
}

View File

@ -7,11 +7,12 @@
class CreateLobbyDialog : public QDialog {
Q_OBJECT
public:
/*
*@param chanId The channel id to send request for
*/
CreateLobbyDialog(const std::list<std::string>& friends_list,QWidget *parent = 0, Qt::WFlags flags = 0);
CreateLobbyDialog(const std::list<std::string>& friends_list, int privacyLevel = 0, QWidget *parent = 0, Qt::WFlags flags = 0);
~CreateLobbyDialog();
protected: