From d975d8bf1feee0509b3199204fd64a81d97c90ff Mon Sep 17 00:00:00 2001 From: nishant Date: Mon, 30 Nov 2009 16:12:13 +0000 Subject: [PATCH] Messenger Window linked with RsAutoupdate git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1855 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 4 ++- retroshare-gui/src/gui/MessengerWindow.cpp | 28 +++++++++++++++------ retroshare-gui/src/gui/MessengerWindow.h | 10 +++++--- retroshare-gui/src/gui/RsAutoUpdatePage.cpp | 6 +++-- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index e6a30a0bc..66aaf676c 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -123,7 +123,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) /* Create all the dialogs of which we only want one instance */ _bandwidthGraph = new BandwidthGraph(); - messengerWindow = new MessengerWindow(); + + /*messengerWindow instance is created statically so that RsAutoUpdatePage can access it*/ + messengerWindow = MessengerWindow::getInstance(); applicationWindow = new ApplicationWindow(); applicationWindow->hide(); diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 20ee91102..411157a0d 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -70,7 +70,24 @@ /****** * #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 */ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags) @@ -115,7 +132,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags) ui.searchlineEdit->setMinimumWidth(20); updateAvatar(); - + insertPeers(); itemFont = QFont("ARIAL", 10); itemFont.setBold(true); @@ -175,13 +192,12 @@ void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point ) contextMnu.exec( mevent->globalPos() ); } - - /* get the list of peers from the RsIface. */ void MessengerWindow::insertPeers() { if (!rsPeers) { + /* not ready yet! */ return; } @@ -190,7 +206,7 @@ void MessengerWindow::insertPeers() std::list::iterator it; rsPeers->getFriendList(peers); - + /* get a link to the table */ QTreeWidget *peerWidget = ui.messengertreeWidget; @@ -200,13 +216,12 @@ void MessengerWindow::insertPeers() for(it = peers.begin(); it != peers.end(); it++) { - RsPeerDetails details; if (!rsPeers->getPeerDetails(*it, details)) { continue; /* BAD */ } - + /* make a widget per friend */ QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); @@ -274,7 +289,6 @@ void MessengerWindow::insertPeers() peerWidget->update(); /* update display */ } - /* Utility Fns */ std::string getMessengerPeerRsCertId(QTreeWidgetItem *i) { diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index e12d8942c..cb6af63cf 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -38,16 +38,16 @@ class MessengerWindow : public RWindow Q_OBJECT public: - /** Default Constructor */ - MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0); - /** Default Destructor */ void setChatDialog(PeersDialog *cd); + NetworkDialog *networkDialog2; QPixmap picture; + static MessengerWindow* getInstance(); + static void releaseInstance(); public slots: void insertPeers(); @@ -58,6 +58,9 @@ public slots: protected: void closeEvent (QCloseEvent * event); + /** Default Constructor */ + MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default Destructor */ private slots: @@ -98,6 +101,7 @@ private slots: private: + static MessengerWindow *mv; /* Worker Functions */ /* (1) Update Display */ diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp index 8a03282c4..d48d63317 100644 --- a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp +++ b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp @@ -1,6 +1,7 @@ #include #include #include "RsAutoUpdatePage.h" +#include "MessengerWindow.h" RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent) : MainPage(parent) @@ -24,8 +25,9 @@ void RsAutoUpdatePage::timerUpdate() // if(!isVisible()) return ; - - updateDisplay() ; + + updateDisplay(); + MessengerWindow::getInstance()->insertPeers(); update() ; // Qt flush }