Messagelib

attachmentmodel.h
1/*
2 * This file is part of KMail.
3 * SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#pragma once
9
10#include "messagecomposer_export.h"
11
12#include <QAbstractItemModel>
13
14#include <QUrl>
15
16#include <Akonadi/Item>
17#include <MessageCore/AttachmentPart>
18
19namespace MessageComposer
20{
21/**
22 * @brief The AttachmentModel class
23 */
24class MESSAGECOMPOSER_EXPORT AttachmentModel : public QAbstractItemModel
25{
26 Q_OBJECT
27
28public:
29 enum {
30 AttachmentPartRole = Qt::UserRole,
31 NameRole,
32 SizeRole,
33 EncodingRole,
34 MimeTypeRole,
35 CompressRole,
36 EncryptRole,
37 SignRole,
38 AutoDisplayRole,
39 };
40
41 /**
42 * @todo: get rid of columns and use the roles instead.
43 */
44 enum Column {
45 NameColumn,
46 SizeColumn,
47 EncodingColumn,
48 MimeTypeColumn,
49 CompressColumn,
50 EncryptColumn,
51 SignColumn,
52 AutoDisplayColumn,
53 LastColumn, ///< @internal
54 };
55
56 explicit AttachmentModel(QObject *parent);
57 ~AttachmentModel() override;
58
59 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
60 [[nodiscard]] QMimeData *mimeData(const QModelIndexList &indexes) const override;
61 [[nodiscard]] QStringList mimeTypes() const override;
62 [[nodiscard]] Qt::DropActions supportedDropActions() const override;
63
64 /// for the save/discard warning
65 [[nodiscard]] bool isModified() const;
66 void setModified(bool modified);
67
68 [[nodiscard]] bool isEncryptEnabled() const;
69 void setEncryptEnabled(bool enabled);
70 [[nodiscard]] bool isSignEnabled() const;
71 void setSignEnabled(bool enabled);
72 [[nodiscard]] bool isEncryptSelected() const;
73 /// sets for all
74 void setEncryptSelected(bool selected);
75 [[nodiscard]] bool isSignSelected() const;
76 /// sets for all
77 void setSignSelected(bool selected);
78
79 [[nodiscard]] bool isAutoDisplayEnabled() const;
80 void setAutoDisplayEnabled(bool enabled);
81
82 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
83 [[nodiscard]] bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
84
85 void addAttachment(const MessageCore::AttachmentPart::Ptr &part);
86 bool updateAttachment(const MessageCore::AttachmentPart::Ptr &part);
87 [[nodiscard]] bool replaceAttachment(const MessageCore::AttachmentPart::Ptr &oldPart, const MessageCore::AttachmentPart::Ptr &newPart);
88 [[nodiscard]] bool removeAttachment(const MessageCore::AttachmentPart::Ptr &part);
89 [[nodiscard]] MessageCore::AttachmentPart::List attachments() const;
90
91 [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
92 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
93 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
94 [[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
95 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
96 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
97
98Q_SIGNALS:
99 void encryptEnabled(bool enabled);
100 void signEnabled(bool enabled);
101 void autoDisplayEnabled(bool enabled);
102 void attachUrlsRequested(const QList<QUrl> &urls);
103 void attachItemsRequester(const Akonadi::Item::List &);
104 void attachmentRemoved(MessageCore::AttachmentPart::Ptr part);
105 void attachmentCompressRequested(MessageCore::AttachmentPart::Ptr part, bool compress);
106
107private:
108 class AttachmentModelPrivate;
109 friend class AttachmentModelPrivate;
110 std::unique_ptr<AttachmentModelPrivate> const d;
111};
112} //
The AttachmentModel class.
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
DropAction
UserRole
typedef ItemFlags
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.