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>
29 #include <messagecore/attachmentpart.h>
30 #include <akonadi/item.h>
44 class MESSAGECOMPOSER_EXPORT AttachmentModel
: public QAbstractItemModel
50 AttachmentPartRole
= Qt::UserRole
61 LastColumn
///< @internal
64 AttachmentModel( QObject
*parent
);
67 virtual bool dropMimeData( const QMimeData
*data
, Qt::DropAction action
,
68 int row
, int column
, const QModelIndex
&parent
);
69 virtual QMimeData
*mimeData( const QModelIndexList
&indexes
) const;
70 virtual QStringList
mimeTypes() const;
71 virtual Qt::DropActions
supportedDropActions() const;
73 /// for the save/discard warning
74 bool isModified() const;
75 void setModified( bool modified
);
77 bool isEncryptEnabled() const;
78 void setEncryptEnabled( bool enabled
);
79 bool isSignEnabled() const;
80 void setSignEnabled( bool enabled
);
81 bool isEncryptSelected() const;
83 void setEncryptSelected( bool selected
);
84 bool isSignSelected() const;
86 void setSignSelected( bool selected
);
88 virtual QVariant
data( const QModelIndex
&index
, int role
= Qt::DisplayRole
) const;
89 virtual bool setData( const QModelIndex
&index
, const QVariant
&value
, int role
= Qt::EditRole
);
91 bool addAttachment( KPIM::AttachmentPart::Ptr part
);
92 bool updateAttachment( KPIM::AttachmentPart::Ptr part
);
93 bool replaceAttachment( KPIM::AttachmentPart::Ptr oldPart
, KPIM::AttachmentPart::Ptr newPart
);
94 bool removeAttachment( KPIM::AttachmentPart::Ptr part
);
95 KPIM::AttachmentPart::List
attachments() const;
97 virtual Qt::ItemFlags
flags( const QModelIndex
&index
) const;
98 virtual QVariant
headerData( int section
, Qt::Orientation orientation
,
99 int role
= Qt::DisplayRole
) const;
100 virtual QModelIndex
index( int row
, int column
,
101 const QModelIndex
&parent
= QModelIndex() ) const;
102 virtual QModelIndex
parent( const QModelIndex
&index
) const;
103 virtual int rowCount( const QModelIndex
&parent
= QModelIndex() ) const;
104 virtual int columnCount( const QModelIndex
&parent
= QModelIndex() ) const;
107 void encryptEnabled( bool enabled
);
108 void signEnabled( bool enabled
);
109 void attachUrlsRequested( const KUrl::List
&urls
);
110 void attachItemsRequester( const Akonadi::Item::List
& );
111 void attachmentRemoved( KPIM::AttachmentPart::Ptr part
);
112 void attachmentCompressRequested( KPIM::AttachmentPart::Ptr part
, bool compress
);
116 friend class Private
;
122 #endif // KMAIL_ATTACHMENTMODEL_H