Messagelib

model.h
1 /******************************************************************************
2  *
3  * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <[email protected]>
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  *
7  *******************************************************************************/
8 
9 #ifndef MESSAGELIST_CORE_MODEL_H
10 #define MESSAGELIST_CORE_MODEL_H
11 
12 #include <QAbstractItemModel>
13 #include <QList>
14 #include <QHash>
15 #include <QVector>
16 #include <QMultiHash>
17 
18 #include <core/enums.h>
19 
20 #include <time.h> // time_t
21 
22 namespace MessageList {
23 namespace Core {
24 typedef long int MessageItemSetReference;
25 
26 class Filter;
27 class GroupHeaderItem;
28 class Item;
29 class MessageItem;
30 class Theme;
31 class StorageModel;
32 class View;
33 class ModelPrivate;
34 class SortOrder;
35 class Aggregation;
36 
52 class Model : public QAbstractItemModel
53 {
54  friend class Item;
55  friend class ItemPrivate;
56 
57  Q_OBJECT
58 public:
59 
63  explicit Model(View *pParent);
64 
68  ~Model() override;
69 
73  StorageModel *storageModel() const;
74 
90  void setStorageModel(StorageModel *storageModel, PreSelectionMode preSelectionMode = PreSelectLastSelected);
91 
99  void setPreSelectionMode(PreSelectionMode preSelect);
100 
105  Item *rootItem() const;
106 
111  Q_REQUIRED_RESULT bool isLoading() const;
112 
119  MessageItem *messageItemByStorageRow(int row) const;
120 
128  void setAggregation(const Aggregation *aggregation);
129 
137  void setTheme(const Theme *theme);
138 
143  void setSortOrder(const SortOrder *sortOrder);
144 
148  const SortOrder *sortOrder() const;
149 
156  void setFilter(const Filter *filter);
157 
168  Q_REQUIRED_RESULT MessageItemSetReference createPersistentSet(const QVector< MessageItem * > &items);
169 
177  Q_REQUIRED_RESULT QList<MessageItem *> persistentSetCurrentMessageItemList(MessageItemSetReference ref);
178 
183  void deletePersistentSet(MessageItemSetReference ref);
184 
185  // Mandatory QAbstractItemModel interface.
186 
187  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
188  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
189  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
190  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
191  QModelIndex index(Item *item, int column) const;
192  QModelIndex parent(const QModelIndex &index) const override;
193  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
194  Qt::ItemFlags flags(const QModelIndex &index) const override;
195 
197  QMimeData *mimeData(const QModelIndexList &indexes) const override;
198 
199 Q_SIGNALS:
204  void statusMessage(const QString &message);
205 
206 private:
207  friend class ModelPrivate;
208  ModelPrivate *const d;
209 };
210 } // namespace Core
211 } // namespace MessageList
212 
213 #endif
void setPreSelectionMode(PreSelectionMode preSelect)
Sets the pre-selection mode.
Definition: model.cpp:1011
A class which holds information about sorting, e.g.
Definition: sortorder.h:21
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: model.cpp:487
A set of aggregation options that can be applied to the MessageList::Model in a single shot...
Definition: aggregation.h:27
void statusMessage(const QString &message)
Notify the outside when updating the status bar with a message could be useful.
The MessageItem class.
Definition: messageitem.h:32
QMimeData * mimeData(const QModelIndexList &indexes) const override
Called when user initiates a drag from the messagelist.
Definition: model.cpp:4548
Item * rootItem() const
Returns the hidden root item that all the messages are (or will be) attached to.
Definition: model.cpp:4562
MessageItem * messageItemByStorageRow(int row) const
Returns the message item that is at the current storage row index or zero if no such storage item is ...
Definition: model.cpp:4572
~Model() override
Destroys the mighty model along with the tree of items it manages.
Definition: model.cpp:349
Q_SIGNALSQ_SIGNALS
The MessageList::View is the real display of the message list.
Definition: view.h:45
StorageModel * storageModel() const
Returns the StorageModel currently set.
Definition: model.cpp:693
This class manages the huge tree of displayable objects: GroupHeaderItems and MessageItems.
Definition: model.h:52
Q_OBJECTQ_OBJECT
DisplayRole
PreSelectionMode
Pre-selection is the action of automatically selecting a message just after the folder has finished l...
void setSortOrder(const SortOrder *sortOrder)
Sets the sort order.
Definition: model.cpp:381
void deletePersistentSet(MessageItemSetReference ref)
Deletes the persistent set pointed by the specified reference.
Definition: model.cpp:4607
Model(View *pParent)
Creates the mighty Model attached to the specified View.
Definition: model.cpp:300
MessageItemSetReference createPersistentSet(const QVector< MessageItem * > &items)
Creates a persistent set for the specified MessageItems and returns its reference.
Definition: model.cpp:4585
void setFilter(const Filter *filter)
Sets the Filter to be applied on messages.
Definition: model.cpp:391
A single item of the MessageList tree managed by MessageList::Model.
Definition: item.h:34
QList< MessageItem * > persistentSetCurrentMessageItemList(MessageItemSetReference ref)
Returns the list of MessageItems that are still existing in the set pointed by the specified referenc...
Definition: model.cpp:4599
void setTheme(const Theme *theme)
Sets the Theme.
Definition: model.cpp:376
The QAbstractItemModel based interface that you need to provide for your storage to work with Message...
void setStorageModel(StorageModel *storageModel, PreSelectionMode preSelectionMode=PreSelectLastSelected)
Sets the storage model from that the messages to be displayed should be fetched.
Definition: model.cpp:743
const SortOrder * sortOrder() const
Returns the sort order.
Definition: model.cpp:386
This class is responsable of matching messages that should be displayed in the View.
Definition: filter.h:28
The Theme class defines the visual appearance of the MessageList.
Definition: theme.h:47
Orientation
void setAggregation(const Aggregation *aggregation)
Sets the Aggregation mode.
Definition: model.cpp:369
QObject * parent() const const
bool isLoading() const
Returns true if the view is currently loading, that is it&#39;s in the first (possibly lengthy) job batch...
Definition: model.cpp:4567
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 23:12:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.