threadingcache.h 1.21 KB
Newer Older
1 2
/******************************************************************************
 *
3
 *  SPDX-FileCopyrightText: 2016 Daniel Vrátil <dvratil@kde.org>
4
 *
5
 *  SPDX-License-Identifier: GPL-2.0-or-later
6 7 8 9 10 11 12 13 14
 *
 *******************************************************************************/

#ifndef THREADINGCACHE_H
#define THREADINGCACHE_H

#include <QHash>
#include "messageitem.h"

Laurent Montel's avatar
Laurent Montel committed
15 16
namespace MessageList {
namespace Core {
17 18 19 20 21 22 23 24 25 26 27 28 29 30
class Aggregation;

class ThreadingCache
{
public:
    ThreadingCache();
    ~ThreadingCache();

    bool isEnabled() const;
    void setEnabled(bool enabled);

    void load(const QString &id, const Aggregation *aggregation);
    void save();

Laurent Montel's avatar
Laurent Montel committed
31 32 33 34 35 36 37
    void addItemToCache(MessageItem *mi);

    void updateParent(MessageItem *mi, MessageItem *parent);

    MessageItem *parentForItem(MessageItem *mi, qint64 &parentId) const;

    void expireParent(MessageItem *item);
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

private:
    QHash<qint64 /* child */, qint64 /* parent */> mParentCache;
    QHash<qint64 /* ID */, MessageItem *> mItemCache;

    QString mCacheId;
    Aggregation::Grouping mGrouping;
    Aggregation::Threading mThreading;
    Aggregation::ThreadLeader mThreadLeader;
    bool mEnabled;
};
} // namespace Core
} // namespace MessageList

#endif