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_DENYFRIEND ":/images/denied16.png"
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png" #define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
#define IMAGE_EXPORTFRIEND ":/images/exportpeers_16x16.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_FRIENDINFO ":/images/peerdetails_16x16.png"
#define IMAGE_CHAT ":/images/chat.png" #define IMAGE_CHAT ":/images/chat.png"
#define IMAGE_MSG ":/images/mail_new.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.addfileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect( ui.msgText, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &))); 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_Offline_Friends, SIGNAL(triggered()), this, SLOT(insertPeers()));
connect(ui.action_Hide_Status_Column, SIGNAL(triggered()), this, SLOT(statusColumn())); 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(); 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(); 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->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); action->setDisabled(standard);
} }
break; break;
@ -1265,6 +1268,24 @@ void PeersDialog::configurefriend()
ConfCertDialog::show(getPeerRsCertId(getCurrentPeer())); 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() void PeersDialog::resetStatusBar()
{ {
#ifdef PEERS_DEBUG #ifdef PEERS_DEBUG
@ -1732,13 +1753,6 @@ void PeersDialog::changeAvatarClicked()
updateAvatar(); updateAvatar();
} }
void PeersDialog::on_actionAdd_Friend_activated()
{
ConnectFriendWizard connectwiz (this);
connectwiz.exec ();
}
void PeersDialog::on_actionCreate_New_Forum_activated() void PeersDialog::on_actionCreate_New_Forum_activated()
{ {
MainWindow::activatePage (MainWindow::Forums); MainWindow::activatePage (MainWindow::Forums);

View File

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

View File

@ -21,6 +21,7 @@
#include "ConnectFriendWizard.h" #include "ConnectFriendWizard.h"
#include "gui/common/PeerDefs.h" #include "gui/common/PeerDefs.h"
#include "gui/common/GroupDefs.h"
#include <retroshare/rspeers.h> //for rsPeers variable #include <retroshare/rspeers.h> //for rsPeers variable
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
@ -56,6 +57,7 @@
#define CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD "peerCertString" #define CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD "peerCertString"
#define SIGN_RADIO_BUTTON_FIELD_CONNECT_FRIEND_WIZARD "signCheckBox" #define SIGN_RADIO_BUTTON_FIELD_CONNECT_FRIEND_WIZARD "signCheckBox"
#define ACCEPT_RADIO_BUTTON_FIELD_CONNECT_FRIEND_WIZARD "acceptCheckBox" #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")); setWindowTitle(tr("Connect Friend Wizard"));
} }
//============================================================================
void ConnectFriendWizard::setGroup(const std::string &groupId)
{
setField(GROUP_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(groupId));
}
//============================================================================ //============================================================================
void void
@ -120,6 +130,11 @@ ConnectFriendWizard::accept()
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl; std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
rsPeers->setAcceptToConnectGPGCertificate(gpg_Id, true); 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 != "") { if (ssl_Id != "") {
@ -915,6 +930,11 @@ ConclusionPage::ConclusionPage(QWidget *parent) : QWizardPage(parent) {
dyndns = new QLineEdit(this); dyndns = new QLineEdit(this);
dyndns->setVisible(false); dyndns->setVisible(false);
registerField("dyndns",dyndns); 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() { void ConclusionPage::initializePage() {
std::string id = field(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD).toString().toStdString(); 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(); 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 ) ); locEdit->setText( QString::fromStdString( detail.location ) );
signersEdit->setPlainText( ts ); 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); ConnectFriendWizard(QWidget *parent = 0);
void setGroup(const std::string &groupId);
void accept(); void accept();
private slots: private slots:
@ -210,6 +212,7 @@ public:
private slots: private slots:
// void printButtonClicked(); // void printButtonClicked();
void groupCurrentIndexChanged(int index);
private: private:
QGroupBox* peerDetailsFrame; QGroupBox* peerDetailsFrame;
@ -224,6 +227,8 @@ private:
QLabel* locEdit; QLabel* locEdit;
QLabel* signersLabel; QLabel* signersLabel;
QTextEdit* signersEdit; QTextEdit* signersEdit;
QComboBox* groupComboBox;
QLabel* groupLabel;
QLabel* radioButtonsLabel; QLabel* radioButtonsLabel;
QCheckBox *signGPGCheckBox; QCheckBox *signGPGCheckBox;

View File

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