1 /***************************************************************************
2 * KT list view item task implementation. *
3 * -------------------------------------------------------------------- *
4 * Copyright (C) 1999, Gary Meyer <gary@meyer.net> *
5 * -------------------------------------------------------------------- *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
12 #include "physicalMemoryChart.h"
20 PhysicalMemoryChart::PhysicalMemoryChart(QWidget
* parent
) :
23 colorsInitialized
= false;
26 void PhysicalMemoryChart::paintEvent(QPaintEvent
* /*event*/) {
28 /* don't rely on the SHARED_MEM value since it may refer to
29 * the size of the System V sharedmem in 2.4.x. Calculate instead! */
31 t_memsize bufferMemory
;
34 #if !defined(__svr4__) || !defined(sun)
35 #if !defined(__NetBSD__) && !defined(__OpenBSD__)
36 bufferMemory
= ZERO_IF_NO_INFO(memoryInfos
[BUFFER_MEM
]);
39 t_memsize cachedMemory
= ZERO_IF_NO_INFO(memoryInfos
[CACHED_MEM
]);
40 t_memsize freeMemory
= ZERO_IF_NO_INFO(memoryInfos
[FREE_MEM
]);
41 t_memsize totalMemory
= ZERO_IF_NO_INFO(memoryInfos
[TOTAL_MEM
]) - bufferMemory
- cachedMemory
- freeMemory
;
43 QList
<t_memsize
> used
;
44 used
.append(freeMemory
);
45 used
.append(cachedMemory
);
46 used
.append(bufferMemory
);
47 used
.append(totalMemory
);
49 if (!colorsInitialized
) {
50 colorsInitialized
= true;
51 texts
.append(i18n("Free Physical Memory"));
52 colors
.append(COLOR_FREE_MEMORY
); // free
53 texts
.append(i18n("Disk Cache"));
54 colors
.append(QColor(88, 176, 36)); // cached
55 texts
.append(i18n("Disk Buffers"));
56 colors
.append(QColor(118, 237, 49)); // buffer
57 texts
.append(i18n("Application Data"));
58 colors
.append(COLOR_USED_MEMORY
); // used+shared
61 drawChart(memoryInfos
[TOTAL_MEM
], used
, colors
, texts
);