Mailcommon

itemcontext.h
1 /*
2  * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <[email protected]>
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 
16 namespace 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  */
26 class MAILCOMMON_EXPORT ItemContext
27 {
28 public:
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  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT bool needsFullPayload() const;
74 
75  void setDeleteItem();
76  Q_REQUIRED_RESULT bool deleteItem() const;
77 
78 private:
79  enum ItemContextAction { None = 0, PlayloadStore = 1, FlagStore = 2, DeleteItem = 4, FullPayload = 8 };
80  Q_DECLARE_FLAGS(ItemContextActions, ItemContextAction)
81 
82  Akonadi::Item mItem;
83  Akonadi::Collection mMoveTargetCollection;
84  ItemContextActions mItemContextAction;
85 };
86 }
A helper class for the filtering process.
Definition: itemcontext.h:26
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Sep 24 2022 03:58:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.