-
Notifications
You must be signed in to change notification settings - Fork 2
/
mcommonpixmaps.h
99 lines (78 loc) · 2.64 KB
/
mcommonpixmaps.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/***************************************************************************
**
** Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef MCOMMONPIXMAPS_H
#define MCOMMONPIXMAPS_H
#include <QObject>
#include <QSet>
#include <QElapsedTimer>
#include "mcpumonitor.h"
#include "mimagedirectory.h"
#include "mthemedaemonprotocol.h"
class MThemeDaemon;
//! \internal
class MCommonPixmaps : public QObject
{
Q_OBJECT
public:
MCommonPixmaps(MThemeDaemon *daemon, bool loadMostUsed);
~MCommonPixmaps();
void clear();
void load();
void save() const;
void increaseRequestCount(const M::MThemeDaemonProtocol::PixmapIdentifier &id, ImageResource *resource);
void reload(const M::MThemeDaemonProtocol::PixmapIdentifier &id, ImageResource *oldResource);
QList<M::MThemeDaemonProtocol::PixmapHandle> mostUsedPixmapHandles();
void setCacheFilename(const QString &filename);
Q_SIGNALS:
void mostUsedPixmapsChanged(const M::MThemeDaemonProtocol::MostUsedPixmaps& mostUsed);
private slots:
void loadOne();
void updateClientsAboutMostUsed();
void considerSaving();
private:
QString cacheFilename() const;
/*!
\brief Number of pixmaps to keep in most used pixmaps cache
*/
static const qint32 CacheSize = 1024;
/*!
\brief Current minimum amount of requests for a pixmap to end up in cache
*/
quint32 minRequestsForCache;
/*!
\brief Counters for pixmaps
*/
QHash<M::MThemeDaemonProtocol::PixmapIdentifier, quint32> requestCounts;
/*!
\brief A list of pixmaps which are currently cached
*/
QSet<M::MThemeDaemonProtocol::PixmapIdentifier> mostUsedPixmaps;
/*!
\brief A list which contains most used pixmaps, which are not yet loaded
*/
QSet<M::MThemeDaemonProtocol::PixmapIdentifier> toLoadList;
/*!
\brief A pointer to MThemeDaemonPrivate, so this class can find image resources from theme
*/
MThemeDaemon *daemon;
/*!
\brief Monitors the cpu usage. Is used for loading pixmaps when the cpu has free time
*/
MCpuMonitor cpuMonitor;
QElapsedTimer timerSinceLastSave;
/*!
\brief Filename of the cache if set from outside
*/
QString requiredCacheFilename;
};
//! \internal_end
#endif