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

@ -75,6 +75,7 @@
#define IMAGE_DENYFRIEND ":/images/denied16.png"
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
#define IMAGE_EXPORTFRIEND ":/images/exportpeers_16x16.png"
#define IMAGE_ADDFRIEND ":/images/user/add_user16.png"
#define IMAGE_FRIENDINFO ":/images/peerdetails_16x16.png"
#define IMAGE_CHAT ":/images/chat.png"
#define IMAGE_MSG ":/images/mail_new.png"
@ -134,6 +135,7 @@ PeersDialog::PeersDialog(QWidget *parent)
connect( ui.addfileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect( ui.msgText, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
connect(ui.actionAdd_Friend, SIGNAL(triggered()), this, SLOT(addFriend()));
connect(ui.action_Hide_Offline_Friends, SIGNAL(triggered()), this, SLOT(insertPeers()));
connect(ui.action_Hide_Status_Column, SIGNAL(triggered()), this, SLOT(statusColumn()));
@ -410,14 +412,15 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
{
bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool();
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message group"), this, SLOT(msgfriend()));
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Group"), this, SLOT(msgfriend()));
contextMnu.addAction(QIcon(IMAGE_ADDFRIEND), tr("Add Friend"), this, SLOT(addFriend()));
contextMnu.addSeparator();
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit group"), this, SLOT(editGroup()));
action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
action->setDisabled(standard);
action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove group"), this, SLOT(removeGroup()));
action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard);
}
break;
@ -1265,6 +1268,24 @@ void PeersDialog::configurefriend()
ConfCertDialog::show(getPeerRsCertId(getCurrentPeer()));
}
void PeersDialog::addFriend()
{
std::string groupId;
QTreeWidgetItem *c = getCurrentPeer();
if (c && c->type() == TYPE_GROUP) {
groupId = c->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
}
ConnectFriendWizard connwiz (this);
if (groupId.empty() == false) {
connwiz.setGroup(groupId);
}
connwiz.exec ();
}
void PeersDialog::resetStatusBar()
{
#ifdef PEERS_DEBUG
@ -1732,13 +1753,6 @@ void PeersDialog::changeAvatarClicked()
updateAvatar();
}
void PeersDialog::on_actionAdd_Friend_activated()
{
ConnectFriendWizard connectwiz (this);
connectwiz.exec ();
}
void PeersDialog::on_actionCreate_New_Forum_activated()
{
MainWindow::activatePage (MainWindow::Forums);

View File

@ -118,6 +118,7 @@ private slots:
/** Remove friend */
void removefriend();
/** start a chat with a friend **/
void addFriend();
void chatfriend(QTreeWidgetItem* );
void chatfriendproxy();
void msgfriend();
@ -148,7 +149,6 @@ private slots:
void changeAvatarClicked();
void getAvatar();
void on_actionAdd_Friend_activated();
void on_actionAdd_Group_activated();
void on_actionCreate_New_Forum_activated();
void on_actionCreate_New_Channel_activated();

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)));
}
//============================================================================

View File

@ -38,6 +38,8 @@ public:
ConnectFriendWizard(QWidget *parent = 0);
void setGroup(const std::string &groupId);
void accept();
private slots:
@ -210,6 +212,7 @@ public:
private slots:
// void printButtonClicked();
void groupCurrentIndexChanged(int index);
private:
QGroupBox* peerDetailsFrame;
@ -224,6 +227,8 @@ private:
QLabel* locEdit;
QLabel* signersLabel;
QTextEdit* signersEdit;
QComboBox* groupComboBox;
QLabel* groupLabel;
QLabel* radioButtonsLabel;
QCheckBox *signGPGCheckBox;

View File

