Akonadi

changerecorder.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include "monitor.h"
11
12class QSettings;
13
14namespace Akonadi
15{
16class ChangeRecorderPrivate;
17
18/**
19 * @short Records and replays change notification.
20 *
21 * This class is responsible for recording change notifications while
22 * an agent is not online and replaying the notifications when the agent
23 * is online again. Therefore the agent doesn't have to care about
24 * online/offline mode in its synchronization algorithm.
25 *
26 * Unlike Akonadi::Monitor this class only emits one change signal at a
27 * time. To receive the next one you need to explicitly call replayNext().
28 * If a signal is emitted that has no receivers, it's automatically skipped,
29 * which means you only need to connect to signals you are actually interested
30 * in.
31 *
32 * @author Volker Krause <vkrause@kde.org>
33 */
34class AKONADICORE_EXPORT ChangeRecorder : public Monitor
35{
36 Q_OBJECT
37public:
38 /**
39 * Creates a new change recorder.
40 */
41 explicit ChangeRecorder(QObject *parent = nullptr);
42
43 /**
44 * Destroys the change recorder.
45 * All not yet processed changes are written back to the config file.
46 */
47 ~ChangeRecorder() override;
48
49 /**
50 * Sets the QSettings object used for persistent recorded changes.
51 */
52 void setConfig(QSettings *settings);
53
54 /**
55 * Returns whether there are recorded changes.
56 */
57 [[nodiscard]] bool isEmpty() const;
58
59 /**
60 * Removes the previously emitted change from the records.
61 */
62 void changeProcessed();
63
64 /**
65 * Enables change recording. If change recording is disabled, this class
66 * behaves exactly like Akonadi::Monitor.
67 * Change recording is enabled by default.
68 * @param enable @c false to disable change recording. @c true by default
69 */
70 void setChangeRecordingEnabled(bool enable);
71
72 /**
73 * Debugging: dump current list of notifications, as saved on disk.
74 */
75 [[nodiscard]] QString dumpNotificationListToString() const;
76
77public Q_SLOTS:
78 /**
79 * Replay the next change notification and erase the previous one from the record.
80 */
81 void replayNext();
82
83Q_SIGNALS:
84 /**
85 * Emitted when new changes are recorded.
86 */
88
89 /**
90 * Emitted when replayNext() was called, but there was no valid change to replay.
91 * This can happen when all pending changes have been filtered out, for example.
92 * You only need to connect to this signal if you rely on one signal being emitted
93 * as a result of calling replayNext().
94 */
96
97protected:
98 /// @cond PRIVATE
99 explicit ChangeRecorder(ChangeRecorderPrivate *d, QObject *parent = nullptr);
100 /// @endcond
101
102private:
103 /// @cond PRIVATE
104 Q_DECLARE_PRIVATE(ChangeRecorder)
105 /// @endcond
106};
107
108}
Records and replays change notification.
void changesAdded()
Emitted when new changes are recorded.
void nothingToReplay()
Emitted when replayNext() was called, but there was no valid change to replay.
Monitors an item or collection for changes.
Definition monitor.h:71
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:11:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.