Mailcommon

itemcontext.h
1/*
2 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 */
7
8#pragma once
9
10#include "mailcommon/searchpattern.h"
11#include "mailcommon_export.h"
12
13#include <Akonadi/Collection>
14#include <Akonadi/Item>
15
16namespace MailCommon
17{
18/**
19 * @short A helper class for the filtering process
20 *
21 * The item context is used to pass the item together with meta data
22 * through the filter chain.
23 * This allows to 'record' all actions that shall be taken and execute them
24 * at the end of the filter chain.
25 */
26class MAILCOMMON_EXPORT ItemContext
27{
28public:
29 /**
30 * Creates an item context for the given @p item.
31 * @p requestedPart the part requested for the item (Envelope, Header or CompleteMessage)
32 */
33 ItemContext(const Akonadi::Item &item, bool needsFullPayload);
34
35 /**
36 * Returns the item of the context.
37 */
38 Akonadi::Item &item();
39
40 /**
41 * Sets the target collection the item should be moved to.
42 */
43 void setMoveTargetCollection(const Akonadi::Collection &collection);
44
45 /**
46 * Returns the target collection the item should be moved to, or an invalid
47 * collection if the item should not be moved at all.
48 */
49 [[nodiscard]] Akonadi::Collection moveTargetCollection() const;
50
51 /**
52 * Marks that the item's payload has been changed and needs to be written back.
53 */
54 void setNeedsPayloadStore();
55
56 /**
57 * Returns whether the item's payload needs to be written back.
58 */
59 [[nodiscard]] bool needsPayloadStore() const;
60
61 /**
62 * Marks that the item's flags has been changed and needs to be written back.
63 */
64 void setNeedsFlagStore();
65
66 /**
67 * Returns whether the item's flags needs to be written back.
68 */
69 [[nodiscard]] bool needsFlagStore() const;
70
71 /** Returns true if the full payload was requested for the item or not.
72 * Full payload is needed to change the headers or the body */
73 [[nodiscard]] bool needsFullPayload() const;
74
75 void setDeleteItem();
76 [[nodiscard]] bool deleteItem() const;
77
78private:
79 enum ItemContextAction {
80 None = 0,
81 PlayloadStore = 1,
82 FlagStore = 2,
83 DeleteItem = 4,
84 FullPayload = 8,
85 };
86 Q_DECLARE_FLAGS(ItemContextActions, ItemContextAction)
87
88 Akonadi::Item mItem;
89 Akonadi::Collection mMoveTargetCollection;
90 ItemContextActions mItemContextAction;
91};
92}
A helper class for the filtering process.
Definition itemcontext.h:27
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:12:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.