fixed display of message links in composer window and message window. Still takes several attempts to display correctly.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7352 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-05-08 08:39:04 +00:00
parent a946504bb5
commit 3766449bec
4 changed files with 51 additions and 16 deletions

View File

@ -576,8 +576,8 @@ bool RetroShareLink::createMessage(const RsGxsId& peerId, const QString& subject
_hash = QString::fromStdString(peerId.toStdString()); _hash = QString::fromStdString(peerId.toStdString());
//PeerDefs::rsidFromId(peerId, &_name); PeerDefs::rsidFromId(peerId, &_name);
_name = QString::fromStdString("GXS_id("+peerId.toStdString()+")") ; //_name = QString::fromStdString("GXS_id("+peerId.toStdString()+")") ;
// do something better here!! // do something better here!!
_subject = subject; _subject = subject;
@ -1543,6 +1543,12 @@ static void processList(const QStringList &list, const QString &textSingular, co
if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details)) if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details))
{ {
if(gxs_details.mIsOwnId)
{
QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?"));
break ;
}
MessageComposer *msg = MessageComposer::newMsg(); MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, gxs_id) ; msg->addRecipient(MessageComposer::TO, gxs_id) ;

View File

@ -72,7 +72,7 @@ const QString PeerDefs::rsidFromId(const RsGxsId &id, QString *name /* = NULL*/)
{ {
QString rsid; QString rsid;
// Check own GXS ids. // Check own GXS ids first, since they can be obtained faster.
// //
std::list<RsGxsId> gxs_ids ; std::list<RsGxsId> gxs_ids ;
rsIdentity->getOwnIds(gxs_ids) ; rsIdentity->getOwnIds(gxs_ids) ;
@ -95,6 +95,18 @@ const QString PeerDefs::rsidFromId(const RsGxsId &id, QString *name /* = NULL*/)
return rsid ; return rsid ;
} }
RsIdentityDetails details ;
if(rsIdentity->getIdDetails(id,details))
{
std::string peerName = details.mNickname ;
rsid = PeerDefs::rsid(peerName, id);
if(name)
*name = QString::fromUtf8(peerName.c_str());
return rsid ;
}
rsid = PeerDefs::rsid("", id); rsid = PeerDefs::rsid("", id);
if (name) if (name)

View File

@ -105,6 +105,7 @@ MessageWidget *MessageWidget::openMsg(const std::string &msgId, bool window)
MessageWidget *msgWidget = new MessageWidget(false, parent); MessageWidget *msgWidget = new MessageWidget(false, parent);
msgWidget->isWindow = window; msgWidget->isWindow = window;
msgWidget->fill(msgId); msgWidget->fill(msgId);
if (parent) { if (parent) {
parent->addWidget(msgWidget); parent->addWidget(msgWidget);
} }
@ -431,12 +432,19 @@ void MessageWidget::showTagLabels()
} }
} }
void MessageWidget::refill()
{
//uint32_t msg_id = currMsgId ;
//currMsgId = 0 ;
//fill(msg_id) ;
}
void MessageWidget::fill(const std::string &msgId) void MessageWidget::fill(const std::string &msgId)
{ {
if (currMsgId == msgId) { // if (currMsgId == msgId) {
// message doesn't changed // // message doesn't changed
return; // return;
} // }
ui.decryptFrame->hide(); ui.decryptFrame->hide();
@ -540,21 +548,29 @@ void MessageWidget::fill(const std::string &msgId)
ui.dateText->setText(DateTime::formatDateTime(msgInfo.ts)); ui.dateText->setText(DateTime::formatDateTime(msgInfo.ts));
RsPeerId ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
QString tooltip_string ;
RsPeerId srcId; if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) // outgoing message are from me
if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) { {
// outgoing message are from me tooltip_string = PeerDefs::rsidFromId(ownId) ;
srcId = ownId; link.createMessage(ownId, "");
} else { }
srcId = msgInfo.rspeerid_srcId; else if(msgInfo.msgflags & RS_MSG_DECRYPTED || msgInfo.msgflags & RS_MSG_ENCRYPTED) // distant message
{
tooltip_string = PeerDefs::rsidFromId(msgInfo.rsgxsid_srcId) ;
link.createMessage(msgInfo.rsgxsid_srcId, "");
}
else
{
tooltip_string = PeerDefs::rsidFromId(msgInfo.rspeerid_srcId) ;
link.createMessage(msgInfo.rspeerid_srcId, "");
} }
link.createMessage(srcId, "");
if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) { if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) {
ui.fromText->setText("RetroShare"); ui.fromText->setText("RetroShare");
} else { } else {
ui.fromText->setText(link.toHtml()); ui.fromText->setText(link.toHtml());
ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId)); ui.fromText->setToolTip(tooltip_string) ;
} }
if (msgInfo.msgflags & RS_MSG_ENCRYPTED) { if (msgInfo.msgflags & RS_MSG_ENCRYPTED) {

View File

@ -69,6 +69,7 @@ private slots:
void print(); void print();
void printPreview(); void printPreview();
void saveAs(); void saveAs();
void refill();
void msgfilelistWidgetCostumPopupMenu(QPoint); void msgfilelistWidgetCostumPopupMenu(QPoint);
void messagesTagsChanged(); void messagesTagsChanged();