removed mMsgTagIds since tags are not in RsMailStorageItem struct

This commit is contained in:
csoler 2022-11-30 15:25:38 +01:00
parent 0db41deb9f
commit 006f4c53be
7 changed files with 35 additions and 37 deletions

View File

@ -1081,7 +1081,7 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
MsgTagInfo tagInfo;
rsMail->getMessageTag(msgId, tagInfo);
msgComposer->m_tagIds = tagInfo.tagIds;
msgComposer->m_tagIds = tagInfo;
msgComposer->showTagLabels();
std::cerr << "Setting modified 005 = false" << std::endl;
msgComposer->ui.msgText->document()->setModified(false);
@ -1267,7 +1267,7 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
MsgTagInfo tagInfo;
rsMail->getMessageTag(msgId, tagInfo);
msgComposer->m_tagIds = tagInfo.tagIds;
msgComposer->m_tagIds = tagInfo;
msgComposer->showTagLabels();
msgComposer->calculateTitle();
@ -1563,18 +1563,15 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
/* insert new tags */
std::list<uint32_t>::iterator tag;
for (tag = m_tagIds.begin(); tag != m_tagIds.end(); ++tag) {
if (std::find(tagInfo.tagIds.begin(), tagInfo.tagIds.end(), *tag) == tagInfo.tagIds.end()) {
rsMail->setMessageTag(mi.msgId, *tag, true);
} else {
tagInfo.tagIds.remove(*tag);
}
}
for (auto tag:m_tagIds)
if (tagInfo.find(tag) == tagInfo.end())
rsMail->setMessageTag(mi.msgId, tag, true);
else
tagInfo.erase(tag);
/* remove deleted tags */
for (tag = tagInfo.tagIds.begin(); tag != tagInfo.tagIds.end(); ++tag) {
rsMail->setMessageTag(mi.msgId, *tag, false);
}
for (auto tag:tagInfo)
rsMail->setMessageTag(mi.msgId, tag, false);
}
std::cerr << "Setting modified 001 = false" << std::endl;
ui.msgText->document()->setModified(false);
@ -2801,17 +2798,17 @@ void MessageComposer::tagSet(int tagId, bool set)
return;
}
std::list<uint32_t>::iterator tag = std::find(m_tagIds.begin(), m_tagIds.end(), tagId);
if (tag == m_tagIds.end()) {
if (set) {
m_tagIds.push_back(tagId);
/* Keep the list sorted */
m_tagIds.sort();
}
} else {
if (set == false) {
m_tagIds.remove(tagId);
}
auto tag = m_tagIds.find(tagId);
if (tag == m_tagIds.end())
{
if (set)
m_tagIds.insert(tagId);
}
else
{
if (set == false)
m_tagIds.erase(tagId);
}
showTagLabels();
@ -2838,8 +2835,8 @@ void MessageComposer::showTagLabels()
rsMail->getMessageTagTypes(tags);
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator tag;
for (std::list<uint32_t>::iterator tagId = m_tagIds.begin(); tagId != m_tagIds.end(); ++tagId) {
tag = tags.types.find(*tagId);
for (auto tagId:m_tagIds) {
tag = tags.types.find(tagId);
if (tag != tags.types.end()) {
QLabel *tagLabel = new QLabel(TagDefs::name(tag->first, tag->second.first), this);
tagLabel->setMaximumHeight(QFontMetrics(tagLabel->font()).height()*1.2);

View File

@ -251,7 +251,7 @@ private:
std::string m_msgParentId; // parent message id
std::string m_sDraftMsgId; // existing message id
enumMessageType m_msgType;
std::list<uint32_t> m_tagIds;
std::set<uint32_t> m_tagIds;
QList<QLabel*> tagLabels;
// needed to send system flags with reply

View File

@ -508,15 +508,14 @@ QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
QString text;
// build tag names
for (auto tagit = tagInfo.tagIds.begin(); tagit != tagInfo.tagIds.end(); ++tagit)
for (auto tag:tagInfo)
{
if (!text.isNull())
text += ",";
auto Tag = Tags.types.find(*tagit);
if (Tag != Tags.types.end()) if (Tag != Tags.types.end())
auto Tag = Tags.types.find(tag);
if (Tag != Tags.types.end())
text += TagDefs::name(Tag->first, Tag->second.first);
else
RS_WARN("Unknown tag ", (int)Tag->first, " in message ", fmpe.msgId);

View File

@ -475,15 +475,17 @@ void MessageWidget::showTagLabels()
MsgTagInfo tagInfo;
rsMail->getMessageTag(currMsgId, tagInfo);
if (tagInfo.tagIds.empty() == false) {
if (!tagInfo.empty())
{
ui.tagsLabel->setVisible(true);
MsgTagType Tags;
rsMail->getMessageTagTypes(Tags);
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (std::list<uint32_t>::iterator tagId = tagInfo.tagIds.begin(); tagId != tagInfo.tagIds.end(); ++tagId) {
Tag = Tags.types.find(*tagId);
for (auto tag:tagInfo)
{
Tag = Tags.types.find(tag);
if (Tag != Tags.types.end()) {
QLabel *tagLabel = new QLabel(TagDefs::name(Tag->first, Tag->second.first), this);
tagLabel->setMaximumHeight(16);

View File

@ -150,7 +150,7 @@ void MessageWindow::tagAboutToShow()
MsgTagInfo tagInfo;
rsMail->getMessageTag(msgWidget->msgId(), tagInfo);
menu->activateActions(tagInfo.tagIds);
menu->activateActions(tagInfo);
}
void MessageWindow::tagRemoveAll()

View File

@ -170,7 +170,7 @@ void TagsMenu::fillTags()
addAction(action);
}
void TagsMenu::activateActions(std::list<uint32_t>& tagIds)
void TagsMenu::activateActions(std::set<uint32_t>& tagIds)
{
foreach(QObject *object, children()) {
QAction *action = qobject_cast<QAction*> (object);
@ -186,7 +186,7 @@ void TagsMenu::activateActions(std::list<uint32_t>& tagIds)
continue;
}
std::list<uint32_t>::iterator tagId = std::find(tagIds.begin(), tagIds.end(), values [ACTION_TAGSINDEX_ID]);
auto tagId = std::find(tagIds.begin(), tagIds.end(), values [ACTION_TAGSINDEX_ID]);
action->setChecked(tagId != tagIds.end());
}
}

View File

@ -34,7 +34,7 @@ public:
TagsMenu(const QString &title, QWidget *parent);
virtual ~TagsMenu();
void activateActions(std::list<uint32_t>& tagIds);
void activateActions(std::set<uint32_t> &tagIds);
signals:
void tagSet(int tagId, bool set);