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 "core/modelinvariantrowmapper.h"
12 
13 #include <QTime>
14 #include <QTimer>
15 
16 namespace MessageList
17 {
18 namespace Core
19 {
20 class ModelInvariantRowMapperPrivate
21 {
22 public:
ModelInvariantRowMapperPrivate(ModelInvariantRowMapper * owner)23     explicit ModelInvariantRowMapperPrivate(ModelInvariantRowMapper *owner)
24         : q(owner)
25     {
26     }
27 
28     /**
29      * Internal. Don't look a this :)
30      */
31     void updateModelInvariantIndex(int modelIndexRow, ModelInvariantIndex *invariantToFill);
32 
33     /**
34      * Internal. Don't look a this :)
35      */
36     ModelInvariantIndex *modelIndexRowToModelInvariantIndexInternal(int modelIndexRow, bool updateIfNeeded);
37 
38     /**
39      * Internal: Removes the first RowShift from the list.
40      */
41     void killFirstRowShift();
42 
43     /**
44      * This is called from the ModelInvariantIndex destructor.
45      * You don't need to care.
46      */
47     void indexDead(ModelInvariantIndex *index);
48 
49     /**
50      * Internal: Performs a lazy update step.
51      */
52     void slotPerformLazyUpdate();
53 
54     ModelInvariantRowMapper *const q;
55 
56     QList<RowShift *> *mRowShiftList = nullptr; ///< The ordered list of RowShifts, most recent at the end
57     QHash<int, ModelInvariantIndex *> *mCurrentInvariantHash; ///< The up-to-date invariants
58     uint mCurrentShiftSerial; ///< Current model change serial: FIXME: it explodes at 2^32 :D
59     uint mRemovedShiftCount; ///< The number of shifts that we have completely processed
60     int mLazyUpdateChunkInterval; ///< Msecs: how much time we spend inside a lazy update chunk
61     int mLazyUpdateIdleInterval; ///< Msecs: how much time we idle between lazy update chunks
62     QTimer *mUpdateTimer = nullptr; ///< Background lazy update timer
63 };
64 } // Core
65 } // MessageList
66 
67