Don't add a ChatMsgItem as feed on own public chat message.

Moved the handling of the avatar from PeerItem::updateItem and ChatMsgItem::updateItem called with QTimer to connect to the signal peerHasNewAvatar.
Fixed compiler warning.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3419 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-08-31 22:42:40 +00:00
parent b01c6bf3d1
commit af4667232b
6 changed files with 44 additions and 37 deletions

View File

@ -24,6 +24,7 @@
#include "NewsFeed.h" #include "NewsFeed.h"
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#include "feeds/ChanNewItem.h" #include "feeds/ChanNewItem.h"
#include "feeds/ChanMsgItem.h" #include "feeds/ChanMsgItem.h"
@ -374,6 +375,11 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if (fi.mId1 == rsPeers->getOwnId()) {
/* chat message from myself */
return;
}
/* make new widget */ /* make new widget */
ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, fi.mId1, fi.mId2, true); ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, fi.mId1, fi.mId2, true);
@ -399,7 +405,6 @@ void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
#endif #endif
} }
void NewsFeed::addFeedItemFilesNew(RsFeedItem &fi) void NewsFeed::addFeedItemFilesNew(RsFeedItem &fi)
{ {
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
@ -408,9 +413,6 @@ void NewsFeed::addFeedItemFilesNew(RsFeedItem &fi)
#endif #endif
} }
/* FeedHolder Functions (for FeedItem functionality) */ /* FeedHolder Functions (for FeedItem functionality) */
void NewsFeed::deleteFeedItem(QWidget *item, uint32_t type) void NewsFeed::deleteFeedItem(QWidget *item, uint32_t type)
{ {

View File

@ -27,6 +27,8 @@
#include "../RsAutoUpdatePage.h" #include "../RsAutoUpdatePage.h"
#include "gui/msgs/MessageComposer.h" #include "gui/msgs/MessageComposer.h"
#include "gui/notifyqt.h"
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
@ -51,8 +53,11 @@ ChatMsgItem::ChatMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId
connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) ); connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) );
connect( msgButton, SIGNAL( clicked( void ) ), this, SLOT( sendMsg ( void ) ) ); connect( msgButton, SIGNAL( clicked( void ) ), this, SLOT( sendMsg ( void ) ) );
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
updateItemStatic(); updateItemStatic();
updateItem(); updateItem();
updateAvatar(QString::fromStdString(mPeerId));
insertChat(message); insertChat(message);
} }
@ -84,8 +89,6 @@ void ChatMsgItem::updateItemStatic()
std::cerr << "ChatMsgItem::updateItemStatic()"; std::cerr << "ChatMsgItem::updateItemStatic()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
void ChatMsgItem::updateItem() void ChatMsgItem::updateItem()
@ -121,8 +124,6 @@ void ChatMsgItem::updateItem()
/* slow Tick */ /* slow Tick */
int msec_rate = 10129; int msec_rate = 10129;
loadAvatar();
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
return; return;
} }
@ -152,7 +153,6 @@ void ChatMsgItem::removeItem()
} }
} }
void ChatMsgItem::gotoHome() void ChatMsgItem::gotoHome()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
@ -198,15 +198,18 @@ 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; unsigned char *data = NULL;
int size = 0 ; int size = 0 ;
rsMsgs->getAvatarData(mPeerId,data,size); rsMsgs->getAvatarData(mPeerId,data,size);
if(size != 0) if(size != 0)
{ {
// set the image // set the image
@ -221,5 +224,3 @@ void ChatMsgItem::loadAvatar()
avatar_label->setPixmap(QPixmap(":/images/user/personal64.png")); avatar_label->setPixmap(QPixmap(":/images/user/personal64.png"));
} }
} }

View File

@ -40,8 +40,6 @@ public:
/** Default Destructor */ /** Default Destructor */
void updateItemStatic(); void updateItemStatic();
void loadAvatar();
private slots: private slots:
/* default stuff */ /* default stuff */
@ -52,6 +50,7 @@ private slots:
void openChat(); void openChat();
void updateItem(); void updateItem();
void updateAvatar(const QString &peer_id);
private: private:
void insertChat(std::string &message); void insertChat(std::string &message);

View File

@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout" name="gridLayout_1">
<property name="margin"> <property name="margin">
<number>6</number> <number>6</number>
</property> </property>

View File

@ -27,6 +27,8 @@
#include "../RsAutoUpdatePage.h" #include "../RsAutoUpdatePage.h"
#include "gui/msgs/MessageComposer.h" #include "gui/msgs/MessageComposer.h"
#include "gui/notifyqt.h"
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
@ -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( addButton, SIGNAL( clicked( void ) ), this, SLOT( addFriend ( void ) ) );
//connect( removeButton, SIGNAL( clicked( void ) ), this, SLOT( removeFriend ( void ) ) ); //connect( removeButton, SIGNAL( clicked( void ) ), this, SLOT( removeFriend ( void ) ) );
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
small(); small();
updateItemStatic(); updateItemStatic();
updateItem(); updateItem();
updateAvatar(QString::fromStdString(mPeerId));
} }
@ -212,13 +217,10 @@ void PeerItem::updateItem()
/* slow Tick */ /* slow Tick */
int msec_rate = 10129; int msec_rate = 10129;
loadAvatar();
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) )); QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
return; return;
} }
void PeerItem::small() void PeerItem::small()
{ {
expandFrame->hide(); 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; unsigned char *data = NULL;
int size = 0 ; int size = 0 ;

View File

@ -45,8 +45,6 @@ public:
void updateItemStatic(); void updateItemStatic();
void small(); void small();
void loadAvatar();
private slots: private slots:
/* default stuff */ /* default stuff */
@ -60,6 +58,7 @@ private slots:
void openChat(); void openChat();
void updateItem(); void updateItem();
void updateAvatar(const QString &peer_id);
private: private:
FeedHolder *mParent; FeedHolder *mParent;