File indexing completed on 2024-12-15 04:54:42
0001 /****************************************************************************** 0002 * 0003 * SPDX-FileCopyrightText: 2016 Daniel Vrátil <dvratil@kde.org> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 * 0007 *******************************************************************************/ 0008 0009 #pragma once 0010 0011 #include "messageitem.h" 0012 #include <QHash> 0013 0014 namespace MessageList 0015 { 0016 namespace Core 0017 { 0018 class Aggregation; 0019 0020 class ThreadingCache 0021 { 0022 public: 0023 ThreadingCache(); 0024 ~ThreadingCache(); 0025 0026 [[nodiscard]] bool isEnabled() const; 0027 void setEnabled(bool enabled); 0028 0029 void load(const QString &id, const Aggregation *aggregation); 0030 void save(); 0031 0032 void addItemToCache(MessageItem *mi); 0033 0034 void updateParent(MessageItem *mi, MessageItem *parent); 0035 0036 MessageItem *parentForItem(MessageItem *mi, qint64 &parentId) const; 0037 0038 void expireParent(MessageItem *item); 0039 0040 private: 0041 QHash<qint64 /* child */, qint64 /* parent */> mParentCache; 0042 QHash<qint64 /* ID */, MessageItem *> mItemCache; 0043 0044 QString mCacheId; 0045 Aggregation::Grouping mGrouping = Aggregation::NoGrouping; 0046 Aggregation::Threading mThreading = Aggregation::NoThreading; 0047 Aggregation::ThreadLeader mThreadLeader = Aggregation::TopmostMessage; 0048 bool mEnabled = true; 0049 }; 0050 } // namespace Core 0051 } // namespace MessageList