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 * @todo: get rid of columns and use the roles instead.
71 LastColumn
///< @internal
74 AttachmentModel( QObject
*parent
);
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;
93 void setEncryptSelected( bool selected
);
94 bool isSignSelected() const;
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;
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
);
126 friend class Private
;
132 #endif // KMAIL_ATTACHMENTMODEL_H