summaryrefslogtreecommitdiff
path: root/plugins/HistoryStats/src/column_events.cpp
blob: b0fee0204c1a4aa52dc63c52a328b9489112e3f1 (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
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
#include "_globals.h"
#include "column_events.h"

/*
 * ColEvents
 */

ColEvents::ColEvents()
	: m_nSource(5), m_hSource(NULL)
{
}

void ColEvents::impl_copyConfig(const Column* pSource)
{
	const ColEvents& src = *reinterpret_cast<const ColEvents*>(pSource);

	m_nSource = src.m_nSource;
}

void ColEvents::impl_configRead(const SettingsTree& settings)
{
	m_nSource = settings.readIntRanged(con::KeySource, 5, 0, 5);
}

void ColEvents::impl_configWrite(SettingsTree& settings) const
{
	settings.writeInt(con::KeySource, m_nSource);
}

void ColEvents::impl_configToUI(OptionsCtrl& Opt, OptionsCtrl::Item hGroup)
{
	m_hSource = Opt.insertCombo(hGroup, TranslateT("Events to count"));

	static const TCHAR* sourceTexts[] = {
		LPGENT("URLs (incoming)"),
		LPGENT("URLs (outgoing)"),
		LPGENT("URLs (all)"),
		LPGENT("Files (incoming)"),
		LPGENT("Files (outgoing)"),
		LPGENT("Files (all)"),
	};

	array_each_(i, sourceTexts)
	{
		Opt.addComboItem(m_hSource, TranslateTS(sourceTexts[i]));
	}

	Opt.setComboSelected(m_hSource, m_nSource);
}

void ColEvents::impl_configFromUI(OptionsCtrl& Opt)
{
	m_nSource = Opt.getComboSelected(m_hSource);
}

void ColEvents::impl_outputRenderHeader(ext::ostream& tos, int row, int rowSpan) const
{
	static const TCHAR* szShortDesc[] = {
		LPGENT("URLs"),
		LPGENT("Files"),
	};

	static const TCHAR* szSourceDesc[] = {
		LPGENT("Incoming URLs"),
		LPGENT("Outgoing URLs"),
		LPGENT("URLs"),
		LPGENT("Incoming files"),
		LPGENT("Outgoing files"),
		LPGENT("Files"),
	};

	if (row == 1)
	{
		writeRowspanTD(tos, getCustomTitle(TranslateTS(szShortDesc[m_nSource / 3]), TranslateTS(szSourceDesc[m_nSource])), row, 1, rowSpan);
	}
}

void ColEvents::impl_outputRenderRow(ext::ostream& tos, const Contact& contact, DisplayType display)
{
	static int (Contact::*getData[6])() const = {
		&Contact::getInUrls,
		&Contact::getOutUrls,
		&Contact::getTotalUrls,
		&Contact::getInFiles,
		&Contact::getOutFiles,
		&Contact::getTotalFiles,
	};

	tos << _T("<td class=\"num\">")
		<< utils::intToGrouped((contact.*getData[m_nSource])())
		<< _T("</td>") << ext::endl;
}