Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / kinfocenter / memory / swapMemoryChart.cpp
blob04160c72eafda161bb99ecef04260f62988a21a2
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 "swapMemoryChart.h"
14 #include <klocale.h>
15 #include <kdebug.h>
17 #include "base.h"
20 SwapMemoryChart::SwapMemoryChart(QWidget* parent) :
21 Chart(parent) {
23 colorsInitialized = false;
26 void SwapMemoryChart::paintEvent(QPaintEvent* /*event*/) {
28 /* display graphical output (ram, hdd, at last: HDD+RAM) */
29 /* be careful ! Maybe we have not all info available ! */
31 // First check swap see bug 167608
33 if (memoryInfos[SWAP_MEM] == Q_INT64_C(0))
34 memoryInfos[SWAP_MEM] = NO_MEMORY_INFO;
36 // SWAP usage:
38 t_memsize freeSwap = ZERO_IF_NO_INFO(memoryInfos[FREESWAP_MEM]);
39 t_memsize swap = ZERO_IF_NO_INFO(memoryInfos[SWAP_MEM]) - freeSwap;
41 QList<t_memsize> used;
43 used.append(freeSwap);
44 used.append(swap);
46 if (!colorsInitialized) {
47 colorsInitialized = true;
48 texts.append(i18n("Free Swap"));
49 colors.append(COLOR_FREE_MEMORY); // free
50 texts.append(i18n("Used Swap"));
51 colors.append(COLOR_USED_SWAP); // used swap
54 drawChart(memoryInfos[SWAP_MEM], used, colors, texts);