summaryrefslogtreecommitdiff
path: root/gui/util.cc
blob: b62ed81b921164b3e978c87a8e8c67fd6af8e3d1 (plain)
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
#include "util.h"
#include "definitions.h"
#include <QString>

int cache_size_mapper(int total_levels, int level)
{
	const int y_min = 4;
	const int y_max = MEM_LINE_SPEC - 4;
	double f, r;

	if (total_levels <= 0)
		return 7;

	f = level / (double)total_levels;
	r = y_min + f * (y_max - y_min);

	return r;
}

QString format_toggled_value(int value, bool is_hex, bool is_cleared)
{
	if (is_cleared)
		return QString();
	return is_hex ? QString::asprintf("%X", value) : QString::number(value);
}