Framework for looking up contacts directly in nepomuk in addition to going through...
[kdepim.git] / messagecomposer / attachmentmodel.h
blob760ca30a139e5024a1c03cae77b7a57718391e61
1 /*
2 * This file is part of KMail.
3 * Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef KMAIL_ATTACHMENTMODEL_H
21 #define KMAIL_ATTACHMENTMODEL_H
23 #include "messagecomposer_export.h"
25 #include <QtCore/QAbstractItemModel>
27 #include <KDE/KUrl>
29 #include <messagecore/attachmentpart.h>
30 #include <akonadi/item.h>
32 namespace Message {
34 /**
35 Columns:
36 name
37 size
38 encoding
39 mime type
40 compress
41 encrypt
42 sign
44 class MESSAGECOMPOSER_EXPORT AttachmentModel : public QAbstractItemModel
46 Q_OBJECT
48 public:
49 enum {
50 AttachmentPartRole = Qt::UserRole,
51 NameRole,
52 SizeRole,
53 EncodingRole,
54 MimeTypeRole,
55 CompressRole,
56 EncryptRole,
57 SignRole
60 /**
61 * @todo: get rid of columns and use the roles instead.
63 enum Column {
64 NameColumn,
65 SizeColumn,
66 EncodingColumn,
67 MimeTypeColumn,
68 CompressColumn,
69 EncryptColumn,
70 SignColumn,
71 LastColumn ///< @internal
74 AttachmentModel( QObject *parent );
75 ~AttachmentModel();
77 virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action,
78 int row, int column, const QModelIndex &parent );
79 virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
80 virtual QStringList mimeTypes() const;
81 virtual Qt::DropActions supportedDropActions() const;
83 /// for the save/discard warning
84 bool isModified() const;
85 void setModified( bool modified );
87 bool isEncryptEnabled() const;
88 void setEncryptEnabled( bool enabled );
89 bool isSignEnabled() const;
90 void setSignEnabled( bool enabled );
91 bool isEncryptSelected() const;
92 /// sets for all
93 void setEncryptSelected( bool selected );
94 bool isSignSelected() const;
95 /// sets for all
96 void setSignSelected( bool selected );
98 virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
99 virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
101 bool addAttachment( MessageCore::AttachmentPart::Ptr part );
102 bool updateAttachment( MessageCore::AttachmentPart::Ptr part );
103 bool replaceAttachment( MessageCore::AttachmentPart::Ptr oldPart, MessageCore::AttachmentPart::Ptr newPart );
104 bool removeAttachment( MessageCore::AttachmentPart::Ptr part );
105 MessageCore::AttachmentPart::List attachments() const;
107 virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
108 virtual QVariant headerData( int section, Qt::Orientation orientation,
109 int role = Qt::DisplayRole ) const;
110 virtual QModelIndex index( int row, int column,
111 const QModelIndex &parent = QModelIndex() ) const;
112 virtual QModelIndex parent( const QModelIndex &index ) const;
113 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
114 virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
116 signals:
117 void encryptEnabled( bool enabled );
118 void signEnabled( bool enabled );
119 void attachUrlsRequested( const KUrl::List &urls );
120 void attachItemsRequester( const Akonadi::Item::List & );
121 void attachmentRemoved( MessageCore::AttachmentPart::Ptr part );
122 void attachmentCompressRequested( MessageCore::AttachmentPart::Ptr part, bool compress );
124 private:
125 class Private;
126 friend class Private;
127 Private *const d;
130 } // namespace KMail
132 #endif // KMAIL_ATTACHMENTMODEL_H