diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index d2b49a28d..0c71ffe52 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -24,6 +24,7 @@ #include "NewsFeed.h" #include +#include #include "feeds/ChanNewItem.h" #include "feeds/ChanMsgItem.h" @@ -374,6 +375,11 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi) std::cerr << std::endl; #endif + if (fi.mId1 == rsPeers->getOwnId()) { + /* chat message from myself */ + return; + } + /* make new widget */ ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, fi.mId1, fi.mId2, true); @@ -399,7 +405,6 @@ void NewsFeed::addFeedItemMessage(RsFeedItem &fi) #endif } - void NewsFeed::addFeedItemFilesNew(RsFeedItem &fi) { #ifdef NEWS_DEBUG @@ -408,9 +413,6 @@ void NewsFeed::addFeedItemFilesNew(RsFeedItem &fi) #endif } - - - /* FeedHolder Functions (for FeedItem functionality) */ void NewsFeed::deleteFeedItem(QWidget *item, uint32_t type) { diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index 64fa920e8..2aed7db0e 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -27,6 +27,8 @@ #include "../RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" +#include "gui/notifyqt.h" + #include #include @@ -51,8 +53,11 @@ ChatMsgItem::ChatMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) ); connect( msgButton, SIGNAL( clicked( void ) ), this, SLOT( sendMsg ( void ) ) ); + connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); + updateItemStatic(); updateItem(); + updateAvatar(QString::fromStdString(mPeerId)); insertChat(message); } @@ -84,8 +89,6 @@ void ChatMsgItem::updateItemStatic() std::cerr << "ChatMsgItem::updateItemStatic()"; std::cerr << std::endl; #endif - - } void ChatMsgItem::updateItem() @@ -121,8 +124,6 @@ void ChatMsgItem::updateItem() /* slow Tick */ int msec_rate = 10129; - loadAvatar(); - QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); return; } @@ -152,7 +153,6 @@ void ChatMsgItem::removeItem() } } - void ChatMsgItem::gotoHome() { #ifdef DEBUG_ITEM @@ -198,28 +198,29 @@ void ChatMsgItem::openChat() } } -void ChatMsgItem::loadAvatar() +void ChatMsgItem::updateAvatar(const QString &peer_id) { + if (peer_id.toStdString() != mPeerId) { + /* it 's not me */ + return; + } - unsigned char *data = NULL; - int size = 0 ; + unsigned char *data = NULL; + int size = 0 ; - rsMsgs->getAvatarData(mPeerId,data,size); + rsMsgs->getAvatarData(mPeerId,data,size); + if(size != 0) + { + // set the image + QPixmap pix ; + pix.loadFromData(data,size,"PNG") ; + avatar_label->setPixmap(pix); + delete[] data ; - if(size != 0) - { - // set the image - QPixmap pix ; - pix.loadFromData(data,size,"PNG") ; - avatar_label->setPixmap(pix); - delete[] data ; - - } - else - { - avatar_label->setPixmap(QPixmap(":/images/user/personal64.png")); - } + } + else + { + avatar_label->setPixmap(QPixmap(":/images/user/personal64.png")); + } } - - diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.h b/retroshare-gui/src/gui/feeds/ChatMsgItem.h index 62b4818b4..fe2de10b3 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.h +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.h @@ -40,8 +40,6 @@ public: /** Default Destructor */ void updateItemStatic(); - void loadAvatar(); - private slots: /* default stuff */ @@ -52,6 +50,7 @@ private slots: void openChat(); void updateItem(); + void updateAvatar(const QString &peer_id); private: void insertChat(std::string &message); diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.ui b/retroshare-gui/src/gui/feeds/ChatMsgItem.ui index 2911c9903..17103583b 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.ui +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.ui @@ -13,7 +13,7 @@ Form - + 6 diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index d13d38e07..b45a53072 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -27,6 +27,8 @@ #include "../RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" +#include "gui/notifyqt.h" + #include #include @@ -55,9 +57,12 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, std::string peerId, uint //connect( addButton, SIGNAL( clicked( void ) ), this, SLOT( addFriend ( void ) ) ); //connect( removeButton, SIGNAL( clicked( void ) ), this, SLOT( removeFriend ( void ) ) ); + connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); + small(); updateItemStatic(); updateItem(); + updateAvatar(QString::fromStdString(mPeerId)); } @@ -212,13 +217,10 @@ void PeerItem::updateItem() /* slow Tick */ int msec_rate = 10129; - loadAvatar(); - QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); return; } - void PeerItem::small() { expandFrame->hide(); @@ -320,8 +322,12 @@ void PeerItem::openChat() } } -void PeerItem::loadAvatar() +void PeerItem::updateAvatar(const QString &peer_id) { + if (peer_id.toStdString() != mPeerId) { + /* it 's not me */ + return; + } unsigned char *data = NULL; int size = 0 ; diff --git a/retroshare-gui/src/gui/feeds/PeerItem.h b/retroshare-gui/src/gui/feeds/PeerItem.h index 010004f71..f0b732e1a 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.h +++ b/retroshare-gui/src/gui/feeds/PeerItem.h @@ -45,8 +45,6 @@ public: void updateItemStatic(); void small(); - void loadAvatar(); - private slots: /* default stuff */ @@ -60,6 +58,7 @@ private slots: void openChat(); void updateItem(); + void updateAvatar(const QString &peer_id); private: FeedHolder *mParent;