Fixed update of the forum message state and the summary in ForumsDialog when the message is read in the news feed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5015 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-03-12 00:27:18 +00:00
parent fedba02d18
commit c918ac84af
3 changed files with 42 additions and 1 deletions

View File

@ -38,6 +38,7 @@
#include "common/PopularityDefs.h"
#include "RetroShareLink.h"
#include "channels/ShareKey.h"
#include "notifyqt.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsforums.h>
@ -135,6 +136,7 @@ ForumsDialog::ForumsDialog(QWidget *parent)
m_bProcessSettings = false;
subscribeFlags = 0;
inMsgAsReadUnread = false;
connect( ui.forumTreeWidget, SIGNAL( treeCustomContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) );
connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) );
@ -160,6 +162,8 @@ ForumsDialog::ForumsDialog(QWidget *parent)
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)));
/* Set initial size the splitter */
QList<int> sizes;
sizes << 300 << width(); // Qt calculates the right sizes
@ -631,6 +635,35 @@ void ForumsDialog::clickedThread (QTreeWidgetItem *item, int column)
}
}
void ForumsDialog::forumMsgReadSatusChanged(const QString &forumId, const QString &msgId, int status)
{
if (inMsgAsReadUnread) {
return;
}
if (forumId.toStdString() == mCurrForumId) {
/* Search exisiting item */
QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget);
QTreeWidgetItem *item = NULL;
while ((item = *itemIterator) != NULL) {
itemIterator++;
if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString() == msgId) {
// update status
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status);
QTreeWidgetItem *parentItem = item;
while (parentItem->parent()) {
parentItem = parentItem->parent();
}
CalculateIconsAndFonts(parentItem);
break;
}
}
}
updateMessageSummaryList(forumId.toStdString());
}
void ForumsDialog::CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren)
{
uint32_t status = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
@ -1260,6 +1293,8 @@ void ForumsDialog::setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead)
QList<QTreeWidgetItem*>::iterator Row;
std::list<QTreeWidgetItem*> changedItems;
inMsgAsReadUnread = true;
for (Row = Rows.begin(); Row != Rows.end(); Row++) {
if ((*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool()) {
/* Missing message */
@ -1293,6 +1328,8 @@ void ForumsDialog::setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead)
}
}
inMsgAsReadUnread = false;
if (changedItems.size()) {
for (std::list<QTreeWidgetItem*>::iterator it = changedItems.begin(); it != changedItems.end(); it++) {
CalculateIconsAndFonts(*it);

View File

@ -61,6 +61,7 @@ private slots:
void changedForum(const QString &id);
void changedThread();
void clickedThread (QTreeWidgetItem *item, int column);
void forumMsgReadSatusChanged(const QString &forumId, const QString &msgId, int status);
void replytomessage();
//void print();
@ -130,6 +131,7 @@ private:
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int filterColumn);
bool m_bProcessSettings;
bool inMsgAsReadUnread;
QTreeWidgetItem *yourForums;
QTreeWidgetItem *subscribedForums;

View File

@ -127,6 +127,8 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WFlags flags)
processSettings("MessageWidget", true);
}
ui.dateText-> setText("");
/* Hide platform specific features */
#ifdef Q_WS_WIN