File indexing completed on 2024-12-15 04:54:38
0001 /****************************************************************************** 0002 * 0003 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 * 0007 *******************************************************************************/ 0008 0009 #pragma once 0010 0011 #include <QHash> 0012 #include <QList> 0013 0014 namespace MessageList 0015 { 0016 namespace Core 0017 { 0018 class MessageItem; 0019 0020 using MessageItemSetReference = long; 0021 0022 /** 0023 * This class manages sets of messageitem references. 0024 * It can be used to create a set, add some messages to it 0025 * and get a reference that later can be used to retrieve 0026 * the stored messages. 0027 * 0028 * It's used by Model to keep track of jobs requested 0029 * from outside that operate on sets of MessageItem instances. 0030 * Model takes care of removing the deleted MessageItem objects 0031 * from the sets in order to avoid invalid references. 0032 */ 0033 class MessageItemSetManager 0034 { 0035 public: 0036 MessageItemSetManager(); 0037 ~MessageItemSetManager(); 0038 0039 private: 0040 QHash<MessageItemSetReference, QHash<MessageItem *, MessageItem *> *> *mSets; 0041 0042 public: 0043 void clearAllSets(); 0044 [[nodiscard]] int setCount() const; 0045 void removeSet(MessageItemSetReference ref); 0046 void removeMessageItemFromAllSets(MessageItem *mi); 0047 [[nodiscard]] QList<MessageItem *> messageItems(MessageItemSetReference ref); 0048 [[nodiscard]] MessageItemSetReference createSet(); 0049 [[nodiscard]] bool addMessageItem(MessageItemSetReference ref, MessageItem *mi); 0050 }; 0051 } // namespace Core 0052 } // namespace MessageList