added proper naming functions for distant chat

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6439 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-06-18 20:13:58 +00:00
parent e6c0217801
commit 491438055d
6 changed files with 32 additions and 5 deletions

View File

@ -306,6 +306,11 @@ bool ChatDialog::hasNewMessages()
return false;
}
QString ChatDialog::getPeerName(const std::string& id) const
{
return QString::fromUtf8( rsPeers->getPeerName(id).c_str() ) ;
}
void ChatDialog::setPeerStatus(uint32_t status)
{
ChatWidget *cw = getChatWidget();

View File

@ -80,6 +80,8 @@ protected:
void closeEvent(QCloseEvent *event);
virtual bool canClose() { return true; }
virtual QString getPeerName(const std::string& sslid) const ; // can be overloaded for chat dialogs that have specific peers
virtual void init(const std::string &peerId, const QString &title);
virtual void onChatChanged(int /*list*/, int /*type*/) {}

View File

@ -50,6 +50,7 @@
#include <retroshare/rsstatus.h>
#include <retroshare/rspeers.h>
#include <retroshare/rshistory.h>
#include <retroshare/rsmsgs.h>
#include <time.h>
@ -860,7 +861,14 @@ void ChatWidget::updateStatus(const QString &peer_id, int status)
if (peer_id.toStdString() == peerId) {
// the peers status has changed
QString peerName = QString::fromUtf8(rsPeers->getPeerName(peerId).c_str());
QString peerName ;
uint32_t status ;
std::string pgp_id ;
if(rsMsgs->getDistantChatStatus(peerId,status,pgp_id))
peerName = QString::fromUtf8(rsPeers->getPeerName(pgp_id).c_str());
else
peerName = QString::fromUtf8(rsPeers->getPeerName(peerId).c_str());
// is scrollbar at the end?
QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar();

View File

@ -124,7 +124,7 @@ void PopupChatDialog::showDialog(uint chatflags)
void PopupChatDialog::chatStatusChanged(const QString &peerId, const QString& statusString, bool isPrivateChat)
{
if (isPrivateChat && this->peerId == peerId.toStdString()) {
ui.chatWidget->updateStatusString(QString::fromUtf8(rsPeers->getPeerName(this->peerId).c_str()) + " %1", statusString);
ui.chatWidget->updateStatusString(getPeerName(peerId.toStdString()) + " %1", statusString);
}
}
@ -135,7 +135,7 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info)
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
QString message = QString::fromStdWString(info.msg);
QString name = QString::fromUtf8(rsPeers->getPeerName(info.rsid).c_str()) ;
QString name = getPeerName(info.rsid) ;
cw->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
}
@ -154,7 +154,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
{
std::list<ChatInfo> savedOfflineChatNew;
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
QString name = getPeerName(rsPeers->getOwnId()) ;
std::list<ChatInfo> offlineChat;
if (rsMsgs->getPrivateChatQueueCount(false) && rsMsgs->getPrivateChatQueue(false, peerId, offlineChat)) {
@ -188,7 +188,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
case NOTIFY_TYPE_DEL:
{
if (manualDelete == false) {
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
QString name = getPeerName(rsPeers->getOwnId()) ;
// now show saved offline chat messages as sent
std::list<ChatInfo>::iterator it;

View File

@ -136,6 +136,16 @@ void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
PopupChatDialog::closeEvent(e) ;
}
QString PopupDistantChatDialog::getPeerName(const std::string& id) const
{
uint32_t status ;
std::string pgp_id ;
if(rsMsgs->getDistantChatStatus(_hash,status,pgp_id))
return ChatDialog::getPeerName(pgp_id) ;
else
return ChatDialog::getPeerName(id) ;
}

View File

@ -42,6 +42,8 @@ class PopupDistantChatDialog: public PopupChatDialog
virtual void init(const std::string& _hash, const QString &title);
virtual void closeEvent(QCloseEvent *e) ;
virtual QString getPeerName(const std::string& id) const ;
protected slots:
void updateDisplay() ; // overloads RsAutoUpdatePage