Messenger Window linked with RsAutoupdate

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1855 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
nishant 2009-11-30 16:12:13 +00:00
parent b524a4cf86
commit d975d8bf1f
4 changed files with 35 additions and 13 deletions

View File

@ -123,7 +123,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
/* Create all the dialogs of which we only want one instance */ /* Create all the dialogs of which we only want one instance */
_bandwidthGraph = new BandwidthGraph(); _bandwidthGraph = new BandwidthGraph();
messengerWindow = new MessengerWindow();
/*messengerWindow instance is created statically so that RsAutoUpdatePage can access it*/
messengerWindow = MessengerWindow::getInstance();
applicationWindow = new ApplicationWindow(); applicationWindow = new ApplicationWindow();
applicationWindow->hide(); applicationWindow->hide();

View File

@ -70,7 +70,24 @@
/****** /******
* #define MSG_DEBUG 1 * #define MSG_DEBUG 1
*****/ *****/
MessengerWindow* MessengerWindow::mv = 0;
MessengerWindow* MessengerWindow::getInstance()
{
if(mv == 0)
{
mv = new MessengerWindow();
}
return mv;
}
void MessengerWindow::releaseInstance()
{
if(mv != 0)
{
delete mv;
}
}
/** Constructor */ /** Constructor */
MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags) MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
@ -115,7 +132,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
ui.searchlineEdit->setMinimumWidth(20); ui.searchlineEdit->setMinimumWidth(20);
updateAvatar(); updateAvatar();
insertPeers();
itemFont = QFont("ARIAL", 10); itemFont = QFont("ARIAL", 10);
itemFont.setBold(true); itemFont.setBold(true);
@ -175,13 +192,12 @@ void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point )
contextMnu.exec( mevent->globalPos() ); contextMnu.exec( mevent->globalPos() );
} }
/* get the list of peers from the RsIface. */ /* get the list of peers from the RsIface. */
void MessengerWindow::insertPeers() void MessengerWindow::insertPeers()
{ {
if (!rsPeers) if (!rsPeers)
{ {
/* not ready yet! */ /* not ready yet! */
return; return;
} }
@ -200,7 +216,6 @@ void MessengerWindow::insertPeers()
for(it = peers.begin(); it != peers.end(); it++) for(it = peers.begin(); it != peers.end(); it++)
{ {
RsPeerDetails details; RsPeerDetails details;
if (!rsPeers->getPeerDetails(*it, details)) if (!rsPeers->getPeerDetails(*it, details))
{ {
@ -274,7 +289,6 @@ void MessengerWindow::insertPeers()
peerWidget->update(); /* update display */ peerWidget->update(); /* update display */
} }
/* Utility Fns */ /* Utility Fns */
std::string getMessengerPeerRsCertId(QTreeWidgetItem *i) std::string getMessengerPeerRsCertId(QTreeWidgetItem *i)
{ {

View File

@ -38,16 +38,16 @@ class MessengerWindow : public RWindow
Q_OBJECT Q_OBJECT
public: public:
/** Default Constructor */
MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
void setChatDialog(PeersDialog *cd); void setChatDialog(PeersDialog *cd);
NetworkDialog *networkDialog2; NetworkDialog *networkDialog2;
QPixmap picture; QPixmap picture;
static MessengerWindow* getInstance();
static void releaseInstance();
public slots: public slots:
void insertPeers(); void insertPeers();
@ -58,6 +58,9 @@ public slots:
protected: protected:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
/** Default Constructor */
MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
private slots: private slots:
@ -98,6 +101,7 @@ private slots:
private: private:
static MessengerWindow *mv;
/* Worker Functions */ /* Worker Functions */
/* (1) Update Display */ /* (1) Update Display */

View File

@ -1,6 +1,7 @@
#include <iostream> #include <iostream>
#include <QTimer> #include <QTimer>
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
#include "MessengerWindow.h"
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent) RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
: MainPage(parent) : MainPage(parent)
@ -25,7 +26,8 @@ void RsAutoUpdatePage::timerUpdate()
if(!isVisible()) if(!isVisible())
return ; return ;
updateDisplay() ; updateDisplay();
MessengerWindow::getInstance()->insertPeers();
update() ; // Qt flush update() ; // Qt flush
} }