Messagelib

storagemodelbase.h
1/******************************************************************************
2 *
3 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 *
7 *******************************************************************************/
8
9#pragma once
10
11#include <QAbstractItemModel>
12#include <QList>
13namespace Akonadi
14{
15class MessageStatus;
16}
17
18namespace MessageList
19{
20namespace Core
21{
22class MessageItem;
23
24/**
25 * The QAbstractItemModel based interface that you need
26 * to provide for your storage to work with MessageList.
27 */
29{
31
32public:
33 explicit StorageModel(QObject *parent = nullptr);
34 ~StorageModel() override;
35
36 /**
37 * Returns an unique id for this Storage collection.
38 * FIXME: This could be embedded in "name()" ?
39 */
40 virtual QString id() const = 0;
41
42 /**
43 * Returns the unique id of the last selected message for this StorageModel.
44 * Returns 0 if this value isn't stored in the configuration.
45 */
46 unsigned long preSelectedMessage() const;
47
48 /**
49 * Stores in the unique id of the last selected message for the specified StorageModel.
50 * The uniqueIdOfMessage may be 0 (which means that no selection shall be stored in the configuration).
51 */
52 void savePreSelectedMessage(unsigned long uniqueIdOfMessage);
53
54 /**
55 * Returns true if this StorageModel (folder) contains outbound messages and false otherwise.
56 */
57 virtual bool containsOutboundMessages() const = 0;
58
59 /**
60 * Returns (a guess for) the number of unread messages: must be pessimistic (i.e. if you
61 * have no idea just return rowCount(), which is also what the default implementation does).
62 * This must be (and is) queried ONLY when the folder is first opened. It doesn't actually need
63 * to keep the number of messages in sync as they later arrive to the storage.
64 */
65 virtual int initialUnreadRowCountGuess() const;
66
67 /**
68 * This method should use the inner model implementation to fill in the
69 * base data for the specified MessageItem from the underlying storage slot at
70 * the specified row index. Must return true if the data fetch was successful
71 * and false otherwise. For base data we intend: subject, sender, receiver,
72 * senderOrReceiver, size, date, encryption state, signature state and status.
73 * If bUseReceiver is true then the "senderOrReceiver"
74 * field must be set to the receiver, otherwise it must be set to the sender.
75 */
76 virtual bool initializeMessageItem(MessageItem *it, int row, bool bUseReceiver) const = 0;
77
79 PerfectThreadingOnly, ///< Only the data for messageIdMD5 and inReplyToMD5 is needed
80 PerfectThreadingPlusReferences, ///< messageIdMD5, inReplyToMD5, referencesIdMD5
81 PerfectThreadingReferencesAndSubject ///< All of the above plus subject stuff
82 };
83
84 /**
85 * This method should use the inner model implementation to fill in the specified subset of
86 * threading data for the specified MessageItem from the underlying storage slot at
87 * the specified row index.
88 */
90
91 /**
92 * This method should use the inner model implementation to re-fill the date, the status,
93 * the encryption state, the signature state and eventually update the min/max dates
94 * for the specified MessageItem from the underlying storage slot at the specified row index.
95 */
96 virtual void updateMessageItemData(MessageItem *mi, int row) const = 0;
97
98 /**
99 * This method should use the inner model implementation to associate the new status
100 * to the specified message item. The new status should be stored (but doesn't need
101 * to be set as mi->status() itself as the caller is responsible for this).
102 */
104
105 /**
106 * The implementation-specific mime data for this list of items.
107 * Called when the user initiates a drag from the messagelist.
108 */
109 virtual QMimeData *mimeData(const QList<MessageItem *> &) const = 0;
111};
112} // namespace Core
113} // namespace MessageList
The MessageItem class.
Definition messageitem.h:35
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
virtual bool initializeMessageItem(MessageItem *it, int row, bool bUseReceiver) const =0
This method should use the inner model implementation to fill in the base data for the specified Mess...
virtual void fillMessageItemThreadingData(MessageItem *mi, int row, ThreadingDataSubset subset) const =0
This method should use the inner model implementation to fill in the specified subset of threading da...
virtual QString id() const =0
Returns an unique id for this Storage collection.
virtual QMimeData * mimeData(const QList< MessageItem * > &) const =0
The implementation-specific mime data for this list of items.
void savePreSelectedMessage(unsigned long uniqueIdOfMessage)
Stores in the unique id of the last selected message for the specified StorageModel.
unsigned long preSelectedMessage() const
Returns the unique id of the last selected message for this StorageModel.
virtual bool containsOutboundMessages() const =0
Returns true if this StorageModel (folder) contains outbound messages and false otherwise.
virtual void setMessageItemStatus(MessageItem *mi, int row, Akonadi::MessageStatus status)=0
This method should use the inner model implementation to associate the new status to the specified me...
virtual void updateMessageItemData(MessageItem *mi, int row) const =0
This method should use the inner model implementation to re-fill the date, the status,...
virtual int initialUnreadRowCountGuess() const
Returns (a guess for) the number of unread messages: must be pessimistic (i.e.
@ PerfectThreadingOnly
Only the data for messageIdMD5 and inReplyToMD5 is needed.
@ PerfectThreadingReferencesAndSubject
All of the above plus subject stuff.
@ PerfectThreadingPlusReferences
messageIdMD5, inReplyToMD5, referencesIdMD5
Q_SCRIPTABLE CaptureState status()
virtual QMimeData * mimeData(const QModelIndexList &indexes) const const
Q_OBJECTQ_OBJECT
QObject * parent() const const
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.