- Added request of complete fill to update broadcast

- Added fill of new messages to GxsChannelPostsWidget instead of a complete refill
- Removed static html text from GxsCannelPostItem.ui

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7334 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-05-05 21:53:47 +00:00
parent 7634afe733
commit 306c8fe431
11 changed files with 185 additions and 53 deletions

View File

@ -11,15 +11,24 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<property name="margin">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
@ -81,11 +90,7 @@
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:11pt; font-weight:600; font-style:italic;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:normal; color:#656565;&quot;&gt;Channel Subject&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string notr="true">Channel Subject</string>
</property>
<property name="scaledContents">
<bool>false</bool>
@ -105,11 +110,7 @@ p, li { white-space: pre-wrap; }
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;DateTime&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string notr="true">DateTime</string>
</property>
</widget>
</item>
@ -132,11 +133,7 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;Short Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string notr="true">Short Description</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -457,7 +454,16 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -469,7 +475,16 @@ p, li { white-space: pre-wrap; }
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
@ -510,9 +525,6 @@ p, li { white-space: pre-wrap; }
</widget>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -39,6 +39,9 @@ public:
GxsFeedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, RsGxsIfaceHelper *iface, bool loadData);
virtual ~GxsFeedItem();
RsGxsGroupId groupId() { return mGroupId; }
RsGxsMessageId messageId() { return mMessageId; }
protected:
// generic Fns - to be overloaded.

View File

@ -739,7 +739,7 @@ void GxsGroupFrameDialog::acknowledgeSubscribeChange(const uint32_t &token)
RsGxsGroupId groupId;
mInterface->acknowledgeGrp(token, groupId);
requestGroupSummary();
fillComplete();
}
/*********************** **** **** **** ***********************/

View File

