Commit 1a9b3917 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add tagmonitormanager.cpp

parent e7ac6ce8
......@@ -155,6 +155,7 @@ set(kmailprivate_widgets_LIB_SRCS
set(kmailprivate_tag_LIB_SRCS
tag/tagactionmanager.cpp
tag/tagselectdialog.cpp
tag/tagmonitormanager.cpp
)
......
......@@ -5,6 +5,7 @@
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "tagactionmanager.h"
#include "tagmonitormanager.h"
#include "messageactions.h"
......@@ -37,16 +38,13 @@ TagActionManager::TagActionManager(QObject *parent, KActionCollection *actionCol
, mActionCollection(actionCollection)
, mMessageActions(messageActions)
, mGUIClient(guiClient)
, mMonitor(new Akonadi::Monitor(this))
{
mMessageActions->messageStatusMenu()->menu()->addSeparator();
mMonitor->setObjectName(QStringLiteral("TagActionManagerMonitor"));
mMonitor->setTypeMonitored(Akonadi::Monitor::Tags);
mMonitor->tagFetchScope().fetchAttribute<Akonadi::TagAttribute>();
connect(mMonitor, &Akonadi::Monitor::tagAdded, this, &TagActionManager::onTagAdded);
connect(mMonitor, &Akonadi::Monitor::tagRemoved, this, &TagActionManager::onTagRemoved);
connect(mMonitor, &Akonadi::Monitor::tagChanged, this, &TagActionManager::onTagChanged);
TagMonitorManager *tagMonitorManager = TagMonitorManager::self();
connect(tagMonitorManager, &TagMonitorManager::tagAdded, this, &TagActionManager::onTagAdded);
connect(tagMonitorManager, &TagMonitorManager::tagRemoved, this, &TagActionManager::onTagRemoved);
connect(tagMonitorManager, &TagMonitorManager::tagChanged, this, &TagActionManager::onTagChanged);
}
TagActionManager::~TagActionManager()
......
......@@ -137,7 +137,6 @@ private:
// Uri of a newly created tag
qint64 mNewTagId = -1;
bool mTagFetchInProgress = false;
Akonadi::Monitor *const mMonitor;
};
}
......
/*
SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "tagmonitormanager.h"
#include <AkonadiCore/Monitor>
#include <AkonadiCore/TagFetchJob>
#include <AkonadiCore/TagFetchScope>
#include <AkonadiCore/TagAttribute>
TagMonitorManager::TagMonitorManager(QObject *parent)
: QObject(parent)
, mMonitor(new Akonadi::Monitor(this))
{
mMonitor->setObjectName(QStringLiteral("TagActionManagerMonitor"));
mMonitor->setTypeMonitored(Akonadi::Monitor::Tags);
mMonitor->tagFetchScope().fetchAttribute<Akonadi::TagAttribute>();
connect(mMonitor, &Akonadi::Monitor::tagAdded, this, &TagMonitorManager::tagAdded);
connect(mMonitor, &Akonadi::Monitor::tagRemoved, this, &TagMonitorManager::tagRemoved);
connect(mMonitor, &Akonadi::Monitor::tagChanged, this, &TagMonitorManager::tagChanged);
}
TagMonitorManager::~TagMonitorManager()
{
}
TagMonitorManager *TagMonitorManager::self()
{
static TagMonitorManager s_self;
return &s_self;
}
/*
SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef TAGMONITORMANAGER_H
#define TAGMONITORMANAGER_H
#include <QObject>
#include <AkonadiCore/Tag>
namespace Akonadi {
class Monitor;
}
class TagMonitorManager : public QObject
{
Q_OBJECT
public:
explicit TagMonitorManager(QObject *parent = nullptr);
~TagMonitorManager();
static TagMonitorManager *self();
Q_SIGNALS:
void tagAdded(const Akonadi::Tag &tag);
void tagChanged(const Akonadi::Tag &tag);
void tagRemoved(const Akonadi::Tag &tag);
private:
Akonadi::Monitor *const mMonitor;
};
#endif // TAGMONITORMANAGER_H
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