GIT_SILENT made messages (after extraction)
[trojita.git] / src / Cryptography / PartReplacer.h
blob6ed28901a00a1e67f71140e31ef8a8b13f9af971
1 /* Copyright (C) 2006 - 2016 Jan Kundrát <jkt@kde.org>
3 This file is part of the Trojita Qt IMAP e-mail client,
4 http://trojita.flaska.net/
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License or (at your option) version 3 or any later version
10 accepted by the membership of KDE e.V. (or its successor approved
11 by the membership of KDE e.V.), which shall act as a proxy
12 defined in Section 14 of version 3 of the license.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef TROJITA_CRYPTO_PART_REPLACER_H
24 #define TROJITA_CRYPTO_PART_REPLACER_H
26 #include "Cryptography/MessagePart.h"
28 namespace Cryptography {
30 /** @short Interface for replacing specific part by a custom tree */
31 class PartReplacer {
32 public:
33 PartReplacer();
34 virtual ~PartReplacer();
36 /** @short Mangle the MIME part if desirable
38 The implementations of this interface checks if it is desirable to override the @arg original MIME part with
39 a custom specification. If not, the @arg original shall be returned without modification.
41 The MessageModel is in an inconsistent state at the time this method is called; the @arg original is actually
42 *not* included within the list of its parent's children (the children of @arg parentPart are undefined). Care
43 should be taken to not access the proxy indexes below the @arg proxyParentIndex. On the other hand, it is safe
44 to use the @arg original to request data from the proxied part, including calling its row().
46 If this module wants to override the MIME part (maybe based on its MIME type, maybe based on some ad-hoc criteria),
47 it should return a replacement part. Note that other part replacers might override this decision by overwriting
48 the returned objects. Resource management is taken care of by the unique_ptr interface.
50 The @arg sourceItemIndex points to an index within the source model (that is *not* the MessageModel) which
51 represents the current item (see @arg original).
53 The @arg proxyParentIndex represents a parent of @arg original within the MessageModel. There is no index
54 representing the current item within the MessageModel because this method is called at the time the model
55 is not in a consistent shape, and therefore accessing its MVC methods for siblings of "this" item (i.e.,
56 children of @arg proxyParentIndex) is not safe.
58 virtual MessagePart::Ptr createPart(MessageModel *model, MessagePart *parentPart, MessagePart::Ptr original,
59 const QModelIndex &sourceItemIndex, const QModelIndex &proxyParentIndex) = 0;
63 #endif