@ -10,7 +10,7 @@ RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl,
: QObject(parent)
{
mUpdateWhenInvisible = false;
mFirstVisible = true;
mFillComplete = true;
mUpdateBroadcast = RsGxsUpdateBroadcast::get(ifaceImpl);
connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged()));
@ -22,6 +22,13 @@ RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase()
{
}
void RsGxsUpdateBroadcastBase::fillComplete()
{
mFillComplete = true;
updateBroadcastChanged();
}
void RsGxsUpdateBroadcastBase::securedUpdateDisplay()
{
if (RsAutoUpdatePage::eventsLocked()) {
@ -30,8 +37,8 @@ void RsGxsUpdateBroadcastBase::securedUpdateDisplay()
return;
}
emit fillDisplay(mFirstVisible);
mFirstVisible = false;
emit fillDisplay(mFillComplete);
mFillComplete = false;
/* Clear updated ids */
mGrpIds.clear();
@ -40,7 +47,7 @@ void RsGxsUpdateBroadcastBase::securedUpdateDisplay()
void RsGxsUpdateBroadcastBase::showEvent(QShowEvent */*event*/)
{
if (mFirstVisible) {
if (mFillComplete) {
/* Initial fill */
securedUpdateDisplay();
}

View File

@ -18,7 +18,9 @@ protected:
RsGxsUpdateBroadcastBase(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL);
virtual ~RsGxsUpdateBroadcastBase();
void fillComplete();
void setUpdateWhenInvisible(bool update) { mUpdateWhenInvisible = update; }
std::list<RsGxsGroupId> &getGrpIds() { return mGrpIds; }
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds() { return mMsgIds; }
@ -35,7 +37,7 @@ private slots:
private:
RsGxsUpdateBroadcast *mUpdateBroadcast;
bool mFirstVisible;
bool mFillComplete;
bool mUpdateWhenInvisible; // Update also when not visible
std::list<RsGxsGroupId> mGrpIds;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgIds;

View File

@ -12,6 +12,11 @@ RsGxsUpdateBroadcastPage::~RsGxsUpdateBroadcastPage()
{
}
void RsGxsUpdateBroadcastPage::fillComplete()
{
mBase->fillComplete();
}
void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update)
{
mBase->setUpdateWhenInvisible(update);

View File

@ -22,6 +22,7 @@ public:
RsGxsUpdateBroadcastPage(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = 0);
virtual ~RsGxsUpdateBroadcastPage();
void fillComplete();
void setUpdateWhenInvisible(bool update);
std::list<RsGxsGroupId> &getGrpIds();
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();

View File

@ -12,6 +12,11 @@ RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget()
{
}
void RsGxsUpdateBroadcastWidget::fillComplete()
{
mBase->fillComplete();
}
void RsGxsUpdateBroadcastWidget::setUpdateWhenInvisible(bool update)
{
mBase->setUpdateWhenInvisible(update);

View File

@ -22,6 +22,7 @@ public:
RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = 0);
virtual ~RsGxsUpdateBroadcastWidget();
void fillComplete();
void setUpdateWhenInvisible(bool update);
std::list<RsGxsGroupId> &getGrpIds();
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();

View File

@ -25,16 +25,12 @@
#include "gui/gxschannels/CreateGxsChannelMsg.h"
#include "gui/common/UIStateHelper.h"
#include <algorithm>
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
#define WARNING_LIMIT 3600*24*2
/* Images for TreeWidget */
#define IMAGE_CHANNELBLUE ":/images/channelsblue.png"
#define IMAGE_CHANNELGREEN ":/images/channelsgreen.png"
#define IMAGE_CHANNELRED ":/images/channelsred.png"
#define IMAGE_CHANNELYELLOW ":/images/channelsyellow.png"
/****
* #define DEBUG_CHANNEL
***/
@ -44,6 +40,7 @@
#define TOKEN_TYPE_MESSAGE_CHANGE 4
#define TOKEN_TYPE_GROUP_DATA 6
#define TOKEN_TYPE_POSTS 7
#define TOKEN_TYPE_RELATEDPOSTS 8
/** Constructor */
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent)
@ -56,7 +53,8 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
/* Setup UI helper */
mStateHelper = new UIStateHelper(this);
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressBar, UISTATE_LOADING_VISIBLE);
// No progress yet
// mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressBar, UISTATE_LOADING_VISIBLE);
mStateHelper->addWidget(TOKEN_TYPE_POSTS, ui->progressLabel, UISTATE_LOADING_VISIBLE);
mStateHelper->addLoadPlaceholder(TOKEN_TYPE_GROUP_DATA, ui->nameLabel);
@ -92,13 +90,17 @@ GxsChannelPostsWidget::~GxsChannelPostsWidget()
void GxsChannelPostsWidget::updateDisplay(bool complete)
{
if (complete) {
/* Not needed */
/* Fill complete */
requestGroupData(mChannelId);
requestPosts(mChannelId);
return;
}
std::list<RsGxsGroupId> &grpIds = getGrpIds();
if (!mChannelId.isNull() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) {
requestGroupData(mChannelId);
/* Do we need to fill all posts? */
requestPosts(mChannelId);
} else {
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs = getMsgIds();
if (!msgs.empty())
@ -106,7 +108,7 @@ void GxsChannelPostsWidget::updateDisplay(bool complete)
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit = msgs.find(mChannelId);
if(mit != msgs.end())
{
requestPosts(mChannelId);
requestRelatedPosts(mChannelId, mit->second);
}
}
}
@ -143,7 +145,7 @@ void GxsChannelPostsWidget::setGroupId(const RsGxsGroupId &groupId)
emit groupChanged(this);
requestGroupData(mChannelId);
fillComplete();
}
QString GxsChannelPostsWidget::groupName(bool withUnreadCount)
@ -238,24 +240,55 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
setAutoDownloadButton(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED);
emit groupChanged(this);
requestPosts(mChannelId);
}
void GxsChannelPostsWidget::insertChannelPosts(const std::vector<RsGxsChannelPost> &posts)
static bool sortChannelMsgSummaryAsc(const RsGxsChannelPost &msg1, const RsGxsChannelPost &msg2)
{
return (msg1.mMeta.mPublishTs > msg2.mMeta.mPublishTs);
}
static bool sortChannelMsgSummaryDesc(const RsGxsChannelPost &msg1, const RsGxsChannelPost &msg2)
{
return (msg1.mMeta.mPublishTs < msg2.mMeta.mPublishTs);
}
void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &posts, bool related)
{
std::vector<RsGxsChannelPost>::const_iterator it;
// Do these need sorting? probably.
// can we add that into the request?
//msgs.sort(sortChannelMsgSummary);
if (related) {
/* Sort descending to add posts at top */
std::sort(posts.begin(), posts.end(), sortChannelMsgSummaryDesc);
} else {
std::sort(posts.begin(), posts.end(), sortChannelMsgSummaryAsc);
}
uint32_t subscribeFlags = 0xffffffff;
for (it = posts.begin(); it != posts.end(); it++)
{
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true);
mChannelPostItems.push_back(item);
ui->verticalLayout->addWidget(item);
GxsChannelPostItem *item = NULL;
if (related) {
foreach (GxsChannelPostItem *loopItem, mChannelPostItems) {
if (loopItem->messageId() == it->mMeta.mMsgId) {
item = loopItem;
break;
}
}
}
if (item) {
//TODO: Update item
} else {
item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true);
mChannelPostItems.push_back(item);
if (related) {
ui->verticalLayout->insertWidget(0, item);
} else {
ui->verticalLayout->addWidget(item);
}
}
}
}
@ -448,6 +481,16 @@ void GxsChannelPostsWidget::setAutoDownloadButton(bool autoDl)
}
}
void GxsChannelPostsWidget::clearPosts()
{
/* replace all the messages with new ones */
QList<GxsChannelPostItem *>::iterator mit;
for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) {
delete (*mit);
}
mChannelPostItems.clear();
}
/**********************************************************************************************
* New Stuff here.
*************/
@ -526,12 +569,8 @@ void GxsChannelPostsWidget::requestPosts(const RsGxsGroupId &grpId)
std::cerr << std::endl;
#endif
/* replace all the messages with new ones */
QList<GxsChannelPostItem *>::iterator mit;
for (mit = mChannelPostItems.begin(); mit != mChannelPostItems.end(); mit++) {
delete (*mit);
}
mChannelPostItems.clear();
/* Request all posts */
clearPosts();
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTS);
@ -566,7 +605,57 @@ void GxsChannelPostsWidget::loadPosts(const uint32_t &token)
mStateHelper->setActive(TOKEN_TYPE_POSTS, true);
insertChannelPosts(posts);
insertChannelPosts(posts, false);
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
}
void GxsChannelPostsWidget::requestRelatedPosts(const RsGxsGroupId &grpId, const std::vector<RsGxsMessageId> &msgIds)
{
#ifdef DEBUG_CHANNEL
std::cerr << "GxsChannelPostsWidget::requestRelatedPosts()";
std::cerr << std::endl;
#endif
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_RELATEDPOSTS);
if (grpId.isNull()) {
mStateHelper->setActive(TOKEN_TYPE_POSTS, false);
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
mStateHelper->clear(TOKEN_TYPE_POSTS);
return;
}
mStateHelper->setLoading(TOKEN_TYPE_POSTS, true);
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(grpId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
uint32_t token;
std::vector<RsGxsGrpMsgIdPair> relatedMsgIds;
for (std::vector<RsGxsMessageId>::const_iterator msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
relatedMsgIds.push_back(RsGxsGrpMsgIdPair(grpId, *msgIt));
}
mChannelQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, relatedMsgIds, TOKEN_TYPE_RELATEDPOSTS);
}
void GxsChannelPostsWidget::loadRelatedPosts(const uint32_t &token)
{
#ifdef DEBUG_CHANNEL
std::cerr << "GxsChannelPostsWidget::loadRelatedPosts()";
std::cerr << std::endl;
#endif
std::vector<RsGxsChannelPost> posts;
rsGxsChannels->getRelatedPosts(token, posts);
mStateHelper->setActive(TOKEN_TYPE_POSTS, true);
insertChannelPosts(posts, true);
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
}
@ -607,6 +696,9 @@ void GxsChannelPostsWidget::loadRequest(const TokenQueue *queue, const TokenRequ
case TOKEN_TYPE_POSTS:
loadPosts(req.mToken);
break;
case TOKEN_TYPE_RELATEDPOSTS:
loadRelatedPosts(req.mToken);
break;
default:
std::cerr << "GxsChannelPostsWidget::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;

View File

@ -82,6 +82,7 @@ private:
void processSettings(bool load);
void setAutoDownloadButton(bool autoDl);
void clearPosts();
/* NEW GXS FNS */
void requestGroupData(const RsGxsGroupId &grpId);
@ -90,8 +91,11 @@ private:
void requestPosts(const RsGxsGroupId &grpId);
void loadPosts(const uint32_t &token);
void requestRelatedPosts(const RsGxsGroupId &grpId, const std::vector<RsGxsMessageId> &msgIds);
void loadRelatedPosts(const uint32_t &token);
void insertChannelDetails(const RsGxsChannelGroup &group);
void insertChannelPosts(const std::vector<RsGxsChannelPost> &posts);
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, bool related);
void acknowledgeMessageUpdate(const uint32_t &token);