Messagelib

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

KDE's Doxygen guidelines are available online.