Commit e7ac6ce8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Store info until we load all tags

parent e1e3ac2b
Pipeline #34355 passed with stage
in 72 minutes and 28 seconds
......@@ -213,10 +213,19 @@ void TagActionManager::createTagActions(const QVector<MailCommon::Tag::Ptr> &tag
if (!mToolbarActions.isEmpty() && mGUIClient->factory()) {
mGUIClient->plugActionList(QStringLiteral("toolbar_messagetag_actions"), mToolbarActions);
}
if (mMessageInfo.hasMessageInfo()) {
updateActionStates(mMessageInfo.numberOfSelectedMessages, mMessageInfo.selectedItem);
}
}
void TagActionManager::updateActionStates(int numberOfSelectedMessages, const Akonadi::Item &selectedItem)
{
qDebug() << " mMessageInfo.selectedItem " << mMessageInfo.selectedItem.tags();
if (mTagFetchInProgress) {
mMessageInfo.numberOfSelectedMessages = numberOfSelectedMessages;
mMessageInfo.selectedItem = selectedItem;
return;
}
mNewTagId = -1;
QMap<qint64, KToggleAction *>::const_iterator it = mTagActions.constBegin();
QMap<qint64, KToggleAction *>::const_iterator end = mTagActions.constEnd();
......@@ -235,6 +244,7 @@ void TagActionManager::updateActionStates(int numberOfSelectedMessages, const Ak
it.value()->setEnabled(true);
if (numberOfSelectedMessages == 1) {
const bool hasTag = selectedItem.hasTag(Akonadi::Tag(it.key()));
qDebug() << "hasTag " << hasTag;
it.value()->setChecked(hasTag);
it.value()->setText(i18n("Message Tag: %1", label));
} else {
......@@ -312,6 +322,7 @@ void TagActionManager::checkTags(const QList<qint64> &tags)
{
for (const qint64 id : tags) {
if (mTagActions.contains(id)) {
qDebug() << " SSSSSSSSSSSSSfdgdfgdf";
mTagActions[id]->setChecked(true);
}
}
......
......@@ -11,6 +11,7 @@
#include "mailcommon/tag.h"
#include <QMap>
#include <QVector>
#include <AkonadiCore/Item>
class KJob;
class KActionCollection;
class KXMLGUIClient;
......@@ -88,6 +89,18 @@ Q_SIGNALS:
void tagMoreActionClicked();
private:
struct MessagesInfo {
int numberOfSelectedMessages = -1;
Akonadi::Item selectedItem;
Q_REQUIRED_RESULT bool hasMessageInfo() const {
return numberOfSelectedMessages != -1;
}
void clear() {
numberOfSelectedMessages = -1;
selectedItem = {};
}
};
Q_DISABLE_COPY(TagActionManager)
void finishedTagListing(KJob *job);
void newTagActionClicked();
......@@ -100,7 +113,7 @@ private:
void createTagAction(const MailCommon::Tag::Ptr &tag, bool addToMenu);
void createTagActions(const QVector<MailCommon::Tag::Ptr> &);
void checkTags(const QList<qint64> &tags);
QList<qint64> checkedTags() const;
Q_REQUIRED_RESULT QList<qint64> checkedTags() const;
KActionCollection *const mActionCollection;
MessageActions *const mMessageActions;
......@@ -120,6 +133,7 @@ private:
// A sorted list of all tags
QVector<MailCommon::Tag::Ptr> mTags;
MessagesInfo mMessageInfo;
// Uri of a newly created tag
qint64 mNewTagId = -1;
bool mTagFetchInProgress = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment