mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 14:12:43 -04:00
GXS:
- added three new classes for automatic refresh of ui - RsGxsUpdateBroadcastBase - RsGxsUpdateBroadcastWidget - RsGxsUpdateBroadcastPage - prevent call to :singleShot on RsProtectedTimer - extend RsGxsUpdateBroadcast - added automatic refresh to Identity and Forums (except subscribe/unsubscribe) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6503 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
14890ef007
commit
621c8037bc
19 changed files with 551 additions and 255 deletions
|
@ -58,7 +58,6 @@
|
||||||
* Transformation Notes:
|
* Transformation Notes:
|
||||||
* there are still a couple of things that the new forums differ from Old version.
|
* there are still a couple of things that the new forums differ from Old version.
|
||||||
* these will need to be addressed in the future.
|
* these will need to be addressed in the future.
|
||||||
* -> Missing Messages are not handled yet.
|
|
||||||
* -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI.
|
* -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI.
|
||||||
* -> Need to handle IDs properly.
|
* -> Need to handle IDs properly.
|
||||||
* -> Popularity not handled in GXS yet.
|
* -> Popularity not handled in GXS yet.
|
||||||
|
@ -67,7 +66,7 @@
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||||
: RsAutoUpdatePage(1000,parent)
|
: RsGxsUpdateBroadcastPage(rsGxsForums, parent)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -111,11 +110,6 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
|
||||||
settingsChanged();
|
settingsChanged();
|
||||||
|
|
||||||
/* Hide platform specific features */
|
|
||||||
#ifdef Q_WS_WIN
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsForumsDialog::~GxsForumsDialog()
|
GxsForumsDialog::~GxsForumsDialog()
|
||||||
|
@ -135,12 +129,11 @@ void GxsForumsDialog::todo()
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, "Todo",
|
QMessageBox::information(this, "Todo",
|
||||||
"<b>Open points:</b><ul>"
|
"<b>Open points:</b><ul>"
|
||||||
"<li>Automatic update"
|
"<li>Automatic refresh after subscribe/unsubscibe"
|
||||||
"<li>Restore forum keys"
|
"<li>Restore forum keys"
|
||||||
"<li>Display AUTHD"
|
"<li>Display AUTHD"
|
||||||
"<li>Copy/navigate forum link"
|
"<li>Copy/navigate forum link"
|
||||||
"<li>Display count of unread messages"
|
"<li>Display count of unread messages"
|
||||||
"<li>Show missing messages"
|
|
||||||
"<li>Show/Edit forum details"
|
"<li>Show/Edit forum details"
|
||||||
"<li>Don't show own posts as unread"
|
"<li>Don't show own posts as unread"
|
||||||
"<li>Remove messages"
|
"<li>Remove messages"
|
||||||
|
@ -266,35 +259,10 @@ void GxsForumsDialog::restoreForumKeys(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumsDialog::updateDisplay()
|
void GxsForumsDialog::updateDisplay(bool /*initialFill*/)
|
||||||
{
|
{
|
||||||
std::list<std::string> forumIds;
|
/* Update forums list */
|
||||||
std::list<std::string>::iterator it;
|
|
||||||
if (!rsGxsForums)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO groupsChanged... HACK XXX.
|
|
||||||
if ((rsGxsForums->groupsChanged(forumIds)) || (rsGxsForums->updated()))
|
|
||||||
{
|
|
||||||
/* update Forums List */
|
|
||||||
insertForums();
|
insertForums();
|
||||||
|
|
||||||
it = std::find(forumIds.begin(), forumIds.end(), mCurrForumId);
|
|
||||||
if (it != forumIds.end())
|
|
||||||
{
|
|
||||||
/* update threads as well */
|
|
||||||
insertThreads();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The proper version (above) can be done with a data request -> TODO */
|
|
||||||
if (rsGxsForums->updated())
|
|
||||||
{
|
|
||||||
/* update Forums List */
|
|
||||||
insertForums();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK until update works.
|
// HACK until update works.
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include "mainpage.h"
|
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
#include "ui_GxsForumsDialog.h"
|
#include "ui_GxsForumsDialog.h"
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class RsGxsForumMsg;
|
||||||
class GxsForumThreadWidget;
|
class GxsForumThreadWidget;
|
||||||
class UIStateHelper;
|
class UIStateHelper;
|
||||||
|
|
||||||
class GxsForumsDialog : public RsAutoUpdatePage, public TokenResponse
|
class GxsForumsDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ public:
|
||||||
|
|
||||||
bool navigate(const std::string& forumId, const std::string& msgId);
|
bool navigate(const std::string& forumId, const std::string& msgId);
|
||||||
|
|
||||||
/* overloaded from RsAuthUpdatePage */
|
|
||||||
virtual void updateDisplay();
|
|
||||||
|
|
||||||
// Callback for all Loads.
|
// Callback for all Loads.
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void updateDisplay(bool initialFill);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void forceUpdateDisplay(); // TEMP HACK FN.
|
void forceUpdateDisplay(); // TEMP HACK FN.
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "IdDialog.h"
|
#include "IdDialog.h"
|
||||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
#include <util/RsProtectedTimer.h>
|
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
@ -63,7 +62,7 @@
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
IdDialog::IdDialog(QWidget *parent)
|
IdDialog::IdDialog(QWidget *parent)
|
||||||
: MainPage(parent)
|
: RsGxsUpdateBroadcastPage(rsIdentity, parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
@ -138,10 +137,6 @@ IdDialog::IdDialog(QWidget *parent)
|
||||||
/* Setup tree */
|
/* Setup tree */
|
||||||
ui.treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
ui.treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
QTimer *timer = new RsProtectedTimer(this);
|
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
|
||||||
timer->start(1000);
|
|
||||||
|
|
||||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||||
|
|
||||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||||
|
@ -152,7 +147,6 @@ void IdDialog::todo()
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, "Todo",
|
QMessageBox::information(this, "Todo",
|
||||||
"<b>Open points:</b><ul>"
|
"<b>Open points:</b><ul>"
|
||||||
"<li>Initial fill of data"
|
|
||||||
"<li>Delete ID"
|
"<li>Delete ID"
|
||||||
"<li>Edit ID"
|
"<li>Edit ID"
|
||||||
"<li>Reputation"
|
"<li>Reputation"
|
||||||
|
@ -511,16 +505,10 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||||
requestRepList(data.mMeta.mGroupId);
|
requestRepList(data.mMeta.mGroupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::checkUpdate()
|
void IdDialog::updateDisplay(bool /*initialFill*/)
|
||||||
{
|
{
|
||||||
/* update */
|
/* Update identity list */
|
||||||
if (!rsIdentity)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (rsIdentity->updated())
|
|
||||||
{
|
|
||||||
requestIdList();
|
requestIdList();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::addIdentity()
|
void IdDialog::addIdentity()
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#ifndef IDENTITYDIALOG_H
|
#ifndef IDENTITYDIALOG_H
|
||||||
#define IDENTITYDIALOG_H
|
#define IDENTITYDIALOG_H
|
||||||
|
|
||||||
#include "retroshare-gui/mainpage.h"
|
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||||
#include "ui_IdDialog.h"
|
#include "ui_IdDialog.h"
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
class UIStateHelper;
|
class UIStateHelper;
|
||||||
|
|
||||||
class IdDialog : public MainPage, public TokenResponse
|
class IdDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -45,11 +45,13 @@ public:
|
||||||
|
|
||||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void updateDisplay(bool initialFill);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void filterComboBoxChanged();
|
void filterComboBoxChanged();
|
||||||
void filterChanged(const QString &text);
|
void filterChanged(const QString &text);
|
||||||
|
|
||||||
void checkUpdate();
|
|
||||||
void addIdentity();
|
void addIdentity();
|
||||||
void editIdentity();
|
void editIdentity();
|
||||||
|
|
||||||
|
|
90
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp
Normal file
90
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "RsGxsUpdateBroadcastBase.h"
|
||||||
|
#include "RsAutoUpdatePage.h"
|
||||||
|
#include "util/RsGxsUpdateBroadcast.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl, QWidget *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
mUpdateWhenInvisible = false;
|
||||||
|
mFirstVisible = true;
|
||||||
|
|
||||||
|
mUpdateBroadcast = RsGxsUpdateBroadcast::get(ifaceImpl);
|
||||||
|
connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged()));
|
||||||
|
connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list<RsGxsGroupId>)), this, SLOT(updateBroadcastGrpsChanged(std::list<RsGxsGroupId>)));
|
||||||
|
connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)), this, SLOT(updateBroadcastMsgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)));
|
||||||
|
}
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastBase::securedUpdateDisplay()
|
||||||
|
{
|
||||||
|
if (RsAutoUpdatePage::eventsLocked()) {
|
||||||
|
/* Wait until events are not locked */
|
||||||
|
QTimer::singleShot(500, this, SLOT(securedUpdateDisplay()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit fillDisplay(mFirstVisible);
|
||||||
|
mFirstVisible = false;
|
||||||
|
|
||||||
|
/* Clear updated ids */
|
||||||
|
mGrpIds.clear();
|
||||||
|
mMsgIds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastBase::showEvent(QShowEvent */*event*/)
|
||||||
|
{
|
||||||
|
if (mFirstVisible) {
|
||||||
|
/* Initial fill */
|
||||||
|
securedUpdateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mUpdateWhenInvisible) {
|
||||||
|
if (!mGrpIds.empty() || !mMsgIds.empty()) {
|
||||||
|
securedUpdateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastBase::updateBroadcastChanged()
|
||||||
|
{
|
||||||
|
QWidget *widget = qobject_cast<QWidget *>(parent());
|
||||||
|
|
||||||
|
/* Update only update when the widget is visible. */
|
||||||
|
if (mUpdateWhenInvisible || !widget || widget->isVisible()) {
|
||||||
|
securedUpdateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastBase::updateBroadcastGrpsChanged(const std::list<RsGxsGroupId> &grpIds)
|
||||||
|
{
|
||||||
|
std::list<RsGxsGroupId>::const_iterator it;
|
||||||
|
for (it = grpIds.begin(); it != grpIds.end(); ++it) {
|
||||||
|
if (std::find(mGrpIds.begin(), mGrpIds.end(), *it) == mGrpIds.end()) {
|
||||||
|
mGrpIds.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
|
||||||
|
{
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
|
||||||
|
for (mapIt = msgIds.begin(); mapIt != msgIds.end(); ++mapIt) {
|
||||||
|
const RsGxsGroupId &grpId = mapIt->first;
|
||||||
|
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||||
|
std::vector<RsGxsMessageId> &destMsgIds = mMsgIds[grpId];
|
||||||
|
|
||||||
|
std::vector<RsGxsMessageId>::const_iterator msgIt;
|
||||||
|
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
|
||||||
|
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
|
||||||
|
destMsgIds.push_back(*msgIt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h
Normal file
42
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
|
|
||||||
|
class QShowEvent;
|
||||||
|
class RsGxsIfaceHelper;
|
||||||
|
class RsGxsUpdateBroadcast;
|
||||||
|
|
||||||
|
class RsGxsUpdateBroadcastBase : public QObject
|
||||||
|
{
|
||||||
|
friend class RsGxsUpdateBroadcastPage;
|
||||||
|
friend class RsGxsUpdateBroadcastWidget;
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RsGxsUpdateBroadcastBase(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL);
|
||||||
|
virtual ~RsGxsUpdateBroadcastBase();
|
||||||
|
|
||||||
|
void setUpdateWhenInvisible(bool update) { mUpdateWhenInvisible = update; }
|
||||||
|
std::list<RsGxsGroupId> &getGrpIds() { return mGrpIds; }
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds() { return mMsgIds; }
|
||||||
|
|
||||||
|
void showEvent(QShowEvent *e);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fillDisplay(bool initialFill);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateBroadcastChanged();
|
||||||
|
void updateBroadcastGrpsChanged(const std::list<RsGxsGroupId>& grpIds);
|
||||||
|
void updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
|
||||||
|
void securedUpdateDisplay();
|
||||||
|
|
||||||
|
private:
|
||||||
|
RsGxsUpdateBroadcast *mUpdateBroadcast;
|
||||||
|
bool mFirstVisible;
|
||||||
|
bool mUpdateWhenInvisible; // Update also when not visible
|
||||||
|
std::list<RsGxsGroupId> mGrpIds;
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgIds;
|
||||||
|
};
|
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp
Normal file
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include "RsGxsUpdateBroadcastPage.h"
|
||||||
|
#include "RsGxsUpdateBroadcastBase.h"
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcastPage::RsGxsUpdateBroadcastPage(RsGxsIfaceHelper *ifaceImpl, QWidget *parent, Qt::WindowFlags flags)
|
||||||
|
: MainPage(parent, flags)
|
||||||
|
{
|
||||||
|
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this);
|
||||||
|
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcastPage::~RsGxsUpdateBroadcastPage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update)
|
||||||
|
{
|
||||||
|
mBase->setUpdateWhenInvisible(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIds()
|
||||||
|
{
|
||||||
|
return mBase->getGrpIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastPage::getMsgIds()
|
||||||
|
{
|
||||||
|
return mBase->getMsgIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastPage::fillDisplay(bool initialFill)
|
||||||
|
{
|
||||||
|
updateDisplay(initialFill);
|
||||||
|
update(); // Qt flush
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastPage::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
mBase->showEvent(event);
|
||||||
|
MainPage::showEvent(event);
|
||||||
|
}
|
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h
Normal file
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mainpage.h"
|
||||||
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
|
|
||||||
|
// This class implement a basic RS functionality which is that widgets displaying info
|
||||||
|
// should update regularly. They also should update only when visible, to save CPU time.
|
||||||
|
//
|
||||||
|
// Using this class simply needs to derive your widget from RsGxsUpdateBroadcastPage
|
||||||
|
// and oveload the updateDisplay() function with the actual code that updates the
|
||||||
|
// widget.
|
||||||
|
//
|
||||||
|
|
||||||
|
class RsGxsIfaceHelper;
|
||||||
|
class RsGxsUpdateBroadcastBase;
|
||||||
|
|
||||||
|
class RsGxsUpdateBroadcastPage : public MainPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RsGxsUpdateBroadcastPage(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = 0);
|
||||||
|
virtual ~RsGxsUpdateBroadcastPage();
|
||||||
|
|
||||||
|
void setUpdateWhenInvisible(bool update);
|
||||||
|
std::list<RsGxsGroupId> &getGrpIds();
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
|
||||||
|
// This is overloaded in subclasses.
|
||||||
|
virtual void updateDisplay(bool initialFill) = 0;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void fillDisplay(bool initialFill);
|
||||||
|
|
||||||
|
private:
|
||||||
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
|
};
|
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp
Normal file
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include "RsGxsUpdateBroadcastWidget.h"
|
||||||
|
#include "RsGxsUpdateBroadcastBase.h"
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcastWidget::RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent, Qt::WindowFlags flags)
|
||||||
|
: QWidget(parent, flags)
|
||||||
|
{
|
||||||
|
mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this);
|
||||||
|
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastWidget::setUpdateWhenInvisible(bool update)
|
||||||
|
{
|
||||||
|
mBase->setUpdateWhenInvisible(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIds()
|
||||||
|
{
|
||||||
|
return mBase->getGrpIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIds()
|
||||||
|
{
|
||||||
|
return mBase->getMsgIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastWidget::fillDisplay(bool initialFill)
|
||||||
|
{
|
||||||
|
updateDisplay(initialFill);
|
||||||
|
update(); // Qt flush
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsGxsUpdateBroadcastWidget::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
mBase->showEvent(event);
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
}
|
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h
Normal file
40
retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
|
|
||||||
|
// This class implement a basic RS functionality which is that widgets displaying info
|
||||||
|
// should update regularly. They also should update only when visible, to save CPU time.
|
||||||
|
//
|
||||||
|
// Using this class simply needs to derive your widget from RsGxsUpdateBroadcastWidget
|
||||||
|
// and oveload the updateDisplay() function with the actual code that updates the
|
||||||
|
// widget.
|
||||||
|
//
|
||||||
|
|
||||||
|
class RsGxsIfaceHelper;
|
||||||
|
class RsGxsUpdateBroadcastBase;
|
||||||
|
|
||||||
|
class RsGxsUpdateBroadcastWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = 0);
|
||||||
|
virtual ~RsGxsUpdateBroadcastWidget();
|
||||||
|
|
||||||
|
void setUpdateWhenInvisible(bool update);
|
||||||
|
std::list<RsGxsGroupId> &getGrpIds();
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
|
||||||
|
// This is overloaded in subclasses.
|
||||||
|
virtual void updateDisplay(bool initialFill) = 0;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void fillDisplay(bool initialFill);
|
||||||
|
|
||||||
|
private:
|
||||||
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
|
};
|
|
@ -86,7 +86,7 @@
|
||||||
#define TOKEN_TYPE_REPLY_MESSAGE 3
|
#define TOKEN_TYPE_REPLY_MESSAGE 3
|
||||||
|
|
||||||
GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *parent) :
|
GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *parent) :
|
||||||
QWidget(parent),
|
RsGxsUpdateBroadcastWidget(rsGxsForums, parent),
|
||||||
ui(new Ui::GxsForumThreadWidget)
|
ui(new Ui::GxsForumThreadWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -94,6 +94,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
mStateHelper = new UIStateHelper(this);
|
mStateHelper = new UIStateHelper(this);
|
||||||
|
|
||||||
|
setUpdateWhenInvisible(true);
|
||||||
|
|
||||||
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||||
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->progressText, UISTATE_LOADING_VISIBLE);
|
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->progressText, UISTATE_LOADING_VISIBLE);
|
||||||
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->newthreadButton);
|
mStateHelper->addWidget(TOKEN_TYPE_CURRENTFORUM, ui->newthreadButton);
|
||||||
|
@ -141,9 +143,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *
|
||||||
connect(ui->nextUnreadButton, SIGNAL(clicked()), this, SLOT(nextUnreadMessage()));
|
connect(ui->nextUnreadButton, SIGNAL(clicked()), this, SLOT(nextUnreadMessage()));
|
||||||
connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles()));
|
connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles()));
|
||||||
|
|
||||||
// HACK - TEMPORARY HIJACKING THIS BUTTON FOR REFRESH.
|
|
||||||
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(forceUpdateDisplay()));
|
|
||||||
|
|
||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
|
connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
|
||||||
|
|
||||||
|
@ -299,7 +298,7 @@ QIcon GxsForumThreadWidget::forumIcon()
|
||||||
|
|
||||||
void GxsForumThreadWidget::changeEvent(QEvent *e)
|
void GxsForumThreadWidget::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
QWidget::changeEvent(e);
|
RsGxsUpdateBroadcastWidget::changeEvent(e);
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::StyleChange:
|
case QEvent::StyleChange:
|
||||||
calculateIconsAndFonts();
|
calculateIconsAndFonts();
|
||||||
|
@ -310,38 +309,25 @@ void GxsForumThreadWidget::changeEvent(QEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
void GxsForumThreadWidget::updateDisplay(bool initialFill)
|
||||||
void GxsForumThreadWidget::updateDisplay()
|
|
||||||
{
|
{
|
||||||
std::list<std::string> forumIds;
|
if (initialFill) {
|
||||||
std::list<std::string>::iterator it;
|
/* Not needed */
|
||||||
if (!rsGxsForums)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
std::list<RsGxsGroupId> &grpIds = getGrpIds();
|
||||||
// TODO groupsChanged... HACK XXX.
|
if (std::find(grpIds.begin(), grpIds.end(), mForumId) != grpIds.end()) {
|
||||||
if ((rsGxsForums->groupsChanged(forumIds)) || (rsGxsForums->updated()))
|
/* Update threads */
|
||||||
{
|
insertThreads();
|
||||||
/* update Forums List */
|
} else {
|
||||||
insertForums();
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds = getMsgIds();
|
||||||
|
if (msgIds.find(mForumId) != msgIds.end()) {
|
||||||
it = std::find(forumIds.begin(), forumIds.end(), mCurrForumId);
|
/* Update threads */
|
||||||
if (it != forumIds.end())
|
|
||||||
{
|
|
||||||
/* update threads as well */
|
|
||||||
insertThreads();
|
insertThreads();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The proper version (above) can be done with a data request -> TODO */
|
|
||||||
if (rsGxsForums->updated())
|
|
||||||
{
|
|
||||||
/* update Forums List */
|
|
||||||
insertThreads();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +439,7 @@ bool GxsForumThreadWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// pass the event on to the parent class
|
// pass the event on to the parent class
|
||||||
return QWidget::eventFilter(obj, event);
|
return RsGxsUpdateBroadcastWidget::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::togglethreadview()
|
void GxsForumThreadWidget::togglethreadview()
|
||||||
|
@ -786,16 +772,6 @@ void GxsForumThreadWidget::fillThreadStatus(QString text)
|
||||||
ui->progressText->setText(text);
|
ui->progressText->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK until update works.
|
|
||||||
void GxsForumThreadWidget::forceUpdateDisplay()
|
|
||||||
{
|
|
||||||
std::cerr << "GxsForumThreadWidget::forceUpdateDisplay()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
/* update Thread List */
|
|
||||||
insertThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
|
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
|
||||||
{
|
{
|
||||||
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
|
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#ifndef GXSFORUMTHREADWIDGET_H
|
#ifndef GXSFORUMTHREADWIDGET_H
|
||||||
#define GXSFORUMTHREADWIDGET_H
|
#define GXSFORUMTHREADWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include "gui/gxs/RsGxsUpdateBroadcastWidget.h"
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
@ -15,7 +14,7 @@ namespace Ui {
|
||||||
class GxsForumThreadWidget;
|
class GxsForumThreadWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GxsForumThreadWidget : public QWidget, public TokenResponse
|
class GxsForumThreadWidget : public RsGxsUpdateBroadcastWidget, public TokenResponse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -62,12 +61,9 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
virtual void updateDisplay(bool initialFill);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void forceUpdateDisplay(); // TEMP HACK FN.
|
|
||||||
|
|
||||||
// void updateDisplay();
|
|
||||||
|
|
||||||
/** Create the context popup menu and it's submenus */
|
/** Create the context popup menu and it's submenus */
|
||||||
void threadListCustomPopupMenu(QPoint point);
|
void threadListCustomPopupMenu(QPoint point);
|
||||||
|
|
||||||
|
@ -143,7 +139,6 @@ private:
|
||||||
int mLastViewType;
|
int mLastViewType;
|
||||||
RSTreeWidgetItemCompareRole *mThreadCompareRole;
|
RSTreeWidgetItemCompareRole *mThreadCompareRole;
|
||||||
TokenQueue *mThreadQueue;
|
TokenQueue *mThreadQueue;
|
||||||
// QTimer *mTimer;
|
|
||||||
GxsForumsFillThread *mFillThread;
|
GxsForumsFillThread *mFillThread;
|
||||||
unsigned int mUnreadCount;
|
unsigned int mUnreadCount;
|
||||||
unsigned int mNewCount;
|
unsigned int mNewCount;
|
||||||
|
|
|
@ -268,6 +268,31 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="postLayout">
|
<layout class="QGridLayout" name="postLayout">
|
||||||
|
<item row="0" column="7">
|
||||||
|
<widget class="QLabel" name="time_label">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="11">
|
||||||
|
<widget class="QPushButton" name="nextUnreadButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Next unread</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QToolButton" name="newmessageButton">
|
<widget class="QToolButton" name="newmessageButton">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
|
@ -291,47 +316,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QPushButton" name="previousButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>24</width>
|
|
||||||
<height>24</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>24</width>
|
|
||||||
<height>24</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Previous Thread</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/back.png</normaloff>:/images/back.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="4">
|
<item row="0" column="4">
|
||||||
<widget class="QPushButton" name="nextButton">
|
<widget class="QPushButton" name="nextButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
|
@ -373,6 +357,32 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="13">
|
||||||
|
<widget class="QPushButton" name="expandButton">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="0" column="5">
|
||||||
<widget class="QToolButton" name="downloadButton">
|
<widget class="QToolButton" name="downloadButton">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
|
@ -403,15 +413,10 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="7">
|
<item row="0" column="8">
|
||||||
<widget class="QLabel" name="time_label">
|
<widget class="Line" name="line">
|
||||||
<property name="font">
|
<property name="orientation">
|
||||||
<font>
|
<enum>Qt::Vertical</enum>
|
||||||
<pointsize>10</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -440,21 +445,23 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="12">
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="nextUnreadButton">
|
<widget class="QPushButton" name="previousButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="minimumSize">
|
||||||
<string>Next unread</string>
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="14">
|
|
||||||
<widget class="QPushButton" name="expandButton">
|
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>24</width>
|
||||||
|
@ -464,33 +471,19 @@
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Previous Thread</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc">
|
<iconset resource="../images.qrc">
|
||||||
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
|
<normaloff>:/images/back.png</normaloff>:/images/back.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="8">
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="11">
|
|
||||||
<widget class="QPushButton" name="refreshButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "gui/SoundManager.h"
|
#include "gui/SoundManager.h"
|
||||||
#include "gui/NetworkView.h"
|
#include "gui/NetworkView.h"
|
||||||
#include "lang/languagesupport.h"
|
#include "lang/languagesupport.h"
|
||||||
|
#include "util/RsGxsUpdateBroadcast.h"
|
||||||
|
|
||||||
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
||||||
#include <gui/qskinobject/qskinobject.h>
|
#include <gui/qskinobject/qskinobject.h>
|
||||||
|
@ -374,6 +375,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
ChatDialog::cleanupChat();
|
ChatDialog::cleanupChat();
|
||||||
|
#ifdef RS_ENABLE_GXS
|
||||||
|
RsGxsUpdateBroadcast::cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
rsicontrol->rsGlobalShutDown();
|
rsicontrol->rsGlobalShutDown();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ gxs {
|
||||||
# thewire is incomplete - dont enable
|
# thewire is incomplete - dont enable
|
||||||
#CONFIG += thewire
|
#CONFIG += thewire
|
||||||
#CONFIG += photoshare
|
#CONFIG += photoshare
|
||||||
|
|
||||||
|
DEFINES += RS_ENABLE_GXS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -624,6 +626,7 @@ SOURCES += main.cpp \
|
||||||
gui/HelpDialog.cpp \
|
gui/HelpDialog.cpp \
|
||||||
gui/LogoBar.cpp \
|
gui/LogoBar.cpp \
|
||||||
lang/languagesupport.cpp \
|
lang/languagesupport.cpp \
|
||||||
|
util/RsProtectedTimer.cpp \
|
||||||
util/stringutil.cpp \
|
util/stringutil.cpp \
|
||||||
util/DateTime.cpp \
|
util/DateTime.cpp \
|
||||||
util/win32.cpp \
|
util/win32.cpp \
|
||||||
|
@ -1132,7 +1135,11 @@ gxsgui {
|
||||||
gui/gxs/GxsCommentDialog.h \
|
gui/gxs/GxsCommentDialog.h \
|
||||||
gui/gxs/GxsCreateCommentDialog.h \
|
gui/gxs/GxsCreateCommentDialog.h \
|
||||||
gui/gxs/GxsFeedItem.h \
|
gui/gxs/GxsFeedItem.h \
|
||||||
|
gui/gxs/RsGxsUpdateBroadcastBase.h \
|
||||||
|
gui/gxs/RsGxsUpdateBroadcastWidget.h \
|
||||||
|
gui/gxs/RsGxsUpdateBroadcastPage.h \
|
||||||
util/TokenQueue.h \
|
util/TokenQueue.h \
|
||||||
|
util/RsGxsUpdateBroadcast.h \
|
||||||
|
|
||||||
# gui/gxs/GxsMsgDialog.h \
|
# gui/gxs/GxsMsgDialog.h \
|
||||||
|
|
||||||
|
@ -1156,7 +1163,11 @@ gxsgui {
|
||||||
gui/gxs/GxsCommentDialog.cpp \
|
gui/gxs/GxsCommentDialog.cpp \
|
||||||
gui/gxs/GxsCreateCommentDialog.cpp \
|
gui/gxs/GxsCreateCommentDialog.cpp \
|
||||||
gui/gxs/GxsFeedItem.cpp \
|
gui/gxs/GxsFeedItem.cpp \
|
||||||
|
gui/gxs/RsGxsUpdateBroadcastBase.cpp \
|
||||||
|
gui/gxs/RsGxsUpdateBroadcastWidget.cpp \
|
||||||
|
gui/gxs/RsGxsUpdateBroadcastPage.cpp \
|
||||||
util/TokenQueue.cpp \
|
util/TokenQueue.cpp \
|
||||||
|
util/RsGxsUpdateBroadcast.cpp \
|
||||||
|
|
||||||
# gui/gxs/GxsMsgDialog.cpp \
|
# gui/gxs/GxsMsgDialog.cpp \
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,67 @@
|
||||||
#include <QTimer>
|
//#include <QTimer>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
#include "RsGxsUpdateBroadcast.h"
|
#include "RsGxsUpdateBroadcast.h"
|
||||||
|
#include "RsProtectedTimer.h"
|
||||||
|
|
||||||
|
#include <retroshare/rsgxsifacehelper.h>
|
||||||
|
|
||||||
RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl, float dt, QObject *parent) :
|
QMap<RsGxsIfaceHelper*, RsGxsUpdateBroadcast*> updateBroadcastMap;
|
||||||
QObject(parent), mIfaceImpl(ifaceImpl), mDt(dt)
|
|
||||||
|
RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) :
|
||||||
|
QObject(NULL), mIfaceImpl(ifaceImpl)
|
||||||
{
|
{
|
||||||
|
mTimer = new RsProtectedTimer(this);
|
||||||
|
mTimer->setInterval(1000);
|
||||||
|
mTimer->setSingleShot(true);
|
||||||
|
connect(mTimer, SIGNAL(timeout()), this, SLOT(poll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsUpdateBroadcast::startMonitor()
|
void RsGxsUpdateBroadcast::cleanup()
|
||||||
{
|
{
|
||||||
slowPoll();
|
QMap<RsGxsIfaceHelper*, RsGxsUpdateBroadcast*>::iterator it;
|
||||||
|
for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) {
|
||||||
|
delete(it.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBroadcastMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl)
|
||||||
void RsGxsUpdateBroadcast::fastPoll()
|
|
||||||
{
|
{
|
||||||
|
QMap<RsGxsIfaceHelper*, RsGxsUpdateBroadcast*>::iterator it = updateBroadcastMap.find(ifaceImpl);
|
||||||
|
if (it != updateBroadcastMap.end()) {
|
||||||
|
return it.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl);
|
||||||
|
updateBroadcastMap.insert(ifaceImpl, updateBroadcast);
|
||||||
|
updateBroadcast->poll();
|
||||||
|
|
||||||
|
return updateBroadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsUpdateBroadcast::slowPoll()
|
void RsGxsUpdateBroadcast::poll()
|
||||||
{
|
{
|
||||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
||||||
std::list<RsGxsGroupId> grps;
|
std::list<RsGxsGroupId> grps;
|
||||||
|
|
||||||
if(mIfaceImpl->updated())
|
if (mIfaceImpl->updated(true, true))
|
||||||
{
|
{
|
||||||
mIfaceImpl->msgsChanged(msgs);
|
mIfaceImpl->msgsChanged(msgs);
|
||||||
if(!msgs.empty())
|
if (!msgs.empty())
|
||||||
{
|
{
|
||||||
emit msgsChanged(msgs);
|
emit msgsChanged(msgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
mIfaceImpl->groupsChanged(grps);
|
mIfaceImpl->groupsChanged(grps);
|
||||||
|
if (!grps.empty())
|
||||||
if(!grps.empty())
|
|
||||||
{
|
{
|
||||||
emit grpsChanged(grps);
|
emit grpsChanged(grps);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot((int) (mDt * 1000.0), this, SLOT(slowPoll()));
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mTimer->start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,31 +3,34 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <retroshare/rsgxsifacehelper.h>
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
|
|
||||||
|
class RsGxsIfaceHelper;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class RsGxsUpdateBroadcast : public QObject
|
class RsGxsUpdateBroadcast : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
explicit RsGxsUpdateBroadcast(RsGxsIfaceHelper* ifaceImpl, float dt, QObject *parent = 0);
|
|
||||||
|
|
||||||
void startMonitor();
|
public:
|
||||||
void update();
|
static void cleanup();
|
||||||
|
|
||||||
|
static RsGxsUpdateBroadcast *get(RsGxsIfaceHelper* ifaceImpl);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void changed();
|
||||||
void msgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > & msgIds);
|
void msgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
|
||||||
void grpsChanged(const std::list<RsGxsGroupId>& grpIds);
|
void grpsChanged(const std::list<RsGxsGroupId>& grpIds);
|
||||||
|
|
||||||
public slots:
|
private slots:
|
||||||
|
void poll();
|
||||||
void fastPoll();
|
|
||||||
void slowPoll();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit RsGxsUpdateBroadcast(RsGxsIfaceHelper* ifaceImpl);
|
||||||
|
|
||||||
|
private:
|
||||||
RsGxsIfaceHelper* mIfaceImpl;
|
RsGxsIfaceHelper* mIfaceImpl;
|
||||||
float mDt;
|
QTimer *mTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGXSUPDATEBROADCAST_H
|
#endif // RSGXSUPDATEBROADCAST_H
|
||||||
|
|
59
retroshare-gui/src/util/RsProtectedTimer.cpp
Normal file
59
retroshare-gui/src/util/RsProtectedTimer.cpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Cyril Soler
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "RsProtectedTimer.h"
|
||||||
|
|
||||||
|
//#define PROTECTED_TIMER_DEBUG
|
||||||
|
|
||||||
|
RsProtectedTimer::RsProtectedTimer(QObject *parent)
|
||||||
|
: QTimer(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsProtectedTimer::timerEvent(QTimerEvent *e)
|
||||||
|
{
|
||||||
|
if(RsAutoUpdatePage::eventsLocked())
|
||||||
|
{
|
||||||
|
#ifdef PROTECTED_TIMER_DEBUG
|
||||||
|
if (isSingleShot()) {
|
||||||
|
/* Singleshot timer will be stopped in QTimer::timerEvent */
|
||||||
|
std::cerr << "Singleshot timer is blocked!" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "Timer is blocked!" << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PROTECTED_TIMER_DEBUG
|
||||||
|
if (isSingleShot()) {
|
||||||
|
std::cerr << "Singleshot timer has passed protection." << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "Timer has passed protection." << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QTimer::timerEvent(e) ;
|
||||||
|
}
|
|
@ -22,33 +22,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#define PROTECTED_TIMER_DEBUG
|
class RsProtectedTimer : public QTimer
|
||||||
|
|
||||||
class RsProtectedTimer: public QTimer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsProtectedTimer(QObject *parent)
|
RsProtectedTimer(QObject *parent);
|
||||||
: QTimer(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void timerEvent(QTimerEvent *e)
|
protected:
|
||||||
{
|
virtual void timerEvent(QTimerEvent *e);
|
||||||
if(RsAutoUpdatePage::eventsLocked())
|
|
||||||
{
|
|
||||||
#ifdef PROTECTED_TIMER_DEBUG
|
|
||||||
std::cerr << "Timer is blocked!." << std::endl;
|
|
||||||
#endif
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROTECTED_TIMER_DEBUG
|
// do not use, please use setInterval, setSingleShot and connect signal timeout
|
||||||
std::cerr << "Timer has passed protection." << std::endl;
|
static void singleShot(int /*msec*/, QObject */*receiver*/, const char */*member*/) {}
|
||||||
#endif
|
|
||||||
QTimer::timerEvent(e) ;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue