diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index b5b3d8264..1b170b87c 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -127,11 +127,45 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) /* Refresh style to have the correct text color */ Rshare::refreshStyleSheet(this, false); + + mEventHandlerId_identities = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { + RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_identities, RsEventType::GXS_IDENTITY ); + mEventHandlerId_peers = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { + RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::PEER_CONNECTION ); } +void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr event) +{ + const RsGxsIdentityEvent *fe = dynamic_cast(event.get()); + + if(fe) + { + updateDisplay(true); + update(); // Qt flush + return; + } + const RsConnectionEvent *fp = dynamic_cast(event.get()); + + if(fp) + switch(fp->mConnectionInfoCode) + { + case RsConnectionEventCode::PEER_REMOVED: + case RsConnectionEventCode::PEER_ADDED: + updateDisplay(true); + update(); // Qt flush + break; + default: break ; + } +} + + FriendSelectionWidget::~FriendSelectionWidget() { - delete ui; + rsEvents->unregisterEventsHandler(mEventHandlerId_peers); + rsEvents->unregisterEventsHandler(mEventHandlerId_identities); + delete ui; } void FriendSelectionWidget::changeEvent(QEvent *e) diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index 20c4a15e9..d0d295a3a 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -24,6 +24,7 @@ #include #include +#include "retroshare/rsevents.h" #include namespace Ui { @@ -151,6 +152,8 @@ private: void setSelectedIds_internal(IdType idType, const std::set &ids, bool add); private: + void handleEvent_main_thread(std::shared_ptr event); + bool mStarted; RSTreeWidgetItemCompareRole *mCompareRole; Modus mListModus; @@ -173,6 +176,9 @@ private: QList mContextMenuActions; std::set mPreSelectedIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them. + + RsEventsHandlerId_t mEventHandlerId_identities; + RsEventsHandlerId_t mEventHandlerId_peers; }; Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes) diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 544366937..a1addb2f0 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -585,8 +585,9 @@ QVariant RsMessageModel::userRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) { switch(col) { - case COLUMN_THREAD_AUTHOR: return displayRole(fmpe,col); + case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.from.toStdString())); case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId)); + case COLUMN_THREAD_TO: return QVariant(QString::fromStdString(fmpe.to.toStdString())); default: return QVariant(); } diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index b733e373b..54266c3fa 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -679,10 +679,13 @@ void MessageWidget::fill(const std::string &msgId) link = RetroShareLink::createMessage(msgInfo.from.toRsPeerId(), ""); } - if (((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.from.toRsPeerId() == ownId) || msgInfo.from.type()!=MsgAddress::MSG_ADDRESS_TYPE_RSPEERID) { + if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.from.toRsPeerId() == ownId) + { ui.fromText->setText("[Notification]"); if (toolButtonReply) toolButtonReply->setEnabled(false); - } else { + } + else + { ui.fromText->setText(link.toHtml()); ui.fromText->setToolTip(tooltip_string) ; if (toolButtonReply) toolButtonReply->setEnabled(true); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 16de2aea3..2d7ca0371 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -379,12 +379,15 @@ void MessagesDialog::postModelUpdate() sel.select(i.sibling(i.row(),0),i.sibling(i.row(),RsMessageModel::COLUMN_THREAD_NB_COLUMNS-1)); } - ui.messageTreeWidget->selectionModel()->select(sel,QItemSelectionModel::SelectCurrent); + // Restoring selection should not trigger anything, especially the re-display of the msg, which + // in turn will change the read status. + + whileBlocking(ui.messageTreeWidget->selectionModel())->select(sel,QItemSelectionModel::SelectCurrent); if (!mTmpSavedCurrentId.isEmpty()) { QModelIndex index = mMessageProxyModel->mapFromSource(mMessageModel->getIndexOfMessage(mTmpSavedCurrentId.toStdString())); if (index.isValid()) { - ui.messageTreeWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select); + whileBlocking(ui.messageTreeWidget->selectionModel())->setCurrentIndex(index, QItemSelectionModel::Select); } } } @@ -898,7 +901,7 @@ void MessagesDialog::changeBox(int box_row) switch(box_row) { case ROW_INBOX: mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_INBOX ); - break; + break; case ROW_OUTBOX: mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_OUTBOX); break; case ROW_DRAFTBOX: mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_DRAFTS); @@ -913,7 +916,8 @@ void MessagesDialog::changeBox(int box_row) insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex()); ui.messageTreeWidget->setPlaceholderText(placeholderText); - } + ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_READ,box_row!=ROW_INBOX); + } else { mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_NONE); @@ -993,21 +997,16 @@ void MessagesDialog::clicked(const QModelIndex& proxy_index) case RsMessageModel::COLUMN_THREAD_READ: { mMessageModel->setMsgReadStatus(real_index, !isMessageRead(proxy_index)); - //Already updated by currentChanged - //insertMsgTxtAndFiles(proxy_index); - updateMessageSummaryList(); return; } case RsMessageModel::COLUMN_THREAD_STAR: { mMessageModel->setMsgStar(real_index, !hasMessageStar(proxy_index)); - updateMessageSummaryList(); return; } case RsMessageModel::COLUMN_THREAD_SPAM: { mMessageModel->setMsgJunk(real_index, !hasMessageSpam(proxy_index)); - updateMessageSummaryList(); return; } }