Messagelib

storagemodel.h
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
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/Message>
15#include <QList>
16
19
20namespace Akonadi
21{
22class Item;
23}
24
25namespace MessageList
26{
27namespace Core
28{
29class MessageItem;
30}
31
32/**
33 * The Akonadi specific implementation of the Core::StorageModel.
34 */
35class MESSAGELIST_EXPORT StorageModel : public MessageList::Core::StorageModel
36{
38
39public:
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 [[nodiscard]] Akonadi::Collection::List displayedCollections() const;
47
48 [[nodiscard]] QString id() const override;
49 [[nodiscard]] bool containsOutboundMessages() const override;
50
51 [[nodiscard]] virtual bool isOutBoundFolder(const Akonadi::Collection &c) const;
52
53 [[nodiscard]] int initialUnreadRowCountGuess() const override;
54 [[nodiscard]] bool initializeMessageItem(MessageList::Core::MessageItem *mi, int row, bool bUseReceiver) const override;
56 void updateMessageItemData(MessageList::Core::MessageItem *mi, int row) const override;
58
59 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
60 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
61 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
62 [[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
63 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
64
67
68 [[nodiscard]] Akonadi::Item itemForRow(int row) const;
69 [[nodiscard]] Akonadi::Collection parentCollectionForRow(int row) const;
70 [[nodiscard]] KMime::Message::Ptr messageForRow(int row) const;
71
72 [[nodiscard]] Akonadi::Collection collectionForId(Akonadi::Collection::Id colId) const;
73
74 void resetModelStorage();
75
76private:
77 class StorageModelPrivate;
78 std::unique_ptr<StorageModelPrivate> const d;
79};
80} // namespace MessageList
QList< Collection > List
QSharedPointer< Message > Ptr
The MessageItem class.
Definition messageitem.h:36
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
virtual QMimeData * mimeData(const QList< MessageItem * > &) const =0
The implementation-specific mime data for this list of items.
int initialUnreadRowCountGuess() const override
Returns (a guess for) the number of unread messages: must be pessimistic (i.e.
void setMessageItemStatus(MessageList::Core::MessageItem *mi, int row, Akonadi::MessageStatus status) override
This method should use the inner model implementation to associate the new status to the specified me...
void fillMessageItemThreadingData(MessageList::Core::MessageItem *mi, int row, ThreadingDataSubset subset) const override
This method should use the inner model implementation to fill in the specified subset of threading da...
bool containsOutboundMessages() const override
Returns true if this StorageModel (folder) contains outbound messages and false otherwise.
StorageModel(QAbstractItemModel *model, QItemSelectionModel *selectionModel, QObject *parent=nullptr)
Create a StorageModel wrapping the specified folder.
void updateMessageItemData(MessageList::Core::MessageItem *mi, int row) const override
This method should use the inner model implementation to re-fill the date, the status,...
QString id() const override
Returns an unique id for this Storage collection.
bool initializeMessageItem(MessageList::Core::MessageItem *mi, int row, bool bUseReceiver) const override
This method should use the inner model implementation to fill in the base data for the specified Mess...
QMimeData * mimeData(const QList< MessageList::Core::MessageItem * > &) const override
The implementation-specific mime data for this list of items.
Q_SCRIPTABLE CaptureState status()
The implementation independent part of the MessageList library.
Definition aggregation.h:22
QAbstractItemModel(QObject *parent)
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
DisplayRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:47:09 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.