diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index dfba26ebb..53206470b 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -38,6 +38,7 @@ #include "common/PopularityDefs.h" #include "RetroShareLink.h" #include "channels/ShareKey.h" +#include "notifyqt.h" #include #include @@ -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 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 &Rows, bool bRead) QList::iterator Row; std::list 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 &Rows, bool bRead) } } + inMsgAsReadUnread = false; + if (changedItems.size()) { for (std::list::iterator it = changedItems.begin(); it != changedItems.end(); it++) { CalculateIconsAndFonts(*it); diff --git a/retroshare-gui/src/gui/ForumsDialog.h b/retroshare-gui/src/gui/ForumsDialog.h index e09fd8330..201bd8a83 100644 --- a/retroshare-gui/src/gui/ForumsDialog.h +++ b/retroshare-gui/src/gui/ForumsDialog.h @@ -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; diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 5ec4be72f..6c7381621 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -127,7 +127,9 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WFlags flags) processSettings("MessageWidget", true); } - /* Hide platform specific features */ + ui.dateText-> setText(""); + + /* Hide platform specific features */ #ifdef Q_WS_WIN #endif