@ -763,7 +763,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>CertificatePage</name>
<message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+607"/>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+617"/>
<source>Certificate files</source>
<translation>Zertifikat-Dateien</translation>
</message>
@ -1325,12 +1325,12 @@ Keine Beschreibung</translation>
<translation>Füge als Freund hinzu, zu dem verbunden wird</translation>
</message>
<message>
<location line="+98"/>
<location line="+100"/>
<source>It seems your friend is already registered. Adding it might just set it&apos;s ip address.</source>
<translation>Ihr Freund ist bereits registriert. Das nochmalige Hinzufügen ändert nur seine IP.</translation>
</message>
<message>
<location line="-129"/>
<location line="-131"/>
<source>Peer details</source>
<translation>Nachbar Details</translation>
</message>
@ -1591,7 +1591,7 @@ und meinen GPG Schlüssel nicht unterzeichnet</translation>
<context>
<name>ConnectFriendWizard</name>
<message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="-762"/>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="-770"/>
<source>Connect Friend Wizard</source>
<translation>Assistent um sich zu einem Freund zu verbinden</translation>
</message>
@ -2834,7 +2834,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>EmailPage</name>
<message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+1002"/>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+1021"/>
<source>Invite Friend by Email</source>
<translation>Einladung per E-Mail versenden</translation>
</message>
@ -2875,7 +2875,7 @@ Bis bald in RetroShare!</translation>
<context>
<name>ErrorMessagePage</name>
<message>
<location line="-315"/>
<location line="-326"/>
<source>Sorry, some error appeared</source>
<translation>Entschuldigung, es trat ein Fehler auf</translation>
</message>
@ -7045,7 +7045,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>PeersDialog</name>
<message>
<location filename="../gui/PeersDialog.cpp" line="+427"/>
<location filename="../gui/PeersDialog.cpp" line="+429"/>
<source>Chat</source>
<translation>Chat</translation>
</message>
@ -7070,7 +7070,7 @@ p, li { white-space: pre-wrap; }
<translation>Verbinde zum Freund</translation>
</message>
<message>
<location line="-299"/>
<location line="-300"/>
<source>Profile</source>
<translation>Profil</translation>
</message>
@ -7105,12 +7105,7 @@ p, li { white-space: pre-wrap; }
<translation>Standort</translation>
</message>
<message>
<location line="+9"/>
<source>Message group</source>
<translation>Gruppe anschreiben</translation>
</message>
<message>
<location line="+19"/>
<location line="+29"/>
<source>Friend Details</source>
<translation>Freund-Details</translation>
</message>
@ -7130,12 +7125,7 @@ p, li { white-space: pre-wrap; }
<translation>Freund anschreiben</translation>
</message>
<message>
<location line="-11"/>
<source>Edit group</source>
<translation>Gruppe ändern</translation>
</message>
<message>
<location line="+20"/>
<location line="+9"/>
<source>Recommend this Friend to...</source>
<translation>Freund weiterempfehlen...</translation>
</message>
@ -7175,17 +7165,12 @@ p, li { white-space: pre-wrap; }
<translation>Aus allen Gruppen entfernen</translation>
</message>
<message>
<location line="-93"/>
<source>Remove group</source>
<translation>Gruppe entfernen</translation>
</message>
<message>
<location line="+598"/>
<location line="+505"/>
<source>Available</source>
<translation>Verfügbar</translation>
</message>
<message>
<location line="+759"/>
<location line="+777"/>
<source>Add Extra File</source>
<translation>Zusätzliche Datei hinzufügen</translation>
</message>
@ -7303,6 +7288,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="-107"/>
<location filename="../gui/PeersDialog.cpp" line="-1485"/>
<source>Add Friend</source>
<translation>Freund hinzufügen</translation>
</message>
@ -7351,18 +7337,33 @@ p, li { white-space: pre-wrap; }
<translation>Chat Verlauf speichern</translation>
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-1506"/>
<location line="+845"/>
<location filename="../gui/PeersDialog.cpp" line="-40"/>
<location line="+846"/>
<source>RetroShare</source>
<translation></translation>
</message>
<message>
<location line="+0"/>
<location line="-807"/>
<source>Message Group</source>
<translation>Gruppe anschreiben</translation>
</message>
<message>
<location line="+5"/>
<source>Edit Group</source>
<translation>Gruppe ändern</translation>
</message>
<message>
<location line="+3"/>
<source>Remove Group</source>
<translation>Gruppe entfernen</translation>
</message>
<message>
<location line="+799"/>
<source>Do you want to remove this Friend?</source>
<translation>Willst du diesen Freund entfernen?</translation>
</message>
<message>
<location line="+719"/>
<location line="+737"/>
<source>Save as...</source>
<translation>Speichern unter...</translation>
</message>
@ -7395,12 +7396,12 @@ p, li { white-space: pre-wrap; }
<translation>Status Spalte ausblenden</translation>
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-1797"/>
<location filename="../gui/PeersDialog.cpp" line="-1816"/>
<source>Friends Storm</source>
<translation>Aktivitäten</translation>
</message>
<message>
<location line="+1144"/>
<location line="+1163"/>
<source>is typing...</source>
<translation>tippt...</translation>
</message>
@ -7420,7 +7421,7 @@ p, li { white-space: pre-wrap; }
<translation>Freunde</translation>
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-844"/>
<location filename="../gui/PeersDialog.cpp" line="-862"/>
<location line="+80"/>
<source>Paste Friend Link</source>
<translation>RetroShare Link einfügen</translation>
@ -8886,7 +8887,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>RsidPage</name>
<message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+853"/>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+864"/>
<source>RetroShare ID</source>
<translation>RetroShare ID</translation>
</message>
@ -10408,7 +10409,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>TextPage</name>
<message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="-877"/>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="-888"/>
<source>Use text representation of the PGP certificates.</source>
<translation>Verwende diesen Text als PGP Zertifikat.</translation>
</message>