Removed old RsNotify code (NOTIFY_LIST_MESSAGE_TAGS) from message service

This commit is contained in:
thunder2 2021-12-30 23:55:26 +01:00
parent f59ede23e1
commit 3eb910a25f
15 changed files with 160 additions and 37 deletions

View File

@ -103,6 +103,9 @@ enum class RsEventType : uint32_t
/// @see rspeers.h /// @see rspeers.h
NETWORK = 16, NETWORK = 16,
/// @see RsMailTagEvent
MAIL_TAG = 17,
/** Emitted to update library clients about file hashing being completed */ /** Emitted to update library clients about file hashing being completed */
FILE_HASHING_COMPLETED = 20, FILE_HASHING_COMPLETED = 20,

View File

@ -310,6 +310,7 @@ enum class RsMailStatusEventCode: uint8_t
SIGNATURE_FAILED = 0x04, SIGNATURE_FAILED = 0x04,
MESSAGE_CHANGED = 0x05, MESSAGE_CHANGED = 0x05,
TAG_CHANGED = 0x06,
}; };
struct RsMailStatusEvent : RsEvent struct RsMailStatusEvent : RsEvent
@ -331,6 +332,32 @@ struct RsMailStatusEvent : RsEvent
~RsMailStatusEvent() override = default; ~RsMailStatusEvent() override = default;
}; };
enum class RsMailTagEventCode: uint8_t
{
TAG_ADDED = 0x00,
TAG_CHANGED = 0x01,
TAG_REMOVED = 0x02,
};
struct RsMailTagEvent : RsEvent
{
RsMailTagEvent() : RsEvent(RsEventType::MAIL_TAG) {}
RsMailTagEventCode mMailTagEventCode;
std::set<std::string> mChangedMsgTagIds;
/// @see RsEvent
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx) override
{
RsEvent::serial_process(j, ctx);
RS_SERIAL_PROCESS(mChangedMsgTagIds);
RS_SERIAL_PROCESS(mMailTagEventCode);
}
~RsMailTagEvent() override = default;
};
#define RS_CHAT_PUBLIC 0x0001 #define RS_CHAT_PUBLIC 0x0001
#define RS_CHAT_PRIVATE 0x0002 #define RS_CHAT_PRIVATE 0x0002
#define RS_CHAT_AVATAR_AVAILABLE 0x0004 #define RS_CHAT_AVATAR_AVAILABLE 0x0004

View File

@ -134,7 +134,6 @@ const int NOTIFY_LIST_CONFIG = 8;
const int NOTIFY_LIST_DIRLIST_LOCAL = 9; const int NOTIFY_LIST_DIRLIST_LOCAL = 9;
const int NOTIFY_LIST_DIRLIST_FRIENDS = 10; const int NOTIFY_LIST_DIRLIST_FRIENDS = 10;
const int NOTIFY_LIST_FORUMLIST_LOCKED = 11; // use connect with Qt::QueuedConnection const int NOTIFY_LIST_FORUMLIST_LOCKED = 11; // use connect with Qt::QueuedConnection
const int NOTIFY_LIST_MESSAGE_TAGS = 12;
const int NOTIFY_LIST_PUBLIC_CHAT = 13; const int NOTIFY_LIST_PUBLIC_CHAT = 13;
const int NOTIFY_LIST_PRIVATE_INCOMING_CHAT = 14; const int NOTIFY_LIST_PRIVATE_INCOMING_CHAT = 14;
const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15; const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15;

View File

@ -1438,7 +1438,7 @@ bool p3MsgService::getMessageTagTypes(MsgTagType& tags)
bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color)
{ {
int nNotifyType = 0; auto ev = std::make_shared<RsMailTagEvent>();
{ {
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -1461,7 +1461,8 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
mTags.insert(std::pair<uint32_t, RsMsgTagType*>(tagId, tagType)); mTags.insert(std::pair<uint32_t, RsMsgTagType*>(tagId, tagType));
nNotifyType = NOTIFY_TYPE_ADD; ev->mMailTagEventCode = RsMailTagEventCode::TAG_ADDED;
ev->mChangedMsgTagIds.insert(std::to_string(tagId));
} else { } else {
if (mit->second->text != text || mit->second->rgb_color != rgb_color) { if (mit->second->text != text || mit->second->rgb_color != rgb_color) {
/* modify existing tag */ /* modify existing tag */
@ -1475,16 +1476,17 @@ bool p3MsgService::setMessageTagType(uint32_t tagId, std::string& text, uint32
} }
mit->second->rgb_color = rgb_color; mit->second->rgb_color = rgb_color;
nNotifyType = NOTIFY_TYPE_MOD; ev->mMailTagEventCode = RsMailTagEventCode::TAG_CHANGED;
ev->mChangedMsgTagIds.insert(std::to_string(tagId));
} }
} }
} /* UNLOCKED */ } /* UNLOCKED */
if (nNotifyType) { if (!ev->mChangedMsgTagIds.empty()) {
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGE_TAGS, nNotifyType); rsEvents->postEvent(ev);
return true; return true;
} }
@ -1499,6 +1501,9 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
return false; return false;
} }
auto msgEvent = std::make_shared<RsMailStatusEvent>();
msgEvent->mMailStatusEventCode = RsMailStatusEventCode::TAG_CHANGED;
{ {
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -1526,7 +1531,10 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
delete(tag); delete(tag);
mMsgTags.erase(mit1++); mMsgTags.erase(mit1++);
continue; }
if (msgEvent->mChangedMsgIds.find(std::to_string(mit1->first)) == msgEvent->mChangedMsgIds.end()) {
msgEvent->mChangedMsgIds.insert(std::to_string(mit1->first));
} }
} }
++mit1; ++mit1;
@ -1540,7 +1548,14 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGE_TAGS, NOTIFY_TYPE_DEL); auto ev = std::make_shared<RsMailTagEvent>();
ev->mMailTagEventCode = RsMailTagEventCode::TAG_REMOVED;
ev->mChangedMsgTagIds.insert(std::to_string(tagId));
rsEvents->postEvent(ev);
if (!msgEvent->mChangedMsgIds.empty()) {
rsEvents->postEvent(msgEvent);
}
return true; return true;
} }
@ -1581,7 +1596,8 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
} }
} }
int nNotifyType = 0; auto ev = std::make_shared<RsMailStatusEvent>();
ev->mMailStatusEventCode = RsMailStatusEventCode::TAG_CHANGED;
{ {
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
@ -1600,7 +1616,7 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
mMsgTags.insert(std::pair<uint32_t, RsMsgTags*>(tag->msgId, tag)); mMsgTags.insert(std::pair<uint32_t, RsMsgTags*>(tag->msgId, tag));
nNotifyType = NOTIFY_TYPE_ADD; ev->mChangedMsgIds.insert(msgId);
} }
} else { } else {
RsMsgTags* tag = mit->second; RsMsgTags* tag = mit->second;
@ -1618,18 +1634,18 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
tag->tagIds.push_back(tagId); tag->tagIds.push_back(tagId);
/* keep the list sorted */ /* keep the list sorted */
tag->tagIds.sort(); tag->tagIds.sort();
nNotifyType = NOTIFY_TYPE_ADD; ev->mChangedMsgIds.insert(msgId);
} }
} else { } else {
if (tagId == 0) { if (tagId == 0) {
/* remove all */ /* remove all */
delete(tag); delete(tag);
mMsgTags.erase(mit); mMsgTags.erase(mit);
nNotifyType = NOTIFY_TYPE_DEL; ev->mChangedMsgIds.insert(msgId);
} else { } else {
if (lit != tag->tagIds.end()) { if (lit != tag->tagIds.end()) {
tag->tagIds.erase(lit); tag->tagIds.erase(lit);
nNotifyType = NOTIFY_TYPE_DEL; ev->mChangedMsgIds.insert(msgId);
if (tag->tagIds.empty()) { if (tag->tagIds.empty()) {
/* remove empty tag */ /* remove empty tag */
@ -1643,10 +1659,10 @@ bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool
} /* UNLOCKED */ } /* UNLOCKED */
if (nNotifyType) { if (!ev->mChangedMsgIds.empty()) {
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGE_TAGS, nNotifyType); rsEvents->postEvent(ev);
return true; return true;
} }

View File

@ -120,6 +120,7 @@ void MsgItem::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
break; break;
case RsMailStatusEventCode::MESSAGE_SENT: case RsMailStatusEventCode::MESSAGE_SENT:
case RsMailStatusEventCode::NEW_MESSAGE: case RsMailStatusEventCode::NEW_MESSAGE:
case RsMailStatusEventCode::TAG_CHANGED:
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK: case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
case RsMailStatusEventCode::SIGNATURE_FAILED: case RsMailStatusEventCode::SIGNATURE_FAILED:
break; break;

View File

@ -98,6 +98,7 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr<const RsEvent> e
updateIcon(); updateIcon();
break; break;
case RsMailStatusEventCode::MESSAGE_SENT: case RsMailStatusEventCode::MESSAGE_SENT:
case RsMailStatusEventCode::TAG_CHANGED:
case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK: case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK:
case RsMailStatusEventCode::SIGNATURE_FAILED: case RsMailStatusEventCode::SIGNATURE_FAILED:
break; break;

View File

@ -160,8 +160,6 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
viewsource->setShortcut(QKeySequence("CTRL+O")); viewsource->setShortcut(QKeySequence("CTRL+O"));
connect(viewsource, SIGNAL(triggered()), this, SLOT(viewSource())); connect(viewsource, SIGNAL(triggered()), this, SLOT(viewSource()));
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true); ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true);
ui.msgText->setImageBlockWidget(ui.imageBlockWidget); ui.msgText->setImageBlockWidget(ui.imageBlockWidget);
@ -252,6 +250,9 @@ void MessageWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event
} }
} }
break; break;
case RsMailStatusEventCode::TAG_CHANGED:
messagesTagsChanged();
break;
case RsMailStatusEventCode::MESSAGE_SENT: case RsMailStatusEventCode::MESSAGE_SENT:
case RsMailStatusEventCode::MESSAGE_CHANGED: case RsMailStatusEventCode::MESSAGE_CHANGED:
case RsMailStatusEventCode::NEW_MESSAGE: case RsMailStatusEventCode::NEW_MESSAGE:

View File

@ -268,8 +268,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ; registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ;
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int))); connect(ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
@ -293,6 +291,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS );
mTagEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_TAG );
} }
void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event) void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
@ -310,6 +311,7 @@ void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> even
case RsMailStatusEventCode::MESSAGE_REMOVED: case RsMailStatusEventCode::MESSAGE_REMOVED:
case RsMailStatusEventCode::NEW_MESSAGE: case RsMailStatusEventCode::NEW_MESSAGE:
case RsMailStatusEventCode::MESSAGE_CHANGED: case RsMailStatusEventCode::MESSAGE_CHANGED:
case RsMailStatusEventCode::TAG_CHANGED:
mMessageModel->updateMessages(); mMessageModel->updateMessages();
updateMessageSummaryList(); updateMessageSummaryList();
break; break;
@ -319,6 +321,27 @@ void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> even
} }
} }
void MessagesDialog::handleTagEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
if (event->mType != RsEventType::MAIL_TAG) {
return;
}
const RsMailTagEvent *fe = dynamic_cast<const RsMailTagEvent*>(event.get());
if (!fe) {
return;
}
switch (fe->mMailTagEventCode) {
case RsMailTagEventCode::TAG_ADDED:
case RsMailTagEventCode::TAG_CHANGED:
case RsMailTagEventCode::TAG_REMOVED:
fillQuickView();
mMessageModel->updateMessages();
break;
}
}
void MessagesDialog::preModelUpdate() void MessagesDialog::preModelUpdate()
{ {
// save current selection // save current selection
@ -373,6 +396,7 @@ MessagesDialog::~MessagesDialog()
processSettings(false); processSettings(false);
rsEvents->unregisterEventsHandler(mEventHandlerId); rsEvents->unregisterEventsHandler(mEventHandlerId);
rsEvents->unregisterEventsHandler(mTagEventHandlerId);
} }
UserNotify *MessagesDialog::createUserNotify(QObject *parent) UserNotify *MessagesDialog::createUserNotify(QObject *parent)
@ -938,13 +962,6 @@ void MessagesDialog::changeQuickView(int newrow)
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model
} }
void MessagesDialog::messagesTagsChanged()
{
fillQuickView();
mMessageModel->updateMessages();
}
// click in messageTreeWidget // click in messageTreeWidget
void MessagesDialog::currentChanged(const QModelIndex& new_proxy_index,const QModelIndex& /*old_proxy_index*/) void MessagesDialog::currentChanged(const QModelIndex& new_proxy_index,const QModelIndex& /*old_proxy_index*/)
{ {

View File

@ -66,7 +66,6 @@ protected:
public slots: public slots:
//void insertMessages(); //void insertMessages();
void messagesTagsChanged();
void messageRemoved(); void messageRemoved();
void preModelUpdate(); void preModelUpdate();
void postModelUpdate(); void postModelUpdate();
@ -112,6 +111,7 @@ private slots:
private: private:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
void handleTagEvent_main_thread(std::shared_ptr<const RsEvent> event);
void updateInterface(); void updateInterface();
@ -163,6 +163,7 @@ private:
QModelIndex lastSelectedIndex; QModelIndex lastSelectedIndex;
RsEventsHandlerId_t mEventHandlerId; RsEventsHandlerId_t mEventHandlerId;
RsEventsHandlerId_t mTagEventHandlerId;
}; };
#endif #endif

View File

@ -30,6 +30,7 @@
#include "gui/common/TagDefs.h" #include "gui/common/TagDefs.h"
#include "gui/settings/NewTag.h" #include "gui/settings/NewTag.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "util/qtthreadsutils.h"
#include "gui/msgs/MessageInterface.h" #include "gui/msgs/MessageInterface.h"
@ -46,11 +47,18 @@ TagsMenu::TagsMenu(const QString &title, QWidget *parent)
: QMenu (title, parent) : QMenu (title, parent)
{ {
connect(this, SIGNAL(triggered (QAction*)), this, SLOT(tagTriggered(QAction*))); connect(this, SIGNAL(triggered (QAction*)), this, SLOT(tagTriggered(QAction*)));
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(fillTags()));
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_TAG );
fillTags(); fillTags();
} }
TagsMenu::~TagsMenu()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
void TagsMenu::paintEvent(QPaintEvent *e) void TagsMenu::paintEvent(QPaintEvent *e)
{ {
QMenu::paintEvent(e); QMenu::paintEvent(e);
@ -89,6 +97,26 @@ void TagsMenu::paintEvent(QPaintEvent *e)
} }
} }
void TagsMenu::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
if (event->mType != RsEventType::MAIL_TAG) {
return;
}
const RsMailTagEvent *fe = dynamic_cast<const RsMailTagEvent*>(event.get());
if (!fe) {
return;
}
switch (fe->mMailTagEventCode) {
case RsMailTagEventCode::TAG_ADDED:
case RsMailTagEventCode::TAG_CHANGED:
case RsMailTagEventCode::TAG_REMOVED:
fillTags();
break;
}
}
void TagsMenu::fillTags() void TagsMenu::fillTags()
{ {
clear(); clear();

View File

@ -24,6 +24,7 @@
#include <QMenu> #include <QMenu>
#include <stdint.h> #include <stdint.h>
#include <retroshare/rsevents.h>
class TagsMenu : public QMenu class TagsMenu : public QMenu
{ {
@ -31,6 +32,7 @@ class TagsMenu : public QMenu
public: public:
TagsMenu(const QString &title, QWidget *parent); TagsMenu(const QString &title, QWidget *parent);
virtual ~TagsMenu();
void activateActions(std::list<uint32_t>& tagIds); void activateActions(std::list<uint32_t>& tagIds);
@ -42,8 +44,14 @@ protected:
virtual void paintEvent(QPaintEvent *e); virtual void paintEvent(QPaintEvent *e);
private slots: private slots:
void fillTags();
void tagTriggered(QAction *action); void tagTriggered(QAction *action);
private:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
void fillTags();
private:
RsEventsHandlerId_t mEventHandlerId;
}; };
#endif #endif

View File

@ -563,12 +563,6 @@ void NotifyQt::notifyListChange(int list, int type)
break; break;
case NOTIFY_LIST_SEARCHLIST: case NOTIFY_LIST_SEARCHLIST:
break; break;
case NOTIFY_LIST_MESSAGE_TAGS:
#ifdef NOTIFY_DEBUG
std::cerr << "received msg tags changed" << std::endl ;
#endif
emit messagesTagsChanged();
break;
case NOTIFY_LIST_CHANNELLIST: case NOTIFY_LIST_CHANNELLIST:
break; break;
case NOTIFY_LIST_TRANSFERLIST: case NOTIFY_LIST_TRANSFERLIST:

View File

@ -109,7 +109,6 @@ class NotifyQt: public QObject, public NotifyClient
void lobbyListChanged() const ; void lobbyListChanged() const ;
void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ;
void neighboursChanged() const ; void neighboursChanged() const ;
void messagesTagsChanged() const;
void configChanged() const ; void configChanged() const ;
void logInfoChanged(const QString&) const ; void logInfoChanged(const QString&) const ;
void chatStatusChanged(const ChatId&,const QString&) const ; void chatStatusChanged(const ChatId&,const QString&) const ;

View File

@ -27,6 +27,7 @@
#include "gui/common/TagDefs.h" #include "gui/common/TagDefs.h"
#include <algorithm> #include <algorithm>
#include "NewTag.h" #include "NewTag.h"
#include "util/qtthreadsutils.h"
MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags) : ConfigPage(parent, flags)
@ -54,10 +55,14 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmbededImages() )); connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmbededImages() ));
connect(ui.openComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(updateMsgOpen() )); connect(ui.openComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(updateMsgOpen() ));
connect(ui.emoticonscheckBox, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmoticons() )); connect(ui.emoticonscheckBox, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmoticons() ));
mTagEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG );
} }
MessagePage::~MessagePage() MessagePage::~MessagePage()
{ {
rsEvents->unregisterEventsHandler(mTagEventHandlerId);
delete(m_pTags); delete(m_pTags);
} }
@ -134,6 +139,27 @@ MessagePage::load()
fillTags(); fillTags();
} }
void MessagePage::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
if (event->mType != RsEventType::MAIL_TAG) {
return;
}
const RsMailTagEvent *fe = dynamic_cast<const RsMailTagEvent*>(event.get());
if (!fe) {
return;
}
switch (fe->mMailTagEventCode) {
case RsMailTagEventCode::TAG_ADDED:
case RsMailTagEventCode::TAG_CHANGED:
case RsMailTagEventCode::TAG_REMOVED:
rsMail->getMessageTagTypes(*m_pTags);
fillTags();
break;
}
}
// fill tags // fill tags
void MessagePage::fillTags() void MessagePage::fillTags()
{ {

View File

@ -62,11 +62,13 @@ private slots:
void updateLoadEmoticons(); void updateLoadEmoticons();
private: private:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
void fillTags(); void fillTags();
/* Pointer for not include of rsmsgs.h */ /* Pointer for not include of rsmsgs.h */
MsgTagType *m_pTags; MsgTagType *m_pTags;
std::list<uint32_t> m_changedTagIds; std::list<uint32_t> m_changedTagIds;
RsEventsHandlerId_t mTagEventHandlerId;
Ui::MessagePage ui; Ui::MessagePage ui;
}; };