Add group support to the ConnectFriendWizard.

Add friend (now also in context menu of the group) sets the current selected group as default for the new user.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3558 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-29 19:30:59 +00:00
parent 7fd43d30b5
commit 327af4ca61
6 changed files with 109 additions and 47 deletions

View file

@ -21,6 +21,7 @@
#include "ConnectFriendWizard.h"
#include "gui/common/PeerDefs.h"
#include "gui/common/GroupDefs.h"
#include <retroshare/rspeers.h> //for rsPeers variable
#include <retroshare/rsiface.h>
@ -56,6 +57,7 @@
#define CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD "peerCertString"
#define SIGN_RADIO_BUTTON_FIELD_CONNECT_FRIEND_WIZARD "signCheckBox"
#define ACCEPT_RADIO_BUTTON_FIELD_CONNECT_FRIEND_WIZARD "acceptCheckBox"
#define GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD "groupIdField"
@ -99,6 +101,14 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent)
setWindowTitle(tr("Connect Friend Wizard"));
}
//============================================================================
void ConnectFriendWizard::setGroup(const std::string &groupId)
{
setField(GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(groupId));
}
//============================================================================
void
@ -120,6 +130,11 @@ ConnectFriendWizard::accept()
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
rsPeers->setAcceptToConnectGPGCertificate(gpg_Id, true);
}
QString groupId = field(GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD).toString();
if (groupId.isEmpty() == false) {
rsPeers->assignPeerToGroup(groupId.toStdString(), gpg_Id, true);
}
}
if (ssl_Id != "") {
@ -915,6 +930,11 @@ ConclusionPage::ConclusionPage(QWidget *parent) : QWizardPage(parent) {
dyndns = new QLineEdit(this);
dyndns->setVisible(false);
registerField("dyndns",dyndns);
groupComboBox = new QComboBox(this);
groupLabel = new QLabel(this);
groupLabel->setVisible(false);
registerField(GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD, groupLabel);
}
//============================================================================
@ -926,6 +946,15 @@ int ConclusionPage::nextId() const {
//
//============================================================================
//
void ConclusionPage::groupCurrentIndexChanged(int index)
{
setField(GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD, groupComboBox->itemData(index, Qt::UserRole));
}
//
//============================================================================
//
void ConclusionPage::initializePage() {
std::string id = field(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD).toString().toStdString();
std::string gpg_id = field(GPG_ID_FIELD_CONNECT_FRIEND_WIZARD).toString().toStdString();
@ -1008,6 +1037,19 @@ void ConclusionPage::initializePage() {
locEdit->setText( QString::fromStdString( detail.location ) );
signersEdit->setPlainText( ts );
std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList);
GroupDefs::sortByName(groupInfoList);
groupComboBox->addItem("", ""); // empty value
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) {
groupComboBox->addItem(GroupDefs::name(*groupIt), QString::fromStdString(groupIt->id));
}
QString groupId = field(GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD).toString();
if (groupId.isEmpty() == false) {
groupComboBox->setCurrentIndex(groupComboBox->findData(groupId));
}
connect(groupComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(groupCurrentIndexChanged(int)));
}
//============================================================================