Messagelib

storagemodel.h
1 /*
2  SPDX-FileCopyrightText: 2009 Kevin Ottens <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <messagelist/storagemodelbase.h>
10 #include <messagelist_export.h>
11 
12 #include <Akonadi/Collection>
13 #include <Akonadi/Item>
14 #include <KMime/KMimeMessage>
15 #include <QVector>
16 
17 class QAbstractItemModel;
19 
20 namespace Akonadi
21 {
22 class Item;
23 }
24 
25 namespace MessageList
26 {
27 namespace Core
28 {
29 class MessageItem;
30 }
31 
32 /**
33  * The Akonadi specific implementation of the Core::StorageModel.
34  */
35 class MESSAGELIST_EXPORT StorageModel : public MessageList::Core::StorageModel
36 {
37  Q_OBJECT
38 
39 public:
40  /**
41  * Create a StorageModel wrapping the specified folder.
42  */
43  explicit StorageModel(QAbstractItemModel *model, QItemSelectionModel *selectionModel, QObject *parent = nullptr);
44  ~StorageModel() override;
45 
46  Q_REQUIRED_RESULT Akonadi::Collection::List displayedCollections() const;
47 
48  Q_REQUIRED_RESULT QString id() const override;
49  Q_REQUIRED_RESULT bool containsOutboundMessages() const override;
50 
51  virtual Q_REQUIRED_RESULT bool isOutBoundFolder(const Akonadi::Collection &c) const;
52 
53  Q_REQUIRED_RESULT int initialUnreadRowCountGuess() const override;
54  Q_REQUIRED_RESULT bool initializeMessageItem(MessageList::Core::MessageItem *mi, int row, bool bUseReceiver) const override;
55  void fillMessageItemThreadingData(MessageList::Core::MessageItem *mi, int row, ThreadingDataSubset subset) const override;
56  void updateMessageItemData(MessageList::Core::MessageItem *mi, int row) const override;
57  void setMessageItemStatus(MessageList::Core::MessageItem *mi, int row, Akonadi::MessageStatus status) override;
58 
59  Q_REQUIRED_RESULT int columnCount(const QModelIndex &parent = QModelIndex()) const override;
60  Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
61  Q_REQUIRED_RESULT QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
62  Q_REQUIRED_RESULT QModelIndex parent(const QModelIndex &index) const override;
63  Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override;
64 
65  QMimeData *mimeData(const QVector<MessageList::Core::MessageItem *> &) const override;
67 
68  Q_REQUIRED_RESULT Akonadi::Item itemForRow(int row) const;
69  Q_REQUIRED_RESULT Akonadi::Collection parentCollectionForRow(int row) const;
70  Q_REQUIRED_RESULT KMime::Message::Ptr messageForRow(int row) const;
71 
72  Q_REQUIRED_RESULT Akonadi::Collection collectionForId(Akonadi::Collection::Id colId) const;
73 
74  void resetModelStorage();
75 
76 private:
77  class StorageModelPrivate;
78  std::unique_ptr<StorageModelPrivate> const d;
79 };
80 } // namespace MessageList
81 
The MessageItem class.
Definition: messageitem.h:34
DisplayRole
virtual QMimeData * mimeData(const QVector< MessageItem * > &) const =0
The implementation-specific mime data for this list of items.
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
The Akonadi specific implementation of the Core::StorageModel.
Definition: storagemodel.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Nov 30 2021 23:05:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.