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
|
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** TQt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
/*
* SQ_ThumbnailCacheMaster manipulates thumbnail cache
* in memory and on disk. It can show current cache size,
* delete cache on disk, clear cache etc.
*/
void SQ_ThumbnailCacheMaster::init()
{
pushCache->setIconSet(SQ_IconLoader::instance()->loadIcon("kcalc", TDEIcon::Desktop, TDEIcon::SizeSmall));
pushCacheMemory->setIconSet(SQ_IconLoader::instance()->loadIcon("kcalc", TDEIcon::Desktop, TDEIcon::SizeSmall));
pushShowCache->setIconSet(SQ_IconLoader::instance()->loadIcon("memory", TDEIcon::Desktop, TDEIcon::SizeSmall));
slotCalcCacheMemory();
}
void SQ_ThumbnailCacheMaster::slotCalcCache()
{
SQ_DirThumbs tmp;
KURL url = tmp.root();
int size = KDirSize::dirSize(url);
TQString s = TDEIO::convertSize(size);
textThumbSize->setText(s);
}
void SQ_ThumbnailCacheMaster::slotClearCache()
{
TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
SQ_DirThumbs tmp;
KURL url = tmp.root();
TDEIO::DeleteJob *job = TDEIO::del(url);
connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotClearFinished(TDEIO::Job*)));
}
void SQ_ThumbnailCacheMaster::slotClearFinished( TDEIO::Job * )
{
TQApplication::restoreOverrideCursor();
slotCalcCache();
}
void SQ_ThumbnailCacheMaster::slotClearMemoryCache()
{
TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
SQ_PixmapCache::instance()->clear();
slotCalcCacheMemory();
TQApplication::restoreOverrideCursor();
}
void SQ_ThumbnailCacheMaster::slotCalcCacheMemory()
{
textCacheMemSize->setText(TQString::fromLatin1("%1/%2")
.arg(TDEIO::convertSize(SQ_PixmapCache::instance()->totalSize()))
.arg(TDEIO::convertSize(SQ_PixmapCache::instance()->cacheLimit())));
}
void SQ_ThumbnailCacheMaster::slotShowDiskCache()
{
SQ_ViewCache m_view(this);
m_view.exec();
}
void SQ_ThumbnailCacheMaster::slotSyncCache()
{
TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
SQ_PixmapCache::instance()->sync();
slotCalcCacheMemory();
slotCalcCache();
TQApplication::restoreOverrideCursor();
}
|