summaryrefslogtreecommitdiffstats
path: root/plugins/stats/StatsPluginPrefs.cc
blob: 1d501a68f8ee703a3ead42b877f7e7d18ba827eb (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
/***************************************************************************
 *   Copyright © 2007 by Krzysztof Kundzicz                                *
 *   athantor@gmail.com                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "StatsPluginPrefs.h"

namespace kt {

StatsPluginPrefs::StatsPluginPrefs() : PrefPageInterface(i18n("Statistics"), i18n("Statistics options"), KGlobal::iconLoader()->loadIcon("ktimemon",KIcon::NoGroup)), pmUi(0)
{	
}

StatsPluginPrefs::~StatsPluginPrefs()
{
}

bool StatsPluginPrefs::apply ()
{
	StatsPluginSettings::setUpdateChartsEveryGuiUpdates(pmUi -> GuiUpdatesSbw -> value());
	StatsPluginSettings::setGatherDataEveryMs(pmUi -> DataIvalSbw -> value());
	StatsPluginSettings::setPeersSpeedDataIval(pmUi -> PeersSpdUpdIvalSbw -> value());
	
	StatsPluginSettings::setPeersSpeed(pmUi -> PeersSpdCbw -> isChecked());
	StatsPluginSettings::setDrawSeedersInSwarms(pmUi -> ConnSdrInSwaCbw -> isChecked());
	StatsPluginSettings::setDrawLeechersInSwarms(pmUi -> ConnLchInSwaCbw -> isChecked());
	
	StatsPluginSettings::setDownloadMeasurements(pmUi -> DownloadMrmtSbw -> value());
	StatsPluginSettings::setPeersSpeedMeasurements(pmUi -> PeersSpdMrmtSbw -> value());
	StatsPluginSettings::setUploadMeasurements(pmUi -> UploadMrmtSbw -> value());
	StatsPluginSettings::setConnectionsMeasurements(pmUi -> ConnsMrmtSbw -> value());
	StatsPluginSettings::setDHTMeasurements(pmUi -> DHTMrmtSbw -> value());
	StatsPluginSettings::setMaxSpdMode(pmUi -> MaxSpdModeCbw -> currentItem());
	
	StatsPluginSettings::writeConfig();
	
	emit Applied();
	
	return true;
}

void StatsPluginPrefs::createWidget (TQWidget *tqparent)
{
	pmUi = new StatsPluginPrefsPage(tqparent);
}

void StatsPluginPrefs::updateData ()
{
	pmUi -> GuiUpdatesSbw -> setValue(StatsPluginSettings::updateChartsEveryGuiUpdates());
	pmUi -> DataIvalSbw -> setValue(StatsPluginSettings::gatherDataEveryMs());
	pmUi -> PeersSpdUpdIvalSbw -> setValue(StatsPluginSettings::peersSpeedDataIval());
	
	pmUi -> PeersSpdCbw -> setChecked(StatsPluginSettings::peersSpeed());
	pmUi -> ConnSdrInSwaCbw -> setChecked(StatsPluginSettings::drawSeedersInSwarms());
	pmUi -> ConnLchInSwaCbw -> setChecked(StatsPluginSettings::drawLeechersInSwarms());
	
	pmUi -> DownloadMrmtSbw -> setValue(StatsPluginSettings::downloadMeasurements());
	pmUi -> PeersSpdMrmtSbw -> setValue(StatsPluginSettings::peersSpeedMeasurements());
	pmUi -> UploadMrmtSbw -> setValue(StatsPluginSettings::uploadMeasurements());
	pmUi -> ConnsMrmtSbw -> setValue(StatsPluginSettings::connectionsMeasurements());
	pmUi -> DHTMrmtSbw -> setValue(StatsPluginSettings::dHTMeasurements());
	pmUi -> MaxSpdModeCbw -> setCurrentItem(StatsPluginSettings::maxSpdMode());
}

void StatsPluginPrefs::deleteWidget ()
{
	delete pmUi;
}


} //NS end

#include "StatsPluginPrefs.moc"