mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed naming and completion in recipient addresses in MessageComposer
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8090 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8a15755ac0
commit
ceac258552
@ -730,19 +730,20 @@ void MessageComposer::buildCompleter()
|
|||||||
RsIdentityDetails detail;
|
RsIdentityDetails detail;
|
||||||
|
|
||||||
if(rsIdentity->getIdDetails(id, detail))
|
if(rsIdentity->getIdDetails(id, detail))
|
||||||
completerList.append( getGxsRecipientName(id,detail)) ;
|
completerList.append( getRecipientEmailAddress(id,detail)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (peerIt = peers.begin(); peerIt != peers.end(); ++peerIt) {
|
for (peerIt = peers.begin(); peerIt != peers.end(); ++peerIt)
|
||||||
|
{
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (!rsPeers->getPeerDetails(*peerIt, detail)) {
|
|
||||||
continue; /* BAD */
|
|
||||||
}
|
|
||||||
|
|
||||||
QString name = PeerDefs::nameWithLocation(detail);
|
if (rsPeers->getPeerDetails(*peerIt, detail))
|
||||||
if (completerList.indexOf(name) == -1) {
|
completerList.append( getRecipientEmailAddress(*peerIt,detail)) ;
|
||||||
completerList.append(name);
|
|
||||||
}
|
// QString name = PeerDefs::nameWithLocation(detail);
|
||||||
|
// if (completerList.indexOf(name) == -1) {
|
||||||
|
// completerList.append(name);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
completerList.sort();
|
completerList.sort();
|
||||||
@ -1497,10 +1498,20 @@ bool MessageComposer::getRecipientFromRow(int row, enumType &type, destinationTy
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MessageComposer::getGxsRecipientName(const RsGxsId& id,const RsIdentityDetails& detail)
|
QString MessageComposer::getRecipientEmailAddress(const RsGxsId& id,const RsIdentityDetails& detail)
|
||||||
{
|
{
|
||||||
return QString("%2 <%2@%1>").arg(QString::fromStdString(id.toStdString())).arg(QString::fromUtf8(detail.mNickname.c_str())) ;
|
return (QString("%2 <")+tr("Distant identity:")+" %2@%1>").arg(QString::fromStdString(id.toStdString())).arg(QString::fromUtf8(detail.mNickname.c_str())) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MessageComposer::getRecipientEmailAddress(const RsPeerId& id,const RsPeerDetails& detail)
|
||||||
|
{
|
||||||
|
QString location_name = detail.location.empty()?tr("[Missing]"):QString::fromUtf8(detail.location.c_str()) ;
|
||||||
|
|
||||||
|
return (QString("%1 (")+tr("Friend node & location:")+" %2, %3)").arg(QString::fromUtf8(detail.name.c_str()))
|
||||||
|
.arg(location_name)
|
||||||
|
.arg(QString::fromUtf8(detail.id.toStdString().c_str())) ;
|
||||||
|
}
|
||||||
|
|
||||||
void MessageComposer::setRecipientToRow(int row, enumType type, destinationType dest_type, const std::string &id)
|
void MessageComposer::setRecipientToRow(int row, enumType type, destinationType dest_type, const std::string &id)
|
||||||
{
|
{
|
||||||
if (row + 1 > ui.recipientWidget->rowCount()) {
|
if (row + 1 > ui.recipientWidget->rowCount()) {
|
||||||
@ -1567,7 +1578,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType
|
|||||||
QList<QIcon> icons ;
|
QList<QIcon> icons ;
|
||||||
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
|
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
|
||||||
|
|
||||||
name = getGxsRecipientName(gid,detail) ;
|
name = getRecipientEmailAddress(gid,detail) ;
|
||||||
|
|
||||||
if(!icons.empty())
|
if(!icons.empty())
|
||||||
icon = icons.front() ;
|
icon = icons.front() ;
|
||||||
@ -1582,7 +1593,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType
|
|||||||
std::cerr << "Can't get peer details from " << id << std::endl;
|
std::cerr << "Can't get peer details from " << id << std::endl;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
name = PeerDefs::nameWithLocation(details);
|
name = getRecipientEmailAddress(RsPeerId(id),details) ;
|
||||||
|
|
||||||
StatusInfo peerStatusInfo;
|
StatusInfo peerStatusInfo;
|
||||||
// No check of return value. Non existing status info is handled as offline.
|
// No check of return value. Non existing status info is handled as offline.
|
||||||
@ -1655,24 +1666,21 @@ bool MessageComposer::eventFilter(QObject *obj, QEvent *event)
|
|||||||
void MessageComposer::editingRecipientFinished()
|
void MessageComposer::editingRecipientFinished()
|
||||||
{
|
{
|
||||||
QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(QObject::sender());
|
QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(QObject::sender());
|
||||||
if (lineEdit == NULL) {
|
|
||||||
|
if (lineEdit == NULL)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
lineEdit->setStyleSheet(QString(STYLE_NORMAL).arg(lineEdit->objectName()));
|
lineEdit->setStyleSheet(QString(STYLE_NORMAL).arg(lineEdit->objectName()));
|
||||||
|
|
||||||
// find row of the widget
|
// find row of the widget
|
||||||
int rowCount = ui.recipientWidget->rowCount();
|
int rowCount = ui.recipientWidget->rowCount();
|
||||||
int row;
|
int row;
|
||||||
for (row = 0; row < rowCount; ++row) {
|
for (row = 0; row < rowCount; ++row)
|
||||||
if (ui.recipientWidget->cellWidget(row, COLUMN_RECIPIENT_NAME) == lineEdit) {
|
if (ui.recipientWidget->cellWidget(row, COLUMN_RECIPIENT_NAME) == lineEdit)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
if (row >= rowCount) // not found
|
||||||
if (row >= rowCount) {
|
|
||||||
// not found
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
enumType type;
|
enumType type;
|
||||||
std::string id; // dummy
|
std::string id; // dummy
|
||||||
@ -1690,22 +1698,31 @@ void MessageComposer::editingRecipientFinished()
|
|||||||
// start with peers
|
// start with peers
|
||||||
std::list<RsPeerId> peers;
|
std::list<RsPeerId> peers;
|
||||||
rsPeers->getFriendList(peers);
|
rsPeers->getFriendList(peers);
|
||||||
|
RsPeerDetails details;
|
||||||
|
|
||||||
std::list<RsPeerId>::iterator peerIt;
|
for (std::list<RsPeerId>::iterator peerIt = peers.begin(); peerIt != peers.end(); ++peerIt)
|
||||||
for (peerIt = peers.begin(); peerIt != peers.end(); ++peerIt) {
|
if (rsPeers->getPeerDetails(*peerIt, details) && text == getRecipientEmailAddress(*peerIt,details))
|
||||||
RsPeerDetails details;
|
{
|
||||||
if (!rsPeers->getPeerDetails(*peerIt, details)) {
|
setRecipientToRow(row, type, PEER_TYPE_SSL, details.id.toStdString());
|
||||||
continue; /* BAD */
|
return ;
|
||||||
}
|
|
||||||
|
|
||||||
QString name = PeerDefs::nameWithLocation(details);
|
|
||||||
if (text.compare(name, Qt::CaseSensitive) == 0) {
|
|
||||||
// found it
|
|
||||||
setRecipientToRow(row, type, PEER_TYPE_SSL, details.id.toStdString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> gxsitems ;
|
||||||
|
ui.friendSelectionWidget->items(gxsitems,FriendSelectionWidget::IDTYPE_GXS) ;
|
||||||
|
RsIdentityDetails detail;
|
||||||
|
|
||||||
|
for (QList<QTreeWidgetItem*>::const_iterator idIt = gxsitems.begin(); idIt != gxsitems.end(); ++idIt)
|
||||||
|
{
|
||||||
|
RsGxsId id ( ui.friendSelectionWidget->idFromItem( *idIt ) );
|
||||||
|
|
||||||
|
if(rsIdentity->getIdDetails(id, detail) && text == getRecipientEmailAddress(id,detail))
|
||||||
|
{
|
||||||
|
setRecipientToRow(row, type, PEER_TYPE_GXS, id.toStdString());
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// then groups
|
// then groups
|
||||||
std::list<RsGroupInfo> groupInfoList;
|
std::list<RsGroupInfo> groupInfoList;
|
||||||
rsPeers->getGroupInfoList(groupInfoList);
|
rsPeers->getGroupInfoList(groupInfoList);
|
||||||
@ -1724,6 +1741,7 @@ void MessageComposer::editingRecipientFinished()
|
|||||||
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
|
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
|
||||||
lineEdit->setText(text);
|
lineEdit->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageComposer::addRecipient(enumType type, const RsPeerId& pid)
|
void MessageComposer::addRecipient(enumType type, const RsPeerId& pid)
|
||||||
{
|
{
|
||||||
int rowCount = ui.recipientWidget->rowCount();
|
int rowCount = ui.recipientWidget->rowCount();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <retroshare/rstypes.h>
|
#include <retroshare/rstypes.h>
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
|
#include <retroshare/rspeers.h>
|
||||||
#include "ui_MessageComposer.h"
|
#include "ui_MessageComposer.h"
|
||||||
|
|
||||||
#include "gui/msgs/MessageInterface.h"
|
#include "gui/msgs/MessageInterface.h"
|
||||||
@ -165,7 +166,9 @@ private:
|
|||||||
|
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
|
|
||||||
QString getGxsRecipientName(const RsGxsId& id,const RsIdentityDetails& detail) ;
|
static QString getRecipientEmailAddress(const RsGxsId& id,const RsIdentityDetails& detail) ;
|
||||||
|
static QString getRecipientEmailAddress(const RsPeerId& id,const RsPeerDetails& detail) ;
|
||||||
|
|
||||||
void addContact(enumType type);
|
void addContact(enumType type);
|
||||||
void setTextColor(const QColor& col) ;
|
void setTextColor(const QColor& col) ;
|
||||||
void setupFileActions();
|
void setupFileActions();
|
||||||
|
Loading…
Reference in New Issue
Block a user