File indexing completed on 2024-11-24 04:53:09
0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net> 0002 0003 This file is part of the Trojita Qt IMAP e-mail client, 0004 http://trojita.flaska.net/ 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License as 0008 published by the Free Software Foundation; either version 2 of 0009 the License or (at your option) version 3 or any later version 0010 accepted by the membership of KDE e.V. (or its successor approved 0011 by the membership of KDE e.V.), which shall act as a proxy 0012 defined in Section 14 of version 3 of the license. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef IMAP_MAILBOXMODEL_H 0024 #define IMAP_MAILBOXMODEL_H 0025 0026 #include <QAbstractProxyModel> 0027 #include "Model.h" 0028 0029 /** @short Namespace for IMAP interaction */ 0030 namespace Imap 0031 { 0032 0033 /** @short Classes for handling of mailboxes and connections */ 0034 namespace Mailbox 0035 { 0036 0037 template <typename SourceModel> class SubtreeClassSpecificItem; 0038 0039 /** @short A model implementing view of the whole IMAP server */ 0040 class MailboxModel: public QAbstractProxyModel 0041 { 0042 Q_OBJECT 0043 0044 public: 0045 MailboxModel(QObject *parent, Model *model); 0046 0047 virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const; 0048 virtual QModelIndex parent(const QModelIndex &index) const; 0049 virtual int rowCount(const QModelIndex &parent=QModelIndex()) const; 0050 virtual int columnCount(const QModelIndex &parent=QModelIndex()) const; 0051 virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const; 0052 virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; 0053 virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const; 0054 0055 virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const; 0056 0057 virtual Qt::ItemFlags flags(const QModelIndex &index) const; 0058 virtual Qt::DropActions supportedDropActions() const; 0059 virtual QStringList mimeTypes() const; 0060 virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const; 0061 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, 0062 int row, int column, const QModelIndex &parent); 0063 0064 virtual QHash<int, QByteArray> roleNames() const; 0065 0066 protected slots: 0067 void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); 0068 void handleMessageCountPossiblyChanged(const QModelIndex &mailbox); 0069 0070 private slots: 0071 void handleModelAboutToBeReset(); 0072 void handleModelReset(); 0073 void handleRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last); 0074 void handleRowsRemoved(const QModelIndex &parent, int first, int last); 0075 void handleRowsAboutToBeInserted(const QModelIndex &parent, int first, int last); 0076 void handleRowsInserted(const QModelIndex &parent, int first, int last); 0077 0078 private: 0079 bool dropTrojitaMessageList(const QString &mailboxName, const Qt::DropAction action, const QByteArray &encodedData); 0080 bool dropFileUrlList(const QString &mailboxName, QList<QUrl> files); 0081 0082 MailboxModel &operator=(const MailboxModel &); // don't implement 0083 MailboxModel(const MailboxModel &); // don't implement 0084 friend class SubtreeClassSpecificItem<MailboxModel>; 0085 }; 0086 0087 } 0088 0089 } 0090 0091 #endif /* IMAP_MAILBOXMODEL_